Skip to content

Commit

Permalink
fixes bug impacting drop and equip item events (#410)
Browse files Browse the repository at this point in the history
* dropped item event didn't include stat boosts
* equipped item event was only being emitted for item swapped during battle
  • Loading branch information
loothero authored Oct 14, 2023
1 parent 9c2fbc5 commit 71ac2f5
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions contracts/game/src/lib.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,10 @@ mod Game {
@self, ref adventurer, ref bag, adventurer_id, items.clone(), false
);

__event_EquippedItems(
ref self, adventurer, adventurer_id, bag, items, unequipped_items,
);

// if the adventurer is equipping an item during battle, the beast will counter attack
if (adventurer.in_battle()) {
// get beast and beast seed
Expand All @@ -428,10 +432,7 @@ mod Game {
ref self, ref adventurer, adventurer_id, beast, beast_seed, rnd1, rnd2,
);

// emit events
__event_EquippedItems(
ref self, adventurer, adventurer_id, bag, items, unequipped_items,
);
// emit attacked by beast event
__event_AttackedByBeast(ref self, adventurer, adventurer_id, beast_battle_details);

// if adventurer died from counter attack, process death
Expand Down Expand Up @@ -469,6 +470,9 @@ mod Game {
// drop items
_drop(ref self, ref adventurer, ref bag, adventurer_id, items.clone());

// emit dropped items event
__event_DroppedItems(ref self, adventurer, adventurer_id, bag, items);

// if the adventurer was mutated, save it
if (adventurer.mutated) {
_save_adventurer(ref self, ref adventurer, adventurer_id);
Expand All @@ -478,9 +482,6 @@ mod Game {
if bag.mutated {
_save_bag(ref self, adventurer_id, bag);
}

// emit dropped items event
__event_DroppedItems(ref self, adventurer, adventurer_id, bag, items);
}

/// @title Upgrade Function
Expand Down

1 comment on commit 71ac2f5

@vercel
Copy link

@vercel vercel bot commented on 71ac2f5 Oct 14, 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.