From f8981a5c035edf98cae916cc16459f5210510115 Mon Sep 17 00:00:00 2001 From: loothero Date: Sat, 27 Apr 2024 17:42:29 +0000 Subject: [PATCH] fixes #577 number out of bounds during optimistic start --- contracts/game/src/lib.cairo | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/contracts/game/src/lib.cairo b/contracts/game/src/lib.cairo index 164ed518c..c28cd3b14 100644 --- a/contracts/game/src/lib.cairo +++ b/contracts/game/src/lib.cairo @@ -800,7 +800,7 @@ mod Game { let adventurer = _load_adventurer(self, adventurer_id); _assert_upgrades_available(adventurer); - let adventurer_entropy = _load_adventurer_entropy(self, adventurer_id); + let adventurer_entropy = _get_adventurer_entropy(self, adventurer_id); _get_items_on_market_by_slot( self, @@ -2458,27 +2458,12 @@ mod Game { self: @ContractState, adventurer_id: felt252 ) -> (Adventurer, felt252, GameEntropy, Bag) { let adventurer = _load_adventurer(self, adventurer_id); - let adventurer_entropy = _load_adventurer_entropy(self, adventurer_id); + let adventurer_entropy = _get_adventurer_entropy(self, adventurer_id); let game_entropy = _load_game_entropy(self); let bag = _load_bag(self, adventurer_id); (adventurer, adventurer_entropy, game_entropy, bag) } - fn _load_adventurer_entropy(self: @ContractState, adventurer_id: felt252) -> felt252 { - // get the block the adventurer started the game on - let start_block = _load_adventurer_metadata(self, adventurer_id).start_block; - - // use longer block delay on mainnet for stronger entropy - let chain_id = starknet::get_execution_info().unbox().tx_info.unbox().chain_id; - if chain_id == MAINNET_CHAIN_ID { - _get_mainnet_entropy(adventurer_id, start_block) - } else if chain_id == GOERLI_CHAIN_ID { - _get_testnet_entropy(adventurer_id, start_block) - } else { - _get_basic_entropy(adventurer_id, start_block) - } - } - fn _load_adventurer(self: @ContractState, adventurer_id: felt252) -> Adventurer { let mut adventurer = self._adventurer.read(adventurer_id); _apply_starting_stats(self, ref adventurer, adventurer_id);