forked from mico/idle_moloch
Fixes the issue with adding units not minting token straight away, fixes overlay issues so the tower is clickable again
This commit is contained in:
parent
e993067360
commit
b153e4b6bd
@ -5,6 +5,8 @@
|
|||||||
bottom: 22px;
|
bottom: 22px;
|
||||||
top: 22px;
|
top: 22px;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
|
user-select: none;
|
||||||
|
pointer-events: none;
|
||||||
}
|
}
|
||||||
.army-gathering {
|
.army-gathering {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
@ -23,8 +25,6 @@
|
|||||||
}
|
}
|
||||||
.marchingGroup {
|
.marchingGroup {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
user-select: none;
|
|
||||||
pointer-events: none;
|
|
||||||
left: 0;
|
left: 0;
|
||||||
bottom: 84px;
|
bottom: 84px;
|
||||||
animation: marching 20s linear;
|
animation: marching 20s linear;
|
||||||
|
|||||||
@ -73,15 +73,19 @@ contract RaidGeld is ERC20, Ownable {
|
|||||||
// Manual minting for itchy fingers
|
// Manual minting for itchy fingers
|
||||||
function raid() external onlyPlayer {
|
function raid() external onlyPlayer {
|
||||||
require(block.timestamp >= players[msg.sender].last_raided_at + RAID_WAIT, "Tried minting too soon");
|
require(block.timestamp >= players[msg.sender].last_raided_at + RAID_WAIT, "Tried minting too soon");
|
||||||
|
performRaid(msg.sender);
|
||||||
|
}
|
||||||
|
|
||||||
uint256 time_past = block.timestamp - players[msg.sender].last_raided_at;
|
// Helper so we can use it when buying units too
|
||||||
uint256 new_geld = armies[msg.sender].profit_per_second * time_past * 10 ** decimals();
|
function performRaid(address player) private {
|
||||||
|
uint256 time_past = block.timestamp - players[player].last_raided_at;
|
||||||
|
uint256 new_geld = armies[player].profit_per_second * time_past * 10 ** decimals();
|
||||||
|
|
||||||
// TODO: Pink noise, make it so sometimes its better than expected
|
// TODO: Pink noise, make it so sometimes its better than expected
|
||||||
|
|
||||||
_mint(msg.sender, new_geld);
|
_mint(player, new_geld);
|
||||||
players[msg.sender].last_raided_at = block.timestamp;
|
players[player].last_raided_at = block.timestamp;
|
||||||
players[msg.sender].total_minted = new_geld;
|
players[player].total_minted = new_geld;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Function to get Player struct
|
// Function to get Player struct
|
||||||
@ -103,6 +107,9 @@ contract RaidGeld is ERC20, Ownable {
|
|||||||
function addUnit(uint8 unit, uint16 n_units) external onlyPlayer {
|
function addUnit(uint8 unit, uint16 n_units) external onlyPlayer {
|
||||||
require(unit <= 3, "Unknown unit");
|
require(unit <= 3, "Unknown unit");
|
||||||
|
|
||||||
|
// First trigger a raid so player receives what he is due at to this moment
|
||||||
|
performRaid(msg.sender);
|
||||||
|
|
||||||
Army storage army = armies[msg.sender];
|
Army storage army = armies[msg.sender];
|
||||||
uint16 currentLevel = 0;
|
uint16 currentLevel = 0;
|
||||||
if (unit == 0) {
|
if (unit == 0) {
|
||||||
@ -119,7 +126,7 @@ contract RaidGeld is ERC20, Ownable {
|
|||||||
currentLevel = army.champion.level;
|
currentLevel = army.champion.level;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint256 cost = RaidGeldUtils.calculateUnitPrice(unit, currentLevel, n_units);
|
uint256 cost = RaidGeldUtils.calculateUnitPrice(unit, currentLevel, n_units) * 10 ** decimals();
|
||||||
require(balanceOf(msg.sender) > cost, "Not enough GELD to add this much");
|
require(balanceOf(msg.sender) > cost, "Not enough GELD to add this much");
|
||||||
_burn(msg.sender, cost);
|
_burn(msg.sender, cost);
|
||||||
|
|
||||||
|
|||||||
@ -13,10 +13,8 @@ contract raid_geldTest is Test {
|
|||||||
function setUp() public {
|
function setUp() public {
|
||||||
owner = address(0x126);
|
owner = address(0x126);
|
||||||
player1 = address(0x123);
|
player1 = address(0x123);
|
||||||
player2 = address(0x124);
|
|
||||||
vm.deal(owner, 10 ether);
|
vm.deal(owner, 10 ether);
|
||||||
vm.deal(player1, 10 ether);
|
vm.deal(player1, 10 ether);
|
||||||
vm.deal(player2, 10 ether);
|
|
||||||
vm.prank(owner);
|
vm.prank(owner);
|
||||||
raid_geld = new RaidGeld();
|
raid_geld = new RaidGeld();
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user