// Contract: RedBalloons
// Target function: function releaseBalloon() public
 ERC20(0x11ffC453B47a13037BaBe3227c80D25D9eC129F9);//0xc483ad6f9b80b38691e95b708de1d46721366ce3
	*/


	address THIS = address(this);
	address address0 = address(0);
	address payable Haley;

	uint genesis;
	uint timeLastBalloonPopped;
	uint totalEthContributed;

	address feather;
	address cattle;
	address panda;
	address penguin;
	address gold;
	address water;
	address fox;
	address bat;
	address wheat;
	address skull;
	address shootingStar;
	address deer;
	address crane;
	address wolf;
	address moon;
	address bee;
	address monkey;
	address eye;
	address golem;
	address pawPrints;
	address goat;
	address lion;
	address unicorn;
	address octopus;
	address frog;
	address forest;
	address snake;
	address spider;
	address rose;
	address sunflower;
	address palmTree;
	address dragonFly;
	address shroom;

	uint redBalloonsLeftOnTheWall = 99;
	bool redBalloonOnTheLoose;
	address redBalloonLocation;

	mapping(address => uint8) token_R;
	mapping(address => uint8) token_G;
	mapping(address => uint8) token_B;
	mapping(address => uint) token_Color;
	
	address balloonGiver;
	uint rationCost = 0.0002 ether;
	
	Token spamJerky;
	Token R99;

	mapping( address => bool) ofBalloons;


	function ofBalloon(address addr) internal view returns(bool){
		return ofBalloons[addr];
	}

	function ofRug(address addr) public view returns(bool){
		return ofBalloon(addr) || lamp.ofRug(addr);
	}

	function tokenRGB(address token) public view returns(uint R,uint G,uint B, uint C){
		if( ofBalloon(token) || token == address(spamJerky) )
			return (token_R[token], token_G[token], token_B[token], token_Color[token]);
		else if( lamp.ofRug(token) ){
			( R, G, B ) = RugToken(token)._RGB();
			return ( R,G,B , 1 );
		}
		revert();
	}

	constructor(){
		//literally a test to prove this latest modification works
		spamJerky = newCard("Spam Jerky", "SpJ", 2, 1, 1, 5);
		R99 = newCard("Red Balloon", "R99", 3, 0, 0, 99);// this should be pretty fucking high forever

		feather= 0xaD288361179bF882999eCc21C67f0A378e59cdBe;
		cattle= 0x58D07E94e042907b73f73d40943f7800fAa72Be7;
		panda= 0xEB8016B75296f6813d6b19214D5242e502bAA77a;
		penguin= 0x9A813eEA1Ff09886822B82C50C69166e0ABA3eA8;
		gold= 0x6C2206803D7b391680115AC58300a7E8A4BF3A86;
		water= 0x3552F79387a2Bf7CF523EB17754557C00fFdeBd4;
		fox= 0x3552F79387a2Bf7CF523EB17754557C00fFdeBd4;
		bat= 0xa21dCf1d1Af5B90Ba595Ac1A75fef02BA0B50783;
		wheat= 0x8CbEbb53B8a055aCdAA8Cf5926A1a49943b6886C;
		skull= 0x1d62238AA18a06dc81825cA3D587F63dE25Ad64E;
		shootingStar= 0xe96E4fAf6471e0c81FD50272B78Cf38ee23B408d;
		deer= 0x7B6f4f87C3a26a9aEf7783376270baff6b862cAB;
		crane= 0xF272bD18A29F2D443Ad0691a92dF33D677caDE05;
		wolf= 0x9277d525296ee2F97B0d0542EC8CB897f13aCA67;
		moon= 0x1aBB66426ee9A3540B1218E1013c3505465074A1;
		bee= 0x4c2F0aD9848cADc43542A0d3Cfca5C6614389529;
		monkey= 0x8C55726D2930f1f9CD852304fA034598FD583363;
		eye= 0xf1858E92c8e85EB4C2a47FccA4f5544669703669;
		golem= 0x852c23ec1dD46119c66E00Ab9177bd3856957462;
		pawPrints= 0xe9f7894459f8dBfE561180C59f1D5296da87F50d;
		goat= 0xA86de0151cC62A93de3EA437Af2ED518720974df;
		lion= 0x001db9B1C90fd9f980771d55b2B9Ac5fD17d76Cc;
		unicorn= 0x96A3fC06Bb4A754e8029e1F302F2c7BB2c75A30d;
		octopus= 0xfd7360c316c997962b2a054cE62502a1cB94E433;
		frog= 0x4c5b1A5c0e3837b76B0f9023360008aF6F6486D5;
		forest= 0xEDf5f8324F3fa8476c2f3b70476ACf2362288E03;
		snake= 0xE297b0fb3aF82D7a57dFd3901a3F31fe077f6dD3;
		spider= 0x8DCA2943C3029A534f0adC0110d9ae03d6A4ba34;
		rose= 0x89d82551aB98Edce5B0f2bd186c9F777aa44dC00;
		sunflower= 0x9855038469cb77E96412e95078bd116247114ace;
		palmTree= 0x54bFd5EcF6a6dF7fE51f4dFAeA603029A168289b;
		dragonFly= 0xA57550bef190c0db3E03922e4aFb156B27e76d95;
		shroom= 0xfb762d7ae46803C91e0db759e417d57Bf2726362;

		redBalloonLocation = panda;

		Haley = msg.sender;
		balloonGiver = Haley;
		genesis = block.timestamp;
		timeLastBalloonPopped = block.timestamp;

		moreShares(Haley, 1e18);//just so we can kick things off without having to wait.
	}

	Token snowman;
	Token jack_o_lantern;
	Token blackSwan;
	Token haleysArrow;
	Token moonHowler;
	Token vampire;
	Token miracleMilk;
	Token beeHive;
	Token surfBoard;
	Token canoe;
	Token boat;
	Token submarine;
	Token apeIn;
	Token teleporter;
	Token thirdEye;
	Token hourglassStarDust;
	Token manyPlace;
	Token chimeraGargoyle;
	Token kyuubi;
	Token ironGiant;
	Token bread;
	Token kraken;
	Token pegasus;
	Token tyrone;
	Token honey;
	Token sniperDrone;
	Token[] cards;

	function newCard(string memory name, string memory symbol, uint8 R, uint8 G, uint8 B, uint C) internal returns(Token){
		Token newToken = new Token(name, symbol);
		address rBT = address(newToken);
		ofBalloons[rBT] = true;
		token_R[rBT] = R;
		token_G[rBT] = G;
		token_B[rBT] = B;
		token_Color[rBT] = C; 
		cards.push(newToken);
		return newToken;
	}

/*
██████╗░░█████╗░░██████╗██╗░█████╗░░██████╗
██╔══██╗██╔══██╗██╔════╝██║██╔══██╗██╔════╝
██████╦╝███████║╚█████╗░██║██║░░╚═╝╚█████╗░
██╔══██╗██╔══██║░╚═══██╗██║██║░░██╗░╚═══██╗
██████╦╝██║░░██║██████╔╝██║╚█████╔╝██████╔╝
╚═════╝░╚═╝░░╚═╝╚═════╝░╚═╝░╚════╝░╚═════╝░
*/


	function floatingCastle() public view returns(address _floatingCastle){
		(,,,,,,_floatingCastle,) = lamp.XY(address0);
	}
	function isCaravan(address kingdom) public view returns(bool IS){
		(,,,,,,,IS) = lamp.XY(kingdom);
	}

/*
░██████╗░███████╗████████╗  ██╗░░██╗██╗░░░██╗
██╔════╝░██╔════╝╚══██╔══╝  ╚██╗██╔╝╚██╗░██╔╝
██║░░██╗░█████╗░░░░░██║░░░  ░╚███╔╝░░╚████╔╝░
██║░░╚██╗██╔══╝░░░░░██║░░░  ░██╔██╗░░░╚██╔╝░░
╚██████╔╝███████╗░░░██║░░░  ██╔╝╚██╗░░░██║░░░
░╚═════╝░╚══════╝░░░╚═╝░░░  ╚═╝░░╚═╝░░░╚═╝░░░
*/

	function getXY(address kingdom) public view returns(uint X, uint Y){
		(X,Y,,,,,,) = lamp.XY(kingdom);
	}


/*
██████╗░██████╗░░█████╗░██╗░░██╗██╗███╗░░░███╗██╗████████╗██╗░░░██╗
██╔══██╗██╔══██╗██╔══██╗╚██╗██╔╝██║████╗░████║██║╚══██╔══╝╚██╗░██╔╝
██████╔╝██████╔╝██║░░██║░╚███╔╝░██║██╔████╔██║██║░░░██║░░░░╚████╔╝░
██╔═══╝░██╔══██╗██║░░██║░██╔██╗░██║██║╚██╔╝██║██║░░░██║░░░░░╚██╔╝░░
██║░░░░░██║░░██║╚█████╔╝██╔╝╚██╗██║██║░╚═╝░██║██║░░░██║░░░░░░██║░░░
╚═╝░░░░░╚═╝░░╚═╝░╚════╝░╚═╝░░╚═╝╚═╝╚═╝░░░░░╚═╝╚═╝░░░╚═╝░░░░░░╚═╝░░░*/
	function proximity(address one, address two, bool _4_8) public view returns(bool){
		(uint x1, uint y1) = getXY(one);
		(uint x2, uint y2) = getXY(two);
		
		uint distance = (x1<x2?(x2-x1):(x1-x2)) + (y1<y2?(y2-y1):(y1-y2));
		address _floatingCastle = floatingCastle();
		return ( (distance == 1) || ( _4_8 && (distance == 2 && x1 != x2 && y1 !=y2) )  ) && one != _floatingCastle && two != _floatingCastle;
	}

	/*
	Freeze Spam
	for Shares on PiZZa dividends that come from whatever valid kingdom the balloon is floating over
	balloon giver gets 5%
	dev gets 5%
	

	Give a fraction of spam to those who buy Rations
	The % of new eth compared to input eth. (yes, it becomes increasingly difficult to get 100% of spam.)


	the buyer that causes the kingdom to become the floating kingdom pops the balloon.
	or the buyer that buys while the kingdom with the balloon is floating
	*/

/*
░██████╗████████╗░█████╗░░█████╗░██╗░░██╗  ██████╗░░█████╗░██╗░░░░░██╗░░░░░░█████╗░░█████╗░███╗░░██╗
██╔════╝╚══██╔══╝██╔══██╗██╔══██╗██║░██╔╝  ██╔══██╗██╔══██╗██║░░░░░██║░░░░░██╔══██╗██╔══██╗████╗░██║
╚█████╗░░░░██║░░░██║░░██║██║░░╚═╝█████═╝░  ██████╦╝███████║██║░░░░░██║░░░░░██║░░██║██║░░██║██╔██╗██║
░╚═══██╗░░░██║░░░██║░░██║██║░░██╗██╔═██╗░  ██╔══██╗██╔══██║██║░░░░░██║░░░░░██║░░██║██║░░██║██║╚████║
██████╔╝░░░██║░░░╚█████╔╝╚█████╔╝██║░╚██╗  ██████╦╝██║░░██║███████╗███████╗╚█████╔╝╚█████╔╝██║░╚███║
╚═════╝░░░░╚═╝░░░░╚════╝░░╚════╝░╚═╝░░╚═╝  ╚═════╝░╚═╝░░╚═╝╚══════╝╚══════╝░╚════╝░░╚════╝░╚═╝░░╚══╝*/
	mapping( uint => mapping(address=>uint) ) stockedBalloons;
	mapping( uint => address ) recordSetter;
	function stockBalloonToken(uint amount) public{
		
		address sender = msg.sender;
		require( 0<amount && PiZZa.balanceOf(sender) >= 10e18 );
		balloonToken.transferFrom(sender, THIS, amount);
		stockedBalloons[redBalloonsLeftOnTheWall][sender] += amount;
		uint newCount = stockedBalloons[redBalloonsLeftOnTheWall][sender];
		
		moreShares(sender, amount*9/10);
		moreShares(/*for the current balloon giver*/balloonGiver, amount/20);
		moreShares(/* operational */ Haley, amount/20);

		if( stockedBalloons[redBalloonsLeftOnTheWall][ recordSetter[redBalloonsLeftOnTheWall] ] < newCount ){
			recordSetter[redBalloonsLeftOnTheWall] = sender;
		}
	}