示例#1
0
        public virtual NulliResult OnNullification(TrustedAI ai, CardEffectStruct effect, bool positive, bool keep)
        {
            NulliResult result = new NulliResult
            {
                Null = false,
                Heg  = false
            };

            return(result);
        }
示例#2
0
        public override void OnEffect(Room room, CardEffectStruct effect)
        {
            Player player = effect.From;

            if (player.Camp == effect.To.Camp && effect.To.Chained)
            {
                room.DrawCards(effect.To, new DrawCardStruct(1, player, Name));
            }
            else if (player.Camp != effect.To.Camp && !effect.To.Chained && RoomLogic.CanBeChainedBy(room, effect.To, player))
            {
                room.SetPlayerChained(effect.To, true);
            }
        }
示例#3
0
 public override void OnEffect(Room room, CardEffectStruct effect)
 {
     if (effect.To.IsWounded())
     {
         RecoverStruct recover = new RecoverStruct
         {
             Recover = 1,
             Who     = effect.From,
             Card    = effect.Card
         };
         room.Recover(effect.To, recover, true);
     }
 }
        public virtual void Use(Room room, CardUseStruct card_use)
        {
            WrappedCard   card    = card_use.Card;
            List <Player> targets = card_use.To;

            for (int index = 0; index < targets.Count; index++)
            {
                Player           target = targets[index];
                CardEffectStruct effect = new CardEffectStruct
                {
                    Card        = card,
                    From        = card_use.From,
                    To          = target,
                    Multiple    = (targets.Count > 1),
                    Drank       = card_use.Drank,
                    ExDamage    = card_use.ExDamage,
                    BasicEffect = card_use.EffectCount.Count > index ? card_use.EffectCount[index] : new CardBasicEffect(target, 0, 0, 0)
                };

                List <Player> players = new List <Player>();
                for (int i = index; i < targets.Count; i++)
                {
                    if (card_use.EffectCount.Count <= i || !card_use.EffectCount[i].Nullified)
                    {
                        players.Add(targets[i]);
                    }
                }
                effect.StackPlayers = players;

                room.CardEffect(effect);
            }

            List <int> table_cardids = room.GetCardIdsOnTable(room.GetSubCards(card));

            if (table_cardids.Count > 0)
            {
                CardMoveReason reason = new CardMoveReason(MoveReason.S_REASON_USE, card_use.From.Name, null, card.Skill, null)
                {
                    Card = card
                };
                if (targets.Count == 1)
                {
                    reason.TargetId = targets[0].Name;
                }
                CardsMoveStruct move = new CardsMoveStruct(table_cardids, card_use.From, null, Place.PlaceTable, Place.DiscardPile, reason);
                room.MoveCardsAtomic(new List <CardsMoveStruct> {
                    move
                }, true);
            }
        }
        public override NulliResult OnNullification(TrustedAI ai, CardEffectStruct effect, bool positive, bool keep)
        {
            NulliResult result = new NulliResult();
            Room        room = ai.Room;
            Player      from = effect.From, to = effect.To;
            WrappedCard trick = effect.Card;

            if (positive && !keep)
            {
                if (ai.IsFriend(to) && ai.HasSkill("gangzhi", to) && !to.Chained)
                {
                    result.Null = true;
                }
            }

            return(result);
        }
        public override NulliResult OnNullification(TrustedAI ai, CardEffectStruct effect, bool positive, bool keep)
        {
            NulliResult   result = new NulliResult();
            Room          room = ai.Room;
            Player        player = ai.Self;
            Player        from = effect.From, to = effect.To;
            WrappedCard   trick   = effect.Card;
            List <Player> delete  = new List <Player>(effect.StackPlayers);
            List <Player> targets = new List <Player>(delete);

            foreach (Player p in delete)
            {
                if (delete.IndexOf(p) < delete.IndexOf(to))
                {
                    targets.Remove(p);
                }
            }

            double good = 0;

            if (positive)
            {
                if (ai.IsEnemy(to))
                {
                    good += 4;
                    if (ai.HasSkill(TrustedAI.MasochismSkill, to))
                    {
                        good += 3;
                    }
                    if (ai.IsWeak(to) && to.Hp <= 1)
                    {
                        good += 5;
                    }

                    if (good > 8)
                    {
                        result.Null = true;
                    }
                }
            }
            else
            {
                if (ai.IsFriend(to))
                {
                    good += 4;
                    if (ai.HasSkill(TrustedAI.MasochismSkill, to))
                    {
                        good += 3;
                    }
                    if (ai.IsWeak(to) && to.Hp <= 1)
                    {
                        good += 5;
                    }

                    if (good > 8)
                    {
                        result.Null = true;
                    }
                }
            }
            return(result);
        }
示例#7
0
 public override void OnEffect(Room room, CardEffectStruct effect)
 {
     room.DrawCards(effect.To, new DrawCardStruct(1, effect.From, Name));
 }
        public override NulliResult OnNullification(TrustedAI ai, CardEffectStruct effect, bool positive, bool keep)
        {
            NulliResult result = new NulliResult();
            Room        room = ai.Room;
            Player      from = effect.From, to = effect.To;
            WrappedCard trick  = effect.Card;
            Player      player = ai.Self;

            List <Player> players = new List <Player>();

            foreach (Player p in room.GetAlivePlayers())
            {
                if (p.IsFemale())
                {
                    players.Add(p);
                }
            }

            int count = Math.Min(players.Count, to.HandcardNum);

            if (positive)
            {
                if (ai.IsFriend(to))
                {
                    double value = -count;
                    if (from.HandcardNum + count < to.HandcardNum)
                    {
                        DamageStruct damage = new DamageStruct(trick, from, to);
                        value += ai.GetDamageScore(damage).Score;
                    }

                    if (count <= -2)
                    {
                        result.Null = true;
                    }
                }
            }
            else
            {
                if (ai.IsFriend(from))
                {
                    double value = count;
                    if (count > 0)
                    {
                        room.SortByActionOrder(ref players);
                        for (int i = 0; i < count; i++)
                        {
                            if (ai.IsFriend(players[i]) && players[i].HandcardNum > 0)
                            {
                                value += players[i].HandcardNum / 5;
                            }
                        }
                    }
                    if (from.HandcardNum + count < to.HandcardNum)
                    {
                        DamageStruct damage = new DamageStruct(trick, from, to);
                        value += ai.GetDamageScore(damage).Score;
                    }

                    if (count > 3)
                    {
                        result.Null = true;
                    }
                }
            }

            return(result);
        }
        public override NulliResult OnNullification(TrustedAI ai, CardEffectStruct effect, bool positive, bool keep)
        {
            NulliResult result = new NulliResult();
            Room        room = ai.Room;
            Player      from = effect.From, to = effect.To;
            WrappedCard trick  = effect.Card;
            Player      player = ai.Self;

            if (positive)
            {
                ScoreStruct score = new ScoreStruct
                {
                    Score = 0
                };
                if (from.Alive)
                {
                    DamageStruct damage = new DamageStruct(trick, from, to);
                    score = ai.GetDamageScore(damage);
                }

                if (to.IsWounded())
                {
                    if (ai.IsFriend(to))
                    {
                        score.Score += 1 * to.GetLostHp();
                    }
                    else if (ai.IsEnemy(to))
                    {
                        score.Score -= 1 * to.GetLostHp();
                    }
                }

                if (score.Score <= -4)
                {
                    result.Null = true;
                }
            }
            else
            {
                ScoreStruct score = new ScoreStruct
                {
                    Score = 0
                };
                if (from.Alive)
                {
                    DamageStruct damage = new DamageStruct(trick, from, to);
                    score = ai.GetDamageScore(damage);
                }

                if (to.IsWounded())
                {
                    if (ai.IsFriend(to))
                    {
                        score.Score += 1 * to.GetLostHp();
                    }
                    else if (ai.IsEnemy(to))
                    {
                        score.Score -= 1 * to.GetLostHp();
                    }
                }

                if (score.Score > 4)
                {
                    result.Null = true;
                }
            }

            return(result);
        }
示例#10
0
        public override void OnEffect(Room room, CardEffectStruct effect)
        {
            WrappedCard card = effect.Card;

            if (room.GetCardIdsOnTable(card).Count == 0)
            {
                return;
            }

            LogMessage log = new LogMessage
            {
                From = effect.To.Name,
                Type = "#DelayedTrick",
                Arg  = card.Name
            };

            room.SendLog(log);

            JudgeStruct judge_struct = new JudgeStruct
            {
                Pattern        = judge.Pattern,
                Good           = judge.Good,
                Negative       = judge.Negative,
                Reason         = judge.Reason,
                PlayAnimation  = judge.PlayAnimation,
                Time_consuming = judge.Time_consuming,
                Who            = effect.To
            };

            room.Judge(ref judge_struct);
            if (judge_struct.IsEffected())
            {
                TakeEffect(room, effect.To, card);
                List <int> table_cardids = room.GetCardIdsOnTable(card);
                if (table_cardids.Count > 0)
                {
                    //DummyCard dummy(table_cardids);
                    CardMoveReason reason = new CardMoveReason(CardMoveReason.MoveReason.S_REASON_NATURAL_ENTER, null);
                    //room->moveCardTo(&dummy, NULL, Player::DiscardPile, reason, true);
                    CardsMoveStruct move = new CardsMoveStruct(table_cardids, null, Place.DiscardPile, reason);
                    room.MoveCardsAtomic(new List <CardsMoveStruct> {
                        move
                    }, true);
                }
            }
            else if (movable)
            {
                OnNullified(room, effect.To, card);
            }
            else
            {
                List <int> table_cardids = room.GetCardIdsOnTable(card);
                if (table_cardids.Count > 0)
                {
                    CardMoveReason  reason = new CardMoveReason(CardMoveReason.MoveReason.S_REASON_NATURAL_ENTER, null);
                    CardsMoveStruct move   = new CardsMoveStruct(table_cardids, null, Place.DiscardPile, reason);
                    room.MoveCardsAtomic(new List <CardsMoveStruct> {
                        move
                    }, true);
                }
            }
        }
示例#11
0
 public virtual bool IsCancelable(Room room, CardEffectStruct effect) => effect.Card != null && effect.Card.Cancelable;
示例#12
0
 public virtual void OnEffect(Room room, CardEffectStruct effect)
 {
 }
示例#13
0
        public virtual void Use(Room room, CardUseStruct card_use)
        {
            WrappedCard   card           = card_use.Card;
            List <Player> targets        = card_use.To;
            List <string> nullified_list = room.GetTag("CardUseNullifiedList") != null ? (List <string>)room.GetTag("CardUseNullifiedList") : new List <string>();
            bool          all_nullified  = nullified_list.Contains("_ALL_TARGETS");

            foreach (Player target in targets)
            {
                CardEffectStruct effect = new CardEffectStruct
                {
                    Card      = card,
                    From      = card_use.From,
                    To        = target,
                    Multiple  = (targets.Count > 1),
                    Nullified = (all_nullified || nullified_list.Contains(target.Name)),
                    Drank     = card_use.Drank,
                };
                if (card_use.EffectCount != null)
                {
                    foreach (EffctCount count in new List <EffctCount>(card_use.EffectCount))
                    {
                        if ((count.From == card_use.From && count.To == target && count.Index == targets.IndexOf(target)) ||
                            (count.To == card_use.From && count.From == target) && count.Index == targets.IndexOf(target))
                        {
                            card_use.EffectCount.Remove(count);
                            if (effect.EffectCount != null)
                            {
                                effect.EffectCount.Add(count);
                            }
                            else
                            {
                                effect.EffectCount = new List <EffctCount> {
                                    count
                                }
                            };
                            break;
                        }
                    }
                }

                List <Player> players = new List <Player>();
                for (int i = targets.IndexOf(target); i < targets.Count; i++)
                {
                    if (!nullified_list.Contains(targets[i].Name) && !all_nullified)
                    {
                        players.Add(targets[i]);
                    }
                }
                room.SetTag("targets" + RoomLogic.CardToString(room, card), players);
                effect.StackPlayers = players;

                room.CardEffect(effect);
            }

            List <int> table_cardids = room.GetCardIdsOnTable(card);

            if (table_cardids.Count > 0)
            {
                CardMoveReason reason = new CardMoveReason(CardMoveReason.MoveReason.S_REASON_USE, card_use.From.Name, null, card.Skill, null)
                {
                    CardString = RoomLogic.CardToString(room, card)
                };
                if (targets.Count == 1)
                {
                    reason.TargetId = targets[0].Name;
                }
                CardsMoveStruct move = new CardsMoveStruct(table_cardids, card_use.From, null, Place.PlaceTable, Place.DiscardPile, reason);
                room.MoveCardsAtomic(new List <CardsMoveStruct> {
                    move
                }, true);
            }
        }
        public override WrappedCard AskForNullification(CardEffectStruct effect, bool positive, CardEffectStruct real)
        {
            Player      from = effect.From, to = effect.To;
            WrappedCard trick = effect.Card;

            Choice[HegNullification.ClassName] = null;
            if (!to.Alive)
            {
                return(null);
            }

            List <WrappedCard> nullcards = GetCards(Nullification.ClassName, self);

            if (nullcards.Count == 0)
            {
                return(null);
            }

            int null_num = nullcards.Count;

            SortByUseValue(ref nullcards);
            WrappedCard null_card = null;

            foreach (WrappedCard c in nullcards)
            {
                if (!RoomLogic.IsCardLimited(room, self, c, HandlingMethod.MethodUse))
                {
                    null_card = c;
                }
            }

            if (null_card == null)
            {
                return(null);
            }

            if (null_num > 1)
            {
                foreach (WrappedCard card in nullcards)
                {
                    if (card.Name != HegNullification.ClassName && !RoomLogic.IsCardLimited(room, self, card, HandlingMethod.MethodUse))
                    {
                        null_card = card;
                        break;
                    }
                }
            }
            if (RoomLogic.IsCardLimited(room, self, null_card, FunctionCard.HandlingMethod.MethodUse))
            {
                return(null);
            }

            if (null_num == 1 && HasSkill("kanpo") && self.Phase == Player.PlayerPhase.NotActive && self.IsLastHandCard(null_card))
            {
                foreach (Player p in GetFriends(self))
                {
                    if (HasSkill("shouchen", p))
                    {
                        null_num = 2;
                        break;
                    }
                }
            }
            bool keep = false;

            if (null_num == 1)
            {
                bool only = true;
                foreach (Player p in FriendNoSelf)
                {
                    if (GetKnownCardsNums(Nullification.ClassName, "he", p, self) > 0)
                    {
                        only = false;
                        break;
                    }
                }

                if (only)
                {
                    foreach (Player p in GetFriends(self))
                    {
                        if (RoomLogic.PlayerContainsTrick(room, p, Indulgence.ClassName) && !HasSkill("guanxing|yizhi|shensu|qiaobian") && p.HandcardNum >= p.Hp &&
                            (trick.Name != Indulgence.ClassName) || p.Name != to.Name)
                        {
                            keep = true;
                            break;
                        }
                    }
                }
            }
            UseCard use = Engine.GetCardUsage(trick.Name);

            if (use != null)
            {
                UseCard.NulliResult result = use.OnNullification(this, effect, positive, keep);
                if (result.Null)
                {
                    if (result.Heg)
                    {
                        foreach (WrappedCard card in nullcards)
                        {
                            if (card.Name == HegNullification.ClassName && !RoomLogic.IsCardLimited(room, self, card, HandlingMethod.MethodUse))
                            {
                                Choice[HegNullification.ClassName] = "all";
                                null_card = card;
                                break;
                            }
                        }
                    }
                    return(null_card);
                }
            }
            return(null);
        }