iOS环境下的可靠时差
我正在开发一款休闲游戏,随着时间的推移,会有一些改进,就像 TinyTower 一样。
但《TinyTower》最大的缺陷(恕我直言,它是一款可爱的游戏)是作弊太容易了。该游戏依赖于设备时间,因此当它说“八小时内完成”时,您只需将时钟调快八小时,拿到东西,然后将其调回即可。
现在,我需要确保这不是人们在我的游戏中获胜的方式。我有一个想法,我可以交叉引用系统时间与服务器时间,但我不能依赖打开的连接,因为离线游戏是一种选择。
我还可以设置一个传感器,指示如果操作系统时间突然早于上次播放时间,您将获得一个看不见的作弊嫌疑计数器。其中三个,游戏就会重置,并将您标记为作弊者。
最后的选择就是根本不在乎,让骗子继续骗子。但如果我想要有一个竞争元素,比如高分之类的,我真的需要这个才能发挥作用。
所以...问题是这样的: 有谁知道一种安全可靠的方法来检测自用户上次打开应用程序以来已经过去了多长时间?
I am working on a casual game with some improvement over time, much like TinyTower.
But the biggest flaw in TinyTower (and all respect, its a cute game) is that cheating is too easy. The game relies on the device time, so when it says that "this is done in eight hours" you just set your clock eight hours ahead, get the thing, and then turn it back.
Now, I need to make sure that this isnt a way people can win in my game. I had one idea that i could crossreference the system time with the server time, but I can't rely on the connection being open, since offline play is an option.
I could also set up a sensor indicating if the OS time suddently was before last-played-time, you would earn an invisible cheat-suspicion counter. Three of these, and the game would reset, and mark you as a cheater.
The final option was to simply not care, let cheaters be cheaters. But if I am to have a competative element, with hoghscores and such, i really need this to work.
So... The question is this:
Does anyone know a safe reliable way of detecting how much time has passed since last time a user last had the app open?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
应用程序委托会收到重大时间更改的通知。您可以捕获对 applicationSignificantTimeChange: 并观察显着的向前或向后时间跳跃。
当然,这只捕获应用程序运行时发生的更改。您还可以将上次运行的时间保存在 NSUserDefaults 中,并在下次启动时检查是否有明显的向后时间跳跃。
The app delegate is notified of significant time changes. You can catch these calls to applicationSignificantTimeChange: and watch for significant forward or backward time jumps.
Of course, that only catches changes that take place while the app is running. You can also save the time last run in the NSUserDefaults and check it next time you start up for significant backwards time jumps.
对于所有这些解决方案,如果用户去了另一个国家并且时区发生变化并进入过去或未来怎么办?
About all those solutions, what if the user goes to another country and the timezone changes and goes into the past or future?
一些想法:
1)让应用程序始终跟踪当前时间与上次关闭时间。当您看到它倒退时,请在所有当前保存的游戏中增加一个计数器,并拒绝该计数器具有足够高值的游戏中的高分。
2)提交高分时,提交设备当前时间。如果这比服务器时间足够早,则拒绝高分。
3) 开始游戏时,请对照游戏当前版本的发布时间检查时间。如果用户据称在游戏发布之前开始游戏,请投诉。
A few ideas:
1) Have the app always keep track of current-time vs. last-closed-time. When you see it go backwards, increment a counter in all current saved games, and reject high scores from games where this counter has a sufficiently high value.
2) When submitting high scores, submit the device's current time. If that's sufficiently ahead of the server time, reject the high score.
3) When starting a game, check the time against the time at which the current version of the game was released. If the user is supposedly starting a game before the game was released, complain.