From 1bb2048e6067077674587d254508f6034b490aa0 Mon Sep 17 00:00:00 2001 From: notV4l Date: Sat, 13 Apr 2024 18:25:42 +0200 Subject: [PATCH] ui fixes --- src/config/encounters.cairo | 4 +- src/packing/player.cairo | 2 +- src/systems/traveling.cairo | 10 ++-- web/src/components/icons/items/Reputation.tsx | 12 +++++ web/src/components/icons/items/Shoes2.tsx | 14 ++++++ web/src/components/layout/MobileMenu.tsx | 4 +- .../components/layout/RefreshGameModal.tsx | 46 +++++++++++++++++++ web/src/components/map/WantedMarkers.tsx | 18 +++++++- .../pages/profile/HustlerProfile.tsx | 8 +++- .../components/pages/profile/HustlerStats.tsx | 27 +++++++++++ web/src/components/pages/profile/Loadout.tsx | 16 ++++--- web/src/components/player/Inventory.tsx | 7 +-- web/src/components/player/WantedIndicator.tsx | 12 +++-- web/src/dojo/helpers.ts | 3 +- web/src/dojo/stores/ui.tsx | 15 ++++++ web/src/pages/[gameId]/event/consequence.tsx | 9 ++-- web/src/pages/[gameId]/event/decision.tsx | 18 ++------ web/src/pages/[gameId]/travel.tsx | 17 +++++-- web/src/pages/_app.tsx | 2 + web/src/theme/components/tabs.tsx | 14 +++--- 20 files changed, 200 insertions(+), 58 deletions(-) create mode 100644 web/src/components/icons/items/Reputation.tsx create mode 100644 web/src/components/icons/items/Shoes2.tsx create mode 100644 web/src/components/layout/RefreshGameModal.tsx create mode 100644 web/src/components/pages/profile/HustlerStats.tsx diff --git a/src/config/encounters.cairo b/src/config/encounters.cairo index a8cbd8294..1bda192ed 100644 --- a/src/config/encounters.cairo +++ b/src/config/encounters.cairo @@ -116,7 +116,7 @@ impl EncounterSpawnerImpl of EncounterSpawnerTrait { let encounter = get!(world, (id), (EncounterConfig)); - if rep >= encounter.min_rep && rep < encounter.max_rep { + if rep >= encounter.min_rep && rep <= encounter.max_rep { encounters_ids.append(encounter.id); }; @@ -142,7 +142,7 @@ impl EncounterSpawnerImpl of EncounterSpawnerTrait { encounter.demand_pct = EncounterSpawnerImpl::get_random_demand_pct(ref game_store); // set scaling payout - encounter.payout = (encounter.level.into() * encounter.level.into() * 4_000) + (game_store.player.turn.into() * 1_000); + encounter.payout = (encounter.level.into() * encounter.level.into() * 3_000) + (game_store.player.turn.into() * 1_000); encounter } diff --git a/src/packing/player.cairo b/src/packing/player.cairo index 9b85f7f3f..8d176c373 100644 --- a/src/packing/player.cairo +++ b/src/packing/player.cairo @@ -202,7 +202,7 @@ impl PlayerImpl of PlayerTrait { // level down if self.drug_level > drug_level { // check if not carrying drug to be disabled - if drugs.quantity > 0 && drugs.drug.into() > drug_level + 4 { + if drugs.quantity > 0 && drugs.drug.into() >= drug_level + 4 { return; } } diff --git a/src/systems/traveling.cairo b/src/systems/traveling.cairo index f734ec7ed..a54d971e5 100644 --- a/src/systems/traveling.cairo +++ b/src/systems/traveling.cairo @@ -112,7 +112,7 @@ fn on_travel(ref game_store: GameStore, ref randomizer: Random) -> (bool, bool) encounter_id: encounter.id, demand_pct: encounter.demand_pct, payout: encounter.payout, - } + } ))); (game_store.player.is_dead(), true) @@ -444,11 +444,11 @@ impl ResolutionImpl of ResolutionTrait { } fn encounter_attack(ref game_store: GameStore, ref encounter: EncounterConfig, ref randomizer: Random) -> AttackResult { - let encounter_attack = encounter.attack; + let encounter_attack = encounter.attack / 3; let hustler_defense = game_store.items.defense(); let dmg_shield = encounter_attack.pct(hustler_defense.into()); - let dmg_dealt = (encounter_attack - dmg_shield) / 3; // TODO: config *** + let dmg_dealt = encounter_attack - dmg_shield; // TODO: config *** // player lose HP game_store.player.health_loss(dmg_dealt); @@ -462,11 +462,11 @@ impl ResolutionImpl of ResolutionTrait { } fn encounter_race_win(ref game_store: GameStore, ref encounter: EncounterConfig, ref randomizer: Random, ref drug_unpacked: DrugsUnpacked) -> EncounterRaceWinResult { - let encounter_attack = encounter.attack; + let encounter_attack = encounter.attack / 5; let hustler_defense = game_store.items.defense(); let dmg_shield = encounter_attack.pct(hustler_defense.into()); - let dmg_dealt = (encounter_attack - dmg_shield) / 5; // TODO: config *** + let dmg_dealt = encounter_attack - dmg_shield; // TODO: config *** // player lose HP game_store.player.health_loss(dmg_dealt); diff --git a/web/src/components/icons/items/Reputation.tsx b/web/src/components/icons/items/Reputation.tsx new file mode 100644 index 000000000..e08c87f64 --- /dev/null +++ b/web/src/components/icons/items/Reputation.tsx @@ -0,0 +1,12 @@ +import { Icon, IconProps } from ".."; + +export const Reputation = (props: IconProps) => { + return ( + + + + ); +}; diff --git a/web/src/components/icons/items/Shoes2.tsx b/web/src/components/icons/items/Shoes2.tsx new file mode 100644 index 000000000..cfc396482 --- /dev/null +++ b/web/src/components/icons/items/Shoes2.tsx @@ -0,0 +1,14 @@ +import { Icon, IconProps } from ".."; + +export const Shoes2 = (props: IconProps) => { + return ( + + <> + + + + ); +}; diff --git a/web/src/components/layout/MobileMenu.tsx b/web/src/components/layout/MobileMenu.tsx index 7c963b2c6..be5a26920 100644 --- a/web/src/components/layout/MobileMenu.tsx +++ b/web/src/components/layout/MobileMenu.tsx @@ -1,5 +1,4 @@ import { useDojoContext, useRouterContext } from "@/dojo/hooks"; -import { Sounds, playSound } from "@/hooks/sound"; import { Menu, MenuItem, Popover, PopoverBody, PopoverContent, PopoverTrigger, StyleProps } from "@chakra-ui/react"; import { Cigarette, Dots, Home } from "../icons"; import { ProfileLinkMobile } from "../pages/profile/Profile"; @@ -40,8 +39,7 @@ export const MobileMenu = ({ ...props }: StyleProps) => { { - playSound(Sounds.Ooo); - //uiStore.openQuitGame(); + uiStore.openRefreshGame(); }} > IM LOST diff --git a/web/src/components/layout/RefreshGameModal.tsx b/web/src/components/layout/RefreshGameModal.tsx new file mode 100644 index 000000000..e22fee370 --- /dev/null +++ b/web/src/components/layout/RefreshGameModal.tsx @@ -0,0 +1,46 @@ +import { useDojoContext, useRouterContext } from "@/dojo/hooks"; +import { + Button, + HStack, + Modal, + ModalBody, + ModalContent, + ModalHeader, + ModalOverlay, + VStack +} from "@chakra-ui/react"; +import { observer } from "mobx-react-lite"; + +export const RefreshGameModal = observer(() => { + const { router, gameId } = useRouterContext(); + const { uiStore } = useDojoContext(); + + return ( + {}}> + + + Im lost + + + + + + + + + + + ); +}); diff --git a/web/src/components/map/WantedMarkers.tsx b/web/src/components/map/WantedMarkers.tsx index 79048ce82..04c50e875 100644 --- a/web/src/components/map/WantedMarkers.tsx +++ b/web/src/components/map/WantedMarkers.tsx @@ -1,5 +1,6 @@ import { useConfigStore, useGameStore } from "@/dojo/hooks"; import { Locations } from "@/dojo/types"; +import { IsMobile } from "@/utils/ui"; import { Box } from "@chakra-ui/react"; import { useEffect, useState } from "react"; import { Alert } from "../icons"; @@ -8,9 +9,12 @@ import { coordinatePercent } from "./Map"; export const WantedMarkers = ({ targetId, current }: { targetId?: Locations; current?: Locations }) => { const { game } = useGameStore(); const configStore = useConfigStore(); + const { config } = configStore; const [wanted, setWanted] = useState>(); - const minWanted = 69; + const minWanted = (config?.config.game_config.max_wanted_shopping * 100n) / 8n; + + const isMobile = IsMobile(); useEffect(() => { const locations = configStore.config?.location!; @@ -33,6 +37,8 @@ export const WantedMarkers = ({ targetId, current }: { targetId?: Locations; cur position="absolute" left={`${coordinatePercent[Locations.Queens].x - 2}%`} top={`${coordinatePercent[Locations.Queens].y - 1}%`} + width={isMobile ? "20px" : "24px"} + height={isMobile ? "20px" : "24px"} /> )} {/* Jersey */} @@ -41,6 +47,8 @@ export const WantedMarkers = ({ targetId, current }: { targetId?: Locations; cur position="absolute" left={`${coordinatePercent[Locations.Jersey].x - 2}%`} top={`${coordinatePercent[Locations.Jersey].y - 1}%`} + width={isMobile ? "20px" : "24px"} + height={isMobile ? "20px" : "24px"} /> )} {/* Bronx */} @@ -49,6 +57,8 @@ export const WantedMarkers = ({ targetId, current }: { targetId?: Locations; cur position="absolute" left={`${coordinatePercent[Locations.Bronx].x - 2}%`} top={`${coordinatePercent[Locations.Bronx].y - 1}%`} + width={isMobile ? "20px" : "24px"} + height={isMobile ? "20px" : "24px"} /> )} {/* Central */} @@ -57,6 +67,8 @@ export const WantedMarkers = ({ targetId, current }: { targetId?: Locations; cur position="absolute" left={`${coordinatePercent[Locations.Central].x - 2}%`} top={`${coordinatePercent[Locations.Central].y - 1}%`} + width={isMobile ? "20px" : "24px"} + height={isMobile ? "20px" : "24px"} /> )} {/* Coney */} @@ -65,6 +77,8 @@ export const WantedMarkers = ({ targetId, current }: { targetId?: Locations; cur position="absolute" left={`${coordinatePercent[Locations.Coney].x - 2}%`} top={`${coordinatePercent[Locations.Coney].y - 1}%`} + width={isMobile ? "20px" : "24px"} + height={isMobile ? "20px" : "24px"} /> )} {/* Brooklyn */} @@ -73,6 +87,8 @@ export const WantedMarkers = ({ targetId, current }: { targetId?: Locations; cur position="absolute" left={`${coordinatePercent[Locations.Brooklyn].x - 2}%`} top={`${coordinatePercent[Locations.Brooklyn].y - 1}%`} + width={isMobile ? "20px" : "24px"} + height={isMobile ? "20px" : "24px"} /> )} diff --git a/web/src/components/pages/profile/HustlerProfile.tsx b/web/src/components/pages/profile/HustlerProfile.tsx index f006303f0..c220dd150 100644 --- a/web/src/components/pages/profile/HustlerProfile.tsx +++ b/web/src/components/pages/profile/HustlerProfile.tsx @@ -9,7 +9,7 @@ import { useEffect, useState } from "react"; import ShareButton from "./ShareButton"; export const HustlerProfile = observer(() => { - const { gameId} = useRouterContext() + const { gameId } = useRouterContext(); const { game, gameInfos } = useGameStore(); const configStore = useConfigStore(); const [hustlerStats, setHustlerStats] = useState(); @@ -90,7 +90,11 @@ export const HustlerProfile = observer(() => { - + {/* + + */} + +