Skip to content

Commit

Permalink
last_get_time发给客户端时调整一下数值
Browse files Browse the repository at this point in the history
  • Loading branch information
CuteReimu committed Dec 13, 2023
1 parent 67eb52e commit 69435b5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/main/kotlin/message/GetSpellsCs.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class GetSpellsCs : Handler {
if (player.roomId.isNullOrEmpty()) throw HandlerException("不在房间里")
val room = Store.getRoom(player.roomId) ?: throw HandlerException("找不到房间")
if (!room.started) throw HandlerException("游戏还未开始")
val now = System.currentTimeMillis()
ctx.writeMessage(
Message(
reply = protoName,
Expand All @@ -27,7 +28,9 @@ class GetSpellsCs : Handler {
status = IntArray(room.spellStatus!!.size) { i -> room.spellStatus!![i].value },
linkData = room.linkData,
phase = room.phase,
lastGetTime = room.lastGetTime
lastGetTime = room.lastGetTime.map {
if (room.pauseBeginMs > 0) it + (now - room.pauseBeginMs) else it
}.toLongArray()
)
)
)
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/message/StopGameCs.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class StopGameCs(val winner: Int) : Handler {
}
room.started = false
room.spells = null
room.lastGetTime.run { indices.forEach { this[it] = 0 } }
room.lastGetTime.indices.forEach { room.lastGetTime[it] = 0 }
room.startMs = 0
// room.gameTime = 0
// room.countDown = 0
Expand Down

0 comments on commit 69435b5

Please sign in to comment.