Skip to content

Commit 7a96b89

Browse files
committed
fixed tests
1 parent a6cffd1 commit 7a96b89

3 files changed

Lines changed: 8 additions & 15 deletions

File tree

src/main/kotlin/dev/robothanzo/werewolf/database/documents/Player.kt

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -418,11 +418,10 @@ data class Player(
418418
// 1. Process THIS player first
419419
// On Day 1, everyone gets Last Words. On later days, usually only the first night death or similar.
420420
// For simplicity, we respect the allowLastWords flag passed to runDeathEvents,
421-
// but since this is the *entry point* for a death chain, we assume this player SHOULD get them
422421
// or specific logic inside runDeathEvents/call sites handles it.
423422
// For EXPEL/HUNTER cases on Day 1, they should get it.
424-
val isDayOne = session.day <= 1
425-
runDeathEvents(isDayOne)
423+
val allowLastWords = session.day <= 1
424+
runDeathEvents(allowLastWords)
426425

427426
// 2. Loop for others (Cascading Deaths)
428427
while (true) {
@@ -437,8 +436,8 @@ data class Player(
437436
} ?: break
438437

439438
try {
440-
// All cascading victims on Day 1 get last words (Request: "players killed by hunter's skill on the first day")
441-
nextVictim.runDeathEvents(isDayOne)
439+
// All cascading victims on Day 1 get last words
440+
nextVictim.runDeathEvents(allowLastWords)
442441
} catch (e: Exception) {
443442
e.printStackTrace()
444443
// Failsafe: mark processed so we don't loop forever

src/test/kotlin/dev/robothanzo/werewolf/game/PlayerDeathTests.kt

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -315,20 +315,14 @@ class PlayerDeathTests {
315315
}
316316

317317
@Test
318-
fun `test processCascadingDeaths allows Last Words on Day 2`() = runBlocking {
318+
fun `test processCascadingDeaths NO Last Words on Day 2`() = runBlocking {
319319
// Arrange
320320
session.day = 2
321321

322322
// Player 1 dies
323323
player.roles.clear(); player.deadRoles.add("Villager")
324324

325325
// Mock acts
326-
doAnswer {
327-
@Suppress("UNCHECKED_CAST")
328-
val callback = it.arguments[3] as () -> Unit
329-
callback.invoke()
330-
}.whenever(speechService).startLastWordsSpeech(any(), any(), any(), any())
331-
332326
doAnswer { (it.arguments[3] as () -> Unit).invoke() }.whenever(policeService)
333327
.transferPolice(any(), any(), any(), any())
334328

@@ -339,8 +333,8 @@ class PlayerDeathTests {
339333
withTimeout(5000) { while (!finished) delay(100) }
340334

341335
// Assert
342-
// Day 2 -> processCascadingDeaths sets allowLastWords = true (due to <= 2 relax)
343-
verify(speechService, times(1)).startLastWordsSpeech(any(), any(), any(), any())
336+
// Day 2 -> processCascadingDeaths sets allowLastWords = false
337+
verify(speechService, never()).startLastWordsSpeech(any(), any(), any(), any())
344338
assertTrue(session.stateData.processedDeathPlayerIds.contains(1))
345339
}
346340

src/test/kotlin/dev/robothanzo/werewolf/game/roles/HunterTests.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ class HunterTests {
9494
assertFalse(session.stateData.playerOwnedActions[hunterPlayer.id]?.containsKey(ActionDefinitionId.HUNTER_REVENGE.toString()) == true)
9595
verify(mockChannel).sendMessage(check<String> { content ->
9696
assertTrue(content.contains("毒死"))
97-
assertTrue(content.contains("無法帶走"))
97+
assertTrue(content.contains("無法發動技能"))
9898
})
9999
}
100100

0 commit comments

Comments
 (0)