Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

优化秦无命技能使用时机 #290

Merged
merged 2 commits into from
Sep 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 60 additions & 14 deletions src/main/kotlin/skill/PinMingSanLang.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ package com.fengsheng.skill

import com.fengsheng.*
import com.fengsheng.RobotPlayer.Companion.bestCard
import com.fengsheng.card.count
import com.fengsheng.card.countTrueCard
import com.fengsheng.card.*
import com.fengsheng.phase.MainPhaseIdle
import com.fengsheng.protos.Common.card_type.Cheng_Qing
import com.fengsheng.protos.Common.color.*
Expand Down Expand Up @@ -74,20 +73,67 @@ class PinMingSanLang : MainPhaseSkill() {
fun ai(e: MainPhaseIdle, skill: ActiveSkill): Boolean {
val p = e.whoseTurn
p.getSkillUseCount(SkillId.PIN_MING_SAN_LANG) == 0 || return false
if (p.messageCards.count(Black) == 2) {
if (p.identity == Black) {
when (p.secretTask) {
Killer -> if (p.messageCards.countTrueCard() < 2) return false
Pioneer -> if (p.messageCards.countTrueCard() < 1) return false
Sweeper -> if (p.messageCards.run { count(Red) > 1 || count(Blue) > 1 }) return false
else -> return false
val card = p.cards.run {
// 已经有2黑
if (p.messageCards.count(Black) == 2) {
if (p.identity == Black) {
// 如果是镇压者、先行者、清道夫,且自身达到任务条件,可以不考虑澄清
if ((p.secretTask == Killer && p.messageCards.countTrueCard() < 2) ||
(p.secretTask == Pioneer && p.messageCards.countTrueCard() < 1) ||
(p.secretTask == Sweeper && p.messageCards.run { count(Red) > 1 || count(Blue) > 1 })) {
filter { it.isPureBlack() }.ifEmpty { return false }.bestCard(p.identity, true)
}
// 其他神秘人不能自杀
else {
p.cards.filter { it.isPureBlack() }.ifEmpty { return false }
.run {
// 只有一张纯黑色手牌且是澄清
if (this.size == 1 && this[0].type == Cheng_Qing) {
// 没有其他澄清,不能自杀
if (p.cards.filter { it.type == Cheng_Qing }.size == 1) {
return false
}
// 有其他澄清,可以用这张澄清自杀
else {
this[0]
}
}
// 其他情况,手里有澄清才能自杀
else {
if (p.cards.filter { it.type == Cheng_Qing }.isEmpty()) {
return false
} else {
this.bestCard(p.identity, true)
}
}
}
}
}
} else if (!p.cards.any { it.type == Cheng_Qing })
return false
else
p.getSkillUseCount(SkillId.YU_SI_WANG_PO) > 0 || return false
// 阵营角色不能自杀
else {
p.cards.filter { it.isPureBlack() }.ifEmpty { return false }
.run {
if (this.size == 1 && this[0].type == Cheng_Qing) {
if (p.cards.filter { it.type == Cheng_Qing }.size == 1) {
return false
} else {
this[0]
}
} else {
if (p.cards.filter { it.type == Cheng_Qing }.isEmpty()) {
return false
} else {
this.bestCard(p.identity, true)
}
}
}
}
}
// 还没到2黑,可以随便选纯黑色牌
else {
filter { it.isPureBlack() }.ifEmpty { return false }.bestCard(p.identity, true)
}
}
val card = p.cards.filter { it.isPureBlack() }.ifEmpty { return false }.bestCard(p.identity, true)
GameExecutor.post(p.game!!, {
skill.executeProtocol(p.game!!, p, skillPinMingSanLangTos { cardId = card.id })
}, 3, TimeUnit.SECONDS)
Expand Down