Esempio n. 1
0
        public override double TargetValueAdjust(TrustedAI ai, WrappedCard card, Player to)
        {
            Room   room  = ai.Room;
            double value = 0;

            if (!RoomLogic.IsVirtualCard(room, card))
            {
                foreach (int id in card.SubCards)
                {
                    if (ai.IsCard(id, Peach.ClassName, to))
                    {
                        value += 1;
                    }
                    if (ai.IsCard(id, Analeptic.ClassName, to))
                    {
                        value += 0.6;
                    }
                }

                if (ai.IsEnemy(to))
                {
                    value = -value;
                }
            }

            return(value);
        }
Esempio n. 2
0
        public virtual void OnCardAnnounce(Room room, CardUseStruct use, bool ignore_rule)
        {
            if (use.EffectCount == null)
            {
                use.EffectCount = new List <EffctCount>();
            }
            use.Card = RoomLogic.ParseUseCard(room, use.Card);
            room.ShowSkill(use.From, use.Card.ShowSkill, use.Card.SkillPosition);

            if (!ignore_rule)
            {
                CheckTargetModSkillShow(room, use);
            }

            WrappedCard use_card = use.Card;

            //将卡牌转化为延时锦囊就相当于改写了该牌的牌名,必须对其重写以保证此延时锦囊将来可以正确生效
            if (Engine.GetFunctionCard(use_card.Name) is DelayedTrick && RoomLogic.IsVirtualCard(room, use_card) && use_card.SubCards.Count == 1)
            {
                WrappedCard wrapped = room.GetCard(use_card.GetEffectiveId());
                wrapped.TakeOver(use_card);
                use.Card = wrapped;
            }

            //record big or small for fighttogether
            if (Engine.GetFunctionCard(use_card.Name) is FightTogether && use.To.Count > 0)
            {
                List <string> big_kingdoms = RoomLogic.GetBigKingdoms(room);
                if (big_kingdoms.Count > 0)
                {
                    string target_kingdom = (use.To[0].HasShownOneGeneral() ?
                                             (use.To[0].Role == "careerist" ? use.To[0].Name : use.To[0].Kingdom) : string.Empty);
                    bool big = big_kingdoms.Contains(target_kingdom);
                    if (big)
                    {
                        use.Pattern = "big";
                    }
                    else
                    {
                        use.Pattern = "small";
                    }
                }
                else
                {
                    use.Pattern = "unknown";
                }
            }

            OnUse(room, use);
        }
Esempio n. 3
0
        public override WrappedCard ViewAs(Room room, List <WrappedCard> cards, Player player)
        {
            if (cards.Count == 1 && RoomLogic.IsVirtualCard(room, cards[0]))
            {
                WrappedCard gs = new WrappedCard(GuishuCard.ClassName)
                {
                    Skill      = Name,
                    ShowSkill  = Name,
                    UserString = cards[0].Name
                };
                gs.AddSubCard(cards[0]);
                return(gs);
            }

            return(null);
        }
Esempio n. 4
0
        public override double CardValue(TrustedAI ai, Player player, WrappedCard card, bool isUse, Player.Place place)
        {
            if (!isUse && place == Player.Place.PlaceEquip)
            {
                return(4);
            }

            if (isUse && RoomLogic.IsVirtualCard(ai.Room, card))
            {
                foreach (int id in card.SubCards)
                {
                    if (ai.Room.GetCardPlace(id) == Player.Place.PlaceEquip)
                    {
                        return(-3);
                    }
                }
            }

            return(0);
        }
Esempio n. 5
0
        // '|' 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)
        {
            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 = room.BloodBattle && card.Name == Peach.ClassName && !RoomLogic.IsVirtualCard(room, card)
                            ? name == Slash.ClassName || name == Jink.ClassName || name == "%Slash" || name == "%Jink"
                            : 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.HandCards)
                                {
                                    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);
        }