Skip to content

Commit

Permalink
优化威逼逻辑
Browse files Browse the repository at this point in the history
  • Loading branch information
CuteReimu committed Dec 6, 2024
1 parent 5d81ebd commit 82adf7f
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/main/kotlin/Game.kt
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class Game(val id: Int, totalPlayerCount: Int, val actorRef: ActorRef) {
var playTime: Long = 0
val isEarly: Boolean
get() = turn <= players.size
val canWeiBiCardIds = ArrayList<Int>()

val waitSecond: Int
get() {
Expand Down
1 change: 1 addition & 0 deletions src/main/kotlin/card/FengYunBianHuan.kt
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ class FengYunBianHuan : Card {
val resolveFunc = { _: Boolean ->
ExecuteFengYunBianHuan(this@FengYunBianHuan, drawCards, players, fsm)
}
drawCards.forEach { g.canWeiBiCardIds.add(it.id) }
r.weiBiFailRate = 0
g.resolve(ResolveCard(r, r, null, getOriginCard(), Feng_Yun_Bian_Huan, resolveFunc, fsm))
}
Expand Down
7 changes: 5 additions & 2 deletions src/main/kotlin/card/WeiBi.kt
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ class WeiBi : Card {
r.weiBiFailRate++
ExecuteWeiBi(fsm, r, target, card, wantType)
} else {
target.cards.forEach { g.canWeiBiCardIds.add(it.id) }
r.weiBiFailRate = 0
logger.info("${target}${r}展示了所有手牌")
g.players.send { p ->
Expand Down Expand Up @@ -232,8 +233,10 @@ class WeiBi : Card {
it.isEnemy(player) &&
it.cards.any { card -> card.type in availableCardType }
}.run {
filter { it!!.cards.any { card -> card.type in listOf(Jie_Huo, Wu_Dao, Diao_Bao) } }.ifEmpty { this }
.run { if (player.identity != Black) filter { it!!.identity != Black }.ifEmpty { this } else this }
filter { it!!.cards.any { card -> card.id in player.game!!.canWeiBiCardIds } }.ifEmpty {
filter { it!!.cards.any { card -> card.type in listOf(Jie_Huo, Wu_Dao, Diao_Bao) } }.ifEmpty { this }
.run { if (player.identity != Black) filter { it!!.identity != Black }.ifEmpty { this } else this }
}
}.randomOrNull() ?: return false
val cardType =
if (player.weiBiFailRate > 0) listOf(Jie_Huo, Wu_Dao, Diao_Bao).random() // 威逼成功后一定纯随机
Expand Down
1 change: 1 addition & 0 deletions src/main/kotlin/phase/NextTurn.kt
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ data class NextTurn(override val whoseTurn: Player) : ProcessFsm() {
it!!.resetSkillUseCount()
it.useCardThisTurn = false
}
game.canWeiBiCardIds.clear()
InvalidSkill.reset(game)
OneTurnSkill.reset(game)
game.players.send { unknownWaitingToc { } }
Expand Down
1 change: 1 addition & 0 deletions src/main/kotlin/skill/HuoXin.kt
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ class HuoXin : MainPhaseSkill() {
g.continueResolve()
return
}
target.cards.forEach { g.canWeiBiCardIds.add(it.id) }
r.weiBiFailRate = 0
g.resolve(ExecuteHuoXin(g.fsm!!, r, target, showCards[0], waitingSecond))
}
Expand Down
1 change: 1 addition & 0 deletions src/main/kotlin/skill/JiBan.kt
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ class JiBan : MainPhaseSkill() {
}
r.incrSeq()
logger.info("${r}${cards.joinToString()}交给$target")
cards.forEach { g.canWeiBiCardIds.add(it.id) }
r.cards.removeAll(cards.toSet())
target.cards.addAll(cards)
g.players.send { p ->
Expand Down
1 change: 1 addition & 0 deletions src/main/kotlin/skill/JiaoJi.kt
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ class JiaoJi : MainPhaseSkill() {
}
r.incrSeq()
logger.info("${r}${cards.joinToString()}还给$target")
cards.forEach { g.canWeiBiCardIds.add(it.id) }
r.cards.removeAll(cards.toSet())
target.cards.addAll(cards)
g.players.send { p ->
Expand Down

0 comments on commit 82adf7f

Please sign in to comment.