From c9dc5e91decf5edcf669fcaa2ed47cc0b0c4156d Mon Sep 17 00:00:00 2001 From: notV4l Date: Sun, 14 Apr 2024 17:22:13 +0200 Subject: [PATCH] encounter admin & fixes --- src/config/config.cairo | 34 +++- src/config/drugs.cairo | 149 +++++++++++++++--- src/config/encounters.cairo | 123 +++++++++------ src/systems/ryo.cairo | 1 - src/systems/traveling.cairo | 39 ++++- web/manifest.json | 105 ++++++++++-- web/src/components/layout/Header.tsx | 4 +- web/src/components/layout/Layout.tsx | 2 + web/src/components/layout/MobileMenu.tsx | 16 +- web/src/components/layout/Pending.tsx | 3 + web/src/components/pages/admin/DrugTable.tsx | 2 +- .../components/pages/admin/EncounterTable.tsx | 21 ++- .../pages/admin/GameConfigTable.tsx | 2 +- .../pages/admin/HustlerItemBaseTable.tsx | 2 +- web/src/components/pages/home/ClaimReward.tsx | 5 +- .../components/pages/profile/HustlerStats.tsx | 18 +-- .../components/wallet/StarknetProvider.tsx | 5 +- web/src/dojo/abis/configAbi.ts | 84 ++++++++++ web/src/dojo/hooks/useAutoBurner.ts | 24 +++ web/src/dojo/hooks/useRouterContext.ts | 8 + web/src/dojo/hooks/useSystems.ts | 67 +++++++- web/src/dojo/stores/config.tsx | 2 +- web/src/generated/graphql.ts | 15 +- web/src/graphql/config.graphql | 4 +- web/src/hooks/sound.tsx | 3 +- web/src/pages/[gameId]/event/consequence.tsx | 5 +- web/src/pages/[gameId]/logs.tsx | 4 +- web/src/pages/[gameId]/travel.tsx | 14 +- web/src/pages/_app.tsx | 5 +- web/src/pages/admin.tsx | 55 ++++++- web/src/pages/create/new.tsx | 4 +- 31 files changed, 659 insertions(+), 166 deletions(-) create mode 100644 web/src/dojo/hooks/useAutoBurner.ts diff --git a/src/config/config.cairo b/src/config/config.cairo index 712a5f774..a59174869 100644 --- a/src/config/config.cairo +++ b/src/config/config.cairo @@ -1,6 +1,6 @@ use rollyourown::config::{ hustlers::{HustlerConfig, HustlerImpl}, - game::{GameConfig}, drugs::{DrugConfig} + game::{GameConfig}, drugs::{DrugConfig}, encounters::{EncounterConfig}, }; @@ -11,9 +11,9 @@ trait IConfig { fn get_config(self: @T) -> Config; fn update_game_config(self: @T, game_config: GameConfig); fn update_drug_config(self: @T, drug_config: DrugConfig); + fn update_encounter_config(self: @T, encounter_config: EncounterConfig); + -// fn update_drug_config_meta(self: @T); -// ... } #[derive(Drop, Serde)] @@ -52,7 +52,7 @@ mod config { initialize_clothes_tiers_config, initialize_feet_tiers_config, initialize_transport_tiers_config, }, - encounters::{initialize_encounter_config, EncounterConfig, Encounters}, + encounters::{initialize_encounter_config,initialize_encounter_config_extra, EncounterConfig, Encounters}, }, packing::{ game_store_layout::{ @@ -104,6 +104,8 @@ mod config { // encounters initialize_encounter_config(world); + initialize_encounter_config_extra(world); + } fn get_config(self: @ContractState) -> Config { @@ -184,6 +186,30 @@ mod config { set!(self.world(), (to_update)); } + fn update_encounter_config(self: @ContractState, encounter_config: EncounterConfig) { + self.assert_caller_is_owner(); + + let mut to_update = get!(self.world(), (encounter_config.id), (EncounterConfig)); + + to_update.encounter = encounter_config.encounter; + + to_update.level = encounter_config.level; + to_update.health = encounter_config.health; + to_update.attack = encounter_config.attack; + to_update.defense = encounter_config.defense; + to_update.speed = encounter_config.speed; + + to_update.rep_pay = encounter_config.rep_pay; + to_update.rep_run = encounter_config.rep_run; + to_update.rep_fight = encounter_config.rep_fight; + + to_update.min_rep = encounter_config.min_rep; + to_update.max_rep = encounter_config.max_rep; + + to_update.payout = encounter_config.payout; + + set!(self.world(), (to_update)); + } } diff --git a/src/config/drugs.cairo b/src/config/drugs.cairo index bc753fdf3..89311a7ab 100644 --- a/src/config/drugs.cairo +++ b/src/config/drugs.cairo @@ -131,9 +131,9 @@ fn initialize_drug_config(world: IWorldDispatcher) { DrugConfig { drug: Drugs::Ludes, drug_id: Drugs::Ludes.into(), - base: 18, - step: 1, - weight: 5, + base: 24, + step: 2, + weight: 10, name: Bytes16Impl::from('Ludes') } ); @@ -143,9 +143,9 @@ fn initialize_drug_config(world: IWorldDispatcher) { DrugConfig { drug: Drugs::Speed, drug_id: Drugs::Speed.into(), - base: 85, - step: 6, - weight: 10, + base: 150, + step: 4, + weight: 14, name: Bytes16Impl::from('Speed') } ); @@ -155,9 +155,9 @@ fn initialize_drug_config(world: IWorldDispatcher) { DrugConfig { drug: Drugs::Weed, drug_id: Drugs::Weed.into(), - base: 290, - step: 18, - weight: 15, + base: 402, + step: 8, + weight: 19, name: Bytes16Impl::from('Weed') } ); @@ -167,9 +167,9 @@ fn initialize_drug_config(world: IWorldDispatcher) { DrugConfig { drug: Drugs::Shrooms, drug_id: Drugs::Shrooms.into(), - base: 980, - step: 54, - weight: 25, + base: 906, + step: 16, + weight: 27, name: Bytes16Impl::from('Shrooms') } ); @@ -179,9 +179,9 @@ fn initialize_drug_config(world: IWorldDispatcher) { DrugConfig { drug: Drugs::Acid, drug_id: Drugs::Acid.into(), - base: 2900, - step: 111, - weight: 30, + base: 1914, + step: 32, + weight: 37, name: Bytes16Impl::from('Acid') } ); @@ -191,9 +191,9 @@ fn initialize_drug_config(world: IWorldDispatcher) { DrugConfig { drug: Drugs::Ketamine, drug_id: Drugs::Ketamine.into(), - base: 6800, - step: 186, - weight: 45, + base: 3930, + step: 64, + weight: 52, name: Bytes16Impl::from('Ketamine') } ); @@ -203,9 +203,9 @@ fn initialize_drug_config(world: IWorldDispatcher) { DrugConfig { drug: Drugs::Heroin, drug_id: Drugs::Heroin.into(), - base: 13500, - step: 231, - weight: 65, + base: 7962, + step: 128, + weight: 72, name: Bytes16Impl::from('Heroin') } ); @@ -215,10 +215,113 @@ fn initialize_drug_config(world: IWorldDispatcher) { DrugConfig { drug: Drugs::Cocaine, drug_id: Drugs::Cocaine.into(), - base: 19800, - step: 284, + base: 16026, + step: 256, weight: 100, name: Bytes16Impl::from('Cocaine') } ); } + + +// +// +// + +// fn initialize_drug_config_v0(world: IWorldDispatcher) { +// set!( +// world, +// DrugConfig { +// drug: Drugs::Ludes, +// drug_id: Drugs::Ludes.into(), +// base: 18, +// step: 1, +// weight: 5, +// name: Bytes16Impl::from('Ludes') +// } +// ); + +// set!( +// world, +// DrugConfig { +// drug: Drugs::Speed, +// drug_id: Drugs::Speed.into(), +// base: 85, +// step: 6, +// weight: 10, +// name: Bytes16Impl::from('Speed') +// } +// ); + +// set!( +// world, +// DrugConfig { +// drug: Drugs::Weed, +// drug_id: Drugs::Weed.into(), +// base: 290, +// step: 18, +// weight: 15, +// name: Bytes16Impl::from('Weed') +// } +// ); + +// set!( +// world, +// DrugConfig { +// drug: Drugs::Shrooms, +// drug_id: Drugs::Shrooms.into(), +// base: 980, +// step: 54, +// weight: 25, +// name: Bytes16Impl::from('Shrooms') +// } +// ); + +// set!( +// world, +// DrugConfig { +// drug: Drugs::Acid, +// drug_id: Drugs::Acid.into(), +// base: 2900, +// step: 111, +// weight: 30, +// name: Bytes16Impl::from('Acid') +// } +// ); + +// set!( +// world, +// DrugConfig { +// drug: Drugs::Ketamine, +// drug_id: Drugs::Ketamine.into(), +// base: 6800, +// step: 186, +// weight: 45, +// name: Bytes16Impl::from('Ketamine') +// } +// ); + +// set!( +// world, +// DrugConfig { +// drug: Drugs::Heroin, +// drug_id: Drugs::Heroin.into(), +// base: 13500, +// step: 231, +// weight: 65, +// name: Bytes16Impl::from('Heroin') +// } +// ); + +// set!( +// world, +// DrugConfig { +// drug: Drugs::Cocaine, +// drug_id: Drugs::Cocaine.into(), +// base: 19800, +// step: 284, +// weight: 100, +// name: Bytes16Impl::from('Cocaine') +// } +// ); +// } \ No newline at end of file diff --git a/src/config/encounters.cairo b/src/config/encounters.cairo index 1bda192ed..5f3c6b7db 100644 --- a/src/config/encounters.cairo +++ b/src/config/encounters.cairo @@ -67,11 +67,7 @@ struct EncounterConfig { max_rep: u8, // payout: u32, - demand_pct: u8, - // crit_rate:u8, - // incorruptible: bool, - // challenger: bool, - // challenger: bool, + } // @@ -137,13 +133,7 @@ impl EncounterSpawnerImpl of EncounterSpawnerTrait { let rand_id = *encounters_ids.at(rand_index.try_into().unwrap()); let mut encounter = get!(game_store.world, (rand_id), (EncounterConfig)); - - // set random demand_pct - encounter.demand_pct = EncounterSpawnerImpl::get_random_demand_pct(ref game_store); - - // set scaling payout - encounter.payout = (encounter.level.into() * encounter.level.into() * 3_000) + (game_store.player.turn.into() * 1_000); - + encounter } @@ -156,8 +146,10 @@ impl EncounterSpawnerImpl of EncounterSpawnerTrait { if rand_0_99 < 1 { 69 - } else if rand_0_99 < 20 { + } else if rand_0_99 < 10 { 50 + } else if rand_0_99 < 20 { + 40 } else if rand_0_99 < 50 { 30 } else { @@ -185,6 +177,14 @@ impl EncounterImpl of EncounterTrait { self.health = self.health.sub_capped(amount, 0); } + fn get_demand_pct(self: EncounterConfig, ref game_store: GameStore) -> u8 { + EncounterSpawnerImpl::get_random_demand_pct(ref game_store) + } + + fn get_payout(self: EncounterConfig, ref game_store: GameStore) -> u32 { + (self.level.into() * self.level.into() * 3_000) + (game_store.player.turn.into() * 1_000) + } + } @@ -252,7 +252,6 @@ fn initialize_encounter_config(world: IWorldDispatcher) { max_rep: (i * 15) + 25, // payout: 0, // overrided - demand_pct: 0, // overrided }; EncounterConfigImpl::add_encounter(world,ref encounter, ref game_config); @@ -287,7 +286,6 @@ fn initialize_encounter_config(world: IWorldDispatcher) { max_rep: (i * 15) + 25, // payout: 0, // overrided - demand_pct: 0, // overrided }; EncounterConfigImpl::add_encounter(world,ref encounter, ref game_config); @@ -297,7 +295,6 @@ fn initialize_encounter_config(world: IWorldDispatcher) { // save encounter_count GameConfigImpl::set(world, game_config); - // initialize_encounter_config_extra(world); } fn initialize_encounter_config_extra(world: IWorldDispatcher) { @@ -311,20 +308,19 @@ fn initialize_encounter_config_extra(world: IWorldDispatcher) { encounter: Encounters::Cops, // level: 1, - health: 16, - attack: 8, - defense: 5, - speed : 2, + health: 15, + attack: 15, + defense: 15, + speed : 15, // - rep_pay: 10, - rep_run: 0, + rep_pay: 5, + rep_run: 1, rep_fight: 2, // min_rep: 0, max_rep: 40, // payout: 0, // overrided - demand_pct: 0, // overrided }; @@ -332,27 +328,47 @@ fn initialize_encounter_config_extra(world: IWorldDispatcher) { id:0, encounter: Encounters::Cops, // - level: 3, - health: 26, - attack: 16, - defense: 11, - speed : 14, + level: 2, + health: 25, + attack: 25, + defense: 25, + speed : 25, // rep_pay: 6, rep_run: 2, rep_fight: 4, // - min_rep: 40, + min_rep: 30, + max_rep: 70, + // + payout: 0, // overrided + }; + + let mut cops3 = EncounterConfig { + id:0, + encounter: Encounters::Cops, + // + level: 3, + health: 35, + attack: 35, + defense: 35, + speed : 25, + // + rep_pay: 7, + rep_run: 3, + rep_fight: 5, + // + min_rep: 50, max_rep: 100, // payout: 0, // overrided - demand_pct: 0, // overrided }; EncounterConfigImpl::add_encounter(world,ref cops1, ref game_config ); EncounterConfigImpl::add_encounter(world,ref cops2, ref game_config ); + EncounterConfigImpl::add_encounter(world,ref cops3, ref game_config ); //////// GANGS //////// @@ -361,47 +377,66 @@ fn initialize_encounter_config_extra(world: IWorldDispatcher) { id:0, encounter: Encounters::Gang, // - level: 2, - health: 40, - attack: 25, + level: 1, + health: 15, + attack: 15, defense: 15, - speed : 20, + speed : 15, // - rep_pay: 10, - rep_run: 0, - rep_fight: 2, + rep_pay: 12, + rep_run: 2, + rep_fight: 3, // min_rep: 0, max_rep: 40, // payout: 0, // overrided - demand_pct: 0, // overrided }; let mut gang2 = EncounterConfig { id:0, encounter: Encounters::Gang, // - level: 4, - health: 60, - attack: 45, + level: 2, + health: 25, + attack: 25, defense: 25, speed : 35, // - rep_pay: 6, + rep_pay: 5, rep_run: 2, rep_fight: 4, // - min_rep: 40, + min_rep: 30, + max_rep: 80, + // + payout: 0, // overrided + }; + + let mut gang3 = EncounterConfig { + id:0, + encounter: Encounters::Gang, + // + level: 4, + health: 45, + attack: 45, + defense: 45, + speed : 45, + // + rep_pay: 4, + rep_run: 3, + rep_fight: 6, + // + min_rep: 60, max_rep: 100, // payout: 0, // overrided - demand_pct: 0, // overrided }; EncounterConfigImpl::add_encounter(world,ref gang1, ref game_config ); EncounterConfigImpl::add_encounter(world,ref gang2, ref game_config ); + EncounterConfigImpl::add_encounter(world,ref gang3, ref game_config ); // save encounter_count GameConfigImpl::set(world, game_config); diff --git a/src/systems/ryo.cairo b/src/systems/ryo.cairo index 4c11cfcfb..da996fc6a 100644 --- a/src/systems/ryo.cairo +++ b/src/systems/ryo.cairo @@ -8,7 +8,6 @@ trait IRyo { fn set_paused(self: @T, paused: bool); fn set_paper_fee(self: @T, fee: u16); fn set_treasury_fee_pct(self: @T, fee_pct: u8); - fn set_leaderboard_duration(self: @T, duration_sec: u32); // diff --git a/src/systems/traveling.cairo b/src/systems/traveling.cairo index 9f650dea6..cf7cc4e94 100644 --- a/src/systems/traveling.cairo +++ b/src/systems/traveling.cairo @@ -110,8 +110,8 @@ fn on_travel(ref game_store: GameStore, ref randomizer: Random) -> (bool, bool) game_id: game_store.game.game_id, player_id: game_store.game.player_id, encounter_id: encounter.id, - demand_pct: encounter.demand_pct, - payout: encounter.payout, + demand_pct: encounter.get_demand_pct(ref game_store), + payout: encounter.get_payout(ref game_store), } ))); @@ -200,7 +200,7 @@ fn on_pay( Encounters::Cops => { // pay demand_pct drugs let mut drug_unpacked = game_store.drugs.get(); - let quantity_lost = drug_unpacked.quantity.pct(encounter.demand_pct.into()); + let quantity_lost = drug_unpacked.quantity.pct(encounter.get_demand_pct(ref game_store).into()); // can't pay assert(quantity_lost > 0, 'you cant pay!'); @@ -214,7 +214,7 @@ fn on_pay( }, Encounters::Gang => { // calc cash_loss - result.cash_loss = game_store.player.cash.pct(encounter.demand_pct.into()); + result.cash_loss = game_store.player.cash.pct(encounter.get_demand_pct(ref game_store).into()); // can't pay assert(result.cash_loss > 0, 'you cant pay!'); @@ -361,7 +361,7 @@ fn on_fight( result.cash_earnt = if game_store.player.is_dead() { 0 } else { - encounter.payout + encounter.get_payout(ref game_store) }; // player get money @@ -417,6 +417,13 @@ struct EncounterRaceWinResult { #[generate_trait] impl ResolutionImpl of ResolutionTrait { + fn plus_or_less_random_pct(value: u8, pct: u8, ref randomizer: Random) -> u8 { + let value_pct = value.pct(pct.into()); + let rand = randomizer.between::(0, value_pct * 2); + + value + rand - value_pct + } + fn race(ref game_store: GameStore, ref encounter: EncounterConfig, ref randomizer: Random) -> RaceResult { let rand_player = randomizer.between::(0,game_store.items.speed()); let rand_encounter = randomizer.between::(0,encounter.speed); @@ -428,7 +435,11 @@ impl ResolutionImpl of ResolutionTrait { } fn hustler_attack(ref game_store: GameStore, ref encounter: EncounterConfig, ref randomizer: Random) -> AttackResult { - let hustler_attack:u8 = game_store.items.attack(); + let hustler_attack:u8 = ResolutionImpl::plus_or_less_random_pct( + game_store.items.attack(), + 20, + ref randomizer + ); let dmg_shield = hustler_attack.pct(encounter.defense.into()); let dmg_dealt = hustler_attack - dmg_shield; @@ -444,7 +455,13 @@ impl ResolutionImpl of ResolutionTrait { } fn encounter_attack(ref game_store: GameStore, ref encounter: EncounterConfig, ref randomizer: Random) -> AttackResult { - let encounter_attack = encounter.attack / 3; // TODO: config *** + let mut encounter_attack = ResolutionImpl::plus_or_less_random_pct( + encounter.attack, + 20, + ref randomizer + ); + + encounter_attack = encounter.attack / 3; // TODO: config *** let hustler_defense = game_store.items.defense(); let dmg_shield = encounter_attack.pct(hustler_defense.into()); @@ -462,7 +479,13 @@ 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 / 5; // TODO: config *** + let mut encounter_attack = ResolutionImpl::plus_or_less_random_pct( + encounter.attack, + 20, + ref randomizer + ); + + encounter_attack = encounter.attack / 5; // TODO: config *** let hustler_defense = game_store.items.defense(); let dmg_shield = encounter_attack.pct(hustler_defense.into()); diff --git a/web/manifest.json b/web/manifest.json index 461995fdb..5e5866c65 100644 --- a/web/manifest.json +++ b/web/manifest.json @@ -1262,8 +1262,8 @@ { "kind": "DojoContract", "address": "0x77cfc8df2e0d60abf3ad87a9773a91f72cde6b65a860fe98cd55c4900ce29ea", - "class_hash": "0x6d7bc9b15c3ee62d3c114089b4e64baafd3c1df44036a2b68ee7451c0b401f2", - "original_class_hash": "0x6d7bc9b15c3ee62d3c114089b4e64baafd3c1df44036a2b68ee7451c0b401f2", + "class_hash": "0x517218b8d3fc4b967b60c7937bfadf5ff82f60d87a6b0022e6ace397366780c", + "original_class_hash": "0x517218b8d3fc4b967b60c7937bfadf5ff82f60d87a6b0022e6ace397366780c", "base_class_hash": "0x679177a2cb757694ac4f326d01052ff0963eac0bc2a17116a2b87badcdf6f76", "abi": [ { @@ -1629,6 +1629,78 @@ } ] }, + { + "type": "enum", + "name": "rollyourown::config::encounters::Encounters", + "variants": [ + { + "name": "Cops", + "type": "()" + }, + { + "name": "Gang", + "type": "()" + } + ] + }, + { + "type": "struct", + "name": "rollyourown::config::encounters::EncounterConfig", + "members": [ + { + "name": "id", + "type": "core::integer::u8" + }, + { + "name": "encounter", + "type": "rollyourown::config::encounters::Encounters" + }, + { + "name": "level", + "type": "core::integer::u8" + }, + { + "name": "health", + "type": "core::integer::u8" + }, + { + "name": "attack", + "type": "core::integer::u8" + }, + { + "name": "defense", + "type": "core::integer::u8" + }, + { + "name": "speed", + "type": "core::integer::u8" + }, + { + "name": "rep_pay", + "type": "core::integer::u8" + }, + { + "name": "rep_run", + "type": "core::integer::u8" + }, + { + "name": "rep_fight", + "type": "core::integer::u8" + }, + { + "name": "min_rep", + "type": "core::integer::u8" + }, + { + "name": "max_rep", + "type": "core::integer::u8" + }, + { + "name": "payout", + "type": "core::integer::u32" + } + ] + }, { "type": "interface", "name": "rollyourown::config::config::IConfig", @@ -1681,6 +1753,18 @@ ], "outputs": [], "state_mutability": "view" + }, + { + "type": "function", + "name": "update_encounter_config", + "inputs": [ + { + "name": "encounter_config", + "type": "rollyourown::config::encounters::EncounterConfig" + } + ], + "outputs": [], + "state_mutability": "view" } ] }, @@ -1908,8 +1992,8 @@ { "kind": "DojoContract", "address": "0x1318cc9a062d080e98792cfc7af13b96bf465134474bcba1a190ae76304df7", - "class_hash": "0xbf7d314d7ab2b6d9a51f772abe004582317537e8ce70ca7b2380d2f7a65f52", - "original_class_hash": "0xbf7d314d7ab2b6d9a51f772abe004582317537e8ce70ca7b2380d2f7a65f52", + "class_hash": "0x7e612582da22cc4cc56266e3019c30063d0d6a204b1b607fd3ff8f5655620d4", + "original_class_hash": "0x7e612582da22cc4cc56266e3019c30063d0d6a204b1b607fd3ff8f5655620d4", "base_class_hash": "0x679177a2cb757694ac4f326d01052ff0963eac0bc2a17116a2b87badcdf6f76", "abi": [ { @@ -3411,15 +3495,10 @@ "name": "payout", "type": "u32", "key": false - }, - { - "name": "demand_pct", - "type": "u8", - "key": false } ], - "class_hash": "0x5160839064ca0d37a8702c95d6c64cb2ce43c018e6d574c1c66b5f528558ae7", - "original_class_hash": "0x5160839064ca0d37a8702c95d6c64cb2ce43c018e6d574c1c66b5f528558ae7", + "class_hash": "0x6096229c6671813a20e47b67831e5f23ff2ea92ec0a81fd2d2d70253d1b8a0b", + "original_class_hash": "0x6096229c6671813a20e47b67831e5f23ff2ea92ec0a81fd2d2d70253d1b8a0b", "abi": [ { "type": "impl", @@ -3663,10 +3742,6 @@ { "name": "payout", "type": "core::integer::u32" - }, - { - "name": "demand_pct", - "type": "core::integer::u8" } ] }, diff --git a/web/src/components/layout/Header.tsx b/web/src/components/layout/Header.tsx index 2409954a7..52d47b403 100644 --- a/web/src/components/layout/Header.tsx +++ b/web/src/components/layout/Header.tsx @@ -22,7 +22,7 @@ interface HeaderProps { export const Header = observer(({ back }: HeaderProps) => { const isMobile = IsMobile(); - const { router, gameId } = useRouterContext(); + const { router, gameId, isAdmin } = useRouterContext(); const { account } = useAccount(); @@ -47,7 +47,7 @@ export const Header = observer(({ back }: HeaderProps) => { fontSize={["14px", "16px"]} > - {!isMobile && ( + {isAdmin && ( <> diff --git a/web/src/components/layout/Layout.tsx b/web/src/components/layout/Layout.tsx index cd4799269..67192a572 100644 --- a/web/src/components/layout/Layout.tsx +++ b/web/src/components/layout/Layout.tsx @@ -5,6 +5,7 @@ import { Header } from "./Header"; import { IsMobile } from "@/utils/ui"; import { CrtEffect } from "./CrtEffect"; +import { Pending } from "./Pending"; interface LayoutProps { CustomLeftPanel?: React.FC; @@ -61,6 +62,7 @@ export const Layout = ({ + ); }; diff --git a/web/src/components/layout/MobileMenu.tsx b/web/src/components/layout/MobileMenu.tsx index be5a26920..ad1f30aba 100644 --- a/web/src/components/layout/MobileMenu.tsx +++ b/web/src/components/layout/MobileMenu.tsx @@ -9,7 +9,7 @@ import { HeaderButton } from "./HeaderButton"; import { MediaPlayer } from "./MediaPlayer"; export const MobileMenu = ({ ...props }: StyleProps) => { - const { gameId } = useRouterContext(); + const { gameId, isRyoDotGame } = useRouterContext(); const { uiStore } = useDojoContext(); return ( <> @@ -28,18 +28,20 @@ export const MobileMenu = ({ ...props }: StyleProps) => { - - {" "} - {" "} - - + {!isRyoDotGame && ( + + + {" "} + + + )} {gameId && ( <> { - uiStore.openRefreshGame(); + uiStore.openRefreshGame(); }} > IM LOST diff --git a/web/src/components/layout/Pending.tsx b/web/src/components/layout/Pending.tsx index 7151eb53a..55e71c098 100644 --- a/web/src/components/layout/Pending.tsx +++ b/web/src/components/layout/Pending.tsx @@ -1,7 +1,10 @@ +import { useSystems } from "@/dojo/hooks"; import { Box } from "@chakra-ui/react"; import { blinkAnim } from "../player"; export const Pending = () => { + const {isPending} = useSystems() + if(!isPending) return null return ( <> { const table = useTable({ onDispatch: (action) => { - console.log(action); + // console.log(action); if (action.type === ActionType.UpdateEditorValue) { const toUpdateIndex = data.findIndex((i) => i.drug_id === action.rowKeyValue); diff --git a/web/src/components/pages/admin/EncounterTable.tsx b/web/src/components/pages/admin/EncounterTable.tsx index 5525e4b4f..f8dfcbfa3 100644 --- a/web/src/components/pages/admin/EncounterTable.tsx +++ b/web/src/components/pages/admin/EncounterTable.tsx @@ -23,7 +23,7 @@ const columns = [ // { key: "min_rep", title: "min_rep", dataType: DataType.Number }, { key: "max_rep", title: "max_rep", dataType: DataType.Number }, - // // + // // { key: "payout", title: "payout", dataType: DataType.Number }, // { key: "demand_pct", title: "demand_pct", dataType: DataType.Number }, @@ -35,13 +35,12 @@ export const EncounterTable = observer(() => { configStore: { config }, } = useDojoContext(); - const { updateDrugConfig } = useSystems(); + const { updateEncounterConfig } = useSystems(); const [data, setData] = useState(config?.encounters || []); const table = useTable({ onDispatch: (action) => { - console.log(action); // triggered on cell modifs if (action.type === ActionType.UpdateEditorValue) { @@ -61,15 +60,13 @@ export const EncounterTable = observer(() => { const update = data.find((i) => i.id === action.rowKeyValue); if (!update) return; - // const newValue = { - // drug: update.drug_id, - // drug_id: update.drug_id, - // base: update.base, - // step: update.step, - // weight: update.weight, - // name: shortString.encodeShortString(update.name), - // }; - // updateDrugConfig(newValue); + const newValue = { + ...update, + encounter: update.encounter === "Cops" ? 0 : 1, + }; + delete newValue.image; + // console.log(newValue) + updateEncounterConfig(newValue); } if (action.type === ActionType.CloseRowEditors) { diff --git a/web/src/components/pages/admin/GameConfigTable.tsx b/web/src/components/pages/admin/GameConfigTable.tsx index 296e32381..0d2e98ea6 100644 --- a/web/src/components/pages/admin/GameConfigTable.tsx +++ b/web/src/components/pages/admin/GameConfigTable.tsx @@ -38,7 +38,7 @@ export const GameConfigTable = observer(() => { const table = useTable({ onDispatch: (action) => { - console.log(action); + // console.log(action); if (action.type === ActionType.UpdateEditorValue) { setData([ diff --git a/web/src/components/pages/admin/HustlerItemBaseTable.tsx b/web/src/components/pages/admin/HustlerItemBaseTable.tsx index 00bab1e72..b35a1898e 100644 --- a/web/src/components/pages/admin/HustlerItemBaseTable.tsx +++ b/web/src/components/pages/admin/HustlerItemBaseTable.tsx @@ -24,7 +24,7 @@ export const HustlerItemBaseTable = observer(() => { width="100%" columns={columns} data={config?.items || []} - rowKeyField={"id"} + rowKeyField={"name"} editingMode={EditingMode.None} childComponents={editComponents} /> diff --git a/web/src/components/pages/home/ClaimReward.tsx b/web/src/components/pages/home/ClaimReward.tsx index ba30620d8..4f4e23b8d 100644 --- a/web/src/components/pages/home/ClaimReward.tsx +++ b/web/src/components/pages/home/ClaimReward.tsx @@ -2,6 +2,7 @@ import { Gem } from "@/components/icons"; import { MakeItRain } from "@/components/layout"; import { useConfigStore, useHallOfFame } from "@/dojo/hooks"; import { Leaderboard } from "@/generated/graphql"; +import { IsMobile } from "@/utils/ui"; import { Button } from "@chakra-ui/react"; import { useAccount } from "@starknet-react/core"; import { useEffect, useState } from "react"; @@ -17,6 +18,8 @@ export const ClaimReward = () => { const [isClaimModalOpen, setIsClaimModalOpen] = useState(false); const [isRainning, setIsRainning] = useState(false); + const isMobile = IsMobile() + useEffect(() => { if (!hallOfFame) { setClaimable([]); @@ -52,7 +55,7 @@ export const ClaimReward = () => { }} onClick={() => setIsClaimModalOpen(true)} > - Claim + {!isMobile ? 'Claim' : ""} diff --git a/web/src/components/pages/profile/HustlerStats.tsx b/web/src/components/pages/profile/HustlerStats.tsx index fff047c3f..0baeda8f0 100644 --- a/web/src/components/pages/profile/HustlerStats.tsx +++ b/web/src/components/pages/profile/HustlerStats.tsx @@ -9,17 +9,17 @@ export const HustlerStats = observer(() => { if(!game) return null return ( - - {game?.items.attack.icon({})} {game?.items.attack.tier.stat} - + + {game?.items.attack.icon({})} {game?.items.attack.tier.stat} + - - {game?.items.defense.icon({})} {game?.items.defense.tier.stat} - + + {game?.items.defense.icon({})} {game?.items.defense.tier.stat} + - - {game?.items.speed.icon({})} {game?.items.speed.tier.stat} - + + {game?.items.speed.icon({})} {game?.items.speed.tier.stat} + diff --git a/web/src/components/wallet/StarknetProvider.tsx b/web/src/components/wallet/StarknetProvider.tsx index f3d8670c9..39c47b4c3 100644 --- a/web/src/components/wallet/StarknetProvider.tsx +++ b/web/src/components/wallet/StarknetProvider.tsx @@ -19,15 +19,16 @@ export const walletInstallLinks = { export type walletInstallLinksKeys = keyof typeof walletInstallLinks; function rpc(chain: Chain) { + //console.log(chain) return { - nodeUrl: process.env.NEXT_PUBLIC_RPC_ENDPOINT, + nodeUrl: chain.rpcUrls.default.http[0], }; } export function StarknetProvider({ children }: { children: ReactNode }) { const { connectors } = useInjectedConnectors({ // Show these connectors if the user has no connector installed. - recommended: [argent(), braavos(), injected({id:'dojoburner'})], + recommended: [argent(), braavos(), injected({ id: "dojoburner" })], // Hide recommended connectors if the user has any connector installed. includeRecommended: "always", // Randomize the order of the connectors. diff --git a/web/src/dojo/abis/configAbi.ts b/web/src/dojo/abis/configAbi.ts index 4d09ead82..322641e4d 100644 --- a/web/src/dojo/abis/configAbi.ts +++ b/web/src/dojo/abis/configAbi.ts @@ -362,6 +362,78 @@ export const ABI = [ } ] }, + { + "type": "enum", + "name": "rollyourown::config::encounters::Encounters", + "variants": [ + { + "name": "Cops", + "type": "()" + }, + { + "name": "Gang", + "type": "()" + } + ] + }, + { + "type": "struct", + "name": "rollyourown::config::encounters::EncounterConfig", + "members": [ + { + "name": "id", + "type": "core::integer::u8" + }, + { + "name": "encounter", + "type": "rollyourown::config::encounters::Encounters" + }, + { + "name": "level", + "type": "core::integer::u8" + }, + { + "name": "health", + "type": "core::integer::u8" + }, + { + "name": "attack", + "type": "core::integer::u8" + }, + { + "name": "defense", + "type": "core::integer::u8" + }, + { + "name": "speed", + "type": "core::integer::u8" + }, + { + "name": "rep_pay", + "type": "core::integer::u8" + }, + { + "name": "rep_run", + "type": "core::integer::u8" + }, + { + "name": "rep_fight", + "type": "core::integer::u8" + }, + { + "name": "min_rep", + "type": "core::integer::u8" + }, + { + "name": "max_rep", + "type": "core::integer::u8" + }, + { + "name": "payout", + "type": "core::integer::u32" + } + ] + }, { "type": "interface", "name": "rollyourown::config::config::IConfig", @@ -414,6 +486,18 @@ export const ABI = [ ], "outputs": [], "state_mutability": "view" + }, + { + "type": "function", + "name": "update_encounter_config", + "inputs": [ + { + "name": "encounter_config", + "type": "rollyourown::config::encounters::EncounterConfig" + } + ], + "outputs": [], + "state_mutability": "view" } ] }, diff --git a/web/src/dojo/hooks/useAutoBurner.ts b/web/src/dojo/hooks/useAutoBurner.ts new file mode 100644 index 000000000..6d515562a --- /dev/null +++ b/web/src/dojo/hooks/useAutoBurner.ts @@ -0,0 +1,24 @@ + +import { useEffect } from "react"; + +export const useAutoBurner = () => { + + useEffect(() => { + + if (!window.localStorage) return + + const lastSelectedChainId = window.localStorage.getItem('lastSelectedChainId') + const lastUsedConnector = window.localStorage.getItem('lastUsedConnector') + + if (!lastSelectedChainId ) { + window.localStorage.setItem('lastSelectedChainId', 'KATANA_SLOT_420') + } + if ( !lastUsedConnector) { + window.localStorage.setItem('lastUsedConnector', 'dojoburner') + } + + + }, []); + +} + diff --git a/web/src/dojo/hooks/useRouterContext.ts b/web/src/dojo/hooks/useRouterContext.ts index b901f39ff..7750b1d24 100644 --- a/web/src/dojo/hooks/useRouterContext.ts +++ b/web/src/dojo/hooks/useRouterContext.ts @@ -13,6 +13,8 @@ type RouterContext = { location: LocationConfigFull | undefined, drug: DrugConfigFull | undefined, tradeDirection: TradeDirection | undefined, + isAdmin: boolean, + isRyoDotGame: boolean, } export const useRouterContext = (): RouterContext => { @@ -26,6 +28,8 @@ export const useRouterContext = (): RouterContext => { location: undefined, drug: undefined, tradeDirection: undefined, + isAdmin: false, + isRyoDotGame: false }); useEffect(() => { @@ -39,6 +43,8 @@ export const useRouterContext = (): RouterContext => { (router.query.tradeDirection as string) === "buy" ? TradeDirection.Buy : TradeDirection.Sell : undefined; + const isAdmin = router.pathname.startsWith('/admin') + const isRyoDotGame = window.location.host === "ryo.game" const ctx = { router, @@ -47,6 +53,8 @@ export const useRouterContext = (): RouterContext => { location, drug, tradeDirection, + isAdmin, + isRyoDotGame } setContext(ctx) diff --git a/web/src/dojo/hooks/useSystems.ts b/web/src/dojo/hooks/useSystems.ts index 591035dc1..36c5c4382 100644 --- a/web/src/dojo/hooks/useSystems.ts +++ b/web/src/dojo/hooks/useSystems.ts @@ -1,4 +1,4 @@ -import { DrugConfig, GameConfig } from "@/generated/graphql"; +import { DrugConfig, EncounterConfig, GameConfig } from "@/generated/graphql"; import { useToast } from "@/hooks/toast"; import { getEvents } from "@dojoengine/utils"; import { useAccount } from "@starknet-react/core"; @@ -26,9 +26,11 @@ export interface SystemsInterface { claimTreasury: () => Promise; setPaperFee: (fee: number) => Promise; setTreasuryFeePct: (fee: number) => Promise; + setLeaderboardDuration: (duration: number) => Promise; // config updateGameConfig: (gameConfig: GameConfig) => Promise; updateDrugConfig: (drugConfig: DrugConfig) => Promise; + updateEncounterConfig: (encounterConfig: EncounterConfig) => Promise; // dev failingTx: () => Promise; @@ -112,11 +114,11 @@ export const useSystems = (): SystemsInterface => { tx = await dojoProvider.executeMulti(account!, params) } - toast({ - message: `tx sent ${tx.transaction_hash.substring(0, 4)}...${tx.transaction_hash.slice(-4)}`, - duration: 5_000, - isError: false - }) + // toast({ + // message: `tx sent ${tx.transaction_hash.substring(0, 4)}...${tx.transaction_hash.slice(-4)}`, + // duration: 5_000, + // isError: false + // }) // chill await sleep(500); @@ -278,7 +280,7 @@ export const useSystems = (): SystemsInterface => { const decide = useCallback( async (gameId: string, action: EncountersAction) => { - const { hash, events, parsedEvents } = await executeAndReceipt( + const { hash, events, parsedEvents } = await executeAndReceipt( { contractName: "rollyourown::systems::game::game", functionName: "decide", @@ -413,6 +415,28 @@ export const useSystems = (): SystemsInterface => { ); + const setLeaderboardDuration = useCallback( + async (duration: number) => { + + const { hash, events, parsedEvents } = await executeAndReceipt( + { + contractName: "rollyourown::systems::ryo::ryo", + functionName: "set_leaderboard_duration", + callData: [duration], + } + ); + + return { + hash, + }; + + }, + [executeAndReceipt], + ); + + + + const updateGameConfig = useCallback( async (gameConfig: GameConfig) => { @@ -456,6 +480,33 @@ export const useSystems = (): SystemsInterface => { // // + const updateEncounterConfig = useCallback( + async (encounterConfig: EncounterConfig) => { + + const { hash, events, parsedEvents } = await executeAndReceipt( + { + contractName: "rollyourown::config::config::config", + functionName: "update_encounter_config", + callData: [encounterConfig], + } + ); + + return { + hash, + }; + + }, + [executeAndReceipt], + ); + + + + // + // + // + + + const feedLeaderboard = useCallback( async (count: number) => { @@ -506,9 +557,11 @@ export const useSystems = (): SystemsInterface => { setPaused, setPaperFee, setTreasuryFeePct, + setLeaderboardDuration, // updateGameConfig, updateDrugConfig, + updateEncounterConfig, // feedLeaderboard, failingTx, diff --git a/web/src/dojo/stores/config.tsx b/web/src/dojo/stores/config.tsx index fec5e3e61..a1d444d2b 100644 --- a/web/src/dojo/stores/config.tsx +++ b/web/src/dojo/stores/config.tsx @@ -60,7 +60,7 @@ export type HustlerItemBaseConfigFull = HustlerItemBaseConfig & { }; export type EncounterConfigFull = EncounterConfig & { - image: string; + image?: string; }; export type HustlerConfig = { diff --git a/web/src/generated/graphql.ts b/web/src/generated/graphql.ts index 480993e2c..8e3e41dd9 100644 --- a/web/src/generated/graphql.ts +++ b/web/src/generated/graphql.ts @@ -302,7 +302,6 @@ export type EncounterConfig = { __typename?: 'EncounterConfig'; attack?: Maybe; defense?: Maybe; - demand_pct?: Maybe; encounter?: Maybe; entity?: Maybe; health?: Maybe; @@ -338,7 +337,6 @@ export type EncounterConfigOrder = { export enum EncounterConfigOrderField { Attack = 'ATTACK', Defense = 'DEFENSE', - DemandPct = 'DEMAND_PCT', Encounter = 'ENCOUNTER', Health = 'HEALTH', Id = 'ID', @@ -367,13 +365,6 @@ export type EncounterConfigWhereInput = { defenseLT?: InputMaybe; defenseLTE?: InputMaybe; defenseNEQ?: InputMaybe; - demand_pct?: InputMaybe; - demand_pctEQ?: InputMaybe; - demand_pctGT?: InputMaybe; - demand_pctGTE?: InputMaybe; - demand_pctLT?: InputMaybe; - demand_pctLTE?: InputMaybe; - demand_pctNEQ?: InputMaybe; encounter?: InputMaybe; health?: InputMaybe; healthEQ?: InputMaybe; @@ -1717,7 +1708,7 @@ export type World__TransactionEdge = { export type ConfigQueryVariables = Exact<{ [key: string]: never; }>; -export type ConfigQuery = { __typename?: 'World__Query', ryoAddressModels?: { __typename?: 'RyoAddressConnection', edges?: Array<{ __typename?: 'RyoAddressEdge', node?: { __typename?: 'RyoAddress', key?: any | null, paper?: any | null, treasury?: any | null } | null } | null> | null } | null, ryoConfigModels?: { __typename?: 'RyoConfigConnection', edges?: Array<{ __typename?: 'RyoConfigEdge', node?: { __typename?: 'RyoConfig', key?: any | null, initialized?: any | null, paused?: any | null, leaderboard_version?: any | null, paper_fee?: any | null, treasury_fee_pct?: any | null, treasury_balance?: any | null } | null } | null> | null } | null, drugConfigModels?: { __typename?: 'DrugConfigConnection', edges?: Array<{ __typename?: 'DrugConfigEdge', node?: { __typename?: 'DrugConfig', drug?: any | null, drug_id?: any | null, base?: any | null, step?: any | null, weight?: any | null, name?: any | null } | null } | null> | null } | null, locationConfigModels?: { __typename?: 'LocationConfigConnection', edges?: Array<{ __typename?: 'LocationConfigEdge', node?: { __typename?: 'LocationConfig', location?: any | null, location_id?: any | null, name?: any | null } | null } | null> | null } | null, hustlerItemBaseConfigModels?: { __typename?: 'HustlerItemBaseConfigConnection', edges?: Array<{ __typename?: 'HustlerItemBaseConfigEdge', node?: { __typename?: 'HustlerItemBaseConfig', slot?: any | null, id?: any | null, slot_id?: any | null, name?: any | null, initial_tier?: any | null } | null } | null> | null } | null, hustlerItemTiersConfigModels?: { __typename?: 'HustlerItemTiersConfigConnection', edges?: Array<{ __typename?: 'HustlerItemTiersConfigEdge', node?: { __typename?: 'HustlerItemTiersConfig', slot?: any | null, slot_id?: any | null, tier?: any | null, cost?: any | null, stat?: any | null } | null } | null> | null } | null, encounterConfigModels?: { __typename?: 'EncounterConfigConnection', edges?: Array<{ __typename?: 'EncounterConfigEdge', node?: { __typename?: 'EncounterConfig', id?: any | null, encounter?: any | null, level?: any | null, health?: any | null, attack?: any | null, defense?: any | null, speed?: any | null, payout?: any | null, demand_pct?: any | null, rep_pay?: any | null, rep_run?: any | null, rep_fight?: any | null, min_rep?: any | null, max_rep?: any | null } | null } | null> | null } | null }; +export type ConfigQuery = { __typename?: 'World__Query', ryoAddressModels?: { __typename?: 'RyoAddressConnection', edges?: Array<{ __typename?: 'RyoAddressEdge', node?: { __typename?: 'RyoAddress', key?: any | null, paper?: any | null, treasury?: any | null } | null } | null> | null } | null, ryoConfigModels?: { __typename?: 'RyoConfigConnection', edges?: Array<{ __typename?: 'RyoConfigEdge', node?: { __typename?: 'RyoConfig', key?: any | null, initialized?: any | null, paused?: any | null, leaderboard_version?: any | null, leaderboard_duration?: any | null, paper_fee?: any | null, treasury_fee_pct?: any | null, treasury_balance?: any | null } | null } | null> | null } | null, drugConfigModels?: { __typename?: 'DrugConfigConnection', edges?: Array<{ __typename?: 'DrugConfigEdge', node?: { __typename?: 'DrugConfig', drug?: any | null, drug_id?: any | null, base?: any | null, step?: any | null, weight?: any | null, name?: any | null } | null } | null> | null } | null, locationConfigModels?: { __typename?: 'LocationConfigConnection', edges?: Array<{ __typename?: 'LocationConfigEdge', node?: { __typename?: 'LocationConfig', location?: any | null, location_id?: any | null, name?: any | null } | null } | null> | null } | null, hustlerItemBaseConfigModels?: { __typename?: 'HustlerItemBaseConfigConnection', edges?: Array<{ __typename?: 'HustlerItemBaseConfigEdge', node?: { __typename?: 'HustlerItemBaseConfig', slot?: any | null, id?: any | null, slot_id?: any | null, name?: any | null, initial_tier?: any | null } | null } | null> | null } | null, hustlerItemTiersConfigModels?: { __typename?: 'HustlerItemTiersConfigConnection', edges?: Array<{ __typename?: 'HustlerItemTiersConfigEdge', node?: { __typename?: 'HustlerItemTiersConfig', slot?: any | null, slot_id?: any | null, tier?: any | null, cost?: any | null, stat?: any | null } | null } | null> | null } | null, encounterConfigModels?: { __typename?: 'EncounterConfigConnection', edges?: Array<{ __typename?: 'EncounterConfigEdge', node?: { __typename?: 'EncounterConfig', id?: any | null, encounter?: any | null, level?: any | null, health?: any | null, attack?: any | null, defense?: any | null, speed?: any | null, rep_pay?: any | null, rep_run?: any | null, rep_fight?: any | null, min_rep?: any | null, max_rep?: any | null, payout?: any | null } | null } | null> | null } | null }; export type GameEventsQueryVariables = Exact<{ gameId: Scalars['String']; @@ -1794,6 +1785,7 @@ export const ConfigDocument = ` initialized paused leaderboard_version + leaderboard_duration paper_fee treasury_fee_pct treasury_balance @@ -1853,13 +1845,12 @@ export const ConfigDocument = ` attack defense speed - payout - demand_pct rep_pay rep_run rep_fight min_rep max_rep + payout } } } diff --git a/web/src/graphql/config.graphql b/web/src/graphql/config.graphql index 54e0d5e0e..c1f8340cb 100644 --- a/web/src/graphql/config.graphql +++ b/web/src/graphql/config.graphql @@ -18,6 +18,7 @@ query Config { initialized paused leaderboard_version + leaderboard_duration paper_fee treasury_fee_pct treasury_balance @@ -87,13 +88,12 @@ query Config { attack defense speed - payout - demand_pct rep_pay rep_run rep_fight min_rep max_rep + payout } } } diff --git a/web/src/hooks/sound.tsx b/web/src/hooks/sound.tsx index be28351f0..fe8761465 100644 --- a/web/src/hooks/sound.tsx +++ b/web/src/hooks/sound.tsx @@ -23,7 +23,8 @@ export enum Sounds { Uzi = "Uzi.wav", Run = "Run.mp3", Pay = "Pay.wav", - Chains = "Chains.mp3", + // Chains = "Chains.mp3", + Chains = "Punch.mp3", Ooo = "Ooo.wav", Death = "Flatline.mp3", Punch = "Punch.mp3", diff --git a/web/src/pages/[gameId]/event/consequence.tsx b/web/src/pages/[gameId]/event/consequence.tsx index 51fbd5729..7d35f39b9 100644 --- a/web/src/pages/[gameId]/event/consequence.tsx +++ b/web/src/pages/[gameId]/event/consequence.tsx @@ -51,7 +51,6 @@ const Consequence = () => { if (!router.isReady || !game || !gameEvents || !encounterResult || !outcomeInfos) { return <>; } - console.log(encounterResult) return ( <> @@ -124,7 +123,7 @@ const Consequence = () => { /> )} - {encounterResult.drugLoss[idx] && ( + {encounterResult.drugLoss[idx] ? ( { } /> + ) : ( + <> )} ); diff --git a/web/src/pages/[gameId]/logs.tsx b/web/src/pages/[gameId]/logs.tsx index d0336b0cc..3656ffa8e 100644 --- a/web/src/pages/[gameId]/logs.tsx +++ b/web/src/pages/[gameId]/logs.tsx @@ -327,7 +327,7 @@ function renderTravelEncounter(configStore: ConfigStoreClass, log: TravelEncount : ""; const action = lastEncouterResult?.action; - const totalHpLoss = lastEncouterResult?.dmgTaken.map((i) => i[0]).reduce((p, c) => p + c, 0) + const totalHpLoss = lastEncouterResult?.dmgTaken.map((i) => i[0]).reduce((p, c) => p + c, 0) || 0 return ( 0 ? `-${totalHpLoss} HP` : ''} action={action} color="yellow.400" /> diff --git a/web/src/pages/[gameId]/travel.tsx b/web/src/pages/[gameId]/travel.tsx index cb275c8f2..31cefd9e7 100644 --- a/web/src/pages/[gameId]/travel.tsx +++ b/web/src/pages/[gameId]/travel.tsx @@ -199,7 +199,7 @@ const Travel = observer(() => { - + {/* Mobile */} { - + ); @@ -279,9 +282,14 @@ const LocationPrices = ({ prices, isCurrentLocation }: { prices: MarketPriceInfo boxSize: "24px", })} ${drug.price.toFixed(0)} + {drug.percentage && drug.diff && drug.diff !== 0 && ( = 0 ? "neon.200" : "red"}> - ({!isPercentage ? `${(drug.percentage || 0).toFixed(0)}%` : formatCash(drug.diff)}) + ( + {!isPercentage || isCurrentLocation === undefined + ? `${(drug.percentage || 0).toFixed(0)}%` + : formatCash(drug.diff)} + ) )} {!(drug.percentage && drug.diff && drug.diff !== 0) && !isCurrentLocation && ( diff --git a/web/src/pages/_app.tsx b/web/src/pages/_app.tsx index bfef54636..8eaad044c 100644 --- a/web/src/pages/_app.tsx +++ b/web/src/pages/_app.tsx @@ -2,6 +2,7 @@ import { LoadingModal, MakeItRain, QuitGameModal, RefreshGameModal } from "@/com import { AccountDetailsModal, ConnectModal } from "@/components/wallet"; import { DeployingModal } from "@/components/wallet/DeployingModal"; import { DojoContextProvider } from "@/dojo/context/DojoContext"; +import { useAutoBurner } from "@/dojo/hooks/useAutoBurner"; import { dojoContextConfig } from "@/dojo/setup/config"; import useKonamiCode, { starkpimpSequence } from "@/hooks/useKonamiCode"; import Fonts from "@/theme/fonts"; @@ -13,8 +14,8 @@ import NextHead from "next/head"; import { useEffect } from "react"; import theme from "../theme"; -// should avoid mobx memory leaks / GC issue.. +// should avoid mobx memory leaks / GC issue.. import { enableStaticRendering } from "mobx-react-lite"; enableStaticRendering(typeof window === "undefined"); @@ -31,6 +32,8 @@ export default function App({ Component, pageProps }: AppProps) { } }, [isRightSequence, setIsRightSequence, setSequence]); + useAutoBurner() + return ( <> diff --git a/web/src/pages/admin.tsx b/web/src/pages/admin.tsx index da42be971..b2c830cc3 100644 --- a/web/src/pages/admin.tsx +++ b/web/src/pages/admin.tsx @@ -31,9 +31,10 @@ import { HustlerItemTiersTable } from "@/components/pages/admin/HustlerItemTiers import { PlayerLayoutTable } from "@/components/pages/admin/PlayerLayoutTable"; import { useEffect, useState } from "react"; -export default function Admin() { +const Admin = () => { const { router } = useRouterContext(); const { account } = useAccount(); + const { configStore } = useDojoContext(); return ( @@ -45,6 +46,11 @@ export default function Admin() { ITEMS ENCOUNTERS LAYOUTS + {/* { + configStore.init(); + }} + /> */} @@ -54,6 +60,7 @@ export default function Admin() { + @@ -104,7 +111,9 @@ export default function Admin() { ); -} +}; + +export default observer(Admin); const RyoAddressCard = observer(() => { const { @@ -203,6 +212,48 @@ const RyoPauseCard = observer(() => { ); }); +const RyoLeaderboardDurationCard = observer(() => { + const { configStore } = useDojoContext(); + const { config } = configStore; + + const [duration, setDuration] = useState(config?.ryo.leaderboard_duration); + + const { setLeaderboardDuration, isPending } = useSystems(); + + const updateLeaderboardDuration = async () => { + await setLeaderboardDuration(duration); + await configStore.init(); + }; + + return ( + + + LEADERBOARD + + + + + DURATION (sec) + + { + setDuration(e.target.value); + }} + /> + + + + + + + + ); +}); + const RyoFeeCard = observer(() => { const { configStore } = useDojoContext(); const { config } = configStore; diff --git a/web/src/pages/create/new.tsx b/web/src/pages/create/new.tsx index b60da86e0..6e33eba99 100644 --- a/web/src/pages/create/new.tsx +++ b/web/src/pages/create/new.tsx @@ -15,7 +15,7 @@ import { observer } from "mobx-react-lite"; import { useEffect, useState } from "react"; const New = observer(() => { - const { router } = useRouterContext(); + const { router, isRyoDotGame } = useRouterContext(); const { account } = useAccount(); @@ -227,7 +227,7 @@ const New = observer(() => { /> - {!isMobile && config?.ryo.paper_fee > 0 && ( + {!isRyoDotGame && !isMobile && config?.ryo.paper_fee > 0 && (