当用户退出 Google Play 服务时保存游戏的最佳做法?

Best practices for saving game when user has signed out of Google Play Services?

Google Play 游戏服务指南规定如下:"After signing in, the player must always have the option to sign out."

想象一下以下场景:

  1. 我下载了一款手机游戏,并在认证期间玩了几周
  2. 在这段时间里,我解锁了关卡并积累了游戏币(保存到云端)
  3. 我决定退出 Google Play 游戏服务,但继续玩游戏

我看到两个管理玩家数据的选项: 1.将他们所有的云保存数据复制到本地设备存储 2. 重新启动用户,将数据保存到本地存储(如果他们重新登录,他们将再次访问他们的云保存数据)

第一个选项听起来最合乎逻辑,但这也意味着如果用户再次登录,我会将本地数据同步回云端。因此,用户可以注销,直接在他们的设备上更改本地存储的首选项(例如添加 1000000 个硬币),然后重新登录并同步该数据。

我的问题是,尽管(某些)玩家有可能篡改他们的数据,但双向同步数据是否是 "correct" 解决此问题的方法?我已经找到了很多关于退出的信息,但不知道之后该怎么做。

谢谢!

这取决于游戏,如果它是基于故事的游戏,您可以通过使用保存菜单区分真实的云保存和离线保存来解决这个问题,因为您不受 API 的限制。 .如果它是基于高级货币的游戏,例如 100 颗宝石 1.00 美元,您应该将所有交易记录保存在服务器上,因为让用户有任何机会更改这些值是不明智的。

"A game can write an arbitrary number of Saved Games for a single player, subject to user quota, so there is no hard requirement to restrict players to a single save file. ... All Saved Games are stored in your players' Google Drive Application Data Folder. This folder can only be read and written by your game - it cannot be viewed or modified by other developers’ games, so there is additional protection against data corruption. ... Saved Games are insulated from direct tampering by players so they cannot modify individual Saved Games. ... In general, the best way to avoid data conflicts is to always load the latest data from the service when your application starts up or resumes, and save data to the service with reasonable frequency. ... Your application should make every effort to handle conflicts such that your users' data is preserved and that they have a good experience."

这里是 link,其中包含更多信息。

My question is, is synchronising the data both ways the "correct" way to go about this, despite the risk of (some) players being able to tamper with their data?

没有。将评分系统分为两个:

离线和在线得分。

当用户注销时,获取在线分数并将其保存到离线分数中。用户的离线分数将从用户离开在线分数的地方继续。

如果您决定再次登录,请使用在线评分。同时使用在线分数更新他们的离线分数。


通过这样做,您只是让玩家更难修改分数。如果游戏 运行 站在玩家这边,玩家可以 always 更改分数,前提是他们了解基本的 APK 逆向工程。数据不必保存在其他地方即可更改。它可以在内存中更改。它也可以通过反编译、更改代码、编译和签署 APK 来更改。


现在,如果您在服务器上 运行 制作游戏,但读取用户的输入,则除非您的服务器被黑,否则无法更改游戏。