Skip to content

Commit

Permalink
Prevent non-zero starting luck (#356)
Browse files Browse the repository at this point in the history
  • Loading branch information
loothero authored Sep 21, 2023
1 parent cab8042 commit 5ccdad1
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions contracts/game/src/game/constants.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ mod messages {
const WRONG_STARTING_STATS: felt252 = 'Wrong starting stat count';
const MUST_USE_ALL_STATS: felt252 = 'Must use all stats';
const NO_ITEMS: felt252 = 'Must provide item ids';
const NON_ZERO_STARTING_LUCK: felt252 = 'Luck must be zero';
}

// TODO: Update for mainnet
Expand Down
6 changes: 3 additions & 3 deletions contracts/game/src/lib.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ mod Game {
starting_stats: Stats,
) {
_assert_valid_starter_weapon(starting_weapon);
_assert_starting_stat_count(starting_stats);
_assert_starting_stats(starting_stats);

let caller = get_caller_address();
let block_number = starknet::get_block_info().unbox().block_number;
Expand Down Expand Up @@ -2150,15 +2150,15 @@ mod Game {
ImplLoot::is_starting_weapon(starting_weapon) == true, messages::INVALID_STARTING_WEAPON
);
}
fn _assert_starting_stat_count(starting_stats: Stats) {
fn _assert_starting_stats(starting_stats: Stats) {
let total_stats = starting_stats.strength
+ starting_stats.dexterity
+ starting_stats.vitality
+ starting_stats.intelligence
+ starting_stats.wisdom
+ starting_stats.charisma;

assert(total_stats == STARTING_STATS, messages::WRONG_STARTING_STATS);
assert(starting_stats.luck == 0, messages::NON_ZERO_STARTING_LUCK);
}
fn _assert_has_enough_gold(adventurer: Adventurer, cost: u16) {
assert(adventurer.gold >= cost, messages::NOT_ENOUGH_GOLD);
Expand Down
2 changes: 1 addition & 1 deletion contracts/game/src/tests/test_game.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -1295,7 +1295,7 @@ mod tests {
}

#[test]
#[available_gas(141506980)]
#[available_gas(141507880)]
fn test_multi_slay_adventurers() {
let STARTING_BLOCK_NUMBER = 512;

Expand Down

1 comment on commit 5ccdad1

@vercel
Copy link

@vercel vercel bot commented on 5ccdad1 Sep 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.