File tree Expand file tree Collapse file tree
src/main/kotlin/dev/robothanzo/werewolf/game Expand file tree Collapse file tree Original file line number Diff line number Diff 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? {
Original file line number Diff line number Diff 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) {
You can’t perform that action at this time.
0 commit comments