Skip to content

Commit

Permalink
修复棋手被威逼超时或托管后不能发动技能的bug
Browse files Browse the repository at this point in the history
  • Loading branch information
CuteReimu committed Oct 8, 2023
1 parent 4359f2e commit 58bb041
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions src/main/kotlin/card/WeiBi.kt
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,11 @@ class WeiBi : Card {
builder.playerId = p.getAlternativeLocation(r.location)
builder.targetPlayerId = p.getAlternativeLocation(target.location)
if (p === target) {
val seq2: Int = p.seq
builder.seq = seq2
val seq = p.seq
builder.seq = seq
p.timeout = GameExecutor.post(r.game!!, {
if (p.checkSeq(seq2)) {
p.incrSeq()
if (p.checkSeq(seq)) {
autoSelect()
r.game!!.resolve(MainPhaseIdle(r))
}
}, p.getWaitSeconds(builder.waitingSecond + 2).toLong(), TimeUnit.SECONDS)
}
Expand All @@ -73,7 +71,6 @@ class WeiBi : Card {
if (target is RobotPlayer) {
GameExecutor.post(r.game!!, {
autoSelect()
r.game!!.resolve(MainPhaseIdle(r))
}, 2, TimeUnit.SECONDS)
}
return null
Expand Down Expand Up @@ -117,9 +114,11 @@ class WeiBi : Card {
}

private fun autoSelect() {
val availableCards = target.cards.filter { it.type == wantType }
val card = availableCards.random()
resolveProtocol(target, wei_bi_give_card_tos.newBuilder().setCardId(card.id).build())
val card = target.cards.filter { it.type == wantType }.random()
val builder = wei_bi_give_card_tos.newBuilder()
builder.cardId = card.id
if (target is HumanPlayer) builder.seq = target.seq
target.game!!.tryContinueResolveProtocol(target, builder.build())
}

companion object {
Expand Down

0 comments on commit 58bb041

Please sign in to comment.