-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0xMousy
committed
Nov 26, 2021
1 parent
327156c
commit 9d7079a
Showing
2 changed files
with
47 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,44 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
|
||
pragma solidity ^0.8.0; | ||
|
||
import "hardhat/console.sol"; | ||
|
||
contract MyEpicGame { | ||
constructor() { | ||
console.log("THIS IS MY GAME CONTRACT. NICE."); | ||
// We'll hold our character's attributes in a struct. Feel free to add | ||
// whatever you'd like as an attribute! (ex. defense, crit chance, etc). | ||
struct CharacterAttributes { | ||
uint characterIndex; | ||
string name; | ||
string imageURI; | ||
uint hp; | ||
uint maxHp; | ||
uint attackDamage; | ||
} | ||
// A lil array to help us hold the default data for our characters. | ||
// This will be helpful when we mint new characters and need to know | ||
// things like their HP, AD, etc. | ||
CharacterAttributes[] defaultCharacters; | ||
|
||
// Data passed in to the contract when it's first created initializing the characters. | ||
// We're going to actually pass these values in from from run.js. | ||
constructor( | ||
string[] memory characterNames, | ||
string[] memory characterImageURIs, | ||
uint[] memory characterHp, | ||
uint[] memory characterAttackDmg | ||
) | ||
{ | ||
// Loop through all the characters, and save their values in our contract so | ||
// we can use them later when we mint our NFTs. | ||
for(uint i = 0; i < characterNames.length; i += 1) { | ||
defaultCharacters.push(CharacterAttributes({ | ||
characterIndex: i, | ||
name: characterNames[i], | ||
imageURI: characterImageURIs[i], | ||
hp: characterHp[i], | ||
maxHp: characterHp[i], | ||
attackDamage: characterAttackDmg[i] | ||
})); | ||
|
||
CharacterAttributes memory c = defaultCharacters[i]; | ||
console.log("Done initializing %s w/ HP %s, img %s", c.name, c.hp, c.imageURI); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters