如何编写能量补充游戏的计时器算法
与 Facebook 上的俄罗斯方块类似,如果你的能量为 100,那么在使用(玩游戏)后,它会减少 5 个单位,并且每 10 分钟充电 1 个单位。我很好奇如何处理轮询,并可能将其设置为服务器端,这样就不会出现“时间操纵”(例如将未来的时钟向前设置)来规避提前接收能量的措施。提前致谢!
Similar to Tetris on Facebook, where if you're at 100 Energy, after usage (playing a game), it goes down 5 units, and the recharges 1 unit every 10 minutes. I'm curious how to handle polling, and possibly making it server-side so that there's no "time manipulation" (e.g setting the clock forward in the future) to circumvent measures for receiving energy early. Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您将需要某种持久性基础设施,理想情况下您希望从客户端对服务器运行检查,只需让它在加载时返回一个带有值的 JSON 字符串即可。另外,不要使用客户端时钟,因为这可能会在机器等之间发生变化,这不会产生理想的结果。
You will need some kind of persistent infrastructure, and ideally you want to run a check against the server from the client side, just have it return a JSON string with the value whenever it loads. Also, don't use the client clock, because that could change across machines etc. which would not yield the ideal results.