Skip to content

Instantly share code, notes, and snippets.

@maxaleks
Created December 17, 2018 20:30
Show Gist options
  • Save maxaleks/964bbf7e8311d57eb14802113c63d25e to your computer and use it in GitHub Desktop.
Save maxaleks/964bbf7e8311d57eb14802113c63d25e to your computer and use it in GitHub Desktop.
pragma solidity 0.4.25;
contract Getter {
function getDragonGenome(uint256) external view returns (uint8[30]);
function getDragonTypes(uint256) external view returns (uint8[11]);
function getDragonTactics(uint256) external view returns (uint8, uint8);
function getDragonBattles(uint256) external view returns (uint16, uint16);
function getDragonSkills(uint256) external view returns (uint32, uint32, uint32, uint32, uint32);
function getDragonParents(uint256) external view returns (uint256[2]);
function getDragonSpecialAttack(uint256) external view returns (uint8, uint32, uint8, uint8);
function getDragonSpecialDefense(uint256) external view returns (uint8, uint32, uint8, uint8);
function getDragonSpecialPeacefulSkill(uint256) external view returns (uint8, uint32, uint32);
function getDragonBuffs(uint256) external view returns (uint32[5]);
function ownerOfDragon(uint256) public view returns (address);
function getDragonOnSaleInfo(uint256) public view returns (address, uint256, uint256, uint256, uint16, uint256, bool);
function getBreedingOnSaleInfo(uint256) public view returns (address, uint256, uint256, uint256, uint16, uint256, bool);
function isDragonOnSale(uint256) public view returns (bool);
function isBreedingOnSale(uint256) public view returns (bool);
}
contract GetterNew {
Getter getter = Getter(0xF88Fdb63dc782dAE646cD6c74728Ca83f56200E4);
function _getDragonTactics(uint256 _id) internal view returns (uint8[2]) {
(uint8 _melee, uint8 _attack) = getter.getDragonTactics(_id);
return [_melee, _attack];
}
function _getDragonSkills(uint256 _id) internal view returns (uint32[5]) {
(
uint32 _attack,
uint32 _defense,
uint32 _stamina,
uint32 _speed,
uint32 _intelligence
) = getter.getDragonSkills(_id);
return [_attack, _defense, _stamina, _speed, _intelligence];
}
function _getDragonBattles(uint256 _id) internal view returns (uint16[2]) {
(uint16 _wins, uint16 _defeats) = getter.getDragonBattles(_id);
return [_wins, _defeats];
}
function getDragonDataPack(uint256 _id) external view returns (
uint8[30] genome,
uint8[11] dragonTypes,
uint256[2] parents,
uint8[2] tactics,
uint32[5] skills,
uint16[2] battles,
uint32[5] buffs,
address owner
) {
genome = getter.getDragonGenome(_id);
dragonTypes = getter.getDragonTypes(_id);
parents = getter.getDragonParents(_id);
tactics = _getDragonTactics(_id);
skills = _getDragonSkills(_id);
battles = _getDragonBattles(_id);
buffs = getter.getDragonBuffs(_id);
owner = getter.ownerOfDragon(_id);
}
function getDragonSpecialSkills(uint256 _id) external view returns (
uint8 attackDragonType,
uint32 attackCost,
uint8 attackFactor,
uint8 attackChance,
uint8 defenseDragonType,
uint32 defenseCost,
uint8 defenseFactor,
uint8 defenseChance,
uint8 peacefulClass,
uint32 peacefulCost,
uint32 peacefulEffect
) {
(
attackDragonType,
attackCost,
attackFactor,
attackChance
) = getter.getDragonSpecialAttack(_id);
(
defenseDragonType,
defenseCost,
defenseFactor,
defenseChance
) = getter.getDragonSpecialDefense(_id);
(
peacefulClass,
peacefulCost,
peacefulEffect
) = getter.getDragonSpecialPeacefulSkill(_id);
}
function getDragonSaleInfo(uint256 _id) external view returns (
bool isOnSale,
bool isOnBreeding,
address seller,
uint256 currentPrice,
uint256 startPrice,
uint256 endPrice,
uint16 period,
uint256 created,
bool isGold
) {
isOnSale = getter.isDragonOnSale(_id);
isOnBreeding = getter.isBreedingOnSale(_id);
if (!isOnSale && !isOnBreeding) return;
(
seller,
currentPrice,
startPrice,
endPrice,
period,
created,
isGold
) =
isOnSale ?
getter.getDragonOnSaleInfo(_id) :
getter.getBreedingOnSaleInfo(_id);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment