contract CryptoWarriorAuction is CryptoWarriorTournament {

    // @notice The auction contract variables are defined in CryptoWarriorBase to allow
    //  us to refer to them in WarriorTokenImpl to prevent accidental transfers.
    // `saleAuction` refers to the auction for miner and p2p sale of warriors.

    /// @dev Sets the reference to the sale auction.
    /// @param _address - Address of sale contract.
    function setSaleAuctionAddress(address _address) external onlyAdmin {
        SaleClockAuction candidateContract = SaleClockAuction(_address);

        // NOTE: verify that a contract is what we expect - https://github.com/Lunyr/crowdsale-contracts/blob/cfadd15986c30521d8ba7d5b6f57b4fefcc7ac38/contracts/LunyrToken.sol#L117
        require(candidateContract.isSaleClockAuction());

        // Set the new contract address
        saleAuction = candidateContract;
    }


    /// @dev Put a warrior up for auction.
    ///  Does some ownership trickery to create auctions in one tx.
    function createSaleAuction(
        uint256 _warriorId,
        uint256 _startingPrice,
        uint256 _endingPrice,
        uint256 _duration
    )
        external
        whenNotPaused
    {
        // Auction contract checks input sizes
        // If warrior is already on any auction, this will throw
        // because it will be owned by the auction contract.
        require(_ownerApproved(msg.sender, _warriorId));
        // Ensure the warrior is not busy to prevent the auction
        // contract creation while warrior is in any kind of battle (PVE, PVP, TOURNAMENT).
        require(warriors[_warriorId].action == IDLE);
        _approve(_warriorId, address(saleAuction));
        // Sale auction throws if inputs are invalid and clears
        // transfer approval after escrowing the warrior.
        saleAuction.createAuction(
            _warriorId,
            _startingPrice,
            _endingPrice,
            _duration,
            msg.sender
        );
    }

}
function createSaleAuction(
    uint256 _warriorId,
    uint256 _startingPrice,
    uint256 _endingPrice,
    uint256 _duration
)
    external
    whenNotPaused
{
    // Auction contract checks input sizes
    // If warrior is already on any auction, this will throw
    // because it will be owned by the auction contract.
    require(_ownerApproved(msg.sender, _warriorId));
    // Ensure the warrior is not busy to prevent the auction
    // contract creation while warrior is in any kind of battle (PVE, PVP, TOURNAMENT).
    require(warriors[_warriorId].action == IDLE);
    _approve(_warriorId, address(saleAuction));
    // Sale auction throws if inputs are invalid and clears
    // transfer approval after escrowing the warrior.
    saleAuction.createAuction(
        _warriorId,
        _startingPrice,
        _endingPrice,
        _duration,
        msg.sender
    );
}

/// @dev Put a warrior up for auction.
///  Does some ownership trickery to create auctions in one tx.