Skip to content

Commit

Permalink
fixes unequipped item not included in EquippedItems event (#421)
Browse files Browse the repository at this point in the history
  • Loading branch information
loothero authored Oct 25, 2023
1 parent a4f2410 commit 970fd47
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions contracts/game/src/lib.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ mod Game {
IERC20Camel, IERC20CamelDispatcher, IERC20CamelDispatcherTrait, IERC20CamelLibraryDispatcher
};

use openzeppelin::introspection::interface::{ISRC5Dispatcher, ISRC5DispatcherTrait, ISRC5CamelDispatcher, ISRC5CamelDispatcherTrait};
use openzeppelin::introspection::interface::{
ISRC5Dispatcher, ISRC5DispatcherTrait, ISRC5CamelDispatcher, ISRC5CamelDispatcherTrait
};

use openzeppelin::token::erc721::interface::{
IERC721, IERC721Dispatcher, IERC721DispatcherTrait, IERC721LibraryDispatcher
Expand Down Expand Up @@ -2022,14 +2024,14 @@ mod Game {
// get a clone of our items to equip to keep ownership for event
let equipped_items = items_to_equip.clone();

// for we item we need to equip
// for each item we need to equip
let mut i: u32 = 0;
loop {
if i == items_to_equip.len() {
break ();
}

// get the item
// get the item id
let item_id = *items_to_equip.at(i);

// assume we won't need to unequip an item to equip new one
Expand Down Expand Up @@ -2167,9 +2169,15 @@ mod Game {
// if we have items to equip as part of the purchase
if (items_to_equip.len() != 0) {
// equip them and record the items that were unequipped
let unequipped_items = _equip_items(
contract_state, ref adventurer, ref bag, adventurer_id, items_to_equip.clone(), true
);
unequipped_items =
_equip_items(
contract_state,
ref adventurer,
ref bag,
adventurer_id,
items_to_equip.clone(),
true
);
}

(purchases, items_to_equip, unequipped_items)
Expand Down Expand Up @@ -3574,7 +3582,7 @@ mod Game {
self
._golden_token_last_use
.write(token_id.try_into().unwrap(), get_block_timestamp().into());
}
}
}

fn _last_usage(self: @ContractState, token_id: u256) -> u256 {
Expand Down

1 comment on commit 970fd47

@vercel
Copy link

@vercel vercel bot commented on 970fd47 Oct 25, 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.