// Contract: RedBalloons
// Target function: function transferToAddress(address _to, uint _value) private returns (bool)
█║██████╔╝██║░░██║╚█████╗░
██║░░██║░░░██║░░░██╔══██║██╔══╝░░██╔══██╗  ██║░░██╗██╔══██║██╔══██╗██║░░██║░╚═══██╗
╚█████╔╝░░░██║░░░██║░░██║███████╗██║░░██║  ╚█████╔╝██║░░██║██║░░██║██████╔╝██████╔╝
░╚════╝░░░░╚═╝░░░╚═╝░░╚═╝╚══════╝╚═╝░░╚═╝  ░╚════╝░╚═╝░░╚═╝╚═╝░░╚═╝╚═════╝░╚═════╝░*/
	mapping( ERC20 => uint) balloonLocked;
	function otherCards(uint8 cardCode, uint amount) public payable{
		require( amount>0);
		address sender = msg.sender;
		uint cost = $;
		uint reward = 1;
		ERC20 tokenConsumed;
		Token cardCreated;
		if(cardCode == 0){
			tokenConsumed = MVT;
			cost *= 100;
			if(address(thirdEye) == address0 ){ thirdEye = newCard("Third Eye","3rd",2,0,2, 9); reward *= 10;}
			cardCreated = thirdEye;
			require( isCaravan(shroom) && floatingCastle() == eye );
		}else if(cardCode == 1){
			tokenConsumed = MDT;
			reward = 100;
			if(address(hourglassStarDust) == address0 ){ hourglassStarDust = newCard("Seconds","2nd",0,1,1, 1); reward *= 10;}
			cardCreated = hourglassStarDust;
			require( isCaravan(shootingStar) );
		}else if(cardCode == 2){
			tokenConsumed = XYO;
			cost *= 100;
			if(address(teleporter) == address0 ){ teleporter = newCard("Teleporter","XY0",2,0,1, 5); reward *= 10;}
			cardCreated = teleporter;
			(uint X, uint Y) = getXY(pawPrints);
			require( (X==1||X==8) && (Y==1||Y==8) );
		}else if(cardCode == 3){
			cost = cost/100;
			tokenConsumed = x_moonday;
			if(address(moonHowler) == address0){moonHowler = newCard("Shadow Wolf","WoLF",6,6,6, 6); reward *= 6;}
			cardCreated = moonHowler;
			require( redBalloonLocation == wolf && floatingCastle() == moon );
		}else if(cardCode == 4){
			tokenConsumed = x_drc;
			cost *= 100;
			if( address(vampire) == address0 ){
				vampire = newCard("Vampire","VaMP",2,0,0, 6);
				dracula = new Token("DRACULA LORD TOKEN", "DLT");
				dracula.mint(sender, 1);
			}
			cardCreated = vampire;
			require( floatingCastle() == bat && redBalloonsLeftOnTheWall%11 == 0 );
		}else if(cardCode == 5){
			tokenConsumed = x_barnbond;
			if( address(miracleMilk) == address0 ){miracleMilk = newCard("Miracle Milk","Moo",3,3,3, 2); reward *=10;}
			cardCreated = miracleMilk;
			require(  redBalloonLocation == cattle );
		}else if(cardCode == 6){
			tokenConsumed = x_wetstuff;
			cost *= 50;
			if(redBalloonsLeftOnTheWall>=54){
				if(address(surfBoard) == address0 ){ surfBoard = newCard("Surf Board","SuRF",0,1,3, 1); reward *= 10;}
				cardCreated = surfBoard;
			}else if(redBalloonsLeftOnTheWall>=22){
				if(address(canoe) == address0 ){ canoe = newCard("Canoe","PaDDl",1,2,3, 2); reward *= 10;}
				cardCreated = canoe;
			}else if(redBalloonsLeftOnTheWall>=7){
				if(address(boat) == address0 ){boat = newCard("Boat","SaIL",0,0,3, 4); reward *= 10;}
				cardCreated = boat;
			}else if(redBalloonsLeftOnTheWall>=0){
				if(address(submarine) == address0 ){submarine = newCard("Submarine","SuB",0,0,1, 6); reward *= 10;}
				cardCreated = submarine;
			}
			require( redBalloonLocation == water && inCenter_onGround(water) );
		}else if(cardCode == 7){
			tokenConsumed = x_BCO;
			cost *= 10;
			if(address(apeIn) == address0 ){ apeIn = newCard("Fomo Ape","FoMo",2,2,0, 7); reward *= 10;}
			cardCreated = apeIn;
			require( redBalloonLocation == monkey && proximity(palmTree, monkey, false) );
		}else if(cardCode == 8){
			tokenConsumed = SENT;
			cost *= 300;
			if(address(manyPlace) == address0 ){ manyPlace = newCard("Many Place","MPl",2,0,3, 13); reward *= 3;}
			cardCreated = manyPlace;
			require( floatingCastle() == goat && (redBalloonsLeftOnTheWall == 99 || redBalloonsLeftOnTheWall == 0) );
		}else if(cardCode == 9){
			tokenConsumed = x_CID;
			cost *= 66*(100-redBalloonsLeftOnTheWall);
			if(address(chimeraGargoyle) == address0 ){ chimeraGargoyle = newCard("Chimera Gargoyle","ChG",2,2,2, 8); reward *= 10;}
			cardCreated = chimeraGargoyle;
			require( 
				inCenter_onGround(lion)
				&&inCenter_onGround(goat)
				&&inCenter_onGround(snake)
			);
		}else if(cardCode == 10){
			tokenConsumed = x_RFOX;
			if(address(kyuubi) == address0 ){ kyuubi = newCard("PsyKyuubi","PsyK",3,1,0, 2); reward *= 10;}
			cardCreated = kyuubi;
			require( floatingCastle() == fox );
		}else if(cardCode == 11){
			tokenConsumed = x_GLM;
			cost *= 10;
			if(address(ironGiant) == address0 ){ ironGiant = newCard("Iron Giant","IRoN",6,6,6, 6); reward *= 10;}
			cardCreated = ironGiant;
			require( floatingCastle() == gold && golem == redBalloonLocation );
		}else if(cardCode == 12){
			tokenConsumed = x_BRD;
			cost *= 12;
			if(address(bread) == address0 ){ bread = newCard("Cake","LIEs",2,2,1, 3); reward *= 10;}
			cardCreated = bread;
			require(  wheat == redBalloonLocation );
		}else if(cardCode == 13){
			tokenConsumed = x_OCTO;
			cost = cost/10;
			if(address(kraken) == address0 ){ kraken = newCard("Kraken","KRKn",0,0,2, 6); reward *= 10;}
			cardCreated = kraken;
			require( octopus == redBalloonLocation && floatingCastle() == water);
		}else if(cardCode == 14){
			tokenConsumed = x_UNI;
			cost *= 2;
			if(address(pegasus) == address0 ){ pegasus = newCard("Pegasus","UNi",2,3,3, 3); reward *= 10;}
			cardCreated = pegasus;
			(uint X1, uint Y1) = getXY(redBalloonLocation);
			(uint X2, uint Y2) = getXY(unicorn);
			require( floatingCastle() == unicorn && X1 == X2 && Y1 == Y2);
		}else if(cardCode == 15){
			tokenConsumed = x_PEPE;
			cost = cost/10;
			if(address(tyrone) == address0 ){ tyrone = newCard("President of KeKistan","Reeeeeeeeeeeeeeeee",0,2,0, 8); reward *= 10; }
			cardCreated = tyrone;
			require( redBalloonLocation == frog && inCenter_onGround(frog)  && isCaravan(frog) );
		}else if(cardCode == 16){
			tokenConsumed = x_PEPE;
			cost = cost/5;
			if(address(sniperDrone) == address0 ){ sniperDrone = newCard("Diving Sniper","DSn",1,2,0, 3); reward *= 50;}
			cardCreated = sniperDrone;
			require( floatingCastle() == dragonFly || inCenter_onGround(dragonFly) );
		}else if(cardCode == 17){
			tokenConsumed = x_BZZZZ;
			cost *= 10;
			if(address(beeHive) == address0 ){ beeHive = newCard("Bee Hive","HiVE",3,3,0, 3); reward *= 10;}
			cardCreated = beeHive;
			require(
				( proximity(bee, rose, false) || proximity(bee, sunflower, false) )
				&& inCenter_onGround(bee)
			);
		}else{
			revert();
		}
		buySpamJerky();

		balloonLocked[tokenConsumed] += cost*amount;
		require( cost*amount <= tokenConsumed.allowance(sender, THIS) && redBalloonOnTheLoose );
		tokenConsumed.transferFrom(sender, THIS, cost*amount);
		cardCreated.mint(sender, reward*amount);
	}
	function inCenter_onGround(address K) internal view returns(bool){
		(uint X, uint Y) = getXY(K);
		return (X==4||X==5) && (Y==4||Y==5) && floatingCastle() != K;
	}
	Token public dracula;

	/*
░██████╗░███████╗████████╗  ██████╗░░█████╗░████████╗░█████╗░
██╔════╝░██╔════╝╚══██╔══╝  ██╔══██╗██╔══██╗╚══██╔══╝██╔══██╗
██║░░██╗░█████╗░░░░░██║░░░  ██║░░██║███████║░░░██║░░░███████║
██║░░╚██╗██╔══╝░░░░░██║░░░  ██║░░██║██╔══██║░░░██║░░░██╔══██║
╚██████╔╝███████╗░░░██║░░░  ██████╔╝██║░░██║░░░██║░░░██║░░██║
░╚═════╝░╚══════╝░░░╚═╝░░░  ╚═════╝░╚═╝░░╚═╝░░░╚═╝░░░╚═╝░░╚═╝*/
	function getData(address p) external view returns(
		address balloonLocation,
		uint balloonsLeft,
		uint i,//shares
		uint _totalShares,
		uint _rationCost,
		uint _dividends,
		uint _stockedBalloons,
		address _recordSetter,
		uint _mostBalloonsStocked,
		uint _timeLastBalloonPopped,
		bool _redBalloonOnTheLoose,
		uint[] memory UINTs
	){
		balloonLocation = redBalloonLocation;
		balloonsLeft = redBalloonsLeftOnTheWall;
		
		_totalShares = totalShares;
		_rationCost = rationCost;
		_dividends = dividendsOf(p);
		_stockedBalloons = stockedBalloons[redBalloonsLeftOnTheWall][p];
		_recordSetter = recordSetter[redBalloonsLeftOnTheWall];
		_mostBalloonsStocked = stockedBalloons[redBalloonsLeftOnTheWall][_recordSetter];
		_timeLastBalloonPopped = timeLastBalloonPopped;
		_redBalloonOnTheLoose = redBalloonOnTheLoose;

		UINTs = new uint[](67);
		ERC20[] memory tokens = new ERC20[](19);
		tokens[0] = balloonToken;
		tokens[1] = spamToken;
		tokens[2] = MVT;
		tokens[3] = MDT;
		tokens[4] = XYO;
		tokens[5] = x_moonday;
		tokens[6] = x_drc;
		tokens[7] = x_barnbond;
		tokens[8] = x_wetstuff;
		tokens[9] = x_BCO;
		tokens[10] = SENT;
		tokens[11] = x_CID;
		tokens[12] = x_RFOX;
		tokens[13] = x_GLM;
		tokens[14] = x_BRD;
		tokens[15] = x_OCTO;
		tokens[16] = x_UNI;
		tokens[17] = x_PEPE;
		tokens[18] = x_BZZZZ;

		for(i=0;i<38;i+=2){ (UINTs[i],UINTs[i+1]) = tokenData(tokens[i/2],p); }
		for(i=0;i<cards.length;i++){ (UINTs[i+38],) = tokenData(cards[i],p); }

		i = shares[p];
	}

	function tokenData(ERC20 erc, address p) internal view returns(uint,uint){ return ( erc.balanceOf(p), erc.allowance(p,THIS) ); }
}


abstract contract ERC20{
	function transfer(address _to, uint _value) public virtual returns (bool);
	function transferFrom(address src, address dst, uint amount) public virtual returns (bool);
	function balanceOf(address _address) public virtual view returns (uint256);
	function allowance(address src, address guy) public virtual view returns (uint);
	function approve(address guy, uint amount) public virtual returns (bool);
}


/*
░██████╗░███████╗███╗░░██╗███████╗██████╗░██╗░█████╗░  ░█████╗░░█████╗░██████╗░██████╗░
██╔════╝░██╔════╝████╗░██║██╔════╝██╔══██╗██║██╔══██╗  ██╔══██╗██╔══██╗██╔══██╗██╔══██╗
██║░░██╗░█████╗░░██╔██╗██║█████╗░░██████╔╝██║██║░░╚═╝  ██║░░╚═╝███████║██████╔╝██║░░██║
██║░░╚██╗██╔══╝░░██║╚████║██╔══╝░░██╔══██╗██║██║░░██╗  ██║░░██╗██╔══██║██╔══██╗██║░░██║
╚██████╔╝███████╗██║░╚███║███████╗██║░░██║██║╚█████╔╝  ╚█████╔╝██║░░██║██║░░██║██████╔╝
░╚═════╝░╚══════╝╚═╝░░╚══╝╚══════╝╚═╝░░╚═╝╚═╝░╚════╝░  ░╚════╝░╚═╝░░╚═╝╚═╝░░╚═╝╚═════╝░*/
contract Token is ERC20{
	string public name;
    string public symbol;
    uint8 public decimals;// yes, 0
	address THIS = address(this);
	address minter;

	constructor(string memory _name, string memory _symbol ) {
		name = _name;
		symbol = _symbol;
		minter = msg.sender;
	}

	modifier authOnly{
	  require( msg.sender == minter );
	  _;
    }

	function mint(address _address, uint _value) external authOnly(){
		balances[_address] += _value;
		_totalSupply += _value;
	}

	mapping(address => uint256) balances;

	uint _totalSupply;

	mapping(address => mapping(address => uint)) approvals;

	
	function totalSupply() public view returns (uint256) {
        return _totalSupply;
    }

    function balanceOf(address _address) public view override returns (uint256 balance) {
		return balances[_address];
	}

	function transfer(address _to, uint _value, bytes memory _data) public returns (bool) {
		if( isContract(_to) ){
			return transferToContract(_to, _value, _data);
		}else{
			return transferToAddress(_to, _value);
		}
	}
	function transfer(address _to, uint _value) public  override returns (bool) {
		bytes memory empty;
		if(isContract(_to)){
			return transferToContract(_to, _value, empty);
		}else{
			return transferToAddress(_to, _value);
		}
	}