moonstream-to / web3

Moonstream game engine for blockchain games. Lootboxes, crafting, dropper, mini games that will enrich your game economy
20 stars 10 forks source link

`StatBlock`: An on-chain registry for token stats and ability scores #317

Closed zomglings closed 1 year ago

zomglings commented 1 year ago

The core layer of a game typically defines the various abilities (e.g. STR, DEX, CON, INT, WIS, CHA) that a character can have, and each item or attribute that a character can game through gameplay can modify its attributes in some way.

StatBlock is an on-chain registry in which:

  1. Games can define the abilities they recognize
  2. Games can assign specific values for each of those abilities to various tokens (ERC20, ERC721, or ERC1155).

This is something we have discovered a need for in the Great Wyrm universe, and we have also observed a need for these in Crypto Unicorns and Arcadians.

zomglings commented 1 year ago

StatBlock will contain a number of ability scores - 1-indexed.

It will also contain a mapping:

mapping(uint256 => mapping(address => mapping(uint256 => uint256))) stats;

stats[i][tokenAddress][tokenID] will be the value for ability i associated with the token specified by (tokenAddress, tokenID). This will support ERC20 tokens, ERC721 tokens, and ERC1155 tokens.

For ERC20 tokens, we will associate the stat with tokenID = 0.

zomglings commented 1 year ago

Only an administrator account (specified by a Terminus badge or by some other similar access control mechanism) will be able to add abilities and set ability scores for tokens.

The StatBlock is intended to serve as a public statement of the stat values that a game considers canonical. The specific means of setting these canonical stat values is a question for each individual game that uses StatBlock.