예제 #1
0
    // doesn't think a lot of time has passed in the day with no plays, which
    // would cause a lot of wins to be given out all at once
    file_put_contents($todayPlayCountFile, "100");
}
$curPlays = (int) file_get_contents($todayPlayCountFile);
/**
 * Setup the distribution, time period and player
 */
$player = new Player();
$player->setMaxWins($winsPerDay);
$player->setCurWins($curWins);
$player->setPlayCount($curPlays);
$timePeriod = new TimePeriod();
$timePeriod->setStartTimestamp($midnightToday);
$timePeriod->setEndTimestamp($midnightTomorrow);
$timePeriod->setCurrentTimestamp(time());
$player->setTimePeriod($timePeriod);
$player->setDistribution(new EvenOverTimeDistribution());
/**
 * Execute a single instant-win play attempt
 */
$win = $player->isWinner();
$curPlays++;
file_put_contents($todayPlayCountFile, $curPlays);
if ($win) {
    echo "You Won!!!\n";
    $curWins++;
    file_put_contents($todayWinCountFile, $curWins);
} else {
    echo "Sorry, you did not win.\n";
}