Skip to content

Commit 68fe110

Browse files
committed
magician fixed and tested
1 parent f903e55 commit 68fe110

2 files changed

Lines changed: 10 additions & 6 deletions

File tree

src/main/kotlin/dev/robothanzo/werewolf/game/roles/actions/MagicianSwapAction.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@ class MagicianSwapAction : BaseRoleAction(
3232
alivePlayers: List<Int>,
3333
accumulatedState: ActionExecutionResult
3434
): List<Int> {
35-
// Can swap any two players (including self, dead players? description says "exchange two players' numbers")
36-
// Usually Magician can swap anyone.
35+
// Can swap any two alive players.
3736
// Constraint: "Each number can only be exchanged once."
38-
// Allow selecting already-swapped targets so they can be deselected in UI
39-
return session.players.keys.map { it.toInt() }
37+
// We filter out players whose numbers have been swapped in previous nights.
38+
val usedTargets = session.stateData.magicianSwapTargets
39+
return alivePlayers.filter { it !in usedTargets }
4040
}
4141

4242
override fun validate(session: Session, actor: Int, targets: List<Int>): String? {

src/main/kotlin/dev/robothanzo/werewolf/game/steps/NightStep.kt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -523,8 +523,12 @@ internal object NightSequence {
523523
var actions =
524524
lockedSession.getAvailableActionsForPlayer(pid, step.roleRegistry, ignoreEffect = true)
525525
if (player.wolf) actions = actions.filter { it.actionId != ActionDefinitionId.WEREWOLF_KILL }
526-
if (player.roles.contains("夢魘")) actions =
527-
actions.filter { it.actionId != ActionDefinitionId.NIGHTMARE_FEAR }
526+
actions =
527+
actions.filter { action -> // we don't want to re-execute actions that were executed already at prior phases (e.g. wolf yb, nightmare and magician...etc)
528+
lockedSession.stateData.submittedActions.none {
529+
it.actor == pid && it.actionDefinitionId == action.actionId && it.status.executed
530+
}
531+
}
528532

529533
if (actions.isNotEmpty()) {
530534
if (currentFearedId != null && currentFearedId == pid) {

0 commit comments

Comments
 (0)