Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- pragma solidity ^0.4.19;
- import "./playerhelper.sol";
- contract PlayerChallenge is PlayerHelper {
- uint randNonce = 0;
- uint victoryProbability = 70;
- function randMod(uint _modulus) internal returns(uint) {
- randNonce++;
- return uint(keccak256(now, msg.sender, randNonce)) % _modulus;
- }
- function challenge(uint _footballerId, uint _targetId) external onlyOwnerOf(_footballerId) {
- Footballer storage myPlayer = players[_footballerId];
- Footballer storage opponentPlayer = players[_targetId];
- uint rand = randMod(100);
- if (rand <= victoryProbability) {
- myPlayer.winCount = myPlayer.winCount.add(1);
- myPlayer.level = myPlayer.level.add(1);
- opponentPlayer.lossCount = opponentPlayer.lossCount.add(1);
- clone(_footballerId, opponentPlayer.dna, "footballer");
- } // start here
- }
- }
Add Comment
Please, Sign In to add comment