Ejemplo n.º 1
0
 public override string OnChoice(TrustedAI ai, Player player, string choice, object data)
 {
     return(player.Hp < player.MaxHp ? "maxhp" : "hp");
 }
Ejemplo n.º 2
0
 public virtual CardUseStruct OnResponding(TrustedAI ai, Player player, string pattern, string prompt, object data) => new CardUseStruct();
Ejemplo n.º 3
0
 public virtual WrappedCard ViewAs(TrustedAI ai, Player player, int id, bool current, Player.Place place) => null;
Ejemplo n.º 4
0
 public virtual List <WrappedCard> GetViewAsCards(TrustedAI ai, string pattern, Player player) => new List <WrappedCard>();
Ejemplo n.º 5
0
 public virtual List <Player> OnPlayerChosen(TrustedAI ai, Player player, List <Player> targets, int min, int max) => null;
Ejemplo n.º 6
0
 public virtual bool IsCardEffect(TrustedAI ai, WrappedCard card, Player from, Player to) => true;
Ejemplo n.º 7
0
 public virtual WrappedCard OnCardShow(TrustedAI ai, Player player, Player request, object data) => null;
Ejemplo n.º 8
0
 public override void Use(TrustedAI ai, Player player, ref CardUseStruct use, WrappedCard card)
 {
     use.Card = card;
 }
Ejemplo n.º 9
0
 public override double CardValue(TrustedAI ai, Player player, bool use, WrappedCard card, Player.Place place)
 {
     return(ai.AjustWeaponRangeValue(player, card));
 }
Ejemplo n.º 10
0
        public static List <Player> FindTuxiTargets(TrustedAI ai, Player player, int max)
        {
            List <Player> result  = new List <Player>();
            List <Player> enemies = ai.GetEnemies(player);

            ai.SortByHandcards(ref enemies, false);
            Room   room       = ai.Room;
            Player zhugeliang = ai.FindPlayerBySkill("kongcheng");

            if (zhugeliang != null && ai.IsFriend(zhugeliang) && zhugeliang.HandcardNum == 1 && ai.GetEnemisBySeat(zhugeliang) > 0 && zhugeliang != player)
            {
                if (ai.IsWeak(zhugeliang))
                {
                    result.Add(zhugeliang);
                }
                else
                {
                    List <int> ids = ai.GetKnownCards(zhugeliang);
                    if (ids.Count == 1)
                    {
                        int id = ids[0];
                        if (!ai.IsCard(id, Jink.ClassName, zhugeliang) && !!ai.IsCard(id, Peach.ClassName, zhugeliang) && !ai.IsCard(id, Analeptic.ClassName, zhugeliang))
                        {
                            result.Add(zhugeliang);
                        }
                    }
                }
            }

            foreach (Player p in enemies)
            {
                if (result.Contains(p) || !RoomLogic.CanGetCard(room, player, p, "h"))
                {
                    continue;
                }
                List <int> ids = ai.GetKnownCards(p);
                foreach (int id in ids)
                {
                    WrappedCard card = room.GetCard(id);
                    if (card.Name == Peach.ClassName || card.Name == Nullification.ClassName || card.Name.Contains(Nullification.ClassName))
                    {
                        result.Add(p);
                        break;
                    }
                }
                if (result.Count >= max)
                {
                    break;
                }
            }

            if (result.Count < max)
            {
                foreach (Player p in enemies)
                {
                    if (result.Contains(p) || !RoomLogic.CanGetCard(room, player, p, "h"))
                    {
                        continue;
                    }
                    if (ai.HasSkill("jijiu|qingnang|leiji|jieyin|beige|kanpo|liuli|qiaobian|zhiheng|guidao|tianxiang|lijian", p))
                    {
                        result.Add(p);
                    }

                    if (result.Count >= max)
                    {
                        break;
                    }
                }
            }
            if (result.Count < max)
            {
                foreach (Player p in enemies)
                {
                    if (result.Contains(p) || !RoomLogic.CanGetCard(room, player, p, "h"))
                    {
                        continue;
                    }
                    int  x    = p.HandcardNum;
                    bool good = true;
                    if (x == 1 && ai.NeedKongcheng(p))
                    {
                        good = false;
                    }
                    if (x >= 2 && ai.HasSkill("tuntian", p))
                    {
                        good = false;
                    }

                    if (good)
                    {
                        result.Add(p);
                    }

                    if (result.Count >= max)
                    {
                        break;
                    }
                }
            }

            return(result);
        }
Ejemplo n.º 11
0
        public override List <WrappedCard> GetTurnUse(TrustedAI ai, Player player)
        {
            Room room = ai.Room;

            ai.Target[Name] = null;
            if (player.HasUsed(ClassicWoodenOxCard.ClassName) || player.IsKongcheng() || player.GetPile("wooden_ox").Count >= 5)
            {
                return(null);
            }
            List <int> cards = new List <int>(player.HandCards);

            int sub = -1;

            foreach (int id in cards)
            {
                WrappedCard card = room.GetCard(id);
                if (card.Name == DragonPhoenix.ClassName)
                {
                    Player target = null;
                    foreach (Player p in room.GetOtherPlayers(player))
                    {
                        if (ai.HasSkill("zhangwu", p))
                        {
                            target = p;
                            break;
                        }
                    }

                    if (target != null && !ai.IsFriend(target, player) || !ai.HasSkill(TrustedAI.LoseEquipSkill, player))
                    {
                        sub = id;
                        break;
                    }
                }
                else if (card.Name == PeaceSpell.ClassName)
                {
                    Player target = null;
                    foreach (Player p in room.GetOtherPlayers(player))
                    {
                        if (ai.HasSkill("wendao", p))
                        {
                            target = p;
                            break;
                        }
                    }

                    if (target != null && !ai.IsFriend(target, player))
                    {
                        sub = id;
                        break;
                    }
                }
                else if (card.Name == LuminouSpearl.ClassName)
                {
                    Player target = null;
                    foreach (Player p in room.GetOtherPlayers(player))
                    {
                        if (ai.HasSkill("jubao", p))
                        {
                            target = p;
                            break;
                        }
                    }

                    if (target != null && !ai.IsFriend(target, player))
                    {
                        sub = id;
                        break;
                    }
                }
            }

            ai.SortByUseValue(ref cards);
            bool keep = false;

            if (ai.HasSkill("jijiu"))
            {
                foreach (Player p in ai.GetFriends(player))
                {
                    if (ai.IsWeak(p))
                    {
                        keep = true;
                        break;
                    }
                }
            }

            if (!keep)
            {
                List <Player> targets = new List <Player>();
                foreach (Player p in ai.FriendNoSelf)
                {
                    if (RoomLogic.CanPutEquip(p, room.GetCard(player.Treasure.Key)) && ai.GetSameEquip(room.GetCard(player.Treasure.Key), p) == null)
                    {
                        targets.Add(p);
                    }
                }

                Player next = null;
                room.SortByActionOrder(ref targets);
                foreach (Player p in targets)
                {
                    if (!ai.WillSkipPlayPhase(p))
                    {
                        next = p;
                        break;
                    }
                }
                if (next != null)
                {
                    if (sub != -1)
                    {
                        ai.Target[Name] = next;
                        WrappedCard card = new WrappedCard(WoodenOxCard.ClassName)
                        {
                            Skill = Name
                        };
                        card.AddSubCard(sub);
                        return(new List <WrappedCard> {
                            card
                        });
                    }
                    else
                    {
                        KeyValuePair <Player, int> result = ai.GetCardNeedPlayer(cards, new List <Player> {
                            next
                        });
                        if (result.Key != null)
                        {
                            ai.Target[Name] = next;
                            WrappedCard card = new WrappedCard(WoodenOxCard.ClassName)
                            {
                                Skill = Name
                            };
                            card.AddSubCard(result.Value);
                            return(new List <WrappedCard> {
                                card
                            });
                        }
                    }
                }
                else if (ai.HasSkill(TrustedAI.LoseEquipSkill) && targets.Count > 0)
                {
                    if (sub != -1)
                    {
                        ai.Target[Name] = targets[0];
                        WrappedCard card = new WrappedCard(WoodenOxCard.ClassName)
                        {
                            Skill = Name
                        };
                        card.AddSubCard(sub);
                        return(new List <WrappedCard> {
                            card
                        });
                    }
                    else
                    {
                        ai.Target[Name] = targets[0];
                        ai.SortByUseValue(ref cards, false);
                        WrappedCard card = new WrappedCard(WoodenOxCard.ClassName)
                        {
                            Skill = Name
                        };
                        card.AddSubCard(cards[0]);
                        return(new List <WrappedCard> {
                            card
                        });
                    }
                }
                else if (targets.Count > 0)
                {
                    List <Player> weaks = new List <Player>();
                    foreach (Player p in targets)
                    {
                        if (ai.IsWeak(p))
                        {
                            weaks.Add(p);
                        }
                    }

                    if (sub != -1 && weaks.Count > 0)
                    {
                        ai.SortByDefense(ref weaks, false);
                        ai.Target[Name] = weaks[0]; WrappedCard card = new WrappedCard(WoodenOxCard.ClassName)
                        {
                            Skill = Name
                        };
                        card.AddSubCard(sub);
                        return(new List <WrappedCard> {
                            card
                        });
                    }

                    KeyValuePair <Player, int> result = ai.GetCardNeedPlayer(cards, weaks);
                    if (result.Key != null)
                    {
                        ai.Target[Name] = result.Key;
                        WrappedCard card = new WrappedCard(WoodenOxCard.ClassName)
                        {
                            Skill = Name
                        };
                        card.AddSubCard(result.Value);
                        return(new List <WrappedCard> {
                            card
                        });
                    }
                }
            }

            if (ai.GetOverflow(player) > 0)
            {
                WrappedCard card = new WrappedCard(WoodenOxCard.ClassName)
                {
                    Skill = Name
                };
                if (sub != -1)
                {
                    card.AddSubCard(sub);
                }
                else
                {
                    ai.SortByKeepValue(ref cards, false);
                    card.AddSubCard(cards[ai.GetOverflow(player) - 1]);
                }
                return(new List <WrappedCard> {
                    card
                });
            }

            if (player.HandcardNum == 1 && ai.HasSkill("kongcheng"))
            {
                WrappedCard card = new WrappedCard(WoodenOxCard.ClassName)
                {
                    Skill = Name
                };
                card.AddSubCards(player.HandCards);
                return(new List <WrappedCard> {
                    card
                });
            }

            return(null);
        }
Ejemplo n.º 12
0
        public override List <Player> OnPlayerChosen(TrustedAI ai, Player player, List <Player> target, int min, int max)
        {
            List <Player> result = FindTuxiTargets(ai, player, max);

            return(result);
        }
Ejemplo n.º 13
0
 public override double GetSkillAdjustValue(TrustedAI ai, Player player)
 {
     return(5);
 }
Ejemplo n.º 14
0
        public override List <WrappedCard> GetTurnUse(TrustedAI ai, Player player)
        {
            if (!player.HasUsed("WendaoCard") && !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")
                    {
                        ShowSkill = Name,
                        Skill     = Name
                    };
                    if (room.GetCardOwner(pp) == player)
                    {
                        wd.AddSubCard(pp);
                        return(new List <WrappedCard> {
                            wd
                        });
                    }
                    else
                    {
                        List <int> ids = player.GetCards("he");
                        ai.SortByKeepValue(ref ids, false);
                        foreach (int id in ids)
                        {
                            if (WrappedCard.IsRed(room.GetCard(id).Suit) && ai.GetKeepValue(id, player) < 0)
                            {
                                wd.AddSubCard(id);
                                return(new List <WrappedCard> {
                                    wd
                                });
                            }
                        }

                        ai.SortByUseValue(ref ids, false);
                        foreach (int id in ids)
                        {
                            if (WrappedCard.IsRed(room.GetCard(id).Suit))
                            {
                                wd.AddSubCard(id);
                                return(new List <WrappedCard> {
                                    wd
                                });
                            }
                        }
                    }
                }
            }

            return(new List <WrappedCard>());
        }
Ejemplo n.º 15
0
 public virtual void Use(TrustedAI ai, Player player, ref CardUseStruct use, WrappedCard card)
 {
 }
Ejemplo n.º 16
0
 public override void Use(TrustedAI ai, Player player, ref CardUseStruct use, WrappedCard card)
 {
     ai.UseEquipCard(ref use, card);
 }
Ejemplo n.º 17
0
 public virtual double CardValue(TrustedAI ai, Player player, bool use, WrappedCard card, Player.Place place) => 0;
Ejemplo n.º 18
0
        public override CardUseStruct OnResponding(TrustedAI ai, Player player, string pattern, string prompt, object data)
        {
            Room room = ai.Room;

            string[] strs = prompt.Split(':');

            CardUseStruct use    = new CardUseStruct(null, player, new List <Player>());
            Player        target = room.FindPlayer(strs[1]);

            if (target != null)
            {
                use.To.Add(target);

                List <ScoreStruct> values = ai.CaculateSlashIncome(player, null, new List <Player> {
                    target
                });
                if (values.Count > 0 && values[0].Score > 0)
                {
                    bool will_slash = false;
                    if (values[0].Score >= 10)
                    {
                        will_slash = true;
                    }
                    else if (ai.GetEnemies(player).Count == 1 && ai.GetOverflow(player) > 0)
                    {
                        foreach (int id in values[0].Card.SubCards)
                        {
                            if (room.GetCardPlace(id) == Player.Place.PlaceHand)
                            {
                                will_slash = true;
                                break;
                            }
                        }
                    }
                    else
                    {
                        foreach (Player p in values[0].Players)
                        {
                            if (ai.GetPrioEnemies().Contains(p))
                            {
                                will_slash = true;
                                break;
                            }
                        }
                    }

                    //todo: adjust ai personality
                    if (!will_slash && ai.GetOverflow(player) > 0)
                    {
                        foreach (int id in values[0].Card.SubCards)
                        {
                            if (room.GetCardPlace(id) == Player.Place.PlaceHand)
                            {
                                will_slash = true;
                                break;
                            }
                        }
                    }

                    if (will_slash)
                    {
                        use.Card = values[0].Card;
                    }
                }
            }
            return(use);
        }
Ejemplo n.º 19
0
 public virtual void DamageEffect(TrustedAI ai, ref DamageStruct damage, DamageStruct.DamageStep step)
 {
 }
Ejemplo n.º 20
0
 public override double UsePriorityAdjust(TrustedAI ai, Player player, List <Player> targets, WrappedCard card)
 {
     return(9);
 }
Ejemplo n.º 21
0
 public virtual void OnEvent(TrustedAI ai, TriggerEvent triggerEvent, Player player, object data)
 {
 }
Ejemplo n.º 22
0
 public override bool OnSkillInvoke(TrustedAI ai, Player player, object data)
 {
     return(true);
 }
Ejemplo n.º 23
0
 public virtual string OnChoice(TrustedAI ai, Player player, string choice, object data) => string.Empty;
Ejemplo n.º 24
0
 public override bool OnSkillInvoke(TrustedAI ai, Player player, object data) => true;
Ejemplo n.º 25
0
 public virtual List <int> OnCardsChosen(TrustedAI ai, Player from, Player to, string flags, int min, int max, List <int> disable_ids) => null;
Ejemplo n.º 26
0
 public override bool OnSkillInvoke(TrustedAI ai, Player player, object data)
 {
     return(ai.WillShowForAttack());
 }
Ejemplo n.º 27
0
 public virtual bool OnSkillInvoke(TrustedAI ai, Player player, object data) => false;
Ejemplo n.º 28
0
 //这张卡牌在使用时的优先级调整
 public virtual double UsePriorityAdjust(TrustedAI ai, Player player, List <Player> targets, WrappedCard card) => 0;
Ejemplo n.º 29
0
 public virtual List <WrappedCard> GetTurnUse(TrustedAI ai, Player player) => new List <WrappedCard>();
Ejemplo n.º 30
0
 public override string OnChoice(TrustedAI ai, Player player, string choice, object data)
 {
     return(YinghunJAI.Choice(ai, player));
 }