Boss updates
This commit is contained in:
parent
3aa429fdd7
commit
76fc15faab
@ -1,26 +1,92 @@
|
||||
[
|
||||
{ "type": "constructor", "inputs": [], "stateMutability": "nonpayable" },
|
||||
{
|
||||
"type": "constructor",
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_daoToken",
|
||||
"type": "address",
|
||||
"internalType": "address"
|
||||
},
|
||||
{
|
||||
"name": "_pool",
|
||||
"type": "address",
|
||||
"internalType": "address"
|
||||
}
|
||||
],
|
||||
"stateMutability": "nonpayable"
|
||||
},
|
||||
{ "type": "fallback", "stateMutability": "payable" },
|
||||
{ "type": "receive", "stateMutability": "payable" },
|
||||
{
|
||||
"type": "function",
|
||||
"name": "BUY_IN_AMOUNT",
|
||||
"inputs": [],
|
||||
"outputs": [{ "name": "", "type": "uint256", "internalType": "uint256" }],
|
||||
"outputs": [
|
||||
{ "name": "", "type": "uint256", "internalType": "uint256" }
|
||||
],
|
||||
"stateMutability": "view"
|
||||
},
|
||||
{
|
||||
"type": "function",
|
||||
"name": "BUY_IN_DAO_TOKEN_AMOUNT",
|
||||
"inputs": [],
|
||||
"outputs": [
|
||||
{ "name": "", "type": "uint256", "internalType": "uint256" }
|
||||
],
|
||||
"stateMutability": "view"
|
||||
},
|
||||
{
|
||||
"type": "function",
|
||||
"name": "DAO_TOKEN",
|
||||
"inputs": [],
|
||||
"outputs": [
|
||||
{ "name": "", "type": "address", "internalType": "address" }
|
||||
],
|
||||
"stateMutability": "view"
|
||||
},
|
||||
{
|
||||
"type": "function",
|
||||
"name": "INITIAL_GELD",
|
||||
"inputs": [],
|
||||
"outputs": [{ "name": "", "type": "uint256", "internalType": "uint256" }],
|
||||
"outputs": [
|
||||
{ "name": "", "type": "uint256", "internalType": "uint256" }
|
||||
],
|
||||
"stateMutability": "view"
|
||||
},
|
||||
{
|
||||
"type": "function",
|
||||
"name": "MANTISSA",
|
||||
"inputs": [],
|
||||
"outputs": [{ "name": "", "type": "uint256", "internalType": "uint256" }],
|
||||
"outputs": [
|
||||
{ "name": "", "type": "uint256", "internalType": "uint256" }
|
||||
],
|
||||
"stateMutability": "view"
|
||||
},
|
||||
{
|
||||
"type": "function",
|
||||
"name": "POOL",
|
||||
"inputs": [],
|
||||
"outputs": [
|
||||
{ "name": "", "type": "address", "internalType": "address" }
|
||||
],
|
||||
"stateMutability": "view"
|
||||
},
|
||||
{
|
||||
"type": "function",
|
||||
"name": "SWAP_ROUTER",
|
||||
"inputs": [],
|
||||
"outputs": [
|
||||
{ "name": "", "type": "address", "internalType": "address" }
|
||||
],
|
||||
"stateMutability": "view"
|
||||
},
|
||||
{
|
||||
"type": "function",
|
||||
"name": "WETH",
|
||||
"inputs": [],
|
||||
"outputs": [
|
||||
{ "name": "", "type": "address", "internalType": "address" }
|
||||
],
|
||||
"stateMutability": "view"
|
||||
},
|
||||
{
|
||||
@ -28,7 +94,11 @@
|
||||
"name": "addUnit",
|
||||
"inputs": [
|
||||
{ "name": "unit", "type": "uint8", "internalType": "uint8" },
|
||||
{ "name": "n_units", "type": "uint16", "internalType": "uint16" }
|
||||
{
|
||||
"name": "n_units",
|
||||
"type": "uint16",
|
||||
"internalType": "uint16"
|
||||
}
|
||||
],
|
||||
"outputs": [],
|
||||
"stateMutability": "nonpayable"
|
||||
@ -37,18 +107,36 @@
|
||||
"type": "function",
|
||||
"name": "allowance",
|
||||
"inputs": [
|
||||
{ "name": "owner", "type": "address", "internalType": "address" },
|
||||
{ "name": "spender", "type": "address", "internalType": "address" }
|
||||
{
|
||||
"name": "owner",
|
||||
"type": "address",
|
||||
"internalType": "address"
|
||||
},
|
||||
{
|
||||
"name": "spender",
|
||||
"type": "address",
|
||||
"internalType": "address"
|
||||
}
|
||||
],
|
||||
"outputs": [
|
||||
{ "name": "", "type": "uint256", "internalType": "uint256" }
|
||||
],
|
||||
"outputs": [{ "name": "", "type": "uint256", "internalType": "uint256" }],
|
||||
"stateMutability": "view"
|
||||
},
|
||||
{
|
||||
"type": "function",
|
||||
"name": "approve",
|
||||
"inputs": [
|
||||
{ "name": "spender", "type": "address", "internalType": "address" },
|
||||
{ "name": "value", "type": "uint256", "internalType": "uint256" }
|
||||
{
|
||||
"name": "spender",
|
||||
"type": "address",
|
||||
"internalType": "address"
|
||||
},
|
||||
{
|
||||
"name": "value",
|
||||
"type": "uint256",
|
||||
"internalType": "uint256"
|
||||
}
|
||||
],
|
||||
"outputs": [{ "name": "", "type": "bool", "internalType": "bool" }],
|
||||
"stateMutability": "nonpayable"
|
||||
@ -57,9 +145,41 @@
|
||||
"type": "function",
|
||||
"name": "balanceOf",
|
||||
"inputs": [
|
||||
{ "name": "account", "type": "address", "internalType": "address" }
|
||||
{
|
||||
"name": "account",
|
||||
"type": "address",
|
||||
"internalType": "address"
|
||||
}
|
||||
],
|
||||
"outputs": [
|
||||
{ "name": "", "type": "uint256", "internalType": "uint256" }
|
||||
],
|
||||
"stateMutability": "view"
|
||||
},
|
||||
{
|
||||
"type": "function",
|
||||
"name": "battle_with_boss",
|
||||
"inputs": [],
|
||||
"outputs": [
|
||||
{
|
||||
"name": "hasWonOrAscended",
|
||||
"type": "bool[2]",
|
||||
"internalType": "bool[2]"
|
||||
}
|
||||
],
|
||||
"stateMutability": "nonpayable"
|
||||
},
|
||||
{
|
||||
"type": "function",
|
||||
"name": "daoToken",
|
||||
"inputs": [],
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "address",
|
||||
"internalType": "contract ERC20"
|
||||
}
|
||||
],
|
||||
"outputs": [{ "name": "", "type": "uint256", "internalType": "uint256" }],
|
||||
"stateMutability": "view"
|
||||
},
|
||||
{
|
||||
@ -86,7 +206,11 @@
|
||||
"type": "tuple",
|
||||
"internalType": "struct Raider",
|
||||
"components": [
|
||||
{ "name": "level", "type": "uint16", "internalType": "uint16" }
|
||||
{
|
||||
"name": "level",
|
||||
"type": "uint16",
|
||||
"internalType": "uint16"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -94,7 +218,11 @@
|
||||
"type": "tuple",
|
||||
"internalType": "struct Raider",
|
||||
"components": [
|
||||
{ "name": "level", "type": "uint16", "internalType": "uint16" }
|
||||
{
|
||||
"name": "level",
|
||||
"type": "uint16",
|
||||
"internalType": "uint16"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -102,7 +230,11 @@
|
||||
"type": "tuple",
|
||||
"internalType": "struct Raider",
|
||||
"components": [
|
||||
{ "name": "level", "type": "uint16", "internalType": "uint16" }
|
||||
{
|
||||
"name": "level",
|
||||
"type": "uint16",
|
||||
"internalType": "uint16"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -110,7 +242,11 @@
|
||||
"type": "tuple",
|
||||
"internalType": "struct Raider",
|
||||
"components": [
|
||||
{ "name": "level", "type": "uint16", "internalType": "uint16" }
|
||||
{
|
||||
"name": "level",
|
||||
"type": "uint16",
|
||||
"internalType": "uint16"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -123,6 +259,33 @@
|
||||
],
|
||||
"stateMutability": "view"
|
||||
},
|
||||
{
|
||||
"type": "function",
|
||||
"name": "getBoss",
|
||||
"inputs": [
|
||||
{ "name": "addr", "type": "address", "internalType": "address" }
|
||||
],
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "tuple",
|
||||
"internalType": "struct Boss",
|
||||
"components": [
|
||||
{
|
||||
"name": "level",
|
||||
"type": "uint8",
|
||||
"internalType": "uint8"
|
||||
},
|
||||
{
|
||||
"name": "variants",
|
||||
"type": "uint8[7]",
|
||||
"internalType": "uint8[7]"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"stateMutability": "view"
|
||||
},
|
||||
{
|
||||
"type": "function",
|
||||
"name": "getPlayer",
|
||||
@ -149,6 +312,31 @@
|
||||
"name": "last_raided_at",
|
||||
"type": "uint256",
|
||||
"internalType": "uint256"
|
||||
},
|
||||
{
|
||||
"name": "total_rewards",
|
||||
"type": "uint256",
|
||||
"internalType": "uint256"
|
||||
},
|
||||
{
|
||||
"name": "n_runs",
|
||||
"type": "uint32",
|
||||
"internalType": "uint32"
|
||||
},
|
||||
{
|
||||
"name": "prestige_level",
|
||||
"type": "uint32",
|
||||
"internalType": "uint32"
|
||||
},
|
||||
{
|
||||
"name": "is_registered",
|
||||
"type": "bool",
|
||||
"internalType": "bool"
|
||||
},
|
||||
{
|
||||
"name": "has_active_session",
|
||||
"type": "bool",
|
||||
"internalType": "bool"
|
||||
}
|
||||
]
|
||||
}
|
||||
@ -175,7 +363,18 @@
|
||||
"type": "function",
|
||||
"name": "owner",
|
||||
"inputs": [],
|
||||
"outputs": [{ "name": "", "type": "address", "internalType": "address" }],
|
||||
"outputs": [
|
||||
{ "name": "", "type": "address", "internalType": "address" }
|
||||
],
|
||||
"stateMutability": "view"
|
||||
},
|
||||
{
|
||||
"type": "function",
|
||||
"name": "pool",
|
||||
"inputs": [],
|
||||
"outputs": [
|
||||
{ "name": "", "type": "address", "internalType": "address" }
|
||||
],
|
||||
"stateMutability": "view"
|
||||
},
|
||||
{
|
||||
@ -187,7 +386,14 @@
|
||||
},
|
||||
{
|
||||
"type": "function",
|
||||
"name": "register",
|
||||
"name": "register_dao",
|
||||
"inputs": [],
|
||||
"outputs": [],
|
||||
"stateMutability": "payable"
|
||||
},
|
||||
{
|
||||
"type": "function",
|
||||
"name": "register_eth",
|
||||
"inputs": [],
|
||||
"outputs": [],
|
||||
"stateMutability": "payable"
|
||||
@ -199,6 +405,19 @@
|
||||
"outputs": [],
|
||||
"stateMutability": "nonpayable"
|
||||
},
|
||||
{
|
||||
"type": "function",
|
||||
"name": "setDaoTokenBuyInAmount",
|
||||
"inputs": [
|
||||
{
|
||||
"name": "newAmount",
|
||||
"type": "uint256",
|
||||
"internalType": "uint256"
|
||||
}
|
||||
],
|
||||
"outputs": [],
|
||||
"stateMutability": "nonpayable"
|
||||
},
|
||||
{
|
||||
"type": "function",
|
||||
"name": "symbol",
|
||||
@ -210,7 +429,9 @@
|
||||
"type": "function",
|
||||
"name": "totalSupply",
|
||||
"inputs": [],
|
||||
"outputs": [{ "name": "", "type": "uint256", "internalType": "uint256" }],
|
||||
"outputs": [
|
||||
{ "name": "", "type": "uint256", "internalType": "uint256" }
|
||||
],
|
||||
"stateMutability": "view"
|
||||
},
|
||||
{
|
||||
@ -218,7 +439,11 @@
|
||||
"name": "transfer",
|
||||
"inputs": [
|
||||
{ "name": "to", "type": "address", "internalType": "address" },
|
||||
{ "name": "value", "type": "uint256", "internalType": "uint256" }
|
||||
{
|
||||
"name": "value",
|
||||
"type": "uint256",
|
||||
"internalType": "uint256"
|
||||
}
|
||||
],
|
||||
"outputs": [{ "name": "", "type": "bool", "internalType": "bool" }],
|
||||
"stateMutability": "nonpayable"
|
||||
@ -227,9 +452,17 @@
|
||||
"type": "function",
|
||||
"name": "transferFrom",
|
||||
"inputs": [
|
||||
{ "name": "from", "type": "address", "internalType": "address" },
|
||||
{
|
||||
"name": "from",
|
||||
"type": "address",
|
||||
"internalType": "address"
|
||||
},
|
||||
{ "name": "to", "type": "address", "internalType": "address" },
|
||||
{ "name": "value", "type": "uint256", "internalType": "uint256" }
|
||||
{
|
||||
"name": "value",
|
||||
"type": "uint256",
|
||||
"internalType": "uint256"
|
||||
}
|
||||
],
|
||||
"outputs": [{ "name": "", "type": "bool", "internalType": "bool" }],
|
||||
"stateMutability": "nonpayable"
|
||||
@ -238,17 +471,27 @@
|
||||
"type": "function",
|
||||
"name": "transferOwnership",
|
||||
"inputs": [
|
||||
{ "name": "newOwner", "type": "address", "internalType": "address" }
|
||||
{
|
||||
"name": "newOwner",
|
||||
"type": "address",
|
||||
"internalType": "address"
|
||||
}
|
||||
],
|
||||
"outputs": [],
|
||||
"stateMutability": "nonpayable"
|
||||
},
|
||||
{
|
||||
"type": "function",
|
||||
"name": "withdraw",
|
||||
"name": "weth",
|
||||
"inputs": [],
|
||||
"outputs": [],
|
||||
"stateMutability": "nonpayable"
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "address",
|
||||
"internalType": "contract IWETH"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view"
|
||||
},
|
||||
{
|
||||
"type": "event",
|
||||
@ -275,6 +518,56 @@
|
||||
],
|
||||
"anonymous": false
|
||||
},
|
||||
{
|
||||
"type": "event",
|
||||
"name": "BossDefeated",
|
||||
"inputs": [
|
||||
{
|
||||
"name": "player",
|
||||
"type": "address",
|
||||
"indexed": true,
|
||||
"internalType": "address"
|
||||
},
|
||||
{
|
||||
"name": "bossLevel",
|
||||
"type": "uint8",
|
||||
"indexed": false,
|
||||
"internalType": "uint8"
|
||||
},
|
||||
{
|
||||
"name": "earnings",
|
||||
"type": "uint256",
|
||||
"indexed": false,
|
||||
"internalType": "uint256"
|
||||
}
|
||||
],
|
||||
"anonymous": false
|
||||
},
|
||||
{
|
||||
"type": "event",
|
||||
"name": "DaoTokenBuyInAmountSet",
|
||||
"inputs": [
|
||||
{
|
||||
"name": "owner",
|
||||
"type": "address",
|
||||
"indexed": true,
|
||||
"internalType": "address"
|
||||
},
|
||||
{
|
||||
"name": "oldAmount",
|
||||
"type": "uint256",
|
||||
"indexed": false,
|
||||
"internalType": "uint256"
|
||||
},
|
||||
{
|
||||
"name": "newAmount",
|
||||
"type": "uint256",
|
||||
"indexed": false,
|
||||
"internalType": "uint256"
|
||||
}
|
||||
],
|
||||
"anonymous": false
|
||||
},
|
||||
{
|
||||
"type": "event",
|
||||
"name": "OwnershipTransferred",
|
||||
@ -313,6 +606,50 @@
|
||||
],
|
||||
"anonymous": false
|
||||
},
|
||||
{
|
||||
"type": "event",
|
||||
"name": "PlayerStrikesAgain",
|
||||
"inputs": [
|
||||
{
|
||||
"name": "player",
|
||||
"type": "address",
|
||||
"indexed": true,
|
||||
"internalType": "address"
|
||||
},
|
||||
{
|
||||
"name": "totalRewards",
|
||||
"type": "uint256",
|
||||
"indexed": false,
|
||||
"internalType": "uint256"
|
||||
},
|
||||
{
|
||||
"name": "initialGeld",
|
||||
"type": "uint256",
|
||||
"indexed": false,
|
||||
"internalType": "uint256"
|
||||
}
|
||||
],
|
||||
"anonymous": false
|
||||
},
|
||||
{
|
||||
"type": "event",
|
||||
"name": "PrestigeGained",
|
||||
"inputs": [
|
||||
{
|
||||
"name": "player",
|
||||
"type": "address",
|
||||
"indexed": true,
|
||||
"internalType": "address"
|
||||
},
|
||||
{
|
||||
"name": "prestigeLevel",
|
||||
"type": "uint32",
|
||||
"indexed": false,
|
||||
"internalType": "uint32"
|
||||
}
|
||||
],
|
||||
"anonymous": false
|
||||
},
|
||||
{
|
||||
"type": "event",
|
||||
"name": "RaidPerformed",
|
||||
@ -428,60 +765,108 @@
|
||||
"type": "error",
|
||||
"name": "ERC20InsufficientAllowance",
|
||||
"inputs": [
|
||||
{ "name": "spender", "type": "address", "internalType": "address" },
|
||||
{ "name": "allowance", "type": "uint256", "internalType": "uint256" },
|
||||
{ "name": "needed", "type": "uint256", "internalType": "uint256" }
|
||||
{
|
||||
"name": "spender",
|
||||
"type": "address",
|
||||
"internalType": "address"
|
||||
},
|
||||
{
|
||||
"name": "allowance",
|
||||
"type": "uint256",
|
||||
"internalType": "uint256"
|
||||
},
|
||||
{
|
||||
"name": "needed",
|
||||
"type": "uint256",
|
||||
"internalType": "uint256"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "error",
|
||||
"name": "ERC20InsufficientBalance",
|
||||
"inputs": [
|
||||
{ "name": "sender", "type": "address", "internalType": "address" },
|
||||
{ "name": "balance", "type": "uint256", "internalType": "uint256" },
|
||||
{ "name": "needed", "type": "uint256", "internalType": "uint256" }
|
||||
{
|
||||
"name": "sender",
|
||||
"type": "address",
|
||||
"internalType": "address"
|
||||
},
|
||||
{
|
||||
"name": "balance",
|
||||
"type": "uint256",
|
||||
"internalType": "uint256"
|
||||
},
|
||||
{
|
||||
"name": "needed",
|
||||
"type": "uint256",
|
||||
"internalType": "uint256"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "error",
|
||||
"name": "ERC20InvalidApprover",
|
||||
"inputs": [
|
||||
{ "name": "approver", "type": "address", "internalType": "address" }
|
||||
{
|
||||
"name": "approver",
|
||||
"type": "address",
|
||||
"internalType": "address"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "error",
|
||||
"name": "ERC20InvalidReceiver",
|
||||
"inputs": [
|
||||
{ "name": "receiver", "type": "address", "internalType": "address" }
|
||||
{
|
||||
"name": "receiver",
|
||||
"type": "address",
|
||||
"internalType": "address"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "error",
|
||||
"name": "ERC20InvalidSender",
|
||||
"inputs": [
|
||||
{ "name": "sender", "type": "address", "internalType": "address" }
|
||||
{
|
||||
"name": "sender",
|
||||
"type": "address",
|
||||
"internalType": "address"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "error",
|
||||
"name": "ERC20InvalidSpender",
|
||||
"inputs": [
|
||||
{ "name": "spender", "type": "address", "internalType": "address" }
|
||||
{
|
||||
"name": "spender",
|
||||
"type": "address",
|
||||
"internalType": "address"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "error",
|
||||
"name": "OwnableInvalidOwner",
|
||||
"inputs": [
|
||||
{ "name": "owner", "type": "address", "internalType": "address" }
|
||||
{
|
||||
"name": "owner",
|
||||
"type": "address",
|
||||
"internalType": "address"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "error",
|
||||
"name": "OwnableUnauthorizedAccount",
|
||||
"inputs": [
|
||||
{ "name": "account", "type": "address", "internalType": "address" }
|
||||
{
|
||||
"name": "account",
|
||||
"type": "address",
|
||||
"internalType": "address"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
@ -8,6 +8,11 @@ type Player @entity {
|
||||
army: Army! @derivedFrom(field: "player")
|
||||
armyStrength: BigInt! # Calculated field for total army power
|
||||
rank: Int # Position in leaderboard, can be updated periodically
|
||||
prestigeLevel: BigInt!
|
||||
totalRuns: Int! # Track number of times player has started a new run
|
||||
bossesDefeated: Int!
|
||||
totalRewards: BigInt! # Track total DAO tokens earned from boss battles
|
||||
isActiveSession: Boolean! # Track if player has an active session
|
||||
}
|
||||
|
||||
type Army @entity {
|
||||
@ -21,6 +26,7 @@ type Army @entity {
|
||||
projectedDailyEarnings: BigInt! # Derived from profitPerSecond
|
||||
totalUnitsPurchased: Int!
|
||||
lastUnitPurchaseTime: BigInt
|
||||
currentBossLevel: Int! # Track current boss level
|
||||
}
|
||||
|
||||
type GlobalStat @entity {
|
||||
@ -30,4 +36,15 @@ type GlobalStat @entity {
|
||||
totalArmyUnits: Int!
|
||||
lastUpdateTime: BigInt!
|
||||
topEarnerProfit: BigInt! # Track highest profit per second
|
||||
totalPrestigeLevels: Int! # Sum of all player prestige levels
|
||||
totalBossesDefeated: Int!
|
||||
totalRuns: Int! # Track total number of runs across all players
|
||||
}
|
||||
|
||||
type BossDefeat @entity {
|
||||
id: ID! # player address + timestamp
|
||||
player: Player!
|
||||
bossLevel: Int!
|
||||
earnings: BigInt!
|
||||
timestamp: BigInt!
|
||||
}
|
||||
270
src/raid-geld.ts
270
src/raid-geld.ts
@ -1,26 +1,29 @@
|
||||
import {
|
||||
PlayerRegistered,
|
||||
RaidPerformed,
|
||||
UnitAdded
|
||||
} from "../generated/RaidGeld/RaidGeld"
|
||||
import { Player, Army, GlobalStat } from "../generated/schema"
|
||||
import { BigInt } from "@graphprotocol/graph-ts"
|
||||
UnitAdded,
|
||||
PlayerStrikesAgain,
|
||||
BossDefeated,
|
||||
PrestigeGained,
|
||||
} from "../generated/RaidGeld/RaidGeld";
|
||||
import { Player, Army, GlobalStat, BossDefeat } from "../generated/schema";
|
||||
import { BigInt } from "@graphprotocol/graph-ts";
|
||||
|
||||
// Constants from RaidGeldUtils
|
||||
const PRECISION = BigInt.fromI32(10000)
|
||||
const PRICE_FACTOR = BigInt.fromI32(11500)
|
||||
const PRECISION = BigInt.fromI32(10000);
|
||||
const PRICE_FACTOR = BigInt.fromI32(11500);
|
||||
|
||||
// Unit profits
|
||||
const MOLOCH_DENIER_PROFIT = BigInt.fromI32(2533)
|
||||
const APPRENTICE_PROFIT = BigInt.fromI32(27863)
|
||||
const ANOINTED_PROFIT = BigInt.fromI32(306493)
|
||||
const CHAMPION_PROFIT = BigInt.fromI32(3371423)
|
||||
const MOLOCH_DENIER_PROFIT = BigInt.fromI32(2533);
|
||||
const APPRENTICE_PROFIT = BigInt.fromI32(27863);
|
||||
const ANOINTED_PROFIT = BigInt.fromI32(306493);
|
||||
const CHAMPION_PROFIT = BigInt.fromI32(3371423);
|
||||
|
||||
// Base costs (not used in profit calculation but useful for reference)
|
||||
const MOLOCH_DENIER_BASE_COST = BigInt.fromI32(380000)
|
||||
const APPRENTICE_BASE_COST = BigInt.fromI32(3420000)
|
||||
const ANOINTED_BASE_COST = BigInt.fromI32(30096000)
|
||||
const CHAMPION_BASE_COST = BigInt.fromI32(255816000)
|
||||
const MOLOCH_DENIER_BASE_COST = BigInt.fromI32(380000);
|
||||
const APPRENTICE_BASE_COST = BigInt.fromI32(3420000);
|
||||
const ANOINTED_BASE_COST = BigInt.fromI32(30096000);
|
||||
const CHAMPION_BASE_COST = BigInt.fromI32(255816000);
|
||||
|
||||
function calculateProfitPerSecond(
|
||||
molochLevel: i32,
|
||||
@ -29,28 +32,32 @@ function calculateProfitPerSecond(
|
||||
championLevel: i32
|
||||
): BigInt {
|
||||
// Exactly matching the RaidGeldUtils calculation
|
||||
let molochDenierProfit = MOLOCH_DENIER_PROFIT.times(BigInt.fromI32(molochLevel))
|
||||
let apprenticeProfit = APPRENTICE_PROFIT.times(BigInt.fromI32(apprenticeLevel))
|
||||
let anointedProfit = ANOINTED_PROFIT.times(BigInt.fromI32(anointedLevel))
|
||||
let championProfit = CHAMPION_PROFIT.times(BigInt.fromI32(championLevel))
|
||||
let molochDenierProfit = MOLOCH_DENIER_PROFIT.times(
|
||||
BigInt.fromI32(molochLevel)
|
||||
);
|
||||
let apprenticeProfit = APPRENTICE_PROFIT.times(
|
||||
BigInt.fromI32(apprenticeLevel)
|
||||
);
|
||||
let anointedProfit = ANOINTED_PROFIT.times(BigInt.fromI32(anointedLevel));
|
||||
let championProfit = CHAMPION_PROFIT.times(BigInt.fromI32(championLevel));
|
||||
|
||||
return molochDenierProfit
|
||||
.plus(apprenticeProfit)
|
||||
.plus(anointedProfit)
|
||||
.plus(championProfit)
|
||||
.plus(championProfit);
|
||||
}
|
||||
|
||||
function getOrCreateGlobalStats(): GlobalStat {
|
||||
let stats = GlobalStat.load("1")
|
||||
let stats = GlobalStat.load("1");
|
||||
if (!stats) {
|
||||
stats = new GlobalStat("1")
|
||||
stats.totalPlayers = 0
|
||||
stats.totalGeldMinted = BigInt.fromI32(0)
|
||||
stats.totalArmyUnits = 0
|
||||
stats.lastUpdateTime = BigInt.fromI32(0)
|
||||
stats.topEarnerProfit = BigInt.fromI32(0)
|
||||
stats = new GlobalStat("1");
|
||||
stats.totalPlayers = 0;
|
||||
stats.totalGeldMinted = BigInt.fromI32(0);
|
||||
stats.totalArmyUnits = 0;
|
||||
stats.lastUpdateTime = BigInt.fromI32(0);
|
||||
stats.topEarnerProfit = BigInt.fromI32(0);
|
||||
}
|
||||
return stats
|
||||
return stats;
|
||||
}
|
||||
|
||||
function calculateArmyStrength(army: Army): BigInt {
|
||||
@ -60,75 +67,161 @@ function calculateArmyStrength(army: Army): BigInt {
|
||||
army.apprenticeLevel,
|
||||
army.anointedLevel,
|
||||
army.championLevel
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
function calculateProjectedDailyEarnings(profitPerSecond: BigInt): BigInt {
|
||||
return profitPerSecond.times(BigInt.fromI32(86400)) // 86400 seconds in a day
|
||||
return profitPerSecond.times(BigInt.fromI32(86400)); // 86400 seconds in a day
|
||||
}
|
||||
|
||||
export function handlePlayerRegistered(event: PlayerRegistered): void {
|
||||
let player = new Player(event.params.player.toHexString())
|
||||
player.createdAt = event.block.timestamp
|
||||
player.lastRaidedAt = event.block.timestamp
|
||||
player.totalMinted = event.params.initialGeld
|
||||
player.currentBalance = event.params.initialGeld
|
||||
player.numberOfRaids = 0
|
||||
player.armyStrength = BigInt.fromI32(0)
|
||||
player.rank = 0
|
||||
player.save()
|
||||
let player = new Player(event.params.player.toHexString());
|
||||
player.createdAt = event.block.timestamp;
|
||||
player.lastRaidedAt = event.block.timestamp;
|
||||
player.totalMinted = event.params.initialGeld;
|
||||
player.currentBalance = event.params.initialGeld;
|
||||
player.numberOfRaids = 0;
|
||||
player.armyStrength = BigInt.fromI32(0);
|
||||
player.rank = 0;
|
||||
// Initialize new fields
|
||||
player.prestigeLevel = BigInt.fromI32(0);
|
||||
player.totalRuns = 1;
|
||||
player.bossesDefeated = 0;
|
||||
player.totalRewards = BigInt.fromI32(0);
|
||||
player.isActiveSession = true;
|
||||
player.save();
|
||||
|
||||
let army = new Army(event.params.player.toHexString())
|
||||
army.player = player.id
|
||||
army.molochDenierLevel = 0
|
||||
army.apprenticeLevel = 0
|
||||
army.anointedLevel = 0
|
||||
army.championLevel = 0
|
||||
army.profitPerSecond = BigInt.fromI32(0)
|
||||
army.projectedDailyEarnings = BigInt.fromI32(0)
|
||||
army.totalUnitsPurchased = 0
|
||||
army.lastUnitPurchaseTime = event.block.timestamp
|
||||
army.save()
|
||||
let army = new Army(event.params.player.toHexString());
|
||||
army.player = player.id;
|
||||
army.molochDenierLevel = 0;
|
||||
army.apprenticeLevel = 0;
|
||||
army.anointedLevel = 0;
|
||||
army.championLevel = 0;
|
||||
army.profitPerSecond = BigInt.fromI32(0);
|
||||
army.projectedDailyEarnings = BigInt.fromI32(0);
|
||||
army.totalUnitsPurchased = 0;
|
||||
army.lastUnitPurchaseTime = event.block.timestamp;
|
||||
army.currentBossLevel = 0;
|
||||
army.save();
|
||||
|
||||
let stats = getOrCreateGlobalStats()
|
||||
stats.totalPlayers += 1
|
||||
stats.totalGeldMinted = stats.totalGeldMinted.plus(event.params.initialGeld)
|
||||
stats.lastUpdateTime = event.block.timestamp
|
||||
stats.save()
|
||||
let stats = getOrCreateGlobalStats();
|
||||
stats.totalPlayers += 1;
|
||||
stats.totalGeldMinted = stats.totalGeldMinted.plus(
|
||||
event.params.initialGeld
|
||||
);
|
||||
stats.totalRuns += 1;
|
||||
stats.lastUpdateTime = event.block.timestamp;
|
||||
stats.save();
|
||||
}
|
||||
|
||||
export function handlePlayerStrikesAgain(event: PlayerStrikesAgain): void {
|
||||
let player = Player.load(event.params.player.toHexString());
|
||||
if (!player) return;
|
||||
|
||||
player.totalRuns += 1;
|
||||
player.currentBalance = event.params.initialGeld;
|
||||
player.totalMinted = event.params.initialGeld;
|
||||
player.lastRaidedAt = event.block.timestamp;
|
||||
player.isActiveSession = true;
|
||||
player.save();
|
||||
|
||||
// Reset army for new run
|
||||
let army = Army.load(event.params.player.toHexString());
|
||||
if (!army) return;
|
||||
|
||||
army.molochDenierLevel = 0;
|
||||
army.apprenticeLevel = 0;
|
||||
army.anointedLevel = 0;
|
||||
army.championLevel = 0;
|
||||
army.profitPerSecond = BigInt.fromI32(0);
|
||||
army.projectedDailyEarnings = BigInt.fromI32(0);
|
||||
army.currentBossLevel = 0;
|
||||
army.save();
|
||||
|
||||
let stats = getOrCreateGlobalStats();
|
||||
stats.totalRuns += 1;
|
||||
stats.lastUpdateTime = event.block.timestamp;
|
||||
stats.save();
|
||||
}
|
||||
|
||||
export function handleBossDefeated(event: BossDefeated): void {
|
||||
let player = Player.load(event.params.player.toHexString());
|
||||
if (!player) return;
|
||||
|
||||
player.bossesDefeated += 1;
|
||||
player.totalRewards = player.totalRewards.plus(event.params.earnings);
|
||||
player.save();
|
||||
|
||||
let army = Army.load(event.params.player.toHexString());
|
||||
if (!army) return;
|
||||
|
||||
army.currentBossLevel += 1;
|
||||
army.save();
|
||||
|
||||
// Create boss defeat record
|
||||
let bossDefeat = new BossDefeat(
|
||||
event.params.player.toHexString() +
|
||||
"-" +
|
||||
event.block.timestamp.toString()
|
||||
);
|
||||
bossDefeat.player = player.id;
|
||||
bossDefeat.bossLevel = event.params.bossLevel;
|
||||
bossDefeat.earnings = event.params.earnings;
|
||||
bossDefeat.timestamp = event.block.timestamp;
|
||||
bossDefeat.save();
|
||||
|
||||
let stats = getOrCreateGlobalStats();
|
||||
stats.totalBossesDefeated += 1;
|
||||
stats.lastUpdateTime = event.block.timestamp;
|
||||
stats.save();
|
||||
}
|
||||
|
||||
export function handlePrestigeGained(event: PrestigeGained): void {
|
||||
let player = Player.load(event.params.player.toHexString());
|
||||
if (!player) return;
|
||||
|
||||
player.prestigeLevel = event.params.prestigeLevel;
|
||||
player.isActiveSession = false;
|
||||
player.save();
|
||||
|
||||
let stats = getOrCreateGlobalStats();
|
||||
stats.totalPrestigeLevels += 1;
|
||||
stats.lastUpdateTime = event.block.timestamp;
|
||||
stats.save();
|
||||
}
|
||||
|
||||
export function handleRaidPerformed(event: RaidPerformed): void {
|
||||
let player = Player.load(event.params.player.toHexString())
|
||||
if (!player) return
|
||||
let player = Player.load(event.params.player.toHexString());
|
||||
if (!player) return;
|
||||
|
||||
// Calculate new GELD minted in this raid
|
||||
let newGeldMinted = event.params.totalMinted.minus(player.totalMinted)
|
||||
let newGeldMinted = event.params.totalMinted.minus(player.totalMinted);
|
||||
|
||||
player.totalMinted = event.params.totalMinted
|
||||
player.currentBalance = event.params.geldBalance
|
||||
player.lastRaidedAt = event.block.timestamp
|
||||
player.numberOfRaids += 1
|
||||
player.save()
|
||||
player.totalMinted = event.params.totalMinted;
|
||||
player.currentBalance = event.params.geldBalance;
|
||||
player.lastRaidedAt = event.block.timestamp;
|
||||
player.numberOfRaids += 1;
|
||||
player.save();
|
||||
|
||||
let stats = getOrCreateGlobalStats()
|
||||
stats.totalGeldMinted = stats.totalGeldMinted.plus(newGeldMinted)
|
||||
stats.lastUpdateTime = event.block.timestamp
|
||||
stats.save()
|
||||
let stats = getOrCreateGlobalStats();
|
||||
stats.totalGeldMinted = stats.totalGeldMinted.plus(newGeldMinted);
|
||||
stats.lastUpdateTime = event.block.timestamp;
|
||||
stats.save();
|
||||
}
|
||||
|
||||
export function handleUnitAdded(event: UnitAdded): void {
|
||||
let army = Army.load(event.params.player.toHexString())
|
||||
if (!army) return
|
||||
let army = Army.load(event.params.player.toHexString());
|
||||
if (!army) return;
|
||||
|
||||
// Update army levels based on the event
|
||||
if (event.params.unitType == 0) {
|
||||
army.molochDenierLevel = event.params.molochDenierLevel
|
||||
army.molochDenierLevel = event.params.molochDenierLevel;
|
||||
} else if (event.params.unitType == 1) {
|
||||
army.apprenticeLevel = event.params.apprenticeLevel
|
||||
army.apprenticeLevel = event.params.apprenticeLevel;
|
||||
} else if (event.params.unitType == 2) {
|
||||
army.anointedLevel = event.params.anointedLevel
|
||||
army.anointedLevel = event.params.anointedLevel;
|
||||
} else if (event.params.unitType == 3) {
|
||||
army.championLevel = event.params.championLevel
|
||||
army.championLevel = event.params.championLevel;
|
||||
}
|
||||
|
||||
// Calculate new profit per second using exact RaidGeldUtils values
|
||||
@ -137,28 +230,29 @@ export function handleUnitAdded(event: UnitAdded): void {
|
||||
army.apprenticeLevel,
|
||||
army.anointedLevel,
|
||||
army.championLevel
|
||||
)
|
||||
);
|
||||
|
||||
army.profitPerSecond = profitPerSecond
|
||||
army.projectedDailyEarnings = calculateProjectedDailyEarnings(profitPerSecond)
|
||||
army.totalUnitsPurchased += event.params.nUnits
|
||||
army.lastUnitPurchaseTime = event.block.timestamp
|
||||
army.save()
|
||||
army.profitPerSecond = profitPerSecond;
|
||||
army.projectedDailyEarnings =
|
||||
calculateProjectedDailyEarnings(profitPerSecond);
|
||||
army.totalUnitsPurchased += event.params.nUnits;
|
||||
army.lastUnitPurchaseTime = event.block.timestamp;
|
||||
army.save();
|
||||
|
||||
// Update player's army strength and balance
|
||||
let player = Player.load(event.params.player.toHexString())
|
||||
if (!player) return
|
||||
let player = Player.load(event.params.player.toHexString());
|
||||
if (!player) return;
|
||||
|
||||
player.currentBalance = event.params.geldBalance
|
||||
player.armyStrength = calculateArmyStrength(army)
|
||||
player.save()
|
||||
player.currentBalance = event.params.geldBalance;
|
||||
player.armyStrength = calculateArmyStrength(army);
|
||||
player.save();
|
||||
|
||||
// Update global stats
|
||||
let stats = getOrCreateGlobalStats()
|
||||
stats.totalArmyUnits += event.params.nUnits
|
||||
let stats = getOrCreateGlobalStats();
|
||||
stats.totalArmyUnits += event.params.nUnits;
|
||||
if (profitPerSecond > stats.topEarnerProfit) {
|
||||
stats.topEarnerProfit = profitPerSecond
|
||||
stats.topEarnerProfit = profitPerSecond;
|
||||
}
|
||||
stats.lastUpdateTime = event.block.timestamp
|
||||
stats.save()
|
||||
stats.lastUpdateTime = event.block.timestamp;
|
||||
stats.save();
|
||||
}
|
||||
@ -19,17 +19,26 @@ dataSources:
|
||||
- Approval
|
||||
- OwnershipTransferred
|
||||
- PlayerRegistered
|
||||
- PlayerStrikesAgain
|
||||
- RaidPerformed
|
||||
- Transfer
|
||||
- UnitAdded
|
||||
- BossDefeated
|
||||
- PrestigeGained
|
||||
abis:
|
||||
- name: RaidGeld
|
||||
file: ./abis/RaidGeld.json
|
||||
eventHandlers:
|
||||
- event: PlayerRegistered(indexed address,uint256)
|
||||
handler: handlePlayerRegistered
|
||||
- event: PlayerStrikesAgain(indexed address,uint256,uint256)
|
||||
handler: handlePlayerStrikesAgain
|
||||
- event: RaidPerformed(indexed address,uint256,uint256)
|
||||
handler: handleRaidPerformed
|
||||
- event: UnitAdded(indexed address,uint8,uint16,uint256,uint256,uint16,uint16,uint16,uint16)
|
||||
handler: handleUnitAdded
|
||||
- event: BossDefeated(indexed address,uint8,uint256)
|
||||
handler: handleBossDefeated
|
||||
- event: PrestigeGained(indexed address,uint32)
|
||||
handler: handlePrestigeGained
|
||||
file: ./src/raid-geld.ts
|
||||
|
||||
Loading…
Reference in New Issue
Block a user