Adding bosses to the game #6

Merged
mico merged 21 commits from feature/boss-mechanic into main 2024-10-31 13:56:05 +00:00
2 changed files with 33 additions and 0 deletions
Showing only changes of commit b79e9c7eb0 - Show all commits

View File

@ -74,6 +74,7 @@ contract RaidGeld is ERC20, Ownable, Constants {
// Reset or set player // Reset or set player
reset_player(player); reset_player(player);
players[player].has_active_session = true; players[player].has_active_session = true;
players[player].is_registered = true;
if (existing_player) { if (existing_player) {
// TODO: Emit new run // TODO: Emit new run

View File

@ -288,6 +288,10 @@ contract raid_geldTest is Test, Constants {
assertLt(initialDaoBalance, afterBossDaoBalance); assertLt(initialDaoBalance, afterBossDaoBalance);
assertGt(initialContractBalance, afterBossContractBalance); assertGt(initialContractBalance, afterBossContractBalance);
// Boss should level up
boss = raid_geld.getBoss(player1);
assertEq(boss.level, 1);
Player memory player = raid_geld.getPlayer(player1); Player memory player = raid_geld.getPlayer(player1);
// Players total rewards should increase // Players total rewards should increase
assertGt(player.total_rewards, 0); assertGt(player.total_rewards, 0);
@ -318,4 +322,32 @@ contract raid_geldTest is Test, Constants {
// Units should reset // Units should reset
assertEq(army.moloch_denier.level, 0); assertEq(army.moloch_denier.level, 0);
} }
function test_08_player_who_lost_can_restart() public {
// Let some time pass so we dont start at block timestamp 0
vm.warp(120);
uint256 balance1 = raid_geld.daoToken().balanceOf(address(raid_geld));
// Register player 1
vm.startPrank(player1);
registerPlayerWithDaoToken();
raid_geld.addUnit(0, 1);
uint256 balance2 = raid_geld.daoToken().balanceOf(address(raid_geld));
// Contract gets DAO Tokens with first register
assertLt(balance1, balance2);
bool[2] memory results = raid_geld.battle_with_boss();
// Should lose with just starting GELD
assertEq(results[0], false);
Player memory player = raid_geld.getPlayer(player1);
// player sessions should end
assertEq(player.has_active_session, false);
assertEq(player.is_registered, true);
registerPlayerWithDaoToken();
player = raid_geld.getPlayer(player1);
assertEq(player.has_active_session, true);
uint256 balance3 = raid_geld.daoToken().balanceOf(address(raid_geld));
assertLt(balance2, balance3);
}
} }