contract ArtBase is ArtAccessControl {
    /*** EVENTS ***/

    /// @dev The Birth event is fired whenever a new kitten comes into existence. This obviously
    ///  includes any time a cat is created through the giveBirth method, but it is also called
    ///  when a new gen0 cat is created.
    event Create(address owner, uint256 artId, uint16 generator);

    /// @dev Transfer event as defined in current draft of ERC721. Emitted every time a kitten
    ///  ownership is assigned, including births.
    event Transfer(address from, address to, uint256 tokenId);

    event Vote(uint16 candidate, uint256 voteCount, uint16 currentGenerator, uint256 currentGeneratorVoteCount);
    event NewRecipient(address recipient, uint256 position);
    event NewGenerator(uint256 position);

    /*** DATA TYPES ***/

    /// @dev The main Art struct. Every cat in CryptoKitties is represented by a copy
    ///  of this structure, so great care was taken to ensure that it fits neatly into
    ///  exactly two 256-bit words. Note that the order of the members in this structure
    ///  is important because of the byte-packing rules used by Ethereum.
    ///  Ref: http://solidity.readthedocs.io/en/develop/miscellaneous.html
    struct ArtToken {
        // The timestamp from the block when this cat came into existence.
        uint64 birthTime;
        // The "generator" of this art token.
        uint16 generator;
    }

    /*** STORAGE ***/

    /// @dev An array containing the Art struct for all Kitties in existence. The ID
    ///  of each cat is actually an index into this array. Note that ID 0 is a negacat,
    ///  the unArt, the mythical beast that is the parent of all gen0 cats. A bizarre
    ///  creature that is both matron and sire... to itself! Has an invalid genetic code.
    ///  In other words, cat ID 0 is invalid... ;-)
    ArtToken[] artpieces;

    /// @dev A mapping from cat IDs to the address that owns them. All cats have
    ///  some valid owner address, even gen0 cats are created with a non-zero owner.
    mapping (uint256 => address) public artIndexToOwner;

    // @dev A mapping from owner address to count of tokens that address owns.
    //  Used internally inside balanceOf() to resolve ownership count.
    mapping (address => uint256) ownershipTokenCount;

    /// @dev A mapping from ArtIDs to an address that has been approved to call
    ///  transferFrom(). Each Art can only have one approved address for transfer
    ///  at any time. A zero value means no approval is outstanding.
    mapping (uint256 => address) public artIndexToApproved;


    /// @dev Assigns ownership of a specific Art to an address.
    function _transfer(address _from, address _to, uint256 _tokenId) internal {
        // Since the number of kittens is capped to 2^32 we can't overflow this
        ownershipTokenCount[_to]++;
        // transfer ownership
        artIndexToOwner[_tokenId] = _to;
        // When creating new kittens _from is 0x0, but we can't account that address.
        if (_from != address(0)) {
            ownershipTokenCount[_from]--;
            // clear any previously approved ownership exchange
            delete artIndexToApproved[_tokenId];
        }
        // Emit the transfer event.
        Transfer(_from, _to, _tokenId);
    }

    /// @dev An internal method that creates a new art and stores it. This
    ///  method doesn't do any checking and should only be called when the
    ///  input data is known to be valid. Will generate both a Birth event
    ///  and a Transfer event.
    /// @param _generator The generator number of this cat, must be computed by caller.
    /// @param _owner The inital owner of this cat, must be non-zero (except for the unArt, ID 0)
    function _createArt(
        uint256 _generator,
        address _owner
    )
        internal
        returns (uint)
    {
        // These requires are not strictly necessary, our calling code should make
        // sure that these conditions are never broken. However! _createArt() is already
        // an expensive call (for storage), and it doesn't hurt to be especially careful
        // to ensure our data structures are always valid.
        require(_generator == uint256(uint16(_generator)));

        ArtToken memory _art = ArtToken({
            birthTime: uint64(now),
            generator: uint16(_generator)
        });
        uint256 newArtId = artpieces.push(_art) - 1;

        // It's probably never going to happen, 4 billion cats is A LOT, but
        // let's just be 100% sure we never let this happen.
        require(newArtId == uint256(uint32(newArtId)));

        // emit the birth event
        Create(
            _owner,
            newArtId,
            _art.generator
        );

        // This will assign ownership, and also emit the Transfer event as
        // per ERC721 draft
        _transfer(0, _owner, newArtId);

        return newArtId;
    }

}
/// @title Base contract for CryptoKitties. Holds all common structs, events and base variables.
/// @author Axiom Zen (https://www.axiomzen.co)
/// @dev See the ArtCore contract documentation to understand how the various contract facets are arranged.
function _createArt(
        uint256 _generator,
        address _owner
    )
        internal
        returns (uint)
    {
        // These requires are not strictly necessary, our calling code should make
        // sure that these conditions are never broken. However! _createArt() is already
        // an expensive call (for storage), and it doesn't hurt to be especially careful
        // to ensure our data structures are always valid.
        require(_generator == uint256(uint16(_generator)));

        ArtToken memory _art = ArtToken({
            birthTime: uint64(now),
            generator: uint16(_generator)
        });
        uint256 newArtId = artpieces.push(_art) - 1;

        // It's probably never going to happen, 4 billion cats is A LOT, but
        // let's just be 100% sure we never let this happen.
        require(newArtId == uint256(uint32(newArtId)));

        // emit the birth event
        Create(
            _owner,
            newArtId,
            _art.generator
        );

        // This will assign ownership, and also emit the Transfer event as
        // per ERC721 draft
        _transfer(0, _owner, newArtId);

        return newArtId;
    }
/// @dev An internal method that creates a new art and stores it. This
///  method doesn't do any checking and should only be called when the
///  input data is known to be valid. Will generate both a Birth event
///  and a Transfer event.
/// @param _generator The generator number of this cat, must be computed by caller.
/// @param _owner The inital owner of this cat, must be non-zero (except for the unArt, ID 0)