Skip to content

Commit

Permalink
修复凌素秋死了也能发动寸步不让的bug
Browse files Browse the repository at this point in the history
  • Loading branch information
CuteReimu committed Nov 3, 2023
1 parent 98061cc commit af70e44
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 8 deletions.
4 changes: 4 additions & 0 deletions doc/Skill.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,7 @@
## 影响游戏结果的技能

有一种特殊的技能叫`ChangeGameResultSkill`,它会影响游戏结果

## 自己死亡前的技能

有一种特殊的技能叫`BeforeDieSkill`。对于这种技能,自己无需存活也能发动。
4 changes: 2 additions & 2 deletions src/main/kotlin/Game.kt
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ class Game private constructor(totalPlayerCount: Int) {
/**
* 遍历监听列表,结算技能
*/
fun dealListeningSkill(beginLocation: Int, includingDead: Boolean = false): ResolveResult? {
fun dealListeningSkill(beginLocation: Int): ResolveResult? {
repeat(100) { // 写个100,防止死循环
if (resolvingEvents.isEmpty()) {
if (unresolvedEvents.isEmpty()) return null
Expand All @@ -378,7 +378,7 @@ class Game private constructor(totalPlayerCount: Int) {
do {
val player = players[i]!!
player.skills.forEach { skill ->
if (includingDead || player.alive || skill !is InitialSkill)
if (player.alive || skill is BeforeDieSkill || skill !is InitialSkill)
(skill as? TriggeredSkill)?.execute(this, player)?.let { return it }
}
i = (i + 1) % players.size
Expand Down
4 changes: 1 addition & 3 deletions src/main/kotlin/ProcessFsm.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ abstract class ProcessFsm : Fsm {

open val needCheckWinAndDying = true

open val needCheckDieSkill = false

/** 刚切到这个状态时执行的操作 */
open fun onSwitch() {}

Expand All @@ -28,7 +26,7 @@ abstract class ProcessFsm : Fsm {
justSwitch = false
onSwitch()
}
val result = whoseTurn.game!!.dealListeningSkill(whoseTurn.location, needCheckDieSkill)
val result = whoseTurn.game!!.dealListeningSkill(whoseTurn.location)
if (result != null) return result
if (needCheckWinAndDying) {
val winResult = checkWin()
Expand Down
1 change: 0 additions & 1 deletion src/main/kotlin/phase/WaitForDieGiveCard.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ data class WaitForDieGiveCard(
val afterDieResolve: Fsm
) : ProcessFsm() {
override val needCheckWinAndDying = false
override val needCheckDieSkill = true

/**
* 结算到dieQueue的第几个人的死亡给三张牌了
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/skill/RuGui.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import java.util.concurrent.TimeUnit
/**
* 老汉技能【如归】:你死亡前,可以将你情报区中的一张情报置入当前回合角色的情报区中。
*/
class RuGui : InitialSkill, TriggeredSkill {
class RuGui : InitialSkill, TriggeredSkill, BeforeDieSkill {
override val skillId = SkillId.RU_GUI

override fun execute(g: Game, askWhom: Player): ResolveResult? {
Expand Down
5 changes: 5 additions & 0 deletions src/main/kotlin/skill/Skill.kt
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,8 @@ interface OneTurnSkill : Skill {
}
}
}

/**
* 自己死亡前技能。对于这种技能,自己无需存活也能发动。
*/
interface BeforeDieSkill : Skill
2 changes: 1 addition & 1 deletion src/main/kotlin/skill/YiXin.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import java.util.concurrent.TimeUnit
/**
* 李宁玉技能【遗信】:你死亡前,可以将一张手牌置入另一名角色的情报区。
*/
class YiXin : InitialSkill, TriggeredSkill {
class YiXin : InitialSkill, TriggeredSkill, BeforeDieSkill {
override val skillId = SkillId.YI_XIN

override fun execute(g: Game, askWhom: Player): ResolveResult? {
Expand Down

0 comments on commit af70e44

Please sign in to comment.