public override List <WrappedCard> GetTurnUse(TrustedAI ai, Player player) { Room room = ai.Room; List <int> ids = player.GetCards("he"); ids.AddRange(player.GetHandPile()); foreach (int id in ids) { WrappedCard card = ai.Room.GetCard(id); if (WrappedCard.IsRed(card.Suit)) { WrappedCard slash = new WrappedCard(Slash.ClassName) { Skill = Name, ShowSkill = Name }; slash.AddSubCard(card); slash = RoomLogic.ParseUseCard(room, slash); return(new List <WrappedCard> { slash }); } } return(null); }
public override double CardValue(TrustedAI ai, Player player, WrappedCard card, bool isUse, Player.Place place) { if (ai.HasSkill(Name, player) && (card.Name.Contains(Slash.ClassName) && WrappedCard.IsRed(card.Suit) || card.Name == Duel.ClassName) && isUse) { return(1.5); } return(0); }
public override TriggerStruct Triggerable(TriggerEvent triggerEvent, Room room, Player player, ref object data, Player ask_who) { if (player != null && player.Alive && data is DamageStruct damage && damage.Card != null && base.Triggerable(damage.To, room) && damage.Card.Name.Contains(Slash.ClassName) && WrappedCard.IsRed(damage.Card.Suit)) { return(new TriggerStruct(Name, damage.To)); } return(new TriggerStruct()); }
public override double TargetValueAdjust(TrustedAI ai, WrappedCard card, Player from, List <Player> targets, Player to) { double value = 0; if ((card.Name.Contains(Slash.ClassName) && WrappedCard.IsRed(card.Suit) || card.Name == Duel.ClassName) && ai.HasSkill(Name, to)) { value += ai.IsFriend(to) ? 2 : -2; } return(value); }
public override double CardValue(TrustedAI ai, Player player, WrappedCard card, bool isUse, Player.Place place) { if (card != null && !card.IsVirtualCard() && ai.HasSkill(Name, player) && card.Name.Contains(Slash.ClassName)) { double value = 2; if (WrappedCard.IsRed(card.Suit)) { value += 1; } if (card.Name != Slash.ClassName) { value += 1.5; } return(value); } return(0); }
public override WrappedCard ViewAs(TrustedAI ai, Player player, int id, bool current, Player.Place place) { Room room = ai.Room; WrappedCard card = room.GetCard(id); if (card.HasFlag("using")) { return(null); } if (WrappedCard.IsRed(card.Suit)) { WrappedCard slash = new WrappedCard(Slash.ClassName) { Skill = Name, ShowSkill = Name }; slash.AddSubCard(card); slash = RoomLogic.ParseUseCard(room, slash); return(slash); } return(null); }
public override void Use(TrustedAI ai, Player player, ref CardUseStruct use, WrappedCard card) { List <int> slashes = new List <int>(); Room room = ai.Room; foreach (int id in player.GetCards("h")) { WrappedCard wrapped = room.GetCard(id); if (wrapped.Name.Contains(Slash.ClassName)) { slashes.Add(id); } } if (slashes.Count > 0) { List <Player> friends = ai.FriendNoSelf; room.SortByActionOrder(ref friends); foreach (int id in slashes) { WrappedCard slash = room.GetCard(id); if (WrappedCard.IsRed(slash.Suit) && slash.Name != Slash.ClassName) { foreach (Player p in friends) { if (p.IsWounded() && !ai.HasSkill("zishu", p) && !ai.WillSkipPlayPhase(player)) { card.AddSubCard(id); use.Card = card; use.To.Add(p); return; } } } } foreach (int id in slashes) { WrappedCard slash = room.GetCard(id); if (!WrappedCard.IsRed(slash.Suit) && slash.Name != Slash.ClassName) { foreach (Player p in friends) { if (!ai.HasSkill("zishu", p) && !ai.WillSkipPlayPhase(player)) { card.AddSubCard(id); use.Card = card; use.To.Add(p); return; } } } } foreach (int id in slashes) { WrappedCard slash = room.GetCard(id); if (WrappedCard.IsRed(slash.Suit)) { foreach (Player p in friends) { if (p.IsWounded() && !ai.HasSkill("zishu", p)) { card.AddSubCard(id); use.Card = card; use.To.Add(p); return; } } } } ai.SortByUseValue(ref slashes, false); { foreach (Player p in friends) { if (!ai.HasSkill("zishu", p) && !ai.WillSkipPlayPhase(player)) { card.AddSubCard(slashes[0]); use.Card = card; use.To.Add(p); return; } } } } }
// '|' means 'and', '#' means 'or'. // the expression splited by '|' has 3 parts, // 1st part means the card name, and ',' means more than one options. // 2nd patt means the card suit, and ',' means more than one options. // 3rd part means the card number, and ',' means more than one options, // the number uses '~' to make a scale for valid expressions #endregion private bool MatchOne(Player player, Room room, WrappedCard card, string exp) { if (card == null && exp != ".") { return(false); } string[] factors = exp.Split('|'); bool checkpoint = false; string[] card_types = factors[0].Split(','); foreach (string or_name in card_types) { checkpoint = false; foreach (string _name in or_name.Split('+')) { string name = _name; if (name == ".") { checkpoint = true; } else { bool positive = true; if (name.StartsWith("^")) { positive = false; name = name.Substring(1); } //国战鏖战模式对桃特殊判断 bool name_match = false; if (room.BloodBattle && card.Name == Peach.ClassName && !card.IsVirtualCard()) { if (positive && (name == Slash.ClassName || name == "%Slash" || name == Jink.ClassName || name == "%Jink")) { name_match = true; } else if (positive && (name == Peach.ClassName || name == "%Peach")) { name_match = false; } else { name_match = Engine.GetFunctionCard(card.Name)?.IsKindOf(name) == true || ("%" + card.Name == name); } } else { name_match = Engine.GetFunctionCard(card.Name)?.IsKindOf(name) == true || ("%" + card.Name == name); } if (name_match || (int.TryParse(name, out int id) && card.GetEffectiveId() == id)) { checkpoint = positive; } else { checkpoint = !positive; } } if (!checkpoint) { break; } } if (checkpoint) { break; } } if (!checkpoint) { return(false); } if (factors.Length < 2) { return(true); } checkpoint = false; string[] card_suits = factors[1].Split(','); foreach (string _suit in card_suits) { string suit = _suit; if (suit == ".") { checkpoint = true; break; } bool positive = true; if (suit.StartsWith("^")) { positive = false; suit = suit.Substring(1); } checkpoint = WrappedCard.GetSuitString(RoomLogic.GetCardSuit(room, card)) == suit || (WrappedCard.IsBlack(RoomLogic.GetCardSuit(room, card)) && suit == "black") || (WrappedCard.IsRed(RoomLogic.GetCardSuit(room, card)) && suit == "red") ? positive : !positive; if (checkpoint) { break; } } if (!checkpoint) { return(false); } if (factors.Length < 3) { return(true); } checkpoint = false; string[] card_numbers = factors[2].Split(','); int cdn = RoomLogic.GetCardNumber(room, card); foreach (string number in card_numbers) { if (number == ".") { checkpoint = true; break; } if (number.Contains('~')) { string[] num_params = number.Split('~'); int from, to; if (num_params[0].Length == 0) { from = 1; } else { from = int.Parse(num_params[0]); } if (num_params.Length == 1 && num_params[1].Length == 0) { to = 13; } else { to = int.Parse(num_params[1]); } if (from <= cdn && cdn <= to) { checkpoint = true; } } else if (int.TryParse(number, out int id) && id == cdn) { checkpoint = true; } else if ((number == "A" && cdn == 1) || (number == "J" && cdn == 11) || (number == "Q" && cdn == 12) || (number == "K" && cdn == 13)) { checkpoint = true; } if (checkpoint) { break; } } if (!checkpoint) { return(false); } if (factors.Length < 4) { return(true); } checkpoint = false; string place = factors[3]; if (player == null || place == ".") { checkpoint = true; } if (!checkpoint) { List <int> ids = new List <int>(card.SubCards); if (ids.Count > 0) { foreach (int id in ids) { checkpoint = false; WrappedCard sub_card = room.GetCard(id); foreach (string _p in place.Split(',')) { string p = _p; if (p == "equipped" && player.HasEquip(sub_card.Name)) { checkpoint = true; } else if (p == "hand" && sub_card.Id >= 0) { foreach (int h_id in player.GetCards("h")) { if (h_id == id) { checkpoint = true; break; } } } else { if (p.Contains('$')) { p = p.Replace('$', '#'); } if (p.StartsWith("%")) { p = p.Substring(1); foreach (Player pl in room.GetAlivePlayers()) { if (pl.GetPile(p).Count > 0 && pl.GetPile(p).Contains(id)) { checkpoint = true; break; } } } else if (player.GetPile(p).Count > 0 && player.GetPile(p).Contains(id)) { checkpoint = true; } } if (checkpoint) { break; } } if (!checkpoint) { break; } } } } return(checkpoint); }
public override List <WrappedCard> GetTurnUse(TrustedAI ai, Player player) { if (!player.HasUsed(WendaoCard.ClassName) && !player.IsNude()) { Room room = ai.Room; int pp = -1; foreach (int id in room.DiscardPile) { WrappedCard card = room.GetCard(id); if (card.Name == PeaceSpell.ClassName) { pp = id; break; } } if (pp == -1) { foreach (Player p in room.GetAlivePlayers()) { foreach (int id in p.GetEquips()) { WrappedCard card = room.GetCard(id); if (card.Name == PeaceSpell.ClassName) { pp = id; break; } } if (pp != -1) { break; } } } if (pp > -1) { WrappedCard wd = new WrappedCard(WendaoCard.ClassName) { ShowSkill = Name, Skill = Name }; List <int> ids = player.GetCards("he"); ai.SortByKeepValue(ref ids, false); foreach (int id in ids) { WrappedCard card = room.GetCard(id); if (WrappedCard.IsRed(card.Suit) && card.Name != PeaceSpell.ClassName && ai.GetKeepValue(id, player) < 0) { wd.AddSubCard(id); return(new List <WrappedCard> { wd }); } } ai.SortByUseValue(ref ids, false); foreach (int id in ids) { WrappedCard card = room.GetCard(id); if (WrappedCard.IsRed(card.Suit) && card.Name != PeaceSpell.ClassName) { wd.AddSubCard(id); return(new List <WrappedCard> { wd }); } } } } return(new List <WrappedCard>()); }