diff --git a/contracts/adventurer/src/adventurer.cairo b/contracts/adventurer/src/adventurer.cairo index 0d759da91..1a36738cf 100644 --- a/contracts/adventurer/src/adventurer.cairo +++ b/contracts/adventurer/src/adventurer.cairo @@ -142,7 +142,8 @@ impl ImplAdventurer of IAdventurer { vitality: starting_stats.vitality, intelligence: starting_stats.intelligence, wisdom: starting_stats.wisdom, - charisma: starting_stats.charisma + charisma: starting_stats.charisma, + luck: 0 }, gold: STARTING_GOLD, weapon: ItemPrimitive { id: starting_item, xp: 0, metadata: 1, }, @@ -352,7 +353,7 @@ impl ImplAdventurer of IAdventurer { // @param bag: Bag to calculate luck for // @return The adventurer's luck. #[inline(always)] - fn get_luck(self: Adventurer, bag: Bag) -> u8 { + fn calculate_luck(self: Adventurer, bag: Bag) -> u8 { let equipped_necklace_luck = self.neck.get_greatness(); let equipped_ring_luck = self.ring.get_greatness(); let bonus_luck = self.get_bonus_luck(); @@ -360,6 +361,14 @@ impl ImplAdventurer of IAdventurer { equipped_necklace_luck + equipped_ring_luck + bonus_luck + bagged_jewelry_luck } + // @notice sets the luck statt of the adventurer + // @param self: Adventurer to set luck for + // @param bag: Bag needed for calculating luck + #[inline(always)] + fn set_luck(ref self: Adventurer, bag: Bag) { + self.stats.luck = self.calculate_luck(bag); + } + // in_battle returns true if the adventurer is in battle // @param self: Adventurer the adventurer to check if in battle // @return bool true if the adventurer is in battle, false otherwise @@ -1150,7 +1159,7 @@ impl ImplAdventurer of IAdventurer { self: Adventurer, name_storage1: ItemSpecialsStorage, name_storage2: ItemSpecialsStorage ) -> Stats { let mut stats = Stats { - strength: 0, dexterity: 0, vitality: 0, charisma: 0, intelligence: 0, wisdom: 0, + strength: 0, dexterity: 0, vitality: 0, charisma: 0, intelligence: 0, wisdom: 0, luck: 0 }; if (self.weapon.get_greatness() >= 15) { @@ -1487,13 +1496,13 @@ mod tests { use pack::{pack::{Packing, rshift_split}, constants::{MASK_16, pow, MASK_8, MASK_BOOL, mask}}; #[test] - #[available_gas(28390)] + #[available_gas(28690)] fn test_beast_gold_reward_multiplier_gas() { let mut adventurer = ImplAdventurer::new( 12, 0, Stats { - strength: 1, dexterity: 1, vitality: 1, intelligence: 1, wisdom: 1, charisma: 1, + strength: 1, dexterity: 1, vitality: 1, intelligence: 1, wisdom: 1, charisma: 1, luck: 1 } ); let reward = adventurer.beast_gold_reward_multiplier(); @@ -1501,13 +1510,13 @@ mod tests { #[test] - #[available_gas(48470)] + #[available_gas(48970)] fn test_beast_gold_reward_multiplier() { let mut adventurer = ImplAdventurer::new( 12, 0, Stats { - strength: 1, dexterity: 1, vitality: 1, intelligence: 1, wisdom: 1, charisma: 1, + strength: 1, dexterity: 1, vitality: 1, intelligence: 1, wisdom: 1, charisma: 1, luck: 1 } ); @@ -1529,27 +1538,26 @@ mod tests { } #[test] - #[available_gas(28390)] + #[available_gas(28690)] fn test_get_bonus_luck_gas() { let adventurer = ImplAdventurer::new( 12, 0, Stats { - strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, - } + strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, luck: 0 } ); let bonus_luck = adventurer.get_bonus_luck(); } #[test] - #[available_gas(48470)] + #[available_gas(48970)] fn test_get_bonus_luck() { let mut adventurer = ImplAdventurer::new( 12, 0, Stats { - strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, + strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, luck: 0 } ); @@ -1571,13 +1579,13 @@ mod tests { } #[test] - #[available_gas(28390)] + #[available_gas(28690)] fn test_obstacle_gold_reward_multplier_gas() { let mut adventurer = ImplAdventurer::new( 12, 0, Stats { - strength: 1, dexterity: 1, vitality: 1, intelligence: 1, wisdom: 1, charisma: 1, + strength: 1, dexterity: 1, vitality: 1, intelligence: 1, wisdom: 1, charisma: 1, luck: 1 } ); let reward = adventurer.obstacle_gold_reward_multplier(); @@ -1590,7 +1598,7 @@ mod tests { 12, 0, Stats { - strength: 1, dexterity: 1, vitality: 1, intelligence: 1, wisdom: 1, charisma: 1, + strength: 1, dexterity: 1, vitality: 1, intelligence: 1, wisdom: 1, charisma: 1, luck: 1 } ); @@ -1612,26 +1620,26 @@ mod tests { } #[test] - #[available_gas(28390)] + #[available_gas(28690)] fn test_discovery_bonus_multplier_gas() { let mut adventurer = ImplAdventurer::new( 12, 0, Stats { - strength: 1, dexterity: 1, vitality: 1, intelligence: 1, wisdom: 1, charisma: 1, + strength: 1, dexterity: 1, vitality: 1, intelligence: 1, wisdom: 1, charisma: 1, luck: 1 } ); let discovery_bonus = adventurer.discovery_bonus_multplier(); } #[test] - #[available_gas(48470)] + #[available_gas(48970)] fn test_discovery_bonus_multplier() { let mut adventurer = ImplAdventurer::new( 12, 0, Stats { - strength: 1, dexterity: 1, vitality: 1, intelligence: 1, wisdom: 1, charisma: 1, + strength: 1, dexterity: 1, vitality: 1, intelligence: 1, wisdom: 1, charisma: 1, luck: 1 } ); @@ -2157,13 +2165,13 @@ mod tests { } #[test] - #[available_gas(35290)] + #[available_gas(35590)] fn test_double_gold_from_beasts_unlocked_gas() { let adventurer = ImplAdventurer::new( 12, 0, Stats { - strength: 1, dexterity: 1, vitality: 1, intelligence: 1, wisdom: 1, charisma: 1, + strength: 1, dexterity: 1, vitality: 1, intelligence: 1, wisdom: 1, charisma: 1, luck: 1 } ); let bag = Bag { @@ -2191,7 +2199,7 @@ mod tests { 12, 0, Stats { - strength: 1, dexterity: 1, vitality: 1, intelligence: 1, wisdom: 1, charisma: 1, + strength: 1, dexterity: 1, vitality: 1, intelligence: 1, wisdom: 1, charisma: 1, luck: 1 } ); @@ -2260,13 +2268,13 @@ mod tests { } #[test] - #[available_gas(28390)] + #[available_gas(28690)] fn test_armor_bonus_multiplier_gas() { let adventurer = ImplAdventurer::new( 12, 0, Stats { - strength: 1, dexterity: 1, vitality: 1, intelligence: 1, wisdom: 1, charisma: 1, + strength: 1, dexterity: 1, vitality: 1, intelligence: 1, wisdom: 1, charisma: 1, luck: 1 } ); @@ -2274,13 +2282,13 @@ mod tests { } #[test] - #[available_gas(40910)] + #[available_gas(41310)] fn test_armor_bonus_multiplier() { let mut adventurer = ImplAdventurer::new( 12, 0, Stats { - strength: 1, dexterity: 1, vitality: 1, intelligence: 1, wisdom: 1, charisma: 1, + strength: 1, dexterity: 1, vitality: 1, intelligence: 1, wisdom: 1, charisma: 1, luck: 1 } ); @@ -2303,13 +2311,13 @@ mod tests { } #[test] - #[available_gas(28790)] + #[available_gas(29090)] fn test_critical_hit_bonus_multiplier_gas() { let mut adventurer = ImplAdventurer::new( 12, 0, Stats { - strength: 1, dexterity: 1, vitality: 1, intelligence: 1, wisdom: 1, charisma: 1, + strength: 1, dexterity: 1, vitality: 1, intelligence: 1, wisdom: 1, charisma: 1, luck: 1 } ); @@ -2319,13 +2327,13 @@ mod tests { } #[test] - #[available_gas(44910)] + #[available_gas(45410)] fn test_critical_hit_bonus_multiplier() { let mut adventurer = ImplAdventurer::new( 12, 0, Stats { - strength: 1, dexterity: 1, vitality: 1, intelligence: 1, wisdom: 1, charisma: 1, + strength: 1, dexterity: 1, vitality: 1, intelligence: 1, wisdom: 1, charisma: 1, luck: 1 } ); @@ -2357,13 +2365,13 @@ mod tests { // gas baseline #[test] - #[available_gas(28790)] + #[available_gas(29090)] fn test_name_match_bonus_damage_multiplier_gas() { let mut adventurer = ImplAdventurer::new( 12, 0, Stats { - strength: 1, dexterity: 1, vitality: 1, intelligence: 1, wisdom: 1, charisma: 1, + strength: 1, dexterity: 1, vitality: 1, intelligence: 1, wisdom: 1, charisma: 1, luck: 1 } ); @@ -2373,13 +2381,13 @@ mod tests { } #[test] - #[available_gas(44910)] + #[available_gas(45410)] fn test_name_match_bonus_damage_multiplier() { let mut adventurer = ImplAdventurer::new( 12, 0, Stats { - strength: 1, dexterity: 1, vitality: 1, intelligence: 1, wisdom: 1, charisma: 1, + strength: 1, dexterity: 1, vitality: 1, intelligence: 1, wisdom: 1, charisma: 1, luck: 1 } ); @@ -2437,13 +2445,13 @@ mod tests { #[test] - #[available_gas(170020)] + #[available_gas(170320)] fn test_get_beast_seed_gas() { let mut adventurer = ImplAdventurer::new( 12, 0, Stats { - strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, + strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, luck: 0 } ); let adventurer_entropy = 1; @@ -2459,7 +2467,7 @@ mod tests { 12, 0, Stats { - strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, + strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, luck: 0 } ); @@ -2491,7 +2499,7 @@ mod tests { } #[test] - #[available_gas(70020)] + #[available_gas(70320)] fn test_get_greatness_gas() { let greatness = ImplAdventurer::get_greatness( ItemPrimitive { id: 1, xp: 400, metadata: 1 } @@ -2499,7 +2507,7 @@ mod tests { } #[test] - #[available_gas(70020)] + #[available_gas(70320)] fn test_get_greatness() { let mut item = ItemPrimitive { id: 1, xp: 0, metadata: 0 }; // test 0 case (should be level 1) @@ -2613,13 +2621,13 @@ mod tests { } #[test] - #[available_gas(70930)] + #[available_gas(71630)] fn test_set_last_action() { let mut adventurer = ImplAdventurer::new( 12, 0, Stats { - strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, + strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, luck: 0 } ); adventurer.set_last_action(0); @@ -2641,7 +2649,7 @@ mod tests { 12, 0, Stats { - strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, + strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, luck: 0 } ); @@ -2668,7 +2676,7 @@ mod tests { #[available_gas(290000)] fn test_charisma_adjusted_potion_price() { let starting_stats = Stats { - strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, + strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, luck: 0 }; let mut adventurer = ImplAdventurer::new(12, 0, starting_stats); @@ -2702,7 +2710,7 @@ mod tests { #[available_gas(150000)] fn test_get_idle_blocks() { let starting_stats = Stats { - strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, + strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, luck: 0 }; let mut adventurer = ImplAdventurer::new(12, 0, starting_stats); adventurer.last_action = 1; @@ -2732,6 +2740,7 @@ mod tests { intelligence: 31, wisdom: 31, charisma: 31, + luck: 31 }, gold: 511, weapon: ItemPrimitive { id: 127, xp: 511, metadata: 31, }, @@ -2804,6 +2813,7 @@ mod tests { intelligence: 255, wisdom: 255, charisma: 255, + luck: 255 }, gold: 511, weapon: ItemPrimitive { id: 127, xp: 511, metadata: 31, }, @@ -2839,7 +2849,7 @@ mod tests { #[available_gas(2000000)] fn test_new_adventurer() { let starting_stats = Stats { - strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, + strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, luck: 0 }; let mut adventurer = ImplAdventurer::new(12, 0, starting_stats); adventurer.pack(); @@ -2852,7 +2862,7 @@ mod tests { #[available_gas(200000)] fn test_increase_health() { let starting_stats = Stats { - strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, + strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, luck: 0 }; let mut adventurer = ImplAdventurer::new(12, 0, starting_stats); @@ -2884,7 +2894,7 @@ mod tests { #[available_gas(2600000)] fn test_increase_gold() { let starting_stats = Stats { - strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, + strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, luck: 0 }; let mut adventurer = ImplAdventurer::new(12, 0, starting_stats); @@ -2910,10 +2920,10 @@ mod tests { } #[test] - #[available_gas(50610)] + #[available_gas(51310)] fn test_decrease_health() { let starting_stats = Stats { - strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, + strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, luck: 0 }; let mut adventurer = ImplAdventurer::new(12, 0, starting_stats); let starting_health = adventurer.health; @@ -2932,7 +2942,7 @@ mod tests { #[available_gas(53000)] fn test_deduct_gold() { let starting_stats = Stats { - strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, + strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, luck: 0 }; let mut adventurer = ImplAdventurer::new(12, 0, starting_stats); let starting_gold = adventurer.gold; @@ -2951,7 +2961,7 @@ mod tests { #[available_gas(250000)] fn test_increase_adventurer_xp() { let starting_stats = Stats { - strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, + strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, luck: 0 }; let mut adventurer = ImplAdventurer::new(12, 0, starting_stats); // base case level increase @@ -2982,7 +2992,7 @@ mod tests { fn test_increase_stat_points_available() { // get new adventurer let starting_stats = Stats { - strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, + strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, luck: 0 }; let mut adventurer = ImplAdventurer::new(12, 0, starting_stats); let original_stat_points = adventurer.stat_points_available; @@ -3020,7 +3030,7 @@ mod tests { #[available_gas(90000)] fn test_increase_strength() { let starting_stats = Stats { - strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, + strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, luck: 0 }; let mut adventurer = ImplAdventurer::new(12, 0, starting_stats); // basic case @@ -3035,7 +3045,7 @@ mod tests { #[available_gas(90000)] fn test_increase_dexterity() { let starting_stats = Stats { - strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, + strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, luck: 0 }; let mut adventurer = ImplAdventurer::new(12, 0, starting_stats); // basic case @@ -3050,7 +3060,7 @@ mod tests { #[available_gas(90000)] fn test_increase_vitality() { let starting_stats = Stats { - strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, + strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, luck: 0 }; let mut adventurer = ImplAdventurer::new(12, 0, starting_stats); // basic case @@ -3065,7 +3075,7 @@ mod tests { #[available_gas(90000)] fn test_increase_intelligence() { let starting_stats = Stats { - strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, + strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, luck: 0 }; let mut adventurer = ImplAdventurer::new(12, 0, starting_stats); // basic case @@ -3080,7 +3090,7 @@ mod tests { #[available_gas(90000)] fn test_increase_wisdom() { let starting_stats = Stats { - strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, + strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, luck: 0 }; let mut adventurer = ImplAdventurer::new(12, 0, starting_stats); // basic case @@ -3095,7 +3105,7 @@ mod tests { #[available_gas(90000)] fn test_increase_charisma() { let starting_stats = Stats { - strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, + strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, luck: 0 }; let mut adventurer = ImplAdventurer::new(12, 0, starting_stats); // basic case @@ -3110,7 +3120,7 @@ mod tests { #[available_gas(90000)] fn test_decrease_strength() { let starting_stats = Stats { - strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, + strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, luck: 0 }; let mut adventurer = ImplAdventurer::new(12, 0, starting_stats); // basic case @@ -3127,7 +3137,7 @@ mod tests { #[available_gas(90000)] fn test_decrease_dexterity() { let starting_stats = Stats { - strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, + strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, luck: 0 }; let mut adventurer = ImplAdventurer::new(12, 0, starting_stats); // basic case @@ -3144,7 +3154,7 @@ mod tests { #[available_gas(90000)] fn test_decrease_vitality() { let starting_stats = Stats { - strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, + strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, luck: 0 }; let mut adventurer = ImplAdventurer::new(12, 0, starting_stats); // basic case @@ -3161,7 +3171,7 @@ mod tests { #[available_gas(90000)] fn test_decrease_intelligence() { let starting_stats = Stats { - strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, + strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, luck: 0 }; let mut adventurer = ImplAdventurer::new(12, 0, starting_stats); // basic case @@ -3175,23 +3185,23 @@ mod tests { } #[test] - #[available_gas(90000)] + #[available_gas(90300)] fn test_decrease_wisdom_gas() { let mut adventurer = ImplAdventurer::new( 12, 0, Stats { - strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 1, charisma: 0, + strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 1, charisma: 0, luck: 0 } ); adventurer.stats.decrease_wisdom(1); } #[test] - #[available_gas(90000)] + #[available_gas(90300)] fn test_decrease_wisdom() { let starting_stats = Stats { - strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, + strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, luck: 0 }; let mut adventurer = ImplAdventurer::new(12, 0, starting_stats); // basic case @@ -3208,7 +3218,7 @@ mod tests { #[available_gas(90000)] fn test_decrease_charisma() { let starting_stats = Stats { - strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, + strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, luck: 0 }; let mut adventurer = ImplAdventurer::new(12, 0, starting_stats); // basic case @@ -3229,7 +3239,7 @@ mod tests { // #[available_gas(90000)] // fn test_equip_invalid_weapon() { // let starting_stats = Stats { - // strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, + // strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, luck: 0 // }; // let mut adventurer = ImplAdventurer::new(12, 0, starting_stats); // // create demon crown item @@ -3246,7 +3256,7 @@ mod tests { #[available_gas(90000)] fn test_equip_valid_weapon() { let starting_stats = Stats { - strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, + strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, luck: 0 }; let mut adventurer = ImplAdventurer::new(12, 0, starting_stats); @@ -3269,7 +3279,7 @@ mod tests { // #[available_gas(90000)] // fn test_equip_invalid_chest() { // let starting_stats = Stats { - // strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, + // strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, luck: 0 // }; // let mut adventurer = ImplAdventurer::new(12, 0, starting_stats); // // try to equip a Demon Crown as chest item @@ -3285,7 +3295,7 @@ mod tests { #[available_gas(90000)] fn test_equip_valid_chest() { let starting_stats = Stats { - strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, + strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, luck: 0 }; let mut adventurer = ImplAdventurer::new(12, 0, starting_stats); // equip Divine Robe as chest item @@ -3306,7 +3316,7 @@ mod tests { // #[available_gas(90000)] // fn test_equip_invalid_head() { // let starting_stats = Stats { - // strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, + // strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, luck: 0 // }; // let mut adventurer = ImplAdventurer::new(12, 0, starting_stats); // // try to equip a Katana as head item @@ -3319,7 +3329,7 @@ mod tests { #[available_gas(90000)] fn test_equip_valid_head() { let starting_stats = Stats { - strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, + strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, luck: 0 }; let mut adventurer = ImplAdventurer::new(12, 0, starting_stats); // equip Crown as head item @@ -3339,7 +3349,7 @@ mod tests { // #[available_gas(90000)] // fn test_equip_invalid_waist() { // let starting_stats = Stats { - // strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, + // strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, luck: 0 // }; // let mut adventurer = ImplAdventurer::new(12, 0, starting_stats); // // try to equip a Demon Crown as waist item @@ -3352,7 +3362,7 @@ mod tests { #[available_gas(90000)] fn test_equip_valid_waist() { let starting_stats = Stats { - strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, + strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, luck: 0 }; let mut adventurer = ImplAdventurer::new(12, 0, starting_stats); @@ -3374,7 +3384,7 @@ mod tests { // #[available_gas(90000)] // fn test_equip_invalid_foot() { // let starting_stats = Stats { - // strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, + // strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, luck: 0 // }; // let mut adventurer = ImplAdventurer::new(12, 0, starting_stats); // // try to equip a Demon Crown as foot item @@ -3387,7 +3397,7 @@ mod tests { #[available_gas(90000)] fn test_equip_valid_foot() { let starting_stats = Stats { - strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, + strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, luck: 0 }; let mut adventurer = ImplAdventurer::new(12, 0, starting_stats); @@ -3409,7 +3419,7 @@ mod tests { // #[available_gas(90000)] // fn test_equip_invalid_hand() { // let starting_stats = Stats { - // strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, + // strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, luck: 0 // }; // let mut adventurer = ImplAdventurer::new(12, 0, starting_stats); @@ -3423,7 +3433,7 @@ mod tests { #[available_gas(90000)] fn test_equip_valid_hand() { let starting_stats = Stats { - strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, + strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, luck: 0 }; let mut adventurer = ImplAdventurer::new(12, 0, starting_stats); @@ -3445,7 +3455,7 @@ mod tests { // #[available_gas(90000)] // fn test_equip_invalid_neck() { // let starting_stats = Stats { - // strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, + // strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, luck: 0 // }; // let mut adventurer = ImplAdventurer::new(12, 0, starting_stats); @@ -3459,7 +3469,7 @@ mod tests { #[available_gas(90000)] fn test_equip_valid_neck() { let starting_stats = Stats { - strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, + strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, luck: 0 }; let mut adventurer = ImplAdventurer::new(12, 0, starting_stats); @@ -3481,7 +3491,7 @@ mod tests { // #[available_gas(90000)] // fn test_equip_invalid_ring() { // let starting_stats = Stats { - // strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, + // strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, luck: 0 // }; // let mut adventurer = ImplAdventurer::new(12, 0, starting_stats); @@ -3498,7 +3508,7 @@ mod tests { 12, 0, Stats { - strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, + strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, luck: 0 } ); let item = ItemPrimitive { id: ItemId::PlatinumRing, xp: 1, metadata: 0 }; @@ -3509,26 +3519,26 @@ mod tests { } #[test] - #[available_gas(52230)] + #[available_gas(51230)] fn test_increase_item_xp_at_slot_gas() { let mut adventurer = ImplAdventurer::new( 12, 0, Stats { - strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, + strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, luck: 0 } ); adventurer.increase_item_xp_at_slot(Slot::Weapon(()), 1); } #[test] - #[available_gas(234830)] + #[available_gas(237530)] fn test_increase_item_xp_at_slot() { let mut adventurer = ImplAdventurer::new( 12, 0, Stats { - strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, + strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, luck: 0 } ); @@ -3568,13 +3578,13 @@ mod tests { } #[test] - #[available_gas(53030)] + #[available_gas(52030)] fn test_increase_item_xp_at_slot_max() { let mut adventurer = ImplAdventurer::new( 12, 0, Stats { - strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, + strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, luck: 0 } ); @@ -3584,13 +3594,13 @@ mod tests { } #[test] - #[available_gas(53030)] + #[available_gas(52030)] fn test_increase_item_xp_at_slot_zero() { let mut adventurer = ImplAdventurer::new( 12, 0, Stats { - strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, + strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, luck: 0 } ); @@ -3600,13 +3610,13 @@ mod tests { } #[test] - #[available_gas(302010)] + #[available_gas(303210)] fn test_get_equipped_items() { let mut adventurer = ImplAdventurer::new( ItemId::Wand, 0, Stats { - strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, + strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, luck: 0 } ); @@ -3728,7 +3738,7 @@ mod tests { #[available_gas(60000)] fn test_set_beast_health() { let starting_stats = Stats { - strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, + strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, luck: 0 }; let mut adventurer = ImplAdventurer::new(12, 0, starting_stats); @@ -3747,7 +3757,7 @@ mod tests { #[available_gas(90000)] fn test_deduct_beast_health() { let starting_stats = Stats { - strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, + strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, luck: 0 }; let mut adventurer = ImplAdventurer::new(12, 0, starting_stats); @@ -3785,7 +3795,7 @@ mod tests { 12, 0, Stats { - strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, + strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, luck: 0 } ); @@ -3827,7 +3837,7 @@ mod tests { 12, 0, Stats { - strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, + strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, luck: 0 } ); @@ -3862,7 +3872,7 @@ mod tests { #[available_gas(600000)] fn test_get_level() { let starting_stats = Stats { - strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, + strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, luck: 0 }; let mut adventurer = ImplAdventurer::new(12, 0, starting_stats); assert(adventurer.get_level() == 1, 'level should be 1'); @@ -3889,7 +3899,7 @@ mod tests { #[available_gas(200000)] fn test_charisma_health_discount_overflow() { let starting_stats = Stats { - strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, + strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, luck: 0 }; let mut adventurer = ImplAdventurer::new(12, 0, starting_stats); @@ -3910,7 +3920,7 @@ mod tests { #[available_gas(200000)] fn test_charisma_item_discount_overflow() { let starting_stats = Stats { - strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, + strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, luck: 0 }; let mut adventurer = ImplAdventurer::new(12, 0, starting_stats); let item_price = 15; @@ -3940,7 +3950,7 @@ mod tests { fn test_increase_xp() { // initialize lvl 1 adventurer with no stat points available let starting_stats = Stats { - strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, + strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, luck: 0 }; let mut adventurer = ImplAdventurer::new(12, 0, starting_stats); @@ -3954,10 +3964,10 @@ mod tests { } #[test] - #[available_gas(145830)] + #[available_gas(148630)] fn test_apply_suffix_boost() { let starting_stats = Stats { - strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, + strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, luck: 0 }; let mut adventurer = ImplAdventurer::new(12, 0, starting_stats); @@ -4006,7 +4016,7 @@ mod tests { #[available_gas(1900000)] fn test_remove_suffix_boost() { let starting_stats = Stats { - strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, + strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, luck: 0 }; let mut adventurer = ImplAdventurer::new(12, 0, starting_stats); @@ -4024,14 +4034,14 @@ mod tests { } #[test] - #[available_gas(332700)] + #[available_gas(337800)] fn test_get_and_apply_stat_boosts() { let mut adventurer = Adventurer { last_action: 511, health: 100, xp: 1, stats: Stats { - strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, + strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, luck: 0 }, gold: 40, weapon: ItemPrimitive { id: 1, xp: 225, metadata: 1, }, @@ -4109,18 +4119,18 @@ mod tests { // test base case #[test] - #[available_gas(61470)] + #[available_gas(62270)] fn test_apply_stat_boosts() { let mut adventurer = ImplAdventurer::new( 12, 0, Stats { - strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, + strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, luck: 0 } ); let boost_stats = Stats { - strength: 5, dexterity: 1, vitality: 5, intelligence: 1, wisdom: 1, charisma: 2, + strength: 5, dexterity: 1, vitality: 5, intelligence: 1, wisdom: 1, charisma: 2, luck: 1 }; adventurer.apply_stat_boosts(boost_stats); @@ -4135,18 +4145,18 @@ mod tests { // test zero case #[test] - #[available_gas(61470)] + #[available_gas(62270)] fn test_apply_stat_boosts_zero() { let mut adventurer = ImplAdventurer::new( 12, 0, Stats { - strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, + strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, luck: 0 } ); let boost_stats = Stats { - strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, + strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, luck: 0 }; adventurer.apply_stat_boosts(boost_stats); @@ -4160,13 +4170,13 @@ mod tests { // test max value case #[test] - #[available_gas(61470)] + #[available_gas(62270)] fn test_apply_stat_boosts_max() { let mut adventurer = ImplAdventurer::new( 12, 0, Stats { - strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, + strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, luck: 0 } ); let boost_stats = Stats { @@ -4176,6 +4186,7 @@ mod tests { intelligence: 255, wisdom: 255, charisma: 255, + luck: 255, }; adventurer.apply_stat_boosts(boost_stats); @@ -4189,18 +4200,18 @@ mod tests { // base case #[test] - #[available_gas(52530)] + #[available_gas(53430)] fn test_remove_stat_boosts() { let mut adventurer = ImplAdventurer::new( 12, 0, Stats { - strength: 5, dexterity: 4, vitality: 3, intelligence: 2, wisdom: 1, charisma: 0, + strength: 5, dexterity: 4, vitality: 3, intelligence: 2, wisdom: 1, charisma: 0, luck: 0 } ); let boost_stats = Stats { - strength: 5, dexterity: 4, vitality: 3, intelligence: 2, wisdom: 1, charisma: 20, + strength: 5, dexterity: 4, vitality: 3, intelligence: 2, wisdom: 1, charisma: 20, luck: 1 }; adventurer.remove_stat_boosts(boost_stats); @@ -4214,18 +4225,18 @@ mod tests { // zero case #[test] - #[available_gas(52530)] + #[available_gas(53430)] fn test_remove_stat_boosts_zero() { let mut adventurer = ImplAdventurer::new( 12, 0, Stats { - strength: 5, dexterity: 4, vitality: 3, intelligence: 2, wisdom: 1, charisma: 0, + strength: 5, dexterity: 4, vitality: 3, intelligence: 2, wisdom: 1, charisma: 0, luck: 1 } ); let boost_stats = Stats { - strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, + strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, luck: 0 }; adventurer.remove_stat_boosts(boost_stats); @@ -4239,13 +4250,13 @@ mod tests { // max values case #[test] - #[available_gas(52530)] + #[available_gas(53430)] fn test_remove_stat_boosts_max() { let mut adventurer = ImplAdventurer::new( 12, 0, Stats { - strength: 5, dexterity: 4, vitality: 3, intelligence: 2, wisdom: 1, charisma: 0, + strength: 5, dexterity: 4, vitality: 3, intelligence: 2, wisdom: 1, charisma: 0, luck: 0 } ); @@ -4256,6 +4267,7 @@ mod tests { intelligence: 255, wisdom: 255, charisma: 255, + luck: 255, }; adventurer.remove_stat_boosts(boost_stats); @@ -4271,7 +4283,7 @@ mod tests { #[available_gas(390000)] fn test_discover_treasure() { let starting_stats = Stats { - strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, + strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, luck: 0 }; let mut adventurer = ImplAdventurer::new(12, 0, starting_stats); @@ -4292,26 +4304,26 @@ mod tests { #[test] #[available_gas(161530)] - fn test_get_luck_gas_no_luck() { + fn test_calculate_luck_gas_no_luck() { let mut adventurer = ImplAdventurer::new( 12, 0, Stats { - strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, + strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, luck: 0 } ); let bag = ImplBag::new(); - assert(adventurer.get_luck(bag) == 2, 'start with 2 luck'); + assert(adventurer.calculate_luck(bag) == 2, 'start with 2 luck'); } #[test] #[available_gas(161530)] - fn test_get_luck_gas_with_luck() { + fn test_calculate_luck_gas_with_luck() { let mut adventurer = ImplAdventurer::new( 12, 0, Stats { - strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, + strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, luck: 0 } ); let bag = ImplBag::new(); @@ -4320,47 +4332,47 @@ mod tests { adventurer.equip_necklace(neck); let ring = ItemPrimitive { id: ItemId::GoldRing, xp: 1, metadata: 8 }; adventurer.equip_ring(ring); - assert(adventurer.get_luck(bag) == 2, 'start with 2 luck'); + assert(adventurer.calculate_luck(bag) == 2, 'start with 2 luck'); } #[test] #[available_gas(983740)] - fn test_get_luck() { + fn test_calculate_luck() { let mut adventurer = ImplAdventurer::new( 12, 0, Stats { - strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, + strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, luck: 0 } ); let bag = ImplBag::new(); - assert(adventurer.get_luck(bag) == 2, 'start with 2 luck'); + assert(adventurer.calculate_luck(bag) == 2, 'start with 2 luck'); // equip a greatness 1 necklace let neck = ItemPrimitive { id: ItemId::Amulet, xp: 1, metadata: 7 }; adventurer.equip_necklace(neck); - assert(adventurer.get_luck(bag) == 2, 'still 2 luck'); + assert(adventurer.calculate_luck(bag) == 2, 'still 2 luck'); // equip a greatness 1 ring let ring = ItemPrimitive { id: ItemId::GoldRing, xp: 1, metadata: 8 }; adventurer.equip_ring(ring); - assert(adventurer.get_luck(bag) == 2, 'still 2 luck'); + assert(adventurer.calculate_luck(bag) == 2, 'still 2 luck'); // equip a greatness 19 silver ring let mut silver_ring = ItemPrimitive { id: ItemId::SilverRing, xp: 399, metadata: 8 }; adventurer.equip_ring(silver_ring); - assert(adventurer.get_luck(bag) == 20, 'should be 20 luck'); + assert(adventurer.calculate_luck(bag) == 20, 'should be 20 luck'); // increase silver ring to greatness 20 to unlock extra 20 luck adventurer.ring.xp = 400; - assert(adventurer.get_luck(bag) == 41, 'should be 41 luck'); + assert(adventurer.calculate_luck(bag) == 41, 'should be 41 luck'); // overflow case adventurer.ring.xp = 65535; adventurer.neck.xp = 65535; - let luck = adventurer.get_luck(bag); + let luck = adventurer.calculate_luck(bag); assert( - adventurer.get_luck(bag) == (ITEM_MAX_GREATNESS * 2) + SILVER_RING_G20_LUCK_BONUS, + adventurer.calculate_luck(bag) == (ITEM_MAX_GREATNESS * 2) + SILVER_RING_G20_LUCK_BONUS, 'should be 60 luck' ); } @@ -4372,7 +4384,7 @@ mod tests { 12, 0, Stats { - strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, + strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, luck: 0 } ); assert(adventurer.in_battle() == true, 'new advntr start in battle'); @@ -4389,7 +4401,7 @@ mod tests { #[available_gas(550000)] fn test_equip_item() { let starting_stats = Stats { - strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, + strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, luck: 0 }; let mut adventurer = ImplAdventurer::new(12, 0, starting_stats); @@ -4439,7 +4451,7 @@ mod tests { let wand = ItemPrimitive { id: ItemId::Wand, xp: 1, metadata: 1 }; let demon_crown = ItemPrimitive { id: ItemId::DemonCrown, xp: 1, metadata: 2 }; let starting_stats = Stats { - strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, + strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, luck: 0 }; let mut adventurer = ImplAdventurer::new(12, 0, starting_stats); @@ -4579,7 +4591,7 @@ mod tests { fn test_drop_item_not_equipped() { // instantiate adventurer let starting_stats = Stats { - strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, + strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, luck: 0 }; let mut adventurer = ImplAdventurer::new(12, 0, starting_stats); // try to drop an item that isn't equipped @@ -4592,7 +4604,7 @@ mod tests { #[available_gas(700000)] fn test_drop_item() { let starting_stats = Stats { - strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, + strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, luck: 0 }; let mut adventurer = ImplAdventurer::new(12, 0, starting_stats); @@ -4676,13 +4688,13 @@ mod tests { } #[test] - #[available_gas(272270)] + #[available_gas(274270)] fn test_is_ambush() { let mut adventurer = ImplAdventurer::new( 12, 0, Stats { - strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, + strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, luck: 0 } ); diff --git a/contracts/adventurer/src/adventurer_stats.cairo b/contracts/adventurer/src/adventurer_stats.cairo index f7dcc3791..510c51053 100644 --- a/contracts/adventurer/src/adventurer_stats.cairo +++ b/contracts/adventurer/src/adventurer_stats.cairo @@ -12,13 +12,17 @@ struct Stats { // 5 bits each // Mental intelligence: u8, // 5 bits wisdom: u8, // 5 bits - charisma: u8 // 5 bits + charisma: u8, // 5 bits + // Metaphysical + luck: u8 // dynamically generated (not stored) } #[generate_trait] impl StatUtils of IStat { fn new() -> Stats { - Stats { strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0 } + Stats { + strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, luck: 0 + } } } @@ -51,7 +55,8 @@ impl StatsPacking of Packing { vitality: vitality.try_into().expect('unpack Stats vitality'), intelligence: intelligence.try_into().expect('unpack Stats intelligence'), wisdom: wisdom.try_into().expect('unpack Stats wisdom'), - charisma: charisma.try_into().expect('unpack Stats charisma') + charisma: charisma.try_into().expect('unpack Stats charisma'), + luck: 0 } } @@ -86,14 +91,16 @@ impl StatsPacking of Packing { // --------------------------- #[cfg(test)] mod tests { - use survivor::{constants::adventurer_constants::MAX_STAT_VALUE, adventurer_stats::{Stats, StatsPacking}}; - + use survivor::{ + constants::adventurer_constants::MAX_STAT_VALUE, adventurer_stats::{Stats, StatsPacking} + }; + #[test] - #[available_gas(1500000)] + #[available_gas(1039260)] fn test_stats_packing() { // zero case let stats = Stats { - strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0 + strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, luck: 0 }; let packed = stats.pack(); @@ -104,10 +111,17 @@ mod tests { assert(stats.intelligence == unpacked.intelligence, 'intelligence zero case'); assert(stats.wisdom == unpacked.wisdom, 'wisdom zero case'); assert(stats.charisma == unpacked.charisma, 'charisma zero case'); + assert(unpacked.luck == 0, 'luck is zero from storage'); // storage limit test (2^5 - 1 = 31) let stats = Stats { - strength: 31, dexterity: 31, vitality: 31, intelligence: 31, wisdom: 31, charisma: 31 + strength: 31, + dexterity: 31, + vitality: 31, + intelligence: 31, + wisdom: 31, + charisma: 31, + luck: 31 }; let packed = stats.pack(); @@ -118,6 +132,7 @@ mod tests { assert(stats.intelligence == unpacked.intelligence, 'intelligence storage limit'); assert(stats.wisdom == unpacked.wisdom, 'wisdom storage limit'); assert(stats.charisma == unpacked.charisma, 'charisma storage limit'); + assert(unpacked.luck == 0, 'luck is zero from storage'); // overflow storage limit using max u8 let stats = Stats { @@ -126,7 +141,8 @@ mod tests { vitality: 255, intelligence: 255, wisdom: 255, - charisma: 255 + charisma: 255, + luck: 255 }; let packed = stats.pack(); @@ -139,5 +155,6 @@ mod tests { assert(unpacked.intelligence == MAX_STAT_VALUE, 'intelligence pack overflow'); assert(unpacked.wisdom == MAX_STAT_VALUE, 'wisdom pack overflow'); assert(unpacked.charisma == MAX_STAT_VALUE, 'charisma pack overflow'); + assert(unpacked.luck == 0, 'luck is zero from storage'); } } diff --git a/contracts/adventurer/src/adventurer_utils.cairo b/contracts/adventurer/src/adventurer_utils.cairo index 473f7acec..59e731683 100644 --- a/contracts/adventurer/src/adventurer_utils.cairo +++ b/contracts/adventurer/src/adventurer_utils.cairo @@ -239,7 +239,7 @@ mod tests { #[available_gas(150000)] fn test_is_health_full() { let starting_stats = Stats { - strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, + strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, luck: 0 }; let mut adventurer = ImplAdventurer::new(12, 0, starting_stats); @@ -276,7 +276,7 @@ mod tests { #[available_gas(200000)] fn test_get_max_health() { let starting_stats = Stats { - strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, + strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, luck: 0 }; let mut adventurer = ImplAdventurer::new(12, 0, starting_stats); diff --git a/contracts/adventurer/src/exploration.cairo b/contracts/adventurer/src/exploration.cairo index 4917b4560..61b69ddd8 100644 --- a/contracts/adventurer/src/exploration.cairo +++ b/contracts/adventurer/src/exploration.cairo @@ -73,13 +73,13 @@ mod tests { use lootitems::constants::ItemId; #[test] - #[available_gas(55560)] + #[available_gas(55960)] fn test_get_gold_discovery_gas() { let adventurer = ImplAdventurer::new( 12, 0, Stats { - strength: 1, dexterity: 1, vitality: 1, intelligence: 1, wisdom: 1, charisma: 1, + strength: 1, dexterity: 1, vitality: 1, intelligence: 1, wisdom: 1, charisma: 1, luck: 1 } ); let entropy = 0; @@ -87,13 +87,13 @@ mod tests { } #[test] - #[available_gas(56060)] + #[available_gas(56460)] fn test_get_gold_discovery() { let mut adventurer = ImplAdventurer::new( 12, 0, Stats { - strength: 1, dexterity: 1, vitality: 1, intelligence: 1, wisdom: 1, charisma: 1, + strength: 1, dexterity: 1, vitality: 1, intelligence: 1, wisdom: 1, charisma: 1, luck: 1 } ); @@ -104,13 +104,13 @@ mod tests { } #[test] - #[available_gas(55560)] + #[available_gas(55960)] fn test_get_health_discovery_gas() { let adventurer = ImplAdventurer::new( 12, 0, Stats { - strength: 1, dexterity: 1, vitality: 1, intelligence: 1, wisdom: 1, charisma: 1, + strength: 1, dexterity: 1, vitality: 1, intelligence: 1, wisdom: 1, charisma: 1, luck: 1 } ); let entropy = 12345; @@ -118,13 +118,13 @@ mod tests { } #[test] - #[available_gas(56060)] + #[available_gas(56460)] fn test_get_health_discovery() { let mut adventurer = ImplAdventurer::new( 12, 0, Stats { - strength: 1, dexterity: 1, vitality: 1, intelligence: 1, wisdom: 1, charisma: 1, + strength: 1, dexterity: 1, vitality: 1, intelligence: 1, wisdom: 1, charisma: 1, luck: 1 } ); diff --git a/contracts/adventurer/src/item_meta.cairo b/contracts/adventurer/src/item_meta.cairo index d46b16777..ede31f585 100644 --- a/contracts/adventurer/src/item_meta.cairo +++ b/contracts/adventurer/src/item_meta.cairo @@ -543,7 +543,7 @@ mod tests { 12, 1, Stats { - strength: 1, dexterity: 1, vitality: 1, intelligence: 1, wisdom: 1, charisma: 1, + strength: 1, dexterity: 1, vitality: 1, intelligence: 1, wisdom: 1, charisma: 1, luck: 1 } ); diff --git a/contracts/game/src/lib.cairo b/contracts/game/src/lib.cairo index 6f3e2eb63..02e05f5ce 100644 --- a/contracts/game/src/lib.cairo +++ b/contracts/game/src/lib.cairo @@ -173,8 +173,8 @@ mod Game { //@param adventurer_id The unique identifier of the adventurer. //@param till_beast Indicates if the adventurer will explore until encountering a beast. fn explore(ref self: ContractState, adventurer_id: u256, till_beast: bool) { - // unpack adventurer from storage and apply item stat boosts - let (mut adventurer, stat_boosts) = _unpack_adventurer_with_stat_boosts( + // get adventurer from storage with stat boosts applied + let (mut adventurer, stat_boosts, _) = _unpack_adventurer_and_bag_with_stat_boosts( @self, adventurer_id ); @@ -217,8 +217,8 @@ mod Game { //@param adventurer_id The unique identifier of the adventurer //@param to_the_death a bool which if true will result in recursively attacking till beast or adventurer is dead fn attack(ref self: ContractState, adventurer_id: u256, to_the_death: bool) { - // unpack adventurer from storage and apply item stat boosts - let (mut adventurer, stat_boosts) = _unpack_adventurer_with_stat_boosts( + // get adventurer from storage with stat boosts applied + let (mut adventurer, stat_boosts, _) = _unpack_adventurer_and_bag_with_stat_boosts( @self, adventurer_id ); @@ -253,8 +253,8 @@ mod Game { //@param adventurer_id The unique identifier of the adventurer //@param to_the_death a bool which if true will result in recursively fleeing till success or death fn flee(ref self: ContractState, adventurer_id: u256, to_the_death: bool) { - // unpack adventurer from storage and apply item stat boosts - let (mut adventurer, stat_boosts) = _unpack_adventurer_with_stat_boosts( + // get adventurer from storage with stat boosts applied + let (mut adventurer, stat_boosts, _) = _unpack_adventurer_and_bag_with_stat_boosts( @self, adventurer_id ); @@ -314,14 +314,12 @@ mod Game { //@param adventurer_id The ID of the adventurer to equip. //@param items An array of items to equip the adventurer with. fn equip(ref self: ContractState, adventurer_id: u256, items: Array) { - // unpack adventurer from storage and apply item stat boosts - let (mut adventurer, stat_boosts) = _unpack_adventurer_with_stat_boosts( + // get adventurer and bag from storage with stat boosts applied + let (mut adventurer, stat_boosts, mut bag) = + _unpack_adventurer_and_bag_with_stat_boosts( @self, adventurer_id ); - // get adventurers bag - let mut bag = _bag_unpacked(@self, adventurer_id); - // assert action is valid _assert_ownership(@self, adventurer_id); _assert_not_dead(adventurer); @@ -380,14 +378,12 @@ mod Game { // @param adventurer_id The ID of the adventurer dropping the items // @param items A Array of item ids to be dropped fn drop_items(ref self: ContractState, adventurer_id: u256, items: Array) { - // unpack adventurer from storage (no need to apply stat boosts) - let (mut adventurer, stat_boosts) = _unpack_adventurer_with_stat_boosts( + // get adventurer and bag from storage with stat boosts applied + let (mut adventurer, stat_boosts, mut bag) = + _unpack_adventurer_and_bag_with_stat_boosts( @self, adventurer_id ); - // get bag from storage - let mut bag = _bag_unpacked(@self, adventurer_id); - // assert action is valid (ownership of item is handled in internal function when we iterate over items) _assert_ownership(@self, adventurer_id); _assert_not_dead(adventurer); @@ -430,14 +426,12 @@ mod Game { stat_upgrades: Stats, items: Array, ) { - // get adventurer from storage and apply stat boosts - let (mut adventurer, stat_boosts) = _unpack_adventurer_with_stat_boosts( + // get adventurer and bag from storage with stat boosts applied + let (mut adventurer, stat_boosts, mut bag) = + _unpack_adventurer_and_bag_with_stat_boosts( @self, adventurer_id ); - // get bag from storage - let mut bag = _bag_unpacked(@self, adventurer_id); - // assert action is valid _assert_ownership(@self, adventurer_id); _assert_not_dead(adventurer); @@ -517,7 +511,9 @@ mod Game { // view functions // fn get_adventurer(self: @ContractState, adventurer_id: u256) -> Adventurer { - let (adventurer, _) = _unpack_adventurer_with_stat_boosts(self, adventurer_id); + let (adventurer, _, _) = _unpack_adventurer_and_bag_with_stat_boosts( + self, adventurer_id + ); adventurer } fn get_adventurer_no_boosts(self: @ContractState, adventurer_id: u256) -> Adventurer { @@ -527,7 +523,7 @@ mod Game { _adventurer_meta_unpacked(self, adventurer_id) } fn get_bag(self: @ContractState, adventurer_id: u256) -> Bag { - _bag_unpacked(self, adventurer_id) + _unpacked_bag(self, adventurer_id) } fn get_weapon_specials(self: @ContractState, adventurer_id: u256) -> ItemSpecials { let adventurer = _unpack_adventurer(self, adventurer_id); @@ -697,49 +693,63 @@ mod Game { _unpack_adventurer(self, adventurer_id).stats } fn get_stats(self: @ContractState, adventurer_id: u256) -> Stats { - let (adventurer, _) = _unpack_adventurer_with_stat_boosts(self, adventurer_id); + let (adventurer, _, _) = _unpack_adventurer_and_bag_with_stat_boosts( + self, adventurer_id + ); adventurer.stats } fn get_base_strength(self: @ContractState, adventurer_id: u256) -> u8 { _unpack_adventurer(self, adventurer_id).stats.strength } fn get_strength(self: @ContractState, adventurer_id: u256) -> u8 { - let (adventurer, _) = _unpack_adventurer_with_stat_boosts(self, adventurer_id); + let (adventurer, _, _) = _unpack_adventurer_and_bag_with_stat_boosts( + self, adventurer_id + ); adventurer.stats.strength } fn get_base_dexterity(self: @ContractState, adventurer_id: u256) -> u8 { _unpack_adventurer(self, adventurer_id).stats.dexterity } fn get_dexterity(self: @ContractState, adventurer_id: u256) -> u8 { - let (adventurer, _) = _unpack_adventurer_with_stat_boosts(self, adventurer_id); + let (adventurer, _, _) = _unpack_adventurer_and_bag_with_stat_boosts( + self, adventurer_id + ); adventurer.stats.dexterity } fn get_base_vitality(self: @ContractState, adventurer_id: u256) -> u8 { _unpack_adventurer(self, adventurer_id).stats.vitality } fn get_vitality(self: @ContractState, adventurer_id: u256) -> u8 { - let (adventurer, _) = _unpack_adventurer_with_stat_boosts(self, adventurer_id); + let (adventurer, _, _) = _unpack_adventurer_and_bag_with_stat_boosts( + self, adventurer_id + ); adventurer.stats.vitality } fn get_base_intelligence(self: @ContractState, adventurer_id: u256) -> u8 { _unpack_adventurer(self, adventurer_id).stats.intelligence } fn get_intelligence(self: @ContractState, adventurer_id: u256) -> u8 { - let (adventurer, _) = _unpack_adventurer_with_stat_boosts(self, adventurer_id); + let (adventurer, _, _) = _unpack_adventurer_and_bag_with_stat_boosts( + self, adventurer_id + ); adventurer.stats.intelligence } fn get_base_wisdom(self: @ContractState, adventurer_id: u256) -> u8 { _unpack_adventurer(self, adventurer_id).stats.wisdom } fn get_wisdom(self: @ContractState, adventurer_id: u256) -> u8 { - let (adventurer, _,) = _unpack_adventurer_with_stat_boosts(self, adventurer_id); + let (adventurer, _, _) = _unpack_adventurer_and_bag_with_stat_boosts( + self, adventurer_id + ); adventurer.stats.wisdom } fn get_base_charisma(self: @ContractState, adventurer_id: u256) -> u8 { _unpack_adventurer(self, adventurer_id).stats.charisma } fn get_charisma(self: @ContractState, adventurer_id: u256) -> u8 { - let (adventurer, _) = _unpack_adventurer_with_stat_boosts(self, adventurer_id); + let (adventurer, _, _) = _unpack_adventurer_and_bag_with_stat_boosts( + self, adventurer_id + ); adventurer.stats.charisma } fn get_special_storage( @@ -821,7 +831,7 @@ mod Game { // get_base_reward from Combat module. Should refactor this to only make that call once and have // get_gold_reward and get_xp_reward operator on the base reward let mut gold_earned = beast.get_gold_reward(beast_seed); - let bag = _bag_unpacked(@self, adventurer_id); + let bag = _unpacked_bag(@self, adventurer_id); adventurer.increase_gold(gold_earned * adventurer.beast_gold_reward_multiplier().into()); // grant adventuer xp @@ -1474,12 +1484,11 @@ mod Game { let weapon_combat_spec = _get_combat_spec(@self, adventurer_id, adventurer.weapon); let critical_hit_damage_multiplier = adventurer.critical_hit_bonus_multiplier(); let name_bonus_damage_multplier = adventurer.name_match_bonus_damage_multiplier(); - let bag = _bag_unpacked(@self, adventurer_id); - let adventurer_luck = adventurer.get_luck(bag); + let bag = _unpacked_bag(@self, adventurer_id); let (damage_dealt, critical_hit) = beast .attack( weapon_combat_spec, - adventurer_luck, + adventurer.stats.luck, adventurer.stats.strength, critical_hit_damage_multiplier, name_bonus_damage_multplier, @@ -1906,7 +1915,8 @@ mod Game { } if stat_upgrades.vitality != 0 { adventurer.stats.increase_vitality(stat_upgrades.vitality); - adventurer.increase_health(VITALITY_INSTANT_HEALTH_BONUS * stat_upgrades.vitality.into()); + adventurer + .increase_health(VITALITY_INSTANT_HEALTH_BONUS * stat_upgrades.vitality.into()); } if stat_upgrades.intelligence != 0 { adventurer.stats.increase_intelligence(stat_upgrades.intelligence); @@ -1957,9 +1967,9 @@ mod Game { fn _unpack_adventurer(self: @ContractState, adventurer_id: u256) -> Adventurer { Packing::unpack(self._adventurer.read(adventurer_id)) } - fn _unpack_adventurer_with_stat_boosts( + fn _unpack_adventurer_and_bag_with_stat_boosts( self: @ContractState, adventurer_id: u256 - ) -> (Adventurer, Stats) { + ) -> (Adventurer, Stats, Bag) { // unpack adventurer let mut adventurer: Adventurer = Packing::unpack(self._adventurer.read(adventurer_id)); // start with no stat boosts @@ -1974,8 +1984,13 @@ mod Game { adventurer.apply_stat_boosts(stat_boosts); } + let bag = _unpacked_bag(self, adventurer_id); + + // luck isn't stored, it is calculated dynamically + adventurer.set_luck(bag); + // return adventurer with stat boosts - (adventurer, stat_boosts) + (adventurer, stat_boosts, bag) } #[inline(always)] @@ -2029,7 +2044,7 @@ mod Game { __event_UpgradesAvailable(ref self, adventurer_state, available_items); } #[inline(always)] - fn _bag_unpacked(self: @ContractState, adventurer_id: u256) -> Bag { + fn _unpacked_bag(self: @ContractState, adventurer_id: u256) -> Bag { Packing::unpack(self._bag.read(adventurer_id)) } #[inline(always)] @@ -2250,12 +2265,12 @@ mod Game { #[inline(always)] fn _get_potion_price(self: @ContractState, adventurer_id: u256) -> u16 { - let (adventurer, _) = _unpack_adventurer_with_stat_boosts(self, adventurer_id); + let (adventurer, _, _) = _unpack_adventurer_and_bag_with_stat_boosts(self, adventurer_id); adventurer.charisma_adjusted_potion_price() } fn _get_item_price(self: @ContractState, adventurer_id: u256, item_id: u8) -> u16 { - let (adventurer, _) = _unpack_adventurer_with_stat_boosts(self, adventurer_id); + let (adventurer, _, _) = _unpack_adventurer_and_bag_with_stat_boosts(self, adventurer_id); let base_item_price = ImplMarket::get_price(ImplLoot::get_tier(item_id)); let charisma_adjusted_price = adventurer.charisma_adjusted_item_price(base_item_price); diff --git a/contracts/game/src/tests/test_game.cairo b/contracts/game/src/tests/test_game.cairo index c97241d56..749e56a4c 100644 --- a/contracts/game/src/tests/test_game.cairo +++ b/contracts/game/src/tests/test_game.cairo @@ -103,7 +103,7 @@ mod tests { }; let starting_stats = Stats { - strength: 0, dexterity: 2, vitality: 0, intelligence: 2, wisdom: 2, charisma: 0, + strength: 0, dexterity: 2, vitality: 0, intelligence: 2, wisdom: 2, charisma: 0, luck: 0 }; game.start(INTERFACE_ID(), ItemId::Wand, adventurer_meta, starting_stats); @@ -129,7 +129,7 @@ mod tests { }; let starting_stats = Stats { - strength: 0, dexterity: 2, vitality: 0, intelligence: 2, wisdom: 2, charisma: 0, + strength: 0, dexterity: 2, vitality: 0, intelligence: 2, wisdom: 2, charisma: 0, luck: 0 }; game.start(INTERFACE_ID(), ItemId::Wand, adventurer_meta, starting_stats); @@ -152,7 +152,7 @@ mod tests { fn new_adventurer_max_charisma() -> IGameDispatcher { let mut game = setup(1000); let starting_stats = Stats { - strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 6, + strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 6, luck: 0 }; game @@ -230,7 +230,7 @@ mod tests { let shopping_cart = ArrayTrait::::new(); let stat_upgrades = Stats { - strength: stat, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 1, + strength: stat, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 1, luck: 0 }; game.upgrade_adventurer(ADVENTURER_ID, 0, stat_upgrades, shopping_cart); @@ -257,7 +257,7 @@ mod tests { // upgrade charisma let shopping_cart = ArrayTrait::::new(); let stat_upgrades = Stats { - strength: stat, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 1, + strength: stat, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 1, luck: 0 }; game.upgrade_adventurer(ADVENTURER_ID, 0, stat_upgrades, shopping_cart); @@ -280,7 +280,7 @@ mod tests { // upgrade charisma let shopping_cart = ArrayTrait::::new(); let stat_upgrades = Stats { - strength: stat, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 1, + strength: stat, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 1, luck: 0 }; game.upgrade_adventurer(ADVENTURER_ID, 0, stat_upgrades, shopping_cart); @@ -341,7 +341,7 @@ mod tests { // upgrade stats let stat_upgrades = Stats { - strength: stat, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 1, + strength: stat, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 1, luck: 0 }; game.upgrade_adventurer(ADVENTURER_ID, 0, stat_upgrades, shopping_cart); @@ -360,7 +360,7 @@ mod tests { let STRENGTH: u8 = 0; let shopping_cart = ArrayTrait::::new(); let stat_upgrades = Stats { - strength: stat, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 1, + strength: stat, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 1, luck: 0 }; game.upgrade_adventurer(ADVENTURER_ID, 0, stat_upgrades, shopping_cart); @@ -378,7 +378,7 @@ mod tests { let STRENGTH: u8 = 0; let shopping_cart = ArrayTrait::::new(); let stat_upgrades = Stats { - strength: stat, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 1, + strength: stat, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 1, luck: 0 }; game.upgrade_adventurer(ADVENTURER_ID, 0, stat_upgrades, shopping_cart); @@ -396,7 +396,7 @@ mod tests { let STRENGTH: u8 = 0; let shopping_cart = ArrayTrait::::new(); let stat_upgrades = Stats { - strength: stat, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 1, + strength: stat, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 1, luck: 0 }; game.upgrade_adventurer(ADVENTURER_ID, 0, stat_upgrades, shopping_cart); @@ -414,7 +414,7 @@ mod tests { let STRENGTH: u8 = 0; let shopping_cart = ArrayTrait::::new(); let stat_upgrades = Stats { - strength: stat, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 1, + strength: stat, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 1, luck: 0 }; game.upgrade_adventurer(ADVENTURER_ID, 0, stat_upgrades, shopping_cart); @@ -435,7 +435,7 @@ mod tests { let STRENGTH: u8 = 0; let shopping_cart = ArrayTrait::::new(); let stat_upgrades = Stats { - strength: stat, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 1, + strength: stat, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 1, luck: 0 }; game.upgrade_adventurer(ADVENTURER_ID, 0, stat_upgrades, shopping_cart); @@ -588,7 +588,7 @@ mod tests { // TODO: use cheat codes to make this less fragile let shopping_cart = ArrayTrait::::new(); let stat_upgrades = Stats { - strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 1, + strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 1, luck: 0 }; game.upgrade_adventurer(ADVENTURER_ID, 0, stat_upgrades, shopping_cart.clone()); @@ -652,7 +652,7 @@ mod tests { // attempt to buy item during battle - should_panic with message 'Action not allowed in battle' // this test is annotated to expect a panic so if it doesn't, this test will fail let stat_upgrades = Stats { - strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 1, + strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 1, luck: 0 }; game.upgrade_adventurer(ADVENTURER_ID, 0, stat_upgrades, shopping_cart); } @@ -674,7 +674,7 @@ mod tests { // upgrade adventurer and don't buy anything let mut empty_shoppping_cart = ArrayTrait::::new(); let stat_upgrades = Stats { - strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 1, + strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 1, luck: 0 }; game.upgrade_adventurer(ADVENTURER_ID, 0, stat_upgrades, empty_shoppping_cart.clone()); @@ -702,7 +702,7 @@ mod tests { // submit an upgrade with duplicate items in the shopping cart // 'Item already owned' which is annotated in the test let stat_upgrades = Stats { - strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 1, + strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 1, luck: 0 }; game.upgrade_adventurer(ADVENTURER_ID, 0, stat_upgrades, shopping_cart); } @@ -725,7 +725,7 @@ mod tests { // should throw 'Item already owned' panic let stat_upgrades = Stats { - strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 1, + strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 1, luck: 0 }; game.upgrade_adventurer(ADVENTURER_ID, 0, stat_upgrades, shopping_cart); } @@ -738,7 +738,7 @@ mod tests { let mut shopping_cart = ArrayTrait::::new(); shopping_cart.append(ItemPurchase { item_id: 255, equip: false }); let stat_upgrades = Stats { - strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 1, + strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 1, luck: 0 }; game.upgrade_adventurer(ADVENTURER_ID, 0, stat_upgrades, shopping_cart); } @@ -752,7 +752,7 @@ mod tests { let mut shopping_cart = ArrayTrait::::new(); shopping_cart.append(ItemPurchase { item_id: item_id, equip: false }); let stat_upgrades = Stats { - strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 1, + strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 1, luck: 0 }; game.upgrade_adventurer(ADVENTURER_ID, 0, stat_upgrades, shopping_cart); let bag = game.get_bag(ADVENTURER_ID); @@ -826,7 +826,7 @@ mod tests { // buy items in shopping cart let stat_upgrades = Stats { - strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 1, + strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 1, luck: 0 }; game.upgrade_adventurer(ADVENTURER_ID, 0, stat_upgrades, shopping_cart.clone()); @@ -998,7 +998,7 @@ mod tests { assert(shopping_cart.len() >= 2, 'insufficient item purchase'); // buy items let stat_upgrades = Stats { - strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 1, + strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 1, luck: 0 }; game.upgrade_adventurer(ADVENTURER_ID, 0, stat_upgrades, shopping_cart); @@ -1059,7 +1059,7 @@ mod tests { let number_of_potions = 1; let shopping_cart = ArrayTrait::::new(); let stat_upgrades = Stats { - strength: 1, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, + strength: 1, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 0, luck: 0 }; game.upgrade_adventurer(ADVENTURER_ID, number_of_potions, stat_upgrades, shopping_cart); @@ -1101,7 +1101,7 @@ mod tests { let shopping_cart = ArrayTrait::::new(); let potions = potions_to_full_health + 1; let stat_upgrades = Stats { - strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 1, + strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 1, luck: 0 }; game.upgrade_adventurer(ADVENTURER_ID, potions, stat_upgrades, shopping_cart); } @@ -1116,7 +1116,7 @@ mod tests { // upgrade adventurer let shopping_cart = ArrayTrait::::new(); let stat_upgrades = Stats { - strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 1, + strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 1, luck: 0 }; game.upgrade_adventurer(ADVENTURER_ID, 0, stat_upgrades, shopping_cart.clone()); @@ -1138,7 +1138,7 @@ mod tests { let shopping_cart = ArrayTrait::::new(); let potions = 1; let stat_upgrades = Stats { - strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 1, + strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 1, luck: 0 }; game.upgrade_adventurer(ADVENTURER_ID, potions, stat_upgrades, shopping_cart); } @@ -1295,7 +1295,7 @@ mod tests { } #[test] - #[available_gas(137891870)] + #[available_gas(141506980)] fn test_multi_slay_adventurers() { let STARTING_BLOCK_NUMBER = 512; @@ -1661,7 +1661,7 @@ mod tests { // buy first item on market and bag it let stat_upgrades = Stats { - strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 1, + strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 1, luck: 0 }; game.upgrade_adventurer(ADVENTURER_ID, 0, stat_upgrades, shopping_cart); @@ -1731,7 +1731,7 @@ mod tests { // because we need a multi-level or G20 stat unlocks let shopping_cart = ArrayTrait::::new(); let stat_upgrades = Stats { - strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 1, + strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 1, luck: 0 }; game.upgrade_adventurer(ADVENTURER_ID, 0, stat_upgrades, shopping_cart); @@ -1758,7 +1758,7 @@ mod tests { // try to upgrade charisma x2 with only 1 stat available let shopping_cart = ArrayTrait::::new(); let stat_upgrades = Stats { - strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 2, + strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 2, luck: 0 }; game.upgrade_adventurer(ADVENTURER_ID, 0, stat_upgrades, shopping_cart); } @@ -1794,7 +1794,7 @@ mod tests { // purchase potions, items, and upgrade stat in single call let stat_upgrades = Stats { - strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 1, + strength: 0, dexterity: 0, vitality: 0, intelligence: 0, wisdom: 0, charisma: 1, luck: 0 }; game.upgrade_adventurer(ADVENTURER_ID, potions, stat_upgrades, items_to_purchase);