Skip to content

Commit d9e4bce

Browse files
committed
增加“获取最近一次游戏距离现在的时间”接口
1 parent e0ddc3c commit d9e4bce

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ push.push_qq_groups=12345678
8686
| /addmessagecard | player=0&card=1&colors=0&count=1 | 其中player参数对应**服务器中的**玩家Id,card参数对应协议中的卡牌类型,colors参数对应协议中的卡牌颜色,count参数(非必填,默认1)为增加卡牌的个数 |
8787
| /addrobot | count=1 | 其中count参数对应想要增加机器人的个数,不填表示加满 |
8888
| /getscore | name=aaa | 其中name参数是想要获取分数的玩家名字 |
89+
| /getlasttime | name=aaa | 获取最近一次游戏距离现在的时间,其中name参数是想要获取分数的玩家名字 |
8990
| /ranklist || 获取排行榜 |
9091
| /resetpwd | name=aaa | 其中name参数是想要重置密码的玩家名字(重置为空,玩家可以自行重新设置) |
9192
| /forbidrole | name=aaa | 禁用角色,禁用的角色不会再出现在角色池里,其中name参数是想要禁用的中文角色名 |
@@ -101,6 +102,7 @@ push.push_qq_groups=12345678
101102
| /winrate || 返回一张胜率统计的png图片 |
102103
| /resetseason || 重置赛季,重置前请手动备份PlayerInfo.csv |
103104
| /addenergy | name=aaa&energy=1 | 增加精力 |
105+
| /getallgames || 获取所有房间的状态 |
104106

105107
## 把战绩推送到QQ群
106108

src/main/kotlin/gm/Getlasttime.kt

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package com.fengsheng.gm
2+
3+
import com.fengsheng.Statistics
4+
import java.util.function.Function
5+
6+
class Getlasttime : Function<Map<String, String>, Any> {
7+
override fun apply(form: Map<String, String>): Any {
8+
return try {
9+
val name = form["name"]!!
10+
val playerInfo = Statistics.getPlayerInfo(name)
11+
if (playerInfo == null || playerInfo.score <= 0) "{\"result\": 0}"
12+
else "{\"result\": \"${System.currentTimeMillis() - playerInfo.lastTime}\"}"
13+
} catch (e: NullPointerException) {
14+
"{\"error\": \"参数错误\"}"
15+
}
16+
}
17+
}

0 commit comments

Comments
 (0)