Skip to content

Commit

Permalink
add remove hatching time using EMON
Browse files Browse the repository at this point in the history
  • Loading branch information
etheremon committed Jan 27, 2018
1 parent 1c1a044 commit 5314694
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 7 deletions.
41 changes: 34 additions & 7 deletions EtheremonPayment.sol
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,10 @@ contract BattleInterface {
function createCastleWithToken(address _trainer, uint32 _noBrick, string _name, uint64 _a1, uint64 _a2, uint64 _a3, uint64 _s1, uint64 _s2, uint64 _s3) external;
}

contract TransformInterface {
function removeHatchingTimeWithToken(address _trainer) external;
}

contract EtheremonPayment is EtheremonEnum, BasicAccessControl, SafeMath {
uint8 constant public STAT_COUNT = 6;
uint8 constant public STAT_MAX = 32;
Expand Down Expand Up @@ -185,13 +189,16 @@ contract EtheremonPayment is EtheremonEnum, BasicAccessControl, SafeMath {
address public dataContract;
address public battleContract;
address public tokenContract;
address public transformContract;

address private lastHunter = address(0x0);

// config
uint public brickPrice = 2 * 10 ** 8; // 2 tokens
uint public brickPrice = 3 * 10 ** 8; // 3 tokens
uint public fastHatchingPrice = 35 * 10 ** 8; // 15 tokens
uint public tokenPrice = 0.004 ether / 10 ** 8;
uint public maxDexSize = 500;
uint public latestValue = 0;

// event
event EventCatchMonster(address indexed trainer, uint64 objId);
Expand All @@ -212,10 +219,16 @@ contract EtheremonPayment is EtheremonEnum, BasicAccessControl, SafeMath {
_;
}

function EtheremonPayment(address _dataContract, address _battleContract, address _tokenContract) public {
modifier requireTransformContract {
require(transformContract != address(0));
_;
}

function EtheremonPayment(address _dataContract, address _battleContract, address _tokenContract, address _transformContract) public {
dataContract = _dataContract;
battleContract = _battleContract;
tokenContract = _tokenContract;
transformContract = _transformContract;
}

// helper
Expand All @@ -236,16 +249,18 @@ contract EtheremonPayment is EtheremonEnum, BasicAccessControl, SafeMath {
token.transfer(_sendTo, _amount);
}

function setContract(address _dataContract, address _battleContract, address _tokenContract) onlyModerators external {
function setContract(address _dataContract, address _battleContract, address _tokenContract, address _transformContract) onlyModerators external {
dataContract = _dataContract;
battleContract = _battleContract;
tokenContract = _tokenContract;
transformContract = _transformContract;
}

function setConfig(uint _brickPrice, uint _tokenPrice, uint _maxDexSize) onlyModerators external {
function setConfig(uint _brickPrice, uint _tokenPrice, uint _maxDexSize, uint _fastHatchingPrice) onlyModerators external {
brickPrice = _brickPrice;
tokenPrice = _tokenPrice;
maxDexSize = _maxDexSize;
fastHatchingPrice = _fastHatchingPrice;
}

// battle
Expand Down Expand Up @@ -297,9 +312,21 @@ contract EtheremonPayment is EtheremonEnum, BasicAccessControl, SafeMath {
return requiredToken;
}

/*
function payService(address _trainer, uint _tokens, uint32 _type, string _text, uint64 _param1, uint64 _param2, uint64 _param3) public returns(uint) {

function payService(address _trainer, uint _tokens, uint32 _type, string _text, uint64 _param1, uint64 _param2, uint64 _param3, uint64 _param4, uint64 _param5, uint64 _param6) isActive requireTransformContract public returns(uint result) {
if (msg.sender != tokenContract)
revert();
}*/

if (_type == 1) {
// remove hatching time
if (_tokens < fastHatchingPrice)
revert();
TransformInterface transform = TransformInterface(transformContract);
transform.removeHatchingTimeWithToken(_trainer);

return fastHatchingPrice;
} else {
revert();
}
}
}
12 changes: 12 additions & 0 deletions EtheremonTransform.sol
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,17 @@ contract EtheremonTransform is EtheremonEnum, BasicAccessControl, SafeMath {
}
}

function removeHatchingTimeWithToken(address _trainer) isActive onlyModerators requireDataContract requireTransformDataContract external {
EtheremonTransformData transformData = EtheremonTransformData(transformDataContract);
MonsterEgg memory egg;
(egg.eggId, egg.objId, egg.classId, egg.trainer, egg.hatchTime, egg.newObjId) = transformData.getHatchingEggData(_trainer);
// not hatching any egg
if (egg.eggId == 0 || egg.trainer != _trainer || egg.newObjId > 0)
revert();

transformData.setHatchTime(egg.eggId, 0);
}

// public

function ceil(uint a, uint m) pure public returns (uint) {
Expand Down Expand Up @@ -508,6 +519,7 @@ contract EtheremonTransform is EtheremonEnum, BasicAccessControl, SafeMath {
}
transformData.setHatchTime(egg.eggId, 0);
}


function checkAncestors(uint32 _classId, address _trainer, uint64 _a1, uint64 _a2, uint64 _a3) constant public returns(bool) {
EtheremonWorld world = EtheremonWorld(worldContract);
Expand Down

0 comments on commit 5314694

Please sign in to comment.