Skip to content

Commit

Permalink
增加“获取最近一次游戏距离现在的时间”接口
Browse files Browse the repository at this point in the history
  • Loading branch information
CuteReimu committed Sep 6, 2024
1 parent e0ddc3c commit ab1d583
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ push.push_qq_groups=12345678
| /addmessagecard | player=0&card=1&colors=0&count=1 | 其中player参数对应**服务器中的**玩家Id,card参数对应协议中的卡牌类型,colors参数对应协议中的卡牌颜色,count参数(非必填,默认1)为增加卡牌的个数 |
| /addrobot | count=1 | 其中count参数对应想要增加机器人的个数,不填表示加满 |
| /getscore | name=aaa | 其中name参数是想要获取分数的玩家名字 |
| /getlasttime | name=aaa | 获取最近一次游戏距离现在的时间,其中name参数是想要获取分数的玩家名字 |
| /ranklist || 获取排行榜 |
| /resetpwd | name=aaa | 其中name参数是想要重置密码的玩家名字(重置为空,玩家可以自行重新设置) |
| /forbidrole | name=aaa | 禁用角色,禁用的角色不会再出现在角色池里,其中name参数是想要禁用的中文角色名 |
Expand All @@ -101,6 +102,7 @@ push.push_qq_groups=12345678
| /winrate || 返回一张胜率统计的png图片 |
| /resetseason || 重置赛季,重置前请手动备份PlayerInfo.csv |
| /addenergy | name=aaa&energy=1 | 增加精力 |
| /getallgames || 获取所有房间的状态 |

## 把战绩推送到QQ群

Expand Down
20 changes: 20 additions & 0 deletions src/main/kotlin/gm/Getlasttime.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.fengsheng.gm

import com.fengsheng.Statistics
import java.util.function.Function

class Getlasttime : Function<Map<String, String>, Any> {
override fun apply(form: Map<String, String>): Any {
return try {
val name = form["name"]!!
val playerInfo = Statistics.getPlayerInfo(name)
if (playerInfo == null) {
"{\"result\": \"${name}已身死道消\"}"
} else {
"{\"result\": \"${System.currentTimeMillis() - playerInfo.lastTime}\"}"
}
} catch (e: NullPointerException) {
"{\"error\": \"参数错误\"}"
}
}
}

0 comments on commit ab1d583

Please sign in to comment.