2

i created a simple jackpot game. I completed the game, but my current problem is replenishing the coins everyday. I'm giving 10 coins per day, and the update should be at 9am. The problem is i don't know when to store the firstPlayedDate it. This is what I have been trying so far.

   public DateTime firstPlayedDate
   {
     get
    {
        CoinTracker firstPlayedEntry = _db.CoinTrackers.Where(u => u.FbId == fbId).OrderByDescending(u => u.CoinTimer).FirstOrDefault();
        return firstPlayedEntry == null ? new DateTime() : firstPlayedEntry.CoinTimer;
    }
   }

   public int AvailableDailyCoins
   {
     get
     {   
        return (DateTime.UtcNow.Date - firstPlayedDate.Date).Days > 0 ? 10 : 0;
     }
   }

One way i thought of was, everytime the player has 10 coins, i store the firstPlayedDate. Any other ideas??

4

1 回答 1

2

如果这是您的想法,我不会根据客户端中运行的计时器发放硬币。这将允许最基本的作弊。任何人都可以使用 fiddler 之类的工具修改浏览器中运行的代码来给自己奖励。

相反,我会将 lastActiveTimestamp 存储在服务器上的用户配置文件中,并使用 cron 作业在给定时间根据需要遍历用户列表奖励硬币,或者,我更喜欢,实际上甚至不在上午 9 点给予奖励 - 只需计算通过读取 lastActiveTimestamp 并从 Datetime.Now() 计算时间跨度,他们的帐户下一次活跃时应获得奖励。

希望这是有道理的。

于 2013-09-09T04:55:42.990 回答