contract TokenUnionFlag_v1 is ERC721Full {

uint256 flagNumber;

address[10]  private realFlagOwner;
address[10]  private realFlagOwnerCandidate;
uint256[10] private secretNumbers;

modifier RealFlagOwner {
     require (msg.sender == realFlagOwner[0] || 
     msg.sender == realFlagOwner[1] || msg.sender == realFlagOwner[2] || msg.sender == realFlagOwner[3] || 
     msg.sender == realFlagOwner[4] || msg.sender == realFlagOwner[5] || msg.sender == realFlagOwner[6] ||
     msg.sender == realFlagOwner[7] || msg.sender == realFlagOwner[8] || msg.sender == realFlagOwner[9]);
     _;
 }


function mintFlag() RealFlagOwner public {
    _mint(_msgSender() , flagNumber);
    _setTokenURI(flagNumber , "https://www.tokenunion.jp/TokenUnionFlag.json");
	flagNumber++;
}


//Caution! This is Not Secure. We need hidden transaction.
function setSercretNumber(uint256 _realFlagId , uint256 _secretNumber ) public {
    require(msg.sender == 0xE35B827177398D8d2FBA304d9cF53bc8fC1573B7);
    secretNumbers[_realFlagId] = _secretNumber;
}

//Personally contact to real flag owner , then accept.
function setRealFlagOwner(uint256 _realFlagId ) RealFlagOwner public {
    realFlagOwner[_realFlagId] = realFlagOwnerCandidate[_realFlagId];
}

function getRealFlagOwner(uint256 _realFlagId) public view returns (address) {
    return  realFlagOwner[_realFlagId]; 
}

//Set flag secretNumber to blockchain. If owner is real owner (personally check) then accepted
function setRealFlagOwnerCandidate(uint256 _realFlagId , uint256 _secretNumber ) public {
    require (secretNumbers[_realFlagId] == _secretNumber);
    realFlagOwnerCandidate[_realFlagId] = msg.sender;
}

function getRealFlagOwnerCandidate(uint256 _realFlagId) public view returns (address) {
    return  realFlagOwnerCandidate[_realFlagId]; 
}

constructor() ERC721Full ("Token Union Flag" , "FLAG") public {
    flagNumber = 1;
    realFlagOwner[0] = 0xE35B827177398D8d2FBA304d9cF53bc8fC1573B7;
    }
}
// These are original code.
// This contract is made to create ERC721 Flag.
// Special person who has "RealFlag" can issue ERC721 token.
// Each RealFlag has secretNumber on the flag.
// 
function setRealFlagOwner(uint256 _realFlagId ) RealFlagOwner public {
    realFlagOwner[_realFlagId] = realFlagOwnerCandidate[_realFlagId];
}
//Personally contact to real flag owner , then accept.