contract ChainMonstersAuction is MonsterOwnership {
    bool lockedMonsterAuction = false;

    function setMonsterAuctionAddress(address _address) external onlyAdmin {
        require(!lockedMonsterAuction);
        MonsterAuction candidateContract = MonsterAuction(_address);

        require(candidateContract.isMonsterAuction());

        monsterAuction = candidateContract;
        lockedMonsterAuction = true;
    }

    uint256 public constant PROMO_CREATION_LIMIT = 5000;
    uint256 public constant GEN0_CREATION_LIMIT = 5000;

    // Counts the number of monster the contract owner has created.
    uint256 public promoCreatedCount;
    uint256 public gen0CreatedCount;

    // its stats are completely dependent on the spawn alghorithm
    function createPromoMonster(uint256 _mId, address _owner) external onlyAdmin {
        // during generation we have to keep in mind that we have only 10,000 tokens available
        // which have to be divided by 151 monsters, some rarer than others
        // see WhitePaper for gen0/promo monster plan
        
        // sanity check that this monster ID is actually in game yet
        require(monsterCreator.baseStats(_mId, 1) > 0);
        
        require(promoCreatedCount < PROMO_CREATION_LIMIT);

        promoCreatedCount++;

        uint8[7] memory ivs = uint8[7](monsterCreator.getGen0IVs());

        bool gender = monsterCreator.getMonsterGender();
        
        bool shiny = false;
        if (ivs[6] == 1) {
            shiny = true;
        }
        uint256 monsterId = _createMonster(0, _owner, _mId, true, gender, shiny);
        monsterIdToTradeable[monsterId] = true;

        monsterIdToIVs[monsterId] = ivs;
    }

    function createGen0Auction(uint256 _mId, uint256 price) external onlyAdmin {
         // sanity check that this monster ID is actually in game yet
        require(monsterCreator.baseStats(_mId, 1) > 0);
        
        require(gen0CreatedCount < GEN0_CREATION_LIMIT);

        uint8[7] memory ivs = uint8[7](monsterCreator.getGen0IVs());

        bool gender = monsterCreator.getMonsterGender();
        
        bool shiny = false;
        if (ivs[6] == 1) {
            shiny = true;
        }
        
        uint256 monsterId = _createMonster(0, this, _mId, true, gender, shiny);
        monsterIdToTradeable[monsterId] = true;

        _approve(monsterId, monsterAuction);

        monsterIdToIVs[monsterId] = ivs;

        monsterAuction.createAuction(monsterId, price, address(this));

        gen0CreatedCount++;
    }
}
function createPromoMonster(uint256 _mId, address _owner) external onlyAdmin {
    // during generation we have to keep in mind that we have only 10,000 tokens available
    // which have to be divided by 151 monsters, some rarer than others
    // see WhitePaper for gen0/promo monster plan
        
    // sanity check that this monster ID is actually in game yet
    require(monsterCreator.baseStats(_mId, 1) > 0);
        
    require(promoCreatedCount < PROMO_CREATION_LIMIT);

    promoCreatedCount++;

    uint8[7] memory ivs = uint8[7](monsterCreator.getGen0IVs());

    bool gender = monsterCreator.getMonsterGender();
        
    bool shiny = false;
    if (ivs[6] == 1) {
        shiny = true;
    }
    uint256 monsterId = _createMonster(0, _owner, _mId, true, gender, shiny);
    monsterIdToTradeable[monsterId] = true;

    monsterIdToIVs[monsterId] = ivs;
}

// its stats are completely dependent on the spawn alghorithm