Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions packages/contracts/.NOTprettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"plugins": ["prettier-plugin-solidity"],
"printWidth": 120,
"semi": true,
"tabWidth": 2,
"useTabs": false,
"bracketSpacing": true
}
4 changes: 4 additions & 0 deletions packages/contracts/constants.sol
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,7 @@ uint256 constant CRIT_MODIFIER = 2;

//Gold Drop constants
uint256 constant BASE_GOLD_DROP = 1e15; //

// LEVELING
uint256 constant BASE_HP_GAIN = 1;
uint256 constant ABILITY_POINTS_PER_LEVEL = 2;
44 changes: 43 additions & 1 deletion packages/contracts/mud.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,13 @@ export default defineWorld({
/**
* Marks an entity as an admin. Used on address entities.
*/
Admin: "bool",
Admin: {
key: ["user"],
schema: {
user: "address",
isAdmin: "bool",
},
},
Characters: {
key: ["characterId"],
schema: {
Expand Down Expand Up @@ -180,6 +186,41 @@ export default defineWorld({
},
key: ["encounterId"],
},
ActionOutcome: {
schema: {
encounterId: "bytes32",
currentTurn: "uint256",
actionNumber: "uint256",
actionId: "bytes32",
weaponId: "uint256",
attackerId: "bytes32",
defenderId: "bytes32",
hit: "bool",
miss: "bool",
crit: "bool",
attackerDamageDelt: "int256",
defenderDamageDelt: "int256",
attackerDied: "bool",
defenderDied: "bool",
blockNumber: "uint256",
timestamp: "uint256",
},
key: ["encounterId", "currentTurn", "actionNumber"],
type: "offchainTable",
},
CombatOutcome: {
schema: {
encounterId: "bytes32",
endTime: "uint256",
expDropped: "uint256",
goldDropped: "uint256",
itemsDropped: "uint256[]",
deadAttackers: "bytes32[]",
deadDefenders: "bytes32[]",
},
key: ["encounterId"],
type: "offchainTable",
},
// when an entity starts combat it creates a "match entity" for that encounter.
//when combat ends, the encounterId is set to zero, and the damage taken subtracted from the entities hp.
MatchEntity: {
Expand All @@ -190,6 +231,7 @@ export default defineWorld({
// if the mob survives its encounter this will be set back to bytes(0)
encounterId: "bytes32",
damageTaken: "int256",
died: "bool",
},
},
RandomNumbers: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
],
"outputs": [
{
"name": "currentLevel",
"name": "currentAvailibleLevel",
"type": "uint256",
"internalType": "uint256"
}
Expand Down Expand Up @@ -307,6 +307,66 @@
],
"stateMutability": "view"
},
{
"type": "function",
"name": "levelCharacter",
"inputs": [
{
"name": "characterId",
"type": "bytes32",
"internalType": "bytes32"
},
{
"name": "desiredStats",
"type": "tuple",
"internalType": "struct StatsData",
"components": [
{
"name": "strength",
"type": "uint256",
"internalType": "uint256"
},
{
"name": "agility",
"type": "uint256",
"internalType": "uint256"
},
{
"name": "class",
"type": "uint8",
"internalType": "enum Classes"
},
{
"name": "intelligence",
"type": "uint256",
"internalType": "uint256"
},
{
"name": "baseHp",
"type": "uint256",
"internalType": "uint256"
},
{
"name": "currentHp",
"type": "int256",
"internalType": "int256"
},
{
"name": "experience",
"type": "uint256",
"internalType": "uint256"
},
{
"name": "level",
"type": "uint256",
"internalType": "uint256"
}
]
}
],
"outputs": [],
"stateMutability": "nonpayable"
},
{
"type": "function",
"name": "mintCharacter",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ declare const abi: [
],
"outputs": [
{
"name": "currentLevel",
"name": "currentAvailibleLevel",
"type": "uint256",
"internalType": "uint256"
}
Expand Down Expand Up @@ -307,6 +307,66 @@ declare const abi: [
],
"stateMutability": "view"
},
{
"type": "function",
"name": "levelCharacter",
"inputs": [
{
"name": "characterId",
"type": "bytes32",
"internalType": "bytes32"
},
{
"name": "desiredStats",
"type": "tuple",
"internalType": "struct StatsData",
"components": [
{
"name": "strength",
"type": "uint256",
"internalType": "uint256"
},
{
"name": "agility",
"type": "uint256",
"internalType": "uint256"
},
{
"name": "class",
"type": "uint8",
"internalType": "enum Classes"
},
{
"name": "intelligence",
"type": "uint256",
"internalType": "uint256"
},
{
"name": "baseHp",
"type": "uint256",
"internalType": "uint256"
},
{
"name": "currentHp",
"type": "int256",
"internalType": "int256"
},
{
"name": "experience",
"type": "uint256",
"internalType": "uint256"
},
{
"name": "level",
"type": "uint256",
"internalType": "uint256"
}
]
}
],
"outputs": [],
"stateMutability": "nonpayable"
},
{
"type": "function",
"name": "mintCharacter",
Expand Down

Large diffs are not rendered by default.

124 changes: 0 additions & 124 deletions packages/contracts/out/CombatSystem.sol/CombatSystem.abi.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,82 +6,6 @@
"outputs": [],
"stateMutability": "nonpayable"
},
{
"type": "function",
"name": "_calculatePhysicalAttack",
"inputs": [
{
"name": "attackStats",
"type": "tuple",
"internalType": "struct PhysicalAttackStats",
"components": [
{
"name": "bonusDamage",
"type": "int256",
"internalType": "int256"
},
{
"name": "armorPenetration",
"type": "int256",
"internalType": "int256"
},
{
"name": "attackModifierBonus",
"type": "int256",
"internalType": "int256"
},
{
"name": "critChanceBonus",
"type": "int256",
"internalType": "int256"
},
{
"name": "classRestrictions",
"type": "uint8[]",
"internalType": "uint8[]"
}
]
},
{
"name": "attackerId",
"type": "bytes32",
"internalType": "bytes32"
},
{
"name": "defenderId",
"type": "bytes32",
"internalType": "bytes32"
},
{
"name": "weaponId",
"type": "uint256",
"internalType": "uint256"
},
{
"name": "randomNumber",
"type": "uint256",
"internalType": "uint256"
}
],
"outputs": [
{
"name": "damage",
"type": "int256",
"internalType": "int256"
},
{
"name": "hit",
"type": "bool",
"internalType": "bool"
},
{
"name": "crit",
"type": "bool",
"internalType": "bool"
}
],
"stateMutability": "nonpayable"
},
{
"type": "function",
"name": "_msgSender",
Expand Down Expand Up @@ -121,54 +45,6 @@
],
"stateMutability": "view"
},
{
"type": "function",
"name": "calculateGoldDrop",
"inputs": [
{
"name": "mobLevel",
"type": "uint256",
"internalType": "uint256"
},
{
"name": "randomNumber",
"type": "uint256",
"internalType": "uint256"
}
],
"outputs": [
{
"name": "dropAmount",
"type": "uint256",
"internalType": "uint256"
}
],
"stateMutability": "nonpayable"
},
{
"type": "function",
"name": "calculateItemDrop",
"inputs": [
{
"name": "randomNumber",
"type": "uint256",
"internalType": "uint256"
},
{
"name": "itemId",
"type": "uint256",
"internalType": "uint256"
}
],
"outputs": [
{
"name": "",
"type": "bool",
"internalType": "bool"
}
],
"stateMutability": "nonpayable"
},
{
"type": "function",
"name": "createMatch",
Expand Down
Loading