Skip to content

Commit

Permalink
游戏暂停时,上次收卡时间也暂停
Browse files Browse the repository at this point in the history
  • Loading branch information
CuteReimu committed Dec 13, 2023
1 parent 1e34c2d commit a257aeb
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/main/kotlin/Room.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class Room(
val lastGetTime = longArrayOf(0, 0) // 上次收卡时间
var totalPauseMs: Long = 0 // 累计暂停时长,毫秒
var pauseBeginMs: Long = 0 // 开始暂停时刻,毫秒,0表示没暂停
var pauseEndMs: Long = 0 // 上一次结束暂停的时刻,毫秒,0表示从未暂停过
var lastWinner: Int = 0 // 上一场是谁赢,1或2
var bpData: BpData? = null
var linkData: LinkData? = null
Expand Down
1 change: 1 addition & 0 deletions src/main/kotlin/message/GetSpellsCs.kt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class GetSpellsCs : Handler {
banPick = room.bpData?.banPick ?: 0,
totalPauseTime = room.totalPauseMs,
pauseBeginMs = room.pauseBeginMs,
pauseEndMs = room.pauseEndMs,
status = IntArray(room.spellStatus!!.size) { i -> room.spellStatus!![i].value },
linkData = room.linkData,
phase = room.phase,
Expand Down
5 changes: 4 additions & 1 deletion src/main/kotlin/message/PauseCs.kt
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,11 @@ class PauseCs(val pause: Boolean) : Handler {
room.pauseBeginMs = now
} else {
if (room.pauseBeginMs != 0L) {
room.totalPauseMs += now - room.pauseBeginMs
val delta = now - room.pauseBeginMs
room.totalPauseMs += delta
room.lastGetTime.forEachIndexed { i, v -> if (v > 0) room.lastGetTime[i] = v + delta }
room.pauseBeginMs = 0
room.pauseEndMs = now
}
}
Store.putRoom(room)
Expand Down
1 change: 1 addition & 0 deletions src/main/kotlin/message/SpellListSc.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class SpellListSc(
val banPick: Int,
val totalPauseTime: Long,
val pauseBeginMs: Long,
val pauseEndMs: Long,
val status: IntArray?,
val phase: Int,
val linkData: LinkData?,
Expand Down
1 change: 1 addition & 0 deletions src/main/kotlin/message/StartGameCs.kt
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class StartGameCs : Handler {
linkData = room.linkData,
phase = room.phase,
pauseBeginMs = 0L,
pauseEndMs = 0L,
status = null,
totalPauseTime = 0L,
lastGetTime = room.lastGetTime
Expand Down
1 change: 1 addition & 0 deletions src/main/kotlin/message/StopGameCs.kt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class StopGameCs(val winner: Int) : Handler {
room.spellStatus = null
room.totalPauseMs = 0
room.pauseBeginMs = 0
room.pauseEndMs = 0
room.bpData = null
Store.putRoom(room)
if (winner == -1)
Expand Down

0 comments on commit a257aeb

Please sign in to comment.