diff --git a/PokemonFactory.sol b/PokemonFactory.sol index ecfeeee4..6264bf0f 100644 --- a/PokemonFactory.sol +++ b/PokemonFactory.sol @@ -22,19 +22,26 @@ contract PokemonFactory { event eventNewPokemon (Pokemon pokemon); - function createPokemon (string memory _name, uint _id, Ability[] memory _abilities) public { - require(_id > 0, "Pokemon's id should be greater than 0"); - require(bytes(_name).length > 2, "Pokemon's name should have more that two characters."); - Pokemon storage pokemon = pokemons.push(); - pokemon.id = _id; - pokemon.name = _name; - for (uint i = 0; i < _abilities.length; i++) { - pokemon.abilities.push(_abilities[i]); + function createPokemon (string memory _name, uint _id) public { + require(_id > 0, "Pokemon's id should be greater than 0"); + require(bytes(_name).length > 2, "Pokemon's name should have more that two characters."); + Pokemon storage pokemon = pokemons.push(); + pokemon.id = _id; + pokemon.name = _name; + pokemonToOwner[_id] = msg.sender; + ownerPokemonCount[msg.sender]++; + emit eventNewPokemon (pokemon); + } + + function addAbilitiesToPokemon(uint _idPokemon, Ability[] memory _abilities) public { + for (uint256 i; i