Skip to content

Commit

Permalink
优化李宁玉、老汉AI(fix #277)(fix #278)(#175)
Browse files Browse the repository at this point in the history
  • Loading branch information
CuteReimu committed Sep 2, 2024
1 parent 4a73f0a commit 7372184
Showing 1 changed file with 40 additions and 3 deletions.
43 changes: 40 additions & 3 deletions src/main/kotlin/MessageCardValue.kt
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ fun Player.calculateMessageCardValue(
override fun canUse(g: Game, r: Player, vararg args: Any) = false
override fun execute(g: Game, r: Player, vararg args: Any) = Unit
}
if (sender.skills.any { it is MianLiCangZhen }) {
if (sender.skills.any { it is MianLiCangZhen }) { // 邵秀
inFrontOfWhom.messageCards.add(TmpCard(colors))
var valueSender = -1
var valueMe = 0
Expand All @@ -236,7 +236,7 @@ fun Player.calculateMessageCardValue(
v1 += valueMe
inFrontOfWhom.messageCards.removeLast()
}
if (Black !in colors && sender.skills.any { it is ChiZiZhiXin } && sender !== inFrontOfWhom) {
if (Black !in colors && sender.skills.any { it is ChiZiZhiXin } && sender !== inFrontOfWhom) { // 青年小九
inFrontOfWhom.messageCards.add(TmpCard(colors))
var valueSender = 30
var valueMe = 0
Expand All @@ -256,7 +256,7 @@ fun Player.calculateMessageCardValue(
inFrontOfWhom.messageCards.removeLast()
}
// TODO CP韩梅还要判断一下拿牌,这里就暂时先不写了
if (Blue in colors && sender.skills.any { it is AnCangShaJi }) {
if (Blue in colors && sender.skills.any { it is AnCangShaJi }) { // SP韩梅
inFrontOfWhom.messageCards.add(TmpCard(colors))
if (sender.cards.any { it.isPureBlack() }) {
val v = sender.calculateMessageCardValue(whoseTurn, inFrontOfWhom, listOf(Black))
Expand All @@ -267,6 +267,40 @@ fun Player.calculateMessageCardValue(
}
inFrontOfWhom.messageCards.removeLast()
}
if (Black in colors && inFrontOfWhom.skills.any { it is ShiSi }) { // 老汉【视死】
v1 += 20
}
if (Black in colors && inFrontOfWhom.skills.any { it is YiXin } && inFrontOfWhom.messageCards.count(Black) == 2) {
// 李宁玉【遗信】
var liNingYuValue = Int.MIN_VALUE
var myValue = Int.MIN_VALUE
for (handCard in inFrontOfWhom.cards) {
for (p in game!!.players) {
if (!p!!.alive || p === inFrontOfWhom) continue
val v = inFrontOfWhom.calculateMessageCardValue(whoseTurn, p, handCard)
if (v > liNingYuValue) {
liNingYuValue = v
myValue = calculateMessageCardValue(whoseTurn, p, handCard)
}
}
}
v1 += myValue
}
if (Black in colors && inFrontOfWhom.skills.any { it is RuGui } && inFrontOfWhom.messageCards.count(Black) == 2) {
// 老汉【如归】
if (whoseTurn !== inFrontOfWhom && whoseTurn.alive) {
var laoHanValue = Int.MIN_VALUE
var myValue = Int.MIN_VALUE
for (mCard in inFrontOfWhom.messageCards + TmpCard(colors)) {
val v = inFrontOfWhom.calculateMessageCardValue(whoseTurn, whoseTurn, mCard)
if (v > laoHanValue) {
laoHanValue = v
myValue = calculateMessageCardValue(whoseTurn, whoseTurn, mCard)
}
}
v1 += myValue
}
}
}
return v1
}
Expand Down Expand Up @@ -572,6 +606,9 @@ fun Player.calSendMessageCard(
* 是否要救人
*/
fun Player.wantToSave(whoseTurn: Player, whoDie: Player): Boolean {
if (whoDie.skills.any { it is RuGui } && whoDie.messageCards.isNotEmpty() ||
whoDie.skills.any { it is YiXin } && whoDie.cards.isNotEmpty())
return false // 如果李宁玉有手牌|老汉有情报,则所有人都不救
var save = isPartnerOrSelf(whoDie)
var notSave = false
val killer = game!!.players.find { it!!.alive && it.identity == Black && it.secretTask == Killer }
Expand Down

0 comments on commit 7372184

Please sign in to comment.