예제 #1
0
        public override void Use(Room room, CardUseStruct card_use)
        {
            WrappedCard card = card_use.Card;

            room.AddToPile(card_use.From, "wooden_ox", card.SubCards, false);

            WrappedCard treasure = room.GetCard(card_use.From.Treasure.Key);

            if (treasure != null)
            {
                List <Player> targets = new List <Player>();
                foreach (Player p in room.GetOtherPlayers(card_use.From))
                {
                    if (!p.GetTreasure() && RoomLogic.CanPutEquip(p, treasure))
                    {
                        targets.Add(p);
                    }
                }
                if (targets.Count == 0)
                {
                    return;
                }
                Player target = room.AskForPlayerChosen(card_use.From, targets, "ClassicWoodenOx", "@wooden_ox-move", true);
                if (target != null)
                {
                    room.MoveCardTo(treasure, card_use.From, target, Place.PlaceEquip,
                                    new CardMoveReason(MoveReason.S_REASON_TRANSFER, card_use.From.Name, "ClassicWoodenOx", null));
                }
            }
        }
예제 #2
0
 public override bool IsAvailable(Room room, Player player, WrappedCard card)
 {
     if (room.GetCardPlace(card.Id) == Place.PlaceEquip)
     {
         return(false);
     }
     return(RoomLogic.IsProhibited(room, player, player, card) == null &&
            RoomLogic.CanPutEquip(player, card) && base.IsAvailable(room, player, card));
 }
예제 #3
0
        public override CardUseStruct OnResponding(TrustedAI ai, Player player, string pattern, string prompt, object data)
        {
            CardUseStruct use = new CardUseStruct(null, player, new List <Player>());

            if (!ai.WillShowForAttack())
            {
                return(use);
            }

            List <int> ids  = new List <int>();
            Room       room = ai.Room;

            foreach (int id in player.GetCards("he"))
            {
                WrappedCard card = room.GetCard(id);
                if (Engine.GetFunctionCard(card.Name) is EquipCard)
                {
                    ids.Add(id);
                }
            }

            if (ids.Count > 0)
            {
                ai.SortByKeepValue(ref ids, false);
                foreach (int id in ids)
                {
                    WrappedCard   card    = room.GetCard(id);
                    EquipCard     equip   = (EquipCard)Engine.GetFunctionCard(card.Name);
                    int           index   = (int)equip.EquipLocation();
                    List <Player> targets = ai.FriendNoSelf;
                    ai.SortByDefense(ref targets, false);
                    foreach (Player p in targets)
                    {
                        if (p.GetEquip(index) == -1 && RoomLogic.CanPutEquip(p, card))
                        {
                            use.Card = new WrappedCard(HuyuanCard.ClassName)
                            {
                                Skill = Name, Mute = true
                            };
                            use.Card.AddSubCard(id);
                            use.To.Add(p);
                            return(use);
                        }
                    }
                }
            }

            return(use);
        }
        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 = player.GetCards("h");

            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(ClassicWoodenOxCard.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(ClassicWoodenOxCard.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(ClassicWoodenOxCard.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(ClassicWoodenOxCard.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(ClassicWoodenOxCard.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(ClassicWoodenOxCard.ClassName)
                        {
                            Skill = Name
                        };
                        card.AddSubCard(result.Value);
                        return(new List <WrappedCard> {
                            card
                        });
                    }
                }
            }

            if (ai.GetOverflow(player) > 0)
            {
                WrappedCard card = new WrappedCard(ClassicWoodenOxCard.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|kongcheng_jx"))
            {
                WrappedCard card = new WrappedCard(ClassicWoodenOxCard.ClassName)
                {
                    Skill = Name
                };
                card.AddSubCards(player.GetCards("h"));
                return(new List <WrappedCard> {
                    card
                });
            }

            return(null);
        }