1
0
forked from mico/idle_moloch

raid before buy in addUnit

This commit is contained in:
yellow 2024-10-25 02:21:50 +02:00
parent 738378d93e
commit 49b7110a6c

View File

@ -109,13 +109,13 @@ contract RaidGeld is ERC20, Ownable {
} }
uint256 cost = RaidGeldUtils.calculateUnitPrice(unit, currentLevel, n_units); 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"); 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 // 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 // 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 // then burn the cost of the new army
_burn(msg.sender, cost); _burn(msg.sender, cost);