public override double CardValue(TrustedAI ai, Player player, bool use, WrappedCard card, Player.Place place) { double value = ai.AjustWeaponRangeValue(player, card); foreach (Player p in ai.GetEnemies(player)) { if (RoomLogic.HasShownArmorEffect(ai.Room, p) && RoomLogic.DistanceTo(ai.Room, player, p, null, true) <= 2) { value += 0.5; } } return(value); }
public override bool OnSkillInvoke(TrustedAI ai, Player player, object data) { if (ai.WillShowForAttack()) { Room room = ai.Room; int adjust = RoomLogic.PlayerHasShownSkill(room, player, "mashu_madai") ? 0 : -1; foreach (Player p in room.GetOtherPlayers(player)) { if (!ai.IsFriend(p) && RoomLogic.DistanceTo(room, player, p) + adjust <= 1) { return(true); } } } return(false); }
public override List <Player> OnPlayerChosen(TrustedAI ai, Player player, List <Player> targets, int min, int max) { Room room = ai.Room; if (room.GetTag("extra_target_skill") is CardUseStruct use) { List <Player> result = new List <Player>(); if (use.Card.Name == ExNihilo.ClassName) { foreach (Player p in targets) { if (ai.IsFriend(p) && !ai.HasSkill("zishu", p)) { return new List <Player> { p } } } ; } else if (use.Card.Name.Contains(Slash.ClassName)) { List <ScoreStruct> scores = ai.CaculateSlashIncome(player, new List <WrappedCard> { use.Card }, targets, false); if (scores.Count > 0 && scores[0].Score > 0) { return(scores[0].Players); } } else if (use.Card.Name == Snatch.ClassName) { foreach (Player p in targets) { if (ai.FindCards2Discard(player, p, use.Card.Name, "hej", HandlingMethod.MethodGet).Score > 0) { return new List <Player> { p } } ; } } else if (use.Card.Name == Dismantlement.ClassName) { foreach (Player p in targets) { if (ai.FindCards2Discard(player, p, use.Card.Name, "hej", HandlingMethod.MethodDiscard).Score > 0) { return new List <Player> { p } } ; } } else if (use.Card.Name == IronChain.ClassName) { foreach (Player p in targets) { if (ai.IsFriend(p) && !ai.HasSkill("jieying", p) && p.Chained) { return new List <Player> { p } } ; } foreach (Player p in targets) { if (ai.IsEnemy(p) && !p.Chained) { return new List <Player> { p } } ; } } else if (use.Card.Name == FireAttack.ClassName) { foreach (Player p in targets) { if (ai.IsEnemy(p)) { return new List <Player> { p } } ; } } else if (use.Card.Name == Duel.ClassName) { WrappedCard duel = use.Card; List <Player> enemies = ai.Exclude(ai.GetEnemies(player), duel); List <Player> friends = ai.Exclude(ai.FriendNoSelf, duel); int n1 = ai.GetKnownCardsNums(Slash.ClassName, "he", player); if (ai.HasSkill("wushuang")) { n1 *= 2; } List <ScoreStruct> scores = new List <ScoreStruct>(); foreach (Player p in friends) { if (!targets.Contains(p)) { continue; } bool fuyin = false; if (ai.HasSkill("fuyin", p) && p.GetMark("fuyin") == 0) { int count = player.HandcardNum; if (count > p.HandcardNum) { fuyin = true; } } if (!fuyin) { ScoreStruct score = ai.GetDamageScore(new DamageStruct(duel, player, p)); score.Players = new List <Player> { p }; foreach (string skill in ai.GetKnownSkills(p)) { SkillEvent skill_e = Engine.GetSkillEvent(skill); if (skill_e != null) { score.Score += skill_e.TargetValueAdjust(ai, duel, player, new List <Player> { p }, p); } } scores.Add(score); } } foreach (Player p in enemies) { if (!targets.Contains(p)) { continue; } bool fuyin = false; if (ai.HasSkill("fuyin", p) && p.GetMark("fuyin") == 0) { int count = player.HandcardNum; foreach (int id in duel.SubCards) { if (room.GetCardPlace(id) == Place.PlaceHand) { count--; } } if (count > p.HandcardNum) { ScoreStruct score = new ScoreStruct { Score = 1, Players = new List <Player> { p } }; scores.Add(score); fuyin = true; } } if (!fuyin) { bool no_red = p.GetMark("@qianxi_red") > 0; bool no_black = p.GetMark("@qianxi_black") > 0; double n2 = ai.GetKnownCardsNums(Slash.ClassName, "he", p, player); bool fuqi = false; if (player.ContainsTag("wenji") && player.GetTag("wenji") is List <string> names && names.Contains(Name)) { fuqi = true; } if (ai.HasSkill("fuqi", player) && RoomLogic.DistanceTo(room, player, p) == 1) { fuqi = true; } if (!fuqi && !ai.IsLackCard(p, Slash.ClassName)) { int rate = 4; if (ai.GetKnownCards(p).Count != p.HandcardNum) { rate = 5; if (ai.HasSkill("longdan", p)) { rate -= 2; if (no_black || no_red) { rate += 1; } } if (ai.HasSkill("wusheng", p) && !no_red) { rate -= 2; } int count = p.HandcardNum - ai.GetKnownCards(p).Count; count += p.GetHandPile(true).Count - ai.GetKnownHandPileCards(p).Count; if (no_red) { rate += 1; } if (no_black) { rate += 2; } n2 += ((double)count / rate); } if (ai.HasSkill("wushuang", p)) { n2 *= 2; } } ScoreStruct score = new ScoreStruct { Players = new List <Player> { p } }; if (fuqi) { score.Score = ai.GetDamageScore(new DamageStruct(duel, player, p)).Score; } else if (n2 > n1) { score.Score = ai.GetDamageScore(new DamageStruct(duel, p, player)).Score; } else { score.Score = ai.GetDamageScore(new DamageStruct(duel, p, player)).Score - (n2 - 1) * 0.4; } foreach (string skill in ai.GetKnownSkills(p)) { SkillEvent skill_e = Engine.GetSkillEvent(skill); if (skill_e != null) { score.Score += skill_e.TargetValueAdjust(ai, duel, player, new List <Player> { p }, p); } } scores.Add(score); } } if (scores.Count > 0) { scores.Sort((x, y) => { return(x.Score > y.Score ? -1 : 1); }); if (scores[0].Score > 1) { return(scores[0].Players); } } } } return(new List <Player>()); }