add to boss fight
This commit is contained in:
parent
ef1c242471
commit
4c8f2250b7
@ -20,12 +20,15 @@ contract RaidGeld is ERC20, Ownable, Constants {
|
||||
uint256 public BUY_IN_DAO_TOKEN_AMOUNT;
|
||||
uint256 public constant INITIAL_GELD = 50 * MANTISSA;
|
||||
uint256 public constant SACRIFICE_SHARE = 1e3; // 10%
|
||||
uint256 public constant SESSION_WALLET_FUNDING_CAP = 0.001 ether;
|
||||
mapping(address => Player) private players;
|
||||
mapping(address => Army) private armies;
|
||||
mapping(address => Boss) private bosses;
|
||||
mapping(address => LastBossResult) private lastBossResults;
|
||||
|
||||
mapping(address => address) private sessionWallets;
|
||||
mapping(address => address) private playerToSessionWallet;
|
||||
mapping(address => address) private sessionWalletToPlayer;
|
||||
mapping(address => address) private proposedSessionWallets;
|
||||
|
||||
// WETH
|
||||
IWETH public immutable weth = IWETH(WETH);
|
||||
@ -94,10 +97,10 @@ contract RaidGeld is ERC20, Ownable, Constants {
|
||||
}
|
||||
|
||||
modifier onlyActiveSession() {
|
||||
address delegatedPlayer = sessionWallets[msg.sender];
|
||||
address delegatedWallet = playerToSessionWallet[msg.sender];
|
||||
require(
|
||||
players[msg.sender].has_active_session ||
|
||||
players[delegatedPlayer].has_active_session, "Session is not active, you need to buy into the game first");
|
||||
players[delegatedWallet].has_active_session, "Session is not active, you need to buy into the game first");
|
||||
_;
|
||||
}
|
||||
|
||||
@ -205,9 +208,7 @@ contract RaidGeld is ERC20, Ownable, Constants {
|
||||
|
||||
// Manual minting for itchy fingers
|
||||
function raid() external onlyActiveSession {
|
||||
address delegatedPlayer = sessionWallets[msg.sender];
|
||||
address player = delegatedPlayer == address(0) ? msg.sender : delegatedPlayer;
|
||||
performRaid(player);
|
||||
performRaid(_player());
|
||||
}
|
||||
|
||||
// Helper so we can use it when buying units too
|
||||
@ -247,8 +248,7 @@ contract RaidGeld is ERC20, Ownable, Constants {
|
||||
|
||||
// Add a unit to your army
|
||||
function addUnit(uint8 unit, uint16 n_units) external onlyActiveSession {
|
||||
address delegatedPlayer = sessionWallets[msg.sender];
|
||||
address player = delegatedPlayer == address(0) ? msg.sender : delegatedPlayer;
|
||||
address player = _player();
|
||||
require(unit <= 3, "Unknown unit");
|
||||
|
||||
Army storage army = armies[player];
|
||||
@ -312,7 +312,8 @@ contract RaidGeld is ERC20, Ownable, Constants {
|
||||
|
||||
function battle_with_boss() external onlyActiveSession returns (bool[2] memory hasWonOrAscended) {
|
||||
// first perform raid
|
||||
performRaid(msg.sender);
|
||||
address player = _player();
|
||||
performRaid(player);
|
||||
Boss memory boss_to_attack = bosses[msg.sender];
|
||||
// calculate how much the player will put into battle
|
||||
uint256 geld_to_burn = balanceOf(msg.sender) >= RaidGeldUtils.getBossPower(boss_to_attack.level)
|
||||
@ -437,11 +438,30 @@ contract RaidGeld is ERC20, Ownable, Constants {
|
||||
DAO = _dao;
|
||||
}
|
||||
|
||||
function approveSessionWallet(address _wallet) payable external onlyPlayer {
|
||||
function proposeSessionWallet(address _wallet) payable external onlyPlayer {
|
||||
require(!isRegistered(_wallet), "Wallet belongs to other player");
|
||||
sessionWallets[msg.sender] = _wallet;
|
||||
require(msg.value <= SESSION_WALLET_FUNDING_CAP, "Too high funding amoount");
|
||||
require(sessionWalletToPlayer[_wallet] == address(0), "Wallet already in use");
|
||||
playerToSessionWallet[msg.sender] = _wallet;
|
||||
sessionWalletToPlayer[_wallet] = msg.sender;
|
||||
payable(_wallet).call{value: msg.value}("");
|
||||
}
|
||||
function acceptSessionWallet(address _player) external {
|
||||
require(proposedSessionWallets[_player] == msg.sender, "Not the proposed session wallet");
|
||||
sessionWalletToPlayer[msg.sender] = _player;
|
||||
playerToSessionWallet[_player] = msg.sender;
|
||||
proposedSessionWallets[msg.sender] = address(0);
|
||||
}
|
||||
function fundSessionWallet() payable external {
|
||||
require(sessionWalletToPlayer[msg.sender] != address(0), "No session wallet found");
|
||||
require(msg.value <= SESSION_WALLET_FUNDING_CAP, "Too high funding amoount");
|
||||
payable(sessionWalletToPlayer[msg.sender]).call{value: msg.value}("");
|
||||
}
|
||||
|
||||
function _player() internal view returns (address) {
|
||||
address delegatedWallet = sessionWalletToPlayer[msg.sender];
|
||||
return delegatedWallet == address(0) ? msg.sender : delegatedWallet;
|
||||
}
|
||||
|
||||
receive() external payable {
|
||||
revert("No plain Ether accepted, use register() function to check in :)");
|
||||
|
||||
Loading…
Reference in New Issue
Block a user