Drinkers (holders of $HOUR): These are the users and community members interacting with the Happy Hour Protocol Engine. These are the happy hour goers, nightlife fist-pumpers, bartenders, and all other alcoholics who make it a priority to support the F&B industry.
Copy function startHOUR(uint _PDEid, uint _accessCode) public payable {
uint validPDE;
for (uint i = 0; i < pdes.length; i++) {
if (pdes[i]._PDEid == _PDEid && pdes[i]._accessCode == _accessCode) {
validPDE = 1;
} else {
validPDE = 0;
}
}
require(validPDE == 1);
require(msg.value == happyHourFee, "Invalid Happy Hour Fee.");
givePoolDrinkingId();
drinkingIDtoPDEid[drinkingID[msg.sender]] = _PDEid;
happyHourFeePool += 1;
timeIN = block.timestamp;
}
Copy function endHOUR(address payable wiped) public {
address PDEcommission;
require(msg.sender == wiped);
timeOUT = block.timestamp;
for (uint i = 0; i < pdes.length; i++) {
if (pdes[i]._PDEid == drinkingIDtoPDEid[drinkingID[msg.sender]]) {
PDEcommission = pdes[i]._address;
}
}
nullPoolDrinkingId();
happyHourFeePool -= 1;
wiped.transfer(1 ether);
hoursSpentDrinking = (timeOUT - timeIN) / 60 / 60;
uint HOURearned = hoursSpentDrinking * HOURperhour;
uint PDEcommissionEarned = HOURearned / PDEcommissionRate;
_mint(wiped, HOURearned);
_mint(PDEcommission, PDEcommissionEarned);
emit endHOURresults(hoursSpentDrinking, HOURearned, PDEcommissionEarned);
}
Copy contract poolDrinkingID {
mapping(address => uint256) public drinkingID;
uint256 drinkingIDcounter;
event createdDrinkingID(address user, uint256 id);
function givePoolDrinkingId() internal returns (uint256) {
require(drinkingID[msg.sender]==0, "You are already drinking.");
drinkingIDcounter += 1;
drinkingID[msg.sender] = uint(keccak256(abi.encodePacked(block.timestamp, msg.sender)));
emit createdDrinkingID(msg.sender,drinkingID[msg.sender]);
return drinkingID[msg.sender];
}
function nullPoolDrinkingId() internal {
require(drinkingID[msg.sender] != 0, "You haven't started drinking yet.");
drinkingIDcounter -= 1;
drinkingID[msg.sender] = 0;
}
function getPoolDrinkingId() public view returns(uint256) {
return drinkingID[msg.sender];
}
function getNumberOfCurrentDrinkers() public view returns(uint) {
return drinkingIDcounter;
}
}
Copy function gethappyHourFeePool() public view returns (uint) {
return happyHourFeePool;
}