Example #1
0
        protected void Run(Player Owner, GameEvent gameEvent, GameEventArgs eventArgs)
        {
            Player           dest   = eventArgs.Targets[0];
            IPlayerProxy     ui     = Game.CurrentGame.UiProxies[Owner];
            List <DeckPlace> places = new List <DeckPlace>();

            places.Add(new DeckPlace(dest, DeckType.Hand));
            places.Add(new DeckPlace(dest, DeckType.Equipment));
            List <string> resultDeckPlace = new List <string>();

            resultDeckPlace.Add("MengJin");
            List <int> resultDeckMax = new List <int>();

            resultDeckMax.Add(1);
            List <List <Card> > answer;

            if (!ui.AskForCardChoice(new CardChoicePrompt("MengJin", Owner), places, resultDeckPlace, resultDeckMax, new RequireOneCardChoiceVerifier(), out answer))
            {
                Trace.TraceInformation("Player {0} Invalid answer", Owner);
                answer = new List <List <Card> >();
                answer.Add(Game.CurrentGame.PickDefaultCardsFrom(places));
            }
            Card theCard = answer[0][0];

            Trace.Assert(answer.Count == 1 && answer[0].Count == 1);

            Game.CurrentGame.HandleCardDiscard(dest, new List <Card>()
            {
                theCard
            });
        }
Example #2
0
            protected void Run(Player Owner, GameEvent gameEvent, GameEventArgs eventArgs)
            {
                Core.Utils.GameDelays.Delay(Core.Utils.GameDelays.HanBingJian);
                Player dest = eventArgs.Targets[0];

                for (int i = 0; i < 2 && Game.CurrentGame.Decks[dest, DeckType.Hand].Concat(Game.CurrentGame.Decks[dest, DeckType.Equipment]).Count() > 0; i++)
                {
                    IPlayerProxy ui = Game.CurrentGame.UiProxies[Owner];
                    if (Owner.IsDead)
                    {
                        return;
                    }
                    List <DeckPlace> places = new List <DeckPlace>();
                    places.Add(new DeckPlace(dest, DeckType.Hand));
                    places.Add(new DeckPlace(dest, DeckType.Equipment));
                    List <string> resultDeckPlace = new List <string>();
                    resultDeckPlace.Add("HanBing");
                    List <int> resultDeckMax = new List <int>();
                    resultDeckMax.Add(1);
                    List <List <Card> > answer;
                    if (!ui.AskForCardChoice(new CardChoicePrompt("HanBing"), places, resultDeckPlace, resultDeckMax, new RequireOneCardChoiceVerifier(), out answer))
                    {
                        Trace.TraceInformation("Player {0} Invalid answer", Owner.Id);
                        answer = new List <List <Card> >();
                        answer.Add(new List <Card>());
                        var collection = Game.CurrentGame.Decks[dest, DeckType.Hand].Concat
                                             (Game.CurrentGame.Decks[dest, DeckType.Equipment]);
                        answer[0].Add(collection.First());
                    }
                    Trace.Assert(answer.Count == 1 && answer[0].Count == 1);
                    Game.CurrentGame.HandleCardDiscard(dest, answer[0]);
                }
                throw new TriggerResultException(TriggerResult.End);
            }
Example #3
0
        public void TryAskForCardChoice(Prompt prompt, List <DeckPlace> sourceDecks, List <string> resultDeckNames, List <int> resultDeckMaximums, ICardChoiceVerifier verifier, AdditionalCardChoiceOptions options, CardChoiceRearrangeCallback callback)
        {
            List <List <Card> > answer;

            if (!IsPlayable)
            {
                if (IsUiDetached)
                {
                    return;
                }
                uiProxy.AskForCardChoice(prompt, sourceDecks, resultDeckNames, resultDeckMaximums, verifier, out answer, options, callback);
                return;
            }
            if (IsUiDetached || !uiProxy.AskForCardChoice(prompt, sourceDecks, resultDeckNames, resultDeckMaximums, verifier, out answer, options, callback) ||
                answer == null)
            {
                Trace.TraceInformation("Invalid answer");
                client.Send(AskForCardChoiceResponse.Parse(numQuestionsAsked, null, 0, client.SelfId));
            }
            else
            {
                client.Send(AskForCardChoiceResponse.Parse(numQuestionsAsked, answer, options == null ? 0 : options.OptionResult, client.SelfId));
            }
        }
Example #4
0
        protected override void Process(Player source, Player dest, ICard card, ReadOnlyCard readonlyCard, GameEventArgs inResponseTo)
        {
            IPlayerProxy ui = Game.CurrentGame.UiProxies[source];

            if (source.IsDead)
            {
                return;
            }
            if (dest.HandCards().Count + dest.Equipments().Count + dest.DelayedTools().Count == 0)
            {
                return;                                                                                    // ShunChai -> WuXie(from target) -> WuXie(soemone else) -> target has no card
            }
            List <DeckPlace> places = new List <DeckPlace>();

            places.Add(new DeckPlace(dest, DeckType.Hand));
            places.Add(new DeckPlace(dest, DeckType.Equipment));
            places.Add(new DeckPlace(dest, DeckType.DelayedTools));
            List <string> resultDeckPlace = new List <string>();

            resultDeckPlace.Add(ResultDeckName);
            List <int> resultDeckMax = new List <int>();

            resultDeckMax.Add(1);
            List <List <Card> > answer;

            if (!ui.AskForCardChoice(new CardChoicePrompt(ChoicePrompt), places, resultDeckPlace, resultDeckMax, new RequireOneCardChoiceVerifier(true), out answer))
            {
                Trace.TraceInformation("Player {0} Invalid answer", source.Id);
                answer = new List <List <Card> >();
                answer.Add(Game.CurrentGame.PickDefaultCardsFrom(places));
            }
            Card theCard = answer[0][0];

            if (ShunChaiDest(source, dest).DeckType == DeckType.Discard)
            {
                Game.CurrentGame.HandleCardDiscard(dest, new List <Card>()
                {
                    theCard
                });
            }
            else
            {
                Game.CurrentGame.HandleCardTransferToHand(dest, source, new List <Card>()
                {
                    theCard
                });
            }
        }
Example #5
0
        void Run(Player Owner, GameEvent gameEvent, GameEventArgs eventArgs)
        {
            DeckType      mjDeck   = DeckType.Register("ManJuan");
            List <Card>   theCards = new List <Card>(eventArgs.Cards);
            CardsMovement move     = new CardsMovement();

            move.Cards = eventArgs.Cards;
            move.To    = new DeckPlace(null, DeckType.Discard);
            move.Helper.IsFakedMove = true;
            Game.CurrentGame.MoveCards(move);
            if (Game.CurrentGame.CurrentPlayer == Owner)
            {
                foreach (var reclaim in theCards)
                {
                    List <Card> garbageList = new List <Card>();
                    foreach (var garbage in Game.CurrentGame.Decks[null, DeckType.Discard])
                    {
                        if (garbage.Rank == reclaim.Rank)
                        {
                            garbageList.Add(garbage);
                        }
                    }
                    move       = new CardsMovement();
                    move.Cards = garbageList;
                    move.To    = new DeckPlace(null, mjDeck);
                    move.Helper.IsFakedMove = true;
                    Game.CurrentGame.MoveCards(move);

                    IPlayerProxy        ui = Game.CurrentGame.UiProxies[Owner];
                    List <List <Card> > answer;

                    if (!ui.AskForCardChoice(new CardChoicePrompt("ManJuan", Owner), new List <DeckPlace>()
                    {
                        new DeckPlace(null, mjDeck)
                    }, new List <string>()
                    {
                        "ZuiXiang"
                    }, new List <int>()
                    {
                        1
                    }, new RequireOneCardChoiceVerifier(), out answer))
                    {
                        Trace.TraceInformation("Player {0} Invalid answer", Owner);
                        answer = new List <List <Card> >();
                        answer.Add(new List <Card>());
                        answer[0].Add(Game.CurrentGame.Decks[null, mjDeck][0]);
                    }
                    Trace.Assert(answer.Count == 1 && answer[0].Count == 1);

                    move       = new CardsMovement();
                    move.Cards = new List <Card>(answer[0]);
                    move.To    = new DeckPlace(Owner, DeckType.Hand);
                    Game.CurrentGame.MoveCards(move);
                    move       = new CardsMovement();
                    move.Cards = new List <Card>(Game.CurrentGame.Decks[null, mjDeck]);
                    move.To    = new DeckPlace(null, DeckType.Discard);
                    move.Helper.IsFakedMove = true;
                    Game.CurrentGame.MoveCards(move);
                }
            }
        }