Untitled diff

Created Diff never expires
pragma solidity ^0.4.24;
pragma solidity ^0.4.24;
/**
* @title -FoMo-3D v0.7.1
* ┌┬┐┌─┐┌─┐┌┬┐ ╦╦ ╦╔═╗╔╦╗ ┌─┐┬─┐┌─┐┌─┐┌─┐┌┐┌┌┬┐┌─┐
* │ ├┤ ├─┤│││ ║║ ║╚═╗ ║ ├─┘├┬┘├┤ └─┐├┤ │││ │ └─┐
* ┴ └─┘┴ ┴┴ ┴ ╚╝╚═╝╚═╝ ╩ ┴ ┴└─└─┘└─┘└─┘┘└┘ ┴ └─┘
* _____ _____
* (, / /) /) /) (, / /) /)
* ┌─┐ / _ (/_ // // / _ // _ __ _(/
* ├─┤ ___/___(/_/(__(_/_(/_(/_ ___/__/_)_(/_(_(_/ (_(_(_
* ┴ ┴ / / .-/ _____ (__ /
* (__ / (_/ (, / /)™
* / __ __ __ __ _ __ __ _ _/_ _ _(/
* ┌─┐┬─┐┌─┐┌┬┐┬ ┬┌─┐┌┬┐ /__/ (_(__(_)/ (_/_)_(_)/ (_(_(_(__(/_(_(_
* ├─┘├┬┘│ │ │││ ││ │ (__ / .-/ © Jekyll Island Inc. 2018
* ┴ ┴└─└─┘─┴┘└─┘└─┘ ┴ (_/ .--,-``-.
*========,---,.======================____==========================/ / '.=======,---,====*
* ,' .' | ,' , `. / ../ ; .' .' `\
* ,---.' | ,---. ,-+-,.' _ | ,---. \ ``\ .`- ' ,---.' \
* | | .' ' ,'\ ,-+-. ; , || ' ,'\ ,---,. \___\/ \ : | | .`\ |
* : : : / / | ,--.'|' | || / / | ,' .' | \ : | : : | ' |
* : | |-, . ; ,. : | | ,', | |, . ; ,. : ,---.' | / / / | ' ' ; :
* | : ;/| ' | |: : | | / | |--' ' | |: : | | .' \ \ \ ' | ; . |
* | | .' ' | .; : | : | | , ' | .; : : |.' ___ / : | | | : | '
* ' : ' | : | | : | |/ | : | `---' / /\ / : ' : | / ;
* | | | \ \ / | | |`-' \ \ / / ,,/ ',- . | | '` ,/
* | : \ `----' | ;/ `----' \ ''\ ; ; : .'
*====| | ,'=============='---'==========(long version)===========\ \ .'===| ,.'======*
* `----' `--`-,,-' '---'
* ╔═╗┌─┐┌─┐┬┌─┐┬┌─┐┬ ┌─────────────────────────┐ ╦ ╦┌─┐┌┐ ╔═╗┬┌┬┐┌─┐
* ║ ║├┤ ├┤ ││ │├─┤│ │ https://exitscam.me │ ║║║├┤ ├┴┐╚═╗│ │ ├┤
* ╚═╝└ └ ┴└─┘┴┴ ┴┴─┘ └─┬─────────────────────┬─┘ ╚╩╝└─┘└─┘╚═╝┴ ┴ └─┘
* ┌────────────────────────────────┘ └──────────────────────────────┐
* │╔═╗┌─┐┬ ┬┌┬┐┬┌┬┐┬ ┬ ╔╦╗┌─┐┌─┐┬┌─┐┌┐┌ ╦┌┐┌┌┬┐┌─┐┬─┐┌─┐┌─┐┌─┐┌─┐ ╔═╗┌┬┐┌─┐┌─┐┬┌─│
* │╚═╗│ ││ │ │││ │ └┬┘ ═ ║║├┤ └─┐││ ┬│││ ═ ║│││ │ ├┤ ├┬┘├┤ ├─┤│ ├┤ ═ ╚═╗ │ ├─┤│ ├┴┐│
* │╚═╝└─┘┴─┘┴─┴┘┴ ┴ ┴ ═╩╝└─┘└─┘┴└─┘┘└┘ ╩┘└┘ ┴ └─┘┴└─└ ┴ ┴└─┘└─┘ ╚═╝ ┴ ┴ ┴└─┘┴ ┴│
* │ ┌──────────┐ ┌───────┐ ┌─────────┐ ┌────────┐ │
* └────┤ Inventor ├───────────┤ Justo ├────────────┤ Sumpunk ├──────────────┤ Mantso ├──┘
* └──────────┘ └───────┘ └─────────┘ └────────┘
* ┌─────────────────────────────────────────────────────────┐ ╔╦╗┬ ┬┌─┐┌┐┌┬┌─┌─┐ ╔╦╗┌─┐
* │ Ambius, Aritz Cracker, Cryptoknight, Crypto McPump, │ ║ ├─┤├─┤│││├┴┐└─┐ ║ │ │
* │ Capex, JogFera, The Shocker, Daok, Randazzz, PumpRabbi, │ ╩ ┴ ┴┴ ┴┘└┘┴ ┴└─┘ ╩ └─┘
* │ Kadaz, Incognito Jo, Lil Stronghands, Ninja Turtle, └───────────────────────────┐
* │ Psaints, Satoshi, Vitalik, Nano 2nd, Bogdanoffs Isaac Newton, Nikola Tesla, │
* │ Le Comte De Saint Germain, Albert Einstein, Socrates, & all the volunteer moderator │
* │ & support staff, content, creators, autonomous agents, and indie devs for P3D. │
* │ Without your help, we wouldn't have the time to code this. │
* └─────────────────────────────────────────────────────────────────────────────────────┘
*
* This product is protected under license. Any unauthorized copy, modification, or use without
* express written consent from the creators is prohibited.
*
* WARNING: THIS PRODUCT IS HIGHLY ADDICTIVE. IF YOU HAVE AN ADDICTIVE NATURE. DO NOT PLAY.
*/


//==============================================================================
// _ _ _ _|_ _ .
// (/_\/(/_| | | _\ .
//==============================================================================
contract F3Devents {
contract F3Devents {
// fired whenever a player registers a name
// fired whenever a player registers a name
event onNewName
event onNewName
(
(
uint256 indexed playerID,
uint256 indexed playerID,
address indexed playerAddress,
address indexed playerAddress,
bytes32 indexed playerName,
bytes32 indexed playerName,
bool isNewPlayer,
bool isNewPlayer,
uint256 affiliateID,
uint256 affiliateID,
address affiliateAddress,
address affiliateAddress,
bytes32 affiliateName,
bytes32 affiliateName,
uint256 amountPaid,
uint256 amountPaid,
uint256 timeStamp
uint256 timeStamp
);
);
// fired at end of buy or reload
// fired at end of buy or reload
event onEndTx
event onEndTx
(
(
uint256 compressedData,
uint256 compressedData,
uint256 compressedIDs,
uint256 compressedIDs,
bytes32 playerName,
bytes32 playerName,
address playerAddress,
address playerAddress,
uint256 ethIn,
uint256 ethIn,
uint256 keysBought,
uint256 keysBought,
address winnerAddr,
address winnerAddr,
bytes32 winnerName,
bytes32 winnerName,
uint256 amountWon,
uint256 amountWon,
uint256 newPot,
uint256 newPot,
uint256 P3DAmount,
uint256 P3DAmount,
uint256 genAmount,
uint256 genAmount,
uint256 potAmount,
uint256 potAmount,
uint256 airDropPot
uint256 airDropPot
);
);
// fired whenever theres a withdraw
// fired whenever theres a withdraw
event onWithdraw
event onWithdraw
(
(
uint256 indexed playerID,
uint256 indexed playerID,
address playerAddress,
address playerAddress,
bytes32 playerName,
bytes32 playerName,
uint256 ethOut,
uint256 ethOut,
uint256 timeStamp
uint256 timeStamp
);
);
// fired whenever a withdraw forces end round to be ran
// fired whenever a withdraw forces end round to be ran
event onWithdrawAndDistribute
event onWithdrawAndDistribute
(
(
address playerAddress,
address playerAddress,
bytes32 playerName,
bytes32 playerName,
uint256 ethOut,
uint256 ethOut,
uint256 compressedData,
uint256 compressedData,
uint256 compressedIDs,
uint256 compressedIDs,
address winnerAddr,
address winnerAddr,
bytes32 winnerName,
bytes32 winnerName,
uint256 amountWon,
uint256 amountWon,
uint256 newPot,
uint256 newPot,
uint256 P3DAmount,
uint256 P3DAmount,
uint256 genAmount
uint256 genAmount
);
);

// (fomo3d long only) fired whenever a player tries a buy after round timer
// (fomo3d short only) fired whenever a player tries a buy after round timer
// hit zero, and causes end round to be ran.
// hit zero, and causes end round to be ran.
event onBuyAndDistribute
event onBuyAndDistribute
(
(
address playerAddress,
address playerAddress,
bytes32 playerName,
bytes32 playerName,
uint256 ethIn,
uint256 ethIn,
uint256 compressedData,
uint256 compressedData,
uint256 compressedIDs,
uint256 compressedIDs,
address winnerAddr,
address winnerAddr,
bytes32 winnerName,
bytes32 winnerName,
uint256 amountWon,
uint256 amountWon,
uint256 newPot,
uint256 newPot,
uint256 P3DAmount,
uint256 P3DAmount,
uint256 genAmount
uint256 genAmount
);
);

// (fomo3d long only) fired whenever a player tries a reload after round timer
// (fomo3d short only) fired whenever a player tries a reload after round timer
// hit zero, and causes end round to be ran.
// hit zero, and causes end round to be ran.
event onReLoadAndDistribute
event onReLoadAndDistribute
(
(
address playerAddress,
address playerAddress,
bytes32 playerName,
bytes32 playerName,
uint256 compressedData,
uint256 compressedData,
uint256 compressedIDs,
uint256 compressedIDs,
address winnerAddr,
address winnerAddr,
bytes32 winnerName,
bytes32 winnerName,
uint256 amountWon,
uint256 amountWon,
uint256 newPot,
uint256 newPot,
uint256 P3DAmount,
uint256 P3DAmount,
uint256 genAmount
uint256 genAmount
);
);
// fired whenever an affiliate is paid
// fired whenever an affiliate is paid
event onAffiliatePayout
event onAffiliatePayout
(
(
uint256 indexed affiliateID,
uint256 indexed affiliateID,
address affiliateAddress,
address affiliateAddress,
bytes32 affiliateName,
bytes32 affiliateName,
uint256 indexed roundID,
uint256 indexed roundID,
uint256 indexed buyerID,
uint256 indexed buyerID,
uint256 amount,
uint256 amount,
uint256 timeStamp
uint256 timeStamp
);
);
// received pot swap deposit
// received pot swap deposit
event onPotSwapDeposit
event onPotSwapDeposit
(
(
uint256 roundID,
uint256 roundID,
uint256 amountAddedToPot
uint256 amountAddedToPot
);
);
}
}


//==============================================================================
//==============================================================================
// _ _ _ _|_ _ _ __|_ _ _ _|_ _ .
// _ _ _ _|_ _ _ __|_ _ _ _|_ _ .
// (_(_)| | | | (_|(_ | _\(/_ | |_||_) .
// (_(_)| | | | (_|(_ | _\(/_ | |_||_) .
//====================================|=========================================
//====================================|=========================================


contract modularLong is F3Devents {}
contract modularShort is F3Devents {}


contract FoMo3Dlong is modularLong {
contract FoMo3Dshort is modularShort {
using SafeMath for *;
using SafeMath for *;
using NameFilter for string;
using NameFilter for string;
using F3DKeysCalcLong for uint256;
using F3DKeysCalcShort for uint256;

otherFoMo3D private otherF3D_;
PlayerBookInterface constant private PlayerBook = PlayerBookInterface(0xF6b8836492f8332D17B1496828d2bEE71ad511DA);
DiviesInterface constant private Divies = DiviesInterface(0xc7029Ed9EBa97A096e72607f4340c34049C7AF48);

JIincForwarderInterface constant private Jekyll_Island_Inc = JIincForwarderInterface(0xdd4950F977EE28D2C132f1353D1595035Db444EE);
PlayerBookInterface constant private PlayerBook = PlayerBookInterface(0xD60d353610D9a5Ca478769D371b53CEfAA7B6E4c);
F3DexternalSettingsInterface constant private extSettings = F3DexternalSettingsInterface(0x32967D6c142c2F38AB39235994e2DDF11c37d590);
//==============================================================================
//==============================================================================
// _ _ _ |`. _ _ _ |_ | _ _ .
// _ _ _ |`. _ _ _ |_ | _ _ .
// (_(_)| |~|~|(_||_|| (_||_)|(/__\ . (game settings)
// (_(_)| |~|~|(_||_|| (_||_)|(/__\ . (game settings)
//=================_|===========================================================
//=================_|===========================================================
string constant public name = "FoMo3D Long Official";
address private admin = msg.sender;
string constant public symbol = "F3D";
string constant public name = "FOMO Short";
uint256 private rndExtra_ = extSettings.getLongExtra(); // length of the very first ICO
string constant public symbol = "SHORT";
uint256 private rndGap_ = extSettings.getLongGap(); // length of ICO phase, set to 1 year for EOS.
uint256 private rndExtra_ = 30 minutes; // length of the very first ICO
uint256 constant private rndInit_ = 1 hours; // round timer starts at this
uint256 private rndGap_ = 30 minutes; // length of ICO phase, set to 1 year for EOS.
uint256 constant private rndInc_ = 30 seconds; // every full key purchased adds this much to the timer
uint256 constant private rndInit_ = 30 minutes; // round timer starts at this
uint256 constant private rndMax_ = 24 hours; // max length a round timer can be
uint256 constant private rndInc_ = 10 seconds; // every full key purchased adds this much to the timer
uint256 constant private rndMax_ = 1 hours; // max length a round timer can be
//==============================================================================
//==============================================================================
// _| _ _|_ _ _ _ _|_ _ .
// _| _ _|_ _ _ _ _|_ _ .
// (_|(_| | (_| _\(/_ | |_||_) . (data used to store game info that changes)
// (_|(_| | (_| _\(/_ | |_||_) . (data used to store game info that changes)
//=============================|================================================
//=============================|================================================
uint256 public airDropPot_; // person who gets the airdrop wins part of this pot
uint256 public airDropPot_; // person who gets the airdrop wins part of this pot
uint256 public airDropTracker_ = 0; // incremented each time a "qualified" tx occurs. used to determine winning air drop
uint256 public airDropTracker_ = 0; // incremented each time a "qualified" tx occurs. used to determine winning air drop
uint256 public rID_; // round id number / total rounds that have happened
uint256 public rID_; // round id number / total rounds that have happened
//****************
//****************
// PLAYER DATA
// PLAYER DATA
//****************
//****************
mapping (address => uint256) public pIDxAddr_; // (addr => pID) returns player id by address
mapping (address => uint256) public pIDxAddr_; // (addr => pID) returns player id by address
mapping (bytes32 => uint256) public pIDxName_; // (name => pID) returns player id by name
mapping (bytes32 => uint256) public pIDxName_; // (name => pID) returns player id by name
mapping (uint256 => F3Ddatasets.Player) public plyr_; // (pID => data) player data
mapping (uint256 => F3Ddatasets.Player) public plyr_; // (pID => data) player data
mapping (uint256 => mapping (uint256 => F3Ddatasets.PlayerRounds)) public plyrRnds_; // (pID => rID => data) player round data by player id & round id
mapping (uint256 => mapping (uint256 => F3Ddatasets.PlayerRounds)) public plyrRnds_; // (pID => rID => data) player round data by player id & round id
mapping (uint256 => mapping (bytes32 => bool)) public plyrNames_; // (pID => name => bool) list of names a player owns. (used so you can change your display name amongst any name you own)
mapping (uint256 => mapping (bytes32 => bool)) public plyrNames_; // (pID => name => bool) list of names a player owns. (used so you can change your display name amongst any name you own)
//****************
//****************
// ROUND DATA
// ROUND DATA
//****************
//****************
mapping (uint256 => F3Ddatasets.Round) public round_; // (rID => data) round data
mapping (uint256 => F3Ddatasets.Round) public round_; // (rID => data) round data
mapping (uint256 => mapping(uint256 => uint256)) public rndTmEth_; // (rID => tID => data) eth in per team, by round id and team id
mapping (uint256 => mapping(uint256 => uint256)) public rndTmEth_; // (rID => tID => data) eth in per team, by round id and team id
//****************
//****************
// TEAM FEE DATA
// TEAM FEE DATA
//****************
//****************
mapping (uint256 => F3Ddatasets.TeamFee) public fees_; // (team => fees) fee distribution by team
mapping (uint256 => F3Ddatasets.TeamFee) public fees_; // (team => fees) fee distribution by team
mapping (uint256 => F3Ddatasets.PotSplit) public potSplit_; // (team => fees) pot split distribution by team
mapping (uint256 => F3Ddatasets.PotSplit) public potSplit_; // (team => fees) pot split distribution by team
//==============================================================================
//==============================================================================
// _ _ _ __|_ _ __|_ _ _ .
// _ _ _ __|_ _ __|_ _ _ .
// (_(_)| |_\ | | |_|(_ | (_)| . (initial data setup upon contract deploy)
// (_(_)| |_\ | | |_|(_ | (_)| . (initial data setup upon contract deploy)
//==============================================================================
//==============================================================================
constructor()
constructor()
public
public
{
{
// Team allocation structures
// Team allocation structures
// 0 = whales
// 0 = whales
// 1 = bears
// 1 = bears
// 2 = sneks
// 2 = sneks
// 3 = bulls
// 3 = bulls


// Team allocation percentages
// Team allocation percentages
// (F3D, P3D) + (Pot , Referrals, Community)
// (F3D, P3D) + (Pot , Referrals, Community)
// Referrals / Community rewards are mathematically designed to come from the winner's share of the pot.
// Referrals / Community rewards are mathematically designed to come from the winner's share of the pot.
fees_[0] = F3Ddatasets.TeamFee(30,6); //50% to pot, 10% to aff, 2% to com, 1% to pot swap, 1% to air drop pot
fees_[0] = F3Ddatasets.TeamFee(30,6); //50% to pot, 10% to aff, 2% to com, 1% to pot swap, 1% to air drop pot
fees_[1] = F3Ddatasets.TeamFee(43,0); //43% to pot, 10% to aff, 2% to com, 1% to pot swap, 1% to air drop pot
fees_[1] = F3Ddatasets.TeamFee(43,0); //43% to pot, 10% to aff, 2% to com, 1% to pot swap, 1% to air drop pot
fees_[2] = F3Ddatasets.TeamFee(56,10); //20% to pot, 10% to aff, 2% to com, 1% to pot swap, 1% to air drop pot
fees_[2] = F3Ddatasets.TeamFee(56,10); //20% to pot, 10% to aff, 2% to com, 1% to pot swap, 1% to air drop pot
fees_[3] = F3Ddatasets.TeamFee(43,8); //35% to pot, 10% to aff, 2% to com, 1% to pot swap, 1% to air drop pot
fees_[3] = F3Ddatasets.TeamFee(43,8); //35% to pot, 10% to aff, 2% to com, 1% to pot swap, 1% to air drop pot
// how to split up the final pot based on which team was picked
// how to split up the final pot based on which team was picked
// (F3D, P3D)
// (F3D, P3D)
potSplit_[0] = F3Ddatasets.PotSplit(15,10); //48% to winner, 25% to next round, 2% to com
potSplit_[0] = F3Ddatasets.PotSplit(15,10); //48% to winner, 25% to next round, 2% to com
potSplit_[1] = F3Ddatasets.PotSplit(25,0); //48% to winner, 25% to next round, 2% to com
potSplit_[1] = F3Ddatasets.PotSplit(25,0); //48% to winner, 25% to next round, 2% to com
potSplit_[2] = F3Ddatasets.PotSplit(20,20); //48% to winner, 10% to next round, 2% to com
potSplit_[2] = F3Ddatasets.PotSplit(20,20); //48% to winner, 10% to next round, 2% to com
potSplit_[3] = F3Ddatasets.PotSplit(30,10); //48% to winner, 10% to next round, 2% to com
potSplit_[3] = F3Ddatasets.PotSplit(30,10); //48% to winner, 10% to next round, 2% to com
}
}
//==============================================================================
//==============================================================================
// _ _ _ _|. |`. _ _ _ .
// _ _ _ _|. |`. _ _ _ .
// | | |(_)(_||~|~|(/_| _\ . (these are safety checks)
// | | |(_)(_||~|~|(/_| _\ . (these are safety checks)
//==============================================================================
//==============================================================================
/**
/**
* @dev used to make sure no one can interact with contract until it has
* @dev used to make sure no one can interact with contract until it has
* been activated.
* been activated.
*/
*/
modifier isActivated() {
modifier isActivated() {
require(activated_ == true, "its not ready yet. check ?eta in discord");
require(activated_ == true, "its not ready yet. check ?eta in discord");
_;
_;
}
}
/**
/**
* @dev prevents contracts from interacting with fomo3d
* @dev prevents contracts from interacting with fomo3d
*/
*/
modifier isHuman() {
modifier isHuman() {
address _addr = msg.sender;
address _addr = msg.sender;
uint256 _codeLength;
uint256 _codeLength;
assembly {_codeLength := extcodesize(_addr)}
assembly {_codeLength := extcodesize(_addr)}
require(_codeLength == 0, "sorry humans only");
require(_codeLength == 0, "sorry humans only");
_;
_;
}
}


/**
/**
* @dev sets boundaries for incoming tx
* @dev sets boundaries for incoming tx
*/
*/
modifier isWithinLimits(uint256 _eth) {
modifier isWithinLimits(uint256 _eth) {
require(_eth >= 1000000000, "pocket lint: not a valid currency");
require(_eth >= 1000000000, "pocket lint: not a valid currency");
require(_eth <= 100000000000000000000000, "no vitalik, no");
require(_eth <= 100000000000000000000000, "no vitalik, no");
_;
_;
}
}
//==============================================================================
//==============================================================================
// _ |_ |. _ |` _ __|_. _ _ _ .
// _ |_ |. _ |` _ __|_. _ _ _ .
// |_)|_||_)||(_ ~|~|_|| |(_ | |(_)| |_\ . (use these to interact with contract)
// |_)|_||_)||(_ ~|~|_|| |(_ | |(_)| |_\ . (use these to interact with contract)
//====|=========================================================================
//====|=========================================================================
/**
/**
* @dev emergency buy uses last stored affiliate ID and team snek
* @dev emergency buy uses last stored affiliate ID and team snek
*/
*/
function()
function()
isActivated()
isActivated()
isHuman()
isHuman()
isWithinLimits(msg.value)
isWithinLimits(msg.value)
public
public
payable
payable
{
{
// set up our tx event data and determine if player is new or not
// set up our tx event data and determine if player is new or not
F3Ddatasets.EventReturns memory _eventData_ = determinePID(_eventData_);
F3Ddatasets.EventReturns memory _eventData_ = determinePID(_eventData_);
// fetch player id
// fetch player id
uint256 _pID = pIDxAddr_[msg.sender];
uint256 _pID = pIDxAddr_[msg.sender];

// buy core
// buy core
buyCore(_pID, plyr_[_pID].laff, 2, _eventData_);
buyCore(_pID, plyr_[_pID].laff, 2, _eventData_);
}
}
/**
/**
* @dev converts all incoming ethereum to keys.
* @dev converts all incoming ethereum to keys.
* -functionhash- 0x8f38f309 (using ID for affiliate)
* -functionhash- 0x8f38f309 (using ID for affiliate)
* -functionhash- 0x98a0871d (using address for affiliate)
* -functionhash- 0x98a0871d (using address for affiliate)
* -functionhash- 0xa65b37a1 (using name for affiliate)
* -functionhash- 0xa65b37a1 (using name for affiliate)
* @param _affCode the ID/address/name of the player who gets the affiliate fee
* @param _affCode the ID/address/name of the player who gets the affiliate fee
* @param _team what team is the player playing for?
* @param _team what team is the player playing for?
*/
*/
function buyXid(uint256 _affCode, uint256 _team)
function buyXid(uint256 _affCode, uint256 _team)
isActivated()
isActivated()
isHuman()
isHuman()
isWithinLimits(msg.value)
isWithinLimits(msg.value)
public
public
payable
payable
{
{
// set up our tx event data and determine if player is new or not
// set up our tx event data and determine if player is new or not
F3Ddatasets.EventReturns memory _eventData_ = determinePID(_eventData_);
F3Ddatasets.EventReturns memory _eventData_ = determinePID(_eventData_);
// fetch player id
// fetch player id
uint256 _pID = pIDxAddr_[msg.sender];
uint256 _pID = pIDxAddr_[msg.sender];
// manage affiliate residuals
// manage affiliate residuals
// if no affiliate code was given or player tried to use their own, lolz
// if no affiliate code was given or player tried to use their own, lolz
if (_affCode == 0 || _affCode == _pID)
if (_affCode == 0 || _affCode == _pID)
{
{
// use last stored affiliate code
// use last stored affiliate code
_affCode = plyr_[_pID].laff;
_affCode = plyr_[_pID].laff;

// if affiliate code was given & its not the same as previously stored
// if affiliate code was given & its not the same as previously stored
} else if (_affCode != plyr_[_pID].laff) {
} else if (_affCode != plyr_[_pID].laff) {
// update last affiliate
// update last affiliate
plyr_[_pID].laff = _affCode;
plyr_[_pID].laff = _affCode;
}
}
// verify a valid team was selected
// verify a valid team was selected
_team = verifyTeam(_team);
_team = verifyTeam(_team);

// buy core
// buy core
buyCore(_pID, _affCode, _team, _eventData_);
buyCore(_pID, _affCode, _team, _eventData_);
}
}
function buyXaddr(address _affCode, uint256 _team)
function buyXaddr(address _affCode, uint256 _team)
isActivated()
isActivated()
isHuman()
isHuman()
isWithinLimits(msg.value)
isWithinLimits(msg.value)
public
public
payable
payable
{
{
// set up our tx event data and determine if player is new or not
// set up our tx event data and determine if player is new or not
F3Ddatasets.EventReturns memory _eventData_ = determinePID(_eventData_);
F3Ddatasets.EventReturns memory _eventData_ = determinePID(_eventData_);
// fetch player id
// fetch player id
uint256 _pID = pIDxAddr_[msg.sender];
uint256 _pID = pIDxAddr_[msg.sender];
// manage affiliate residuals
// manage affiliate residuals
uint256 _affID;
uint256 _affID;
// if no affiliate code was given or player tried to use their own, lolz
// if no affiliate code was given or player tried to use their own, lolz
if (_affCode == address(0) || _affCode == msg.sender)
if (_affCode == address(0) || _affCode == msg.sender)
{
{
// use last stored affiliate code
// use last stored affiliate code
_affID = plyr_[_pID].laff;
_affID = plyr_[_pID].laff;

// if affiliate code was given
// if affiliate code was given
} else {
} else {
// get affiliate ID from aff Code
// get affiliate ID from aff Code
_affID = pIDxAddr_[_affCode];
_affID = pIDxAddr_[_affCode];

// if affID is not the same as previously stored
// if affID is not the same as previously stored
if (_affID != plyr_[_pID].laff)
if (_affID != plyr_[_pID].laff)
{
{
// update last affiliate
// update last affiliate
plyr_[_pID].laff = _affID;
plyr_[_pID].laff = _affID;
}
}
}
}
// verify a valid team was selected
// verify a valid team was selected
_team = verifyTeam(_team);
_team = verifyTeam(_team);

// buy core
// buy core
buyCore(_pID, _affID, _team, _eventData_);
buyCore(_pID, _affID, _team, _eventData_);
}
}
function buyXname(bytes32 _affCode, uint256 _team)
function buyXname(bytes32 _affCode, uint256 _team)
isActivated()
isActivated()
isHuman()
isHuman()
isWithinLimits(msg.value)
isWithinLimits(msg.value)
public
public
payable
payable
{
{
// set up our tx event data and determine if player is new or not
// set up our tx event data and determine if player is new or not
F3Ddatasets.EventReturns memory _eventData_ = determinePID(_eventData_);
F3Ddatasets.EventReturns memory _eventData_ = determinePID(_eventData_);
// fetch player id
// fetch player id
uint256 _pID = pIDxAddr_[msg.sender];
uint256 _pID = pIDxAddr_[msg.sender];
// manage affiliate residuals
// manage affiliate residuals
uint256 _affID;
uint256 _affID;
// if no affiliate code was given or player tried to use their own, lolz
// if no affiliate code was given or player tried to use their own, lolz
if (_affCode == '' || _affCode == plyr_[_pID].name)
if (_affCode == '' || _affCode == plyr_[_pID].name)
{
{
// use last stored affiliate code
// use last stored affiliate code
_affID = plyr_[_pID].laff;
_affID = plyr_[_pID].laff;
// if affiliate code was given
// if affiliate code was given
} else {
} else {
// get affiliate ID from aff Code
// get affiliate ID from aff Code
_affID = pIDxName_[_affCode];
_affID = pIDxName_[_affCode];
// if affID is not the same as previously stored
// if affID is not the same as previously stored
if (_affID != plyr_[_pID].laff)
if (_affID != plyr_[_pID].laff)
{
{
// update last affiliate
// update last affiliate
plyr_[_pID].laff = _affID;
plyr_[_pID].laff = _affID;
}
}
}
}
// verify a valid team was selected
// verify a valid team was selected
_team = verifyTeam(_team);
_team = verifyTeam(_team);

// buy core
// buy core
buyCore(_pID, _affID, _team, _eventData_);
buyCore(_pID, _affID, _team, _eventData_);
}
}
/**
/**
* @dev essentially the same as buy, but instead of you sending ether
* @dev essentially the same as buy, but instead of you sending ether
* from your wallet, it uses your unwithdrawn earnings.
* from your wallet, it uses your unwithdrawn earnings.
* -functionhash- 0x349cdcac (using ID for affiliate)
* -functionhash- 0x349cdcac (using ID for affiliate)
* -functionhash- 0x82bfc739 (using address for affiliate)
* -functionhash- 0x82bfc739 (using address for affiliate)
* -functionhash- 0x079ce327 (using name for affiliate)
* -functionhash- 0x079ce327 (using name for affiliate)
* @param _affCode the ID/address/name of the player who gets the affiliate fee
* @param _affCode the ID/address/name of the player who gets the affiliate fee
* @param _team what team is the player playing for?
* @param _team what team is the player playing for?
* @param _eth amount of earnings to use (remainder returned to gen vault)
* @param _eth amount of earnings to use (remainder returned to gen vault)
*/
*/
function reLoadXid(uint256 _affCode, uint256 _team, uint256 _eth)
function reLoadXid(uint256 _affCode, uint256 _team, uint256 _eth)
isActivated()
isActivated()
isHuman()
isHuman()
isWithinLimits(_eth)
isWithinLimits(_eth)
public
public
{
{
// set up our tx event data
// set up our tx event data
F3Ddatasets.EventReturns memory _eventData_;
F3Ddatasets.EventReturns memory _eventData_;
// fetch player ID
// fetch player ID
uint256 _pID = pIDxAddr_[msg.sender];
uint256 _pID = pIDxAddr_[msg.sender];
// manage affiliate residuals
// manage affiliate residuals
// if no affiliate code was given or player tried to use their own, lolz
// if no affiliate code was given or player tried to use their own, lolz
if (_affCode == 0 || _affCode == _pID)
if (_affCode == 0 || _affCode == _pID)
{
{
// use last stored affiliate code
// use last stored affiliate code
_affCode = plyr_[_pID].laff;
_affCode = plyr_[_pID].laff;

// if affiliate code was given & its not the same as previously stored
// if affiliate code was given & its not the same as previously stored
} else if (_affCode != plyr_[_pID].laff) {
} else if (_affCode != plyr_[_pID].laff) {
// update last affiliate
// update last affiliate
plyr_[_pID].laff = _affCode;
plyr_[_pID].laff = _affCode;
}
}


// verify a valid team was selected
// verify a valid team was selected
_team = verifyTeam(_team);
_team = verifyTeam(_team);


// reload core
// reload core
reLoadCore(_pID, _affCode, _team, _eth, _eventData_);
reLoadCore(_pID, _affCode, _team, _eth, _eventData_);
}
}
function reLoadXaddr(address _affCode, uint256 _team, uint256 _eth)
function reLoadXaddr(address _affCode, uint256 _team, uint256 _eth)
isActivated()
isActivated()
isHuman()
isHuman()
isWithinLimits(_eth)
isWithinLimits(_eth)
public
public
{
{
// set up our tx event data
// set up our tx event data
F3Ddatasets.EventReturns memory _eventData_;
F3Ddatasets.EventReturns memory _eventData_;
// fetch player ID
// fetch player ID
uint256 _pID = pIDxAddr_[msg.sender];
uint256 _pID = pIDxAddr_[msg.sender];
// manage affiliate residuals
// manage affiliate residuals
uint256 _affID;
uint256 _affID;
// if no affiliate code was given or player tried to use their own, lolz
// if no affiliate code was given or player tried to use their own, lolz
if (_affCode == address(0) || _affCode == msg.sender)
if (_affCode == address(0) || _affCode == msg.sender)
{
{
// use last stored affiliate code
// use last stored affiliate code
_affID = plyr_[_pID].laff;
_affID = plyr_[_pID].laff;

// if affiliate code was given
// if affiliate code was given
} else {
} else {
// get affiliate ID from aff Code
// get affiliate ID from aff Code
_affID = pIDxAddr_[_affCode];
_affID = pIDxAddr_[_affCode];

// if affID is not the same as previously stored
// if affID is not the same as previously stored
if (_affID != plyr_[_pID].laff)
if (_affID != plyr_[_pID].laff)
{
{
// update last affiliate
// update last affiliate
plyr_[_pID].laff = _affID;
plyr_[_pID].laff = _affID;
}
}
}
}
// verify a valid team was selected
// verify a valid team was selected
_team = verifyTeam(_team);
_team = verifyTeam(_team);
// reload core
// reload core
reLoadCore(_pID, _affID, _team, _eth, _eventData_);
reLoadCore(_pID, _affID, _team, _eth, _eventData_);
}
}
function reLoadXname(bytes32 _affCode, uint256 _team, uint256 _eth)
function reLoadXname(bytes32 _affCode, uint256 _team, uint256 _eth)
isActivated()
isActivated()
isHuman()
isHuman()
isWithinLimits(_eth)
isWithinLimits(_eth)
public
public
{
{
// set up our tx event data
// set up our tx event data
F3Ddatasets.EventReturns memory _eventData_;
F3Ddatasets.EventReturns memory _eventData_;
// fetch player ID
// fetch player ID
uint256 _pID = pIDxAddr_[msg.sender];
uint256 _pID = pIDxAddr_[msg.sender];
// manage affiliate residuals
// manage affiliate residuals
uint256 _affID;
uint256 _affID;
// if no affiliate code was given or player tried to use their own, lolz
// if no affiliate code was given or player tried to use their own, lolz
if (_affCode == '' || _affCode == plyr_[_pID].name)
if (_affCode == '' || _affCode == plyr_[_pID].name)
{
{
// use last stored affiliate code
// use last stored affiliate code
_affID = plyr_[_pID].laff;
_affID = plyr_[_pID].laff;
// if affiliate code was given
// if affiliate code was given
} else {
} else {
// get affiliate ID from aff Code
// get affiliate ID from aff Code
_affID = pIDxName_[_affCode];
_affID = pIDxName_[_affCode];
// if affID is not the same as previously stored
// if affID is not the same as previously stored
if (_affID != plyr_[_pID].laff)
if (_affID != plyr_[_pID].laff)
{
{
// update last affiliate
// update last affiliate
plyr_[_pID].laff = _affID;
plyr_[_pID].laff = _affID;
}
}
}
}
// verify a valid team was selected
// verify a valid team was selected
_team = verifyTeam(_team);
_team = verifyTeam(_team);
// reload core
// reload core
reLoadCore(_pID, _affID, _team, _eth, _eventData_);
reLoadCore(_pID, _affID, _team, _eth, _eventData_);
}
}


/**
/**
* @dev withdraws all of your earnings.
* @dev withdraws all of your earnings.
* -functionhash- 0x3ccfd60b
* -functionhash- 0x3ccfd60b
*/
*/
function withdraw()
function withdraw()
isActivated()
isActivated()
isHuman()
isHuman()
public
public
{
{
// setup local rID
// setup local rID
uint256 _rID = rID_;
uint256 _rID = rID_;
// grab time
// grab time
uint256 _now = now;
uint256 _now = now;
// fetch player ID
// fetch player ID
uint256 _pID = pIDxAddr_[msg.sender];
uint256 _pID = pIDxAddr_[msg.sender];
// setup temp var for player eth
// setup temp var for player eth
uint256 _eth;
uint256 _eth;
// check to see if round has ended and no one has run round end yet
// check to see if round has ended and no one has run round end yet
if (_now > round_[_rID].end && round_[_rID].ended == false && round_[_rID].plyr != 0)
if (_now > round_[_rID].end && round_[_rID].ended == false && round_[_rID].plyr != 0)
{
{
// set up our tx event data
// set up our tx event data
F3Ddatasets.EventReturns memory _eventData_;
F3Ddatasets.EventReturns memory _eventData_;
// end the round (distributes pot)
// end the round (distributes pot)
round_[_rID].ended = true;
round_[_rID].ended = true;
_eventData_ = endRound(_eventData_);
_eventData_ = endRound(_eventData_);
// get their earnings
// get their earnings
_eth = withdrawEarnings(_pID);
_eth = withdrawEarnings(_pID);
// gib moni
// gib moni
if (_eth > 0)
if (_eth > 0)
plyr_[_pID].addr.transfer(_eth);
plyr_[_pID].addr.transfer(_eth);

// build event data
// build event data
_eventData_.compressedData = _eventData_.compressedData + (_now * 1000000000000000000);
_eventData_.compressedData = _eventData_.compressedData + (_now * 1000000000000000000);
_eventData_.compressedIDs = _eventData_.compressedIDs + _pID;
_eventData_.compressedIDs = _eventData_.compressedIDs + _pID;
// fire withdraw and distribute event
// fire withdraw and distribute event
emit F3Devents.onWithdrawAndDistribute
emit F3Devents.onWithdrawAndDistribute
(
(
msg.sender,
msg.sender,
plyr_[_pID].name,
plyr_[_pID].name,
_eth,
_eth,
_eventData_.compressedData,
_eventData_.compressedData,
_eventData_.compressedIDs,
_eventData_.compressedIDs,
_eventData_.winnerAddr,
_eventData_.winnerAddr,
_eventData_.winnerName,
_eventData_.winnerName,
_eventData_.amountWon,
_eventData_.amountWon,
_eventData_.newPot,
_eventData_.newPot,
_eventData_.P3DAmount,
_eventData_.P3DAmount,
_eventData_.genAmount
_eventData_.genAmount
);
);
// in any other situation
// in any other situation
} else {
} else {
// get their earnings
// get their earnings
_eth = withdrawEarnings(_pID);
_eth = withdrawEarnings(_pID);
// gib moni
// gib moni
if (_eth > 0)
if (_eth > 0)
plyr_[_pID].addr.transfer(_eth);
plyr_[_pID].addr.transfer(_eth);
// fire withdraw event
// fire withdraw event
emit F3Devents.onWithdraw(_pID, msg.sender, plyr_[_pID].name, _eth, _now);
emit F3Devents.onWithdraw(_pID, msg.sender, plyr_[_pID].name, _eth, _now);
}
}
}
}

/**
* @dev use these to register names. they are just wrappers that will send the
* registration requests to the PlayerBook contract. So registering here is the
* same as registering there. UI will always display the last name you registered.
* but you will still own all previously registered names to use as affiliate
* links.
* - must pay a registration fee.
* - name must be unique
* - names will be converted to lowercase
* - name cannot start or end with a space
* - cannot have more than 1 space in a row
* - cannot be only numbers
* - cannot start with 0x
* - name must be at least 1 char
* - max length of 32 characters long
* - allowed characters: a-z, 0-9, and space
* -functionhash- 0x921dec21 (using ID for affiliate)
* -functionhash- 0x3ddd4698 (using address for affiliate)
* -functionhash- 0x685ffd83 (using name for affiliate)
* @param _nameString players desired name
* @param _affCode affiliate ID, address, or name of who referred you
* @param _all set to true if you want this to push your info to all games
* (this might cost a lot of gas)
*/
function registerNameXID(string _nameString, uint256 _affCode, bool _all)
isHuman()
public
payable
{
bytes32 _name = _nameString.nameFilter();
address _addr = msg.sender;
uint256 _paid = msg.value;
(bool _isNewPlayer, uint256 _affID) = PlayerBook.registerNameXIDFromDapp.value(_paid)(_addr, _name, _affCode, _all);

uint256 _pID = pIDxAddr_[_addr];

// fire event
emit F3Devents.onNewName(_pID, _addr, _name, _isNewPlayer, _affID, plyr_[_affID].addr, plyr_[_affID].name, _paid, now);
}

function registerNameXaddr(string _nameString, address _affCode, bool _all)
isHuman()
public
payable
{
bytes32 _name = _nameString.nameFilter();
address _addr = msg.sender;
uint256 _paid = msg.value;
(bool _isNewPlayer, uint256 _affID) = PlayerBook.registerNameXaddrFromDapp.value(msg.value)(msg.sender, _name, _affCode, _all);

uint256 _pID = pIDxAddr_[_addr];

// fire event
emit F3Devents.onNewName(_pID, _addr, _name, _isNewPlayer, _affID, plyr_[_affID].addr, plyr_[_affID].name, _paid, now);
}

function registerNameXname(string _nameString, bytes32 _affCode, bool _all)
isHuman()
public
payable
{
bytes32 _name = _nameString.nameFilter();
address _addr = msg.sender;
uint256 _paid = msg.value;
(bool _isNewPlayer, uint256 _affID) = PlayerBook.registerNameXnameFromDapp.value(msg.value)(msg.sender, _name, _affCode, _all);

uint256 _pID = pIDxAddr_[_addr];

// fire event
emit F3Devents.onNewName(_pID, _addr, _name, _isNewPlayer, _affID, plyr_[_affID].addr, plyr_[_affID].name, _paid, now);
}
//==============================================================================
// _ _ _|__|_ _ _ _ .
// (_|(/_ | | (/_| _\ . (for UI & viewing things on etherscan)
//=====_|=======================================================================
/**
/**
* @dev return the price buyer will pay for next 1 individual key.
* -functionhash- 0x018a25e8
* @return price for next key bought (in wei format)
*/
function getBuyPrice()
public
view
returns(uint256)
{
// setup local rID
uint256 _rID = rID_;

// grab time
uint256 _now = now;

// are we in a round?
if (_now > round_[_rID].strt + rndGap_ && (_now <= round_[_rID].end || (_now > round_[_rID].end && round_[_rID].plyr == 0)))
return ( (round_[_rID].keys.add(1000000000000000000)).ethRec(1000000000000000000) );
else // rounds over. need price for new round
return ( 75000000000000 ); // init
}

/**
* @dev returns time left. dont spam this, you'll ddos yourself from your node
* provider
* -functionhash- 0xc7e284b8
* @return time left in seconds
*/
function getTimeLeft()
public
view
returns(uint256)
{
// setup local rID
uint256 _rID = rID_;

// grab time
uint256 _now = now;

if (_now < round_[_rID].end)
if (_now > round_[_rID].strt + rndGap_)
return( (round_[_rID].end).sub(_now) );
else
return( (round_[_rID].strt + rndGap_).sub(_now) );
else
return(0);
}

/**
* @dev returns player earnings per vaults
* -functionhash- 0x63066434
* @return winnings vault
* @return general vault
* @return affiliate vault
*/
function getPlayerVaults(uint256 _pID)
public
view
returns(uint256 ,uint256, uint256)
{
// setup local rID
uint256 _rID = rID_;

// if round has ended. but round end has not been run (so contract has not distributed winnings)
if (now > round_[_rID].end && round_[_rID].ended == false && round_[_rID].plyr != 0)
{
// if player is winner
if (round_[_rID].plyr == _pID)
{
return
(
(plyr_[_pID].win).add( ((round_[_rID].pot).mul(48)) / 100 ),
(plyr_[_pID].gen).add( getPlayerVaultsHelper(_pID, _rID).sub(plyrRnds_[_pI