Skip to content

Commit

Permalink
fix: battle attack winner error
Browse files Browse the repository at this point in the history
  • Loading branch information
lewis committed Nov 10, 2023
1 parent 67da21b commit cee9ccc
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/contracts/src/systems/BattleSystem.sol
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ contract BattleSystem is System {
BattleList.setAttackerHP(_battleId, BattleUtils.getAttackResult(battle.attackerHP, defenderAttackPower));
BattleList.setDefenderHP(_battleId, BattleUtils.getAttackResult(battle.defenderHP, attackerAttackPower));
if (BattleList.getAttackerHP(_battleId) == 0 || BattleList.getDefenderHP(_battleId) == 0) {
address winner = battle.attackerHP == 0 ? battle.defender : battle.attacker;
address looser = battle.attackerHP == 0 ? battle.attacker : battle.defender;
address winner = BattleList.getDefenderHP(_battleId) == 0 ? battle.attacker : battle.defender;
address looser = winner == battle.attacker ? battle.defender : battle.attacker;
BattleList.setWinner(_battleId, winner);
BattleList.setIsEnd(_battleId, true);
BattleUtils.loseGame(looser, winner);
Expand Down

0 comments on commit cee9ccc

Please sign in to comment.