Skip to content

Commit

Permalink
add gameConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
notV4l committed May 22, 2024
1 parent ee438c1 commit d0f899a
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 9 deletions.
4 changes: 2 additions & 2 deletions web/src/components/map/WantedMarkers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ import { Alert } from "../icons";
import { coordinatePercent } from "./Map";

export const WantedMarkers = ({ targetId, current }: { targetId?: Locations; current?: Locations }) => {
const { game } = useGameStore();
const { game , gameConfig} = useGameStore();
const configStore = useConfigStore();
const { config } = configStore;

const [wanted, setWanted] = useState<Map<number, number>>();
const minWanted = (config?.config.game_config.max_wanted_shopping * 100n) / 8n;
const minWanted = (gameConfig?.max_wanted_shopping * 100) / 8;

const isMobile = IsMobile();

Expand Down
7 changes: 5 additions & 2 deletions web/src/dojo/class/Game.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Season, SeasonSettings } from "./../../generated/graphql";
import { GameConfig, Season, SeasonSettings } from "./../../generated/graphql";
import { Game, GameStorePacked } from "@/generated/graphql";
import { computed, makeObservable, observable } from "mobx";
import { CairoCustomEnum } from "starknet";
Expand Down Expand Up @@ -47,6 +47,7 @@ export const pendingCallToCairoEnum = (i: PendingCall) => {
export class GameClass {
configStore: ConfigStoreClass;
gameInfos: Game;
gameConfig: GameConfig;
seasonSettings: SeasonSettings;
packed: bigint;

Expand All @@ -62,11 +63,13 @@ export class GameClass {
configStore: ConfigStoreClass,
gameInfos: Game,
seasonSettings: SeasonSettings,
gameConfig: GameConfig,
gameStorePacked: GameStorePacked,
) {
this.configStore = configStore;
this.gameInfos = gameInfos;
this.seasonSettings = seasonSettings;
this.gameConfig = gameConfig;

this.packed = gameStorePacked.packed;
//
Expand Down Expand Up @@ -128,7 +131,7 @@ export class GameClass {

get isShopOpen() {
const wanted = this.player.wanted;
const maxWantedShopping = this.gameInfos.max_wanted_shopping;
const maxWantedShopping = this.gameConfig.max_wanted_shopping;

return wanted < maxWantedShopping && this.shopCount < 1;
}
Expand Down
16 changes: 14 additions & 2 deletions web/src/dojo/stores/game.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,13 @@ export class GameStoreClass {
const eventsEdges = gameEventsData.events?.edges as World__EventEdge[];
const eventsNodes = eventsEdges.map((i) => i.node as World__Event);

const game = new GameClass(this.configStore, this.gameInfos!, this.seasonSettings!, gameStorePacked);
const game = new GameClass(
this.configStore,
this.gameInfos!,
this.seasonSettings!,
this.gameConfig!,
gameStorePacked,
);
const gameEvents = new EventClass(this.configStore, this.gameInfos!, eventsNodes);

this.game = game;
Expand All @@ -229,7 +235,13 @@ export class GameStoreClass {
) as GameStorePacked;

if (gameStorePacked) {
this.game = new GameClass(this.configStore, this.gameInfos!, this.seasonSettings!, gameStorePacked);
this.game = new GameClass(
this.configStore,
this.gameInfos!,
this.seasonSettings!,
this.gameConfig!,
gameStorePacked,
);
}
};

Expand Down
6 changes: 3 additions & 3 deletions web/src/pages/[gameId]/travel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ interface MarketPriceInfo {
const Travel = observer(() => {
const { router, gameId } = useRouterContext();
const { account } = useAccount();
const { game, gameEvents } = useGameStore();
const { game, gameConfig } = useGameStore();
const { travel, isPending } = useSystems();
const configStore = useConfigStore();
const { config } = configStore;
Expand Down Expand Up @@ -194,7 +194,7 @@ const Travel = observer(() => {
{targetLocation && (
<WantedIndicator
wantedTick={game.wanted.getWantedTick(configStore.getLocation(targetLocation).location_id)}
highLimit={config?.config.game_config.max_wanted_shopping}
highLimit={gameConfig?.max_wanted_shopping}
/>
)}
</HStack>
Expand Down Expand Up @@ -222,7 +222,7 @@ const Travel = observer(() => {
<Box position="absolute" top="20px" left="16px">
<WantedIndicator
wantedTick={game.wanted.getWantedTick(configStore.getLocation(targetLocation).location_id)}
highLimit={config?.config.game_config.max_wanted_shopping}
highLimit={gameConfig?.max_wanted_shopping}
/>
</Box>
)}
Expand Down

0 comments on commit d0f899a

Please sign in to comment.