在基于JavaScript的游戏中制作在线高分列表的最佳做法是什么? [英] What are the best practices for making online high score lists in JavaScript based games?

查看:110
本文介绍了在基于JavaScript的游戏中制作在线高分列表的最佳做法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

[我知道有关防止高分榜上作弊的类似问题,但没有答案对我基于JavaScript的游戏没有真正的帮助,所以在告诉我类似之前请尝试考虑我的问题帖子。我询问最佳实践,因为JavaScript总是对用户可见,因此无法完全防止作弊,我只是想让它变得更难。]

[I know there have been similar questions about preventing cheating on high score lists, but no answer didn't really help me for JavaScript based games, so please try to think about my question, before telling me about similar posts. I ask about best practices because the JavaScript is always visible for the user and therefore it is not possible to prevent cheating completly, I just want to make it harder.]

我正在开发一款适用于浏览器的基于JavaScript的游戏。我想制作一个包含用户名和所有用户分数的高分列表。为了达到这个目的,浏览器将用户名和分数发送到我的服务器(通过AJAX)。

I'm developing a JavaScript based game that works in the browser. I want to make a high score list that contains the user name and the score of all users. To achieve that the browser sends the username and the score to my server (via AJAX).

将虚假分数提交到此列表将非常简单:可以看看在AJAX请求,然后用假的分数制作一个自己的AJAX请求。使用必须与其他数据一起发送的令牌之类的内容毫无意义,因为它很容易被发现。

Submitting fake scores to this list would be fairly easy: One could take a look at the AJAX requests and then make an own AJAX request with a faked score. Using something like a token that has to be send with the other data is pointless, as it will be easy to discover.

我唯一可以防止作弊的方法是将每个用户操作的描述发送到服务器并计算其中的分数。但这实际上并不可行,因为服务器太多了。

My only approach, that would prevent cheating, would be to send a description of every user action to the server and calculate the score there. But this is not really practicable as it would be too much for the server.

我接受了答案,但万一有人对如何制作有其他想法作弊更难,请创建另一个答案!

推荐答案

你几乎回答了自己的问题。如果你想真的让用户更难欺骗,可以将游戏日志发送到服务器,在那里你可以计算得分。

You pretty much answered your own question. If you want to really make it harder for users to cheat, send game log to the server, where you'll calculate the score.

您不必发送所有事件,只需发送影响结果得分的事件。

You don't have to send all the events, just ones that affect result score.

但是,有一些技巧可能有所帮助您:

There are some techniques, though, that may help you:


  • 在您的请求中包含签名。像MD5(secret_key + params)之类的东西。虽然秘密密钥必须在JS源代码中,但它将有效地保护您免受简单的请求拦截(参见篡改数据 Charles

如果是多人游戏,请接受客户计算的分数并进行比较。骗子将非常明显(假设大多数用户都诚实)。

if it's a multiplayer game, accept scores calculated by clients and compare them. Cheaters will be pretty visible (assuming that the majority of users are honest).

你可以设置一个分数上限,一个无法达到的结果。发表得分高于此的每个人都是骗子。例如,速度打字游戏:没有人能以1500字符/分钟输入正确的文字,甚至700也很难(尽管可以实现)。

you can set a score cap, an "unreachable" result. Everyone who posts score higher than this is a cheater. For example, speed typing game: no one can type correct text at 1500 chars/minute, even 700 is pretty damn hard (though achievable).

这篇关于在基于JavaScript的游戏中制作在线高分列表的最佳做法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆