We are initially selling our players for 0.01 ETH for the Paladins and 0.016 ETH for standard issue characters. There are 4 classes and two genders, each will come with more role-specific quests and items. Here’s how the minting process works under the hood. Each player NFT has the traditional properties of a standard erc-721 contract as well. Basically, you need a player to do anything.
Let's begin by taking a closer look at the code snippet within the '_mint' function of the 'PlayerStorageLib' contract. This function plays a vital role in creating a new player in our system and configuring their attributes.
Initialization: The code kicks off by setting up a 'PlayerStorage' struct and locating the storage space reserved for player data.
Validation: It then performs a series of checks to ensure that we stay within the system's limits. These checks include verifying that the total player count is less than 8000, ensuring the chosen player name is unique, and confirming that the selected player class falls within a valid range (0 to 2).
URI Generation: Following this, the code generates a URL for the player's profile image on IPFS. The URL is determined based on the player's chosen class. Our system provides unique placeholder images for warriors, assassins, and mages.
Player Configuration: The code proceeds to create a new 'PlayerSlotLib.Player' struct and assigns various attributes to it, such as level, experience, status, strength, health, current health, magic, mana, max mana, agility, luck, defense, name, URI, gender, and class. These attributes define the player's characteristics in the game.
Storage and Mapping: Subsequently, the code adds the newly created player to the 'players' mapping and allocates them a slot in the 'slots' mapping. It also marks the chosen player name as used in the 'usedNames' mapping and assigns the owner's address to the player. Additionally, it manages the player's balance.
Event and Completion: To notify the system of a successful player creation, the code emits a 'Mint' event. It also calls the '_safeMint' function from the 'ERC721FacetInternal' contract and finalizes the process.
This 'mint' function is a crucial part of our system, responsible for adding new players and ensuring that all the necessary data is correctly initialized.
Here’s the code for the function in the contract called claimPlayerDropPaladin(). This function is used to claim a player drop for a paladin, which is a special type of player with increased stats. The code checks that the msg.value (the amount of Ether sent with the transaction) is greater than or equal to the price of the player drop and then sends the full amount to a fee account.
The code then calls a function in the PlayerDropStorageLib library, claimPlayerDropPaladin(), which updates the claim status for the player drop and mints a new player. Finally, the code emits an event ClaimPlayer, and then mints the new player to the claimant.