From 49b7110a6c38f9b85437b0b3b0ba2446f8c078b9 Mon Sep 17 00:00:00 2001 From: yellow <8539006+yellowBirdy@users.noreply.github.com> Date: Fri, 25 Oct 2024 02:21:50 +0200 Subject: [PATCH] raid before buy in addUnit --- src/RaidGeld.sol | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/RaidGeld.sol b/src/RaidGeld.sol index e5bf6ba..a70b9e6 100644 --- a/src/RaidGeld.sol +++ b/src/RaidGeld.sol @@ -109,13 +109,13 @@ contract RaidGeld is ERC20, Ownable { } uint256 cost = RaidGeldUtils.calculateUnitPrice(unit, currentLevel, n_units); + // First trigger a raid so player receives what he is due at to this moment + performRaid(msg.sender); require(balanceOf(msg.sender) > cost, "Not enough GELD to add this much"); // TODO: Since we are first minting then burning the token, this could be simplified // by first calculating the difference and then minting / burning in just one operation - // First trigger a raid so player receives what he is due at to this moment - performRaid(msg.sender); // then burn the cost of the new army _burn(msg.sender, cost);