我对每项攻击功能的伤害都会增加。即使我console.log在服务器端和客户端损坏我。第一次单击会给它带来3000点好的伤害,第二次单击会给另一个Click 9000造成6000伤害,等等。为什么会这样?这是我的代码:
服务器端:
$ cat tst.awk
BEGIN {
FS = "[, :]"
OFS = ","
split("Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec",tmp)
for (i in tmp) {
mth[tmp[i]] = i
}
maxSecs = 5 * 60
}
{
begSecs = mktime($10" "mth[$4]" "$5" "$6" "$7" "$8)
endSecs = mktime($18" "mth[$12]" "$13" "$14" "$15" "$16)
print $0, ( (endSecs - begSecs) > maxSecs ? "yes" : "no" )
}
$ awk -f tst.awk file
D00O0:SOURCE3,Mon Oct 01 16:02:35 AST 2018,Mon Oct 01 16:04:19 AST 2018,no
D00O0:SOURCE3,Mon Oct 08 08:53:17 AST 2018,Mon Oct 08 08:54:57 AST 2018,no
D00O1:SOURCE3,Mon Oct 15 09:25:14 AST 2018,Mon Oct 15 09:26:59 AST 2018,no
D00O1:SOURCE3,Mon Oct 15 16:56:58 AST 2018,Mon Oct 15 17:58:41 AST 2018,yes
D00O1:SOURCE3,Mon Oct 22 08:56:48 AST 2018,Mon Oct 22 09:58:31 AST 2018,yes
D00O1:SOURCE3,Sat Oct 06 09:17:42 AST 2018,Sat Oct 06 09:19:24 AST 2018,no
D00O1:SOURCE3,Sat Oct 13 09:11:05 AST 2018,Sat Oct 13 09:12:47 AST 2018,no
D00O1:SOURCE3,Sat Oct 20 09:51:40 AST 2018,Sat Oct 20 09:53:23 AST 2018,no
D00O0:SOURCE3,Sat Oct 27 09:15:32 AST 2018,Sat Oct 27 09:17:11 AST 2018,no
D00O0:SOURCE3,Sat Sep 29 10:05:58 AST 2018,Sat Sep 29 11:07:43 AST 2018,yes
D00O0:SOURCE3,Sun Oct 14 08:48:57 AST 2018,Sun Oct 14 09:50:43 AST 2018,yes
D00O0:SOURCE3,Sun Oct 14 16:04:19 AST 2018,Sun Oct 14 16:06:00 AST 2018,no
D00O0:SOURCE3,Sun Oct 21 06:17:34 AST 2018,Sun Oct 21 06:19:17 AST 2018,no
D00O0:SOURCE3,Sun Oct 21 16:15:18 AST 2018,Sun Oct 21 17:17:00 AST 2018,yes
D00O0:SOURCE3,Sun Oct 28 09:39:09 AST 2018,Sun Oct 28 09:40:47 AST 2018,no
客户端
if(socket.id === data.playerID) {
let damage = 3000;
console.log(damage); // 3000 everytime
io.emit('attack-damage', {
damage: damage
});
}