Ejemplo n.º 1
0
        public override void Play(Player player)
        {
            base.Play(player);

            CardBenefit benefit = new CardBenefit();

            Choice choice = new Choice("Choose one:", this, new CardCollection()
            {
                this
            }, new List <string>()
            {
                "+2<nbsp/>Cards", "+<coin>2</coin>", "Trash 2 cards from your hand"
            }, player);
            ChoiceResult result = player.MakeChoice(choice);

            if (result.Options.Contains("+2<nbsp/>Cards"))
            {
                benefit.Cards = 2;
            }
            else if (result.Options.Contains("+<coin>2</coin>"))
            {
                benefit.Currency += new Coin(2);
            }
            else
            {
                Choice       choiceTrash = new Choice("Choose 2 cards to trash", this, player.Hand, player, false, 2, 2);
                ChoiceResult resultTrash = player.MakeChoice(choiceTrash);
                player.Trash(player.RetrieveCardsFrom(DeckLocation.Hand, resultTrash.Cards));
            }

            player.ReceiveBenefit(this, benefit);
        }
Ejemplo n.º 2
0
        public override void Play(Player player)
        {
            base.Play(player);

            player.Gain(player._Game.Table.Estate);

            IEnumerator <Player> enumerator = player._Game.GetPlayersStartingWithEnumerator(player);

            enumerator.MoveNext();
            while (enumerator.MoveNext())
            {
                Player attackee = enumerator.Current;
                // Skip if the attack is blocked (Moat, Lighthouse, etc.)
                if (this.IsAttackBlocked[attackee])
                {
                    continue;
                }

                attackee.Gain(player._Game.Table.Curse);

                Choice       choice = new Choice("Choose cards to discard.  You must discard down to 3 cards in hand", this, attackee.Hand, attackee, false, attackee.Hand.Count - 3, attackee.Hand.Count - 3);
                ChoiceResult result = attackee.MakeChoice(choice);
                attackee.Discard(DeckLocation.Hand, result.Cards);
            }
        }
Ejemplo n.º 3
0
        internal override void Act(Card card, TokenActionEventArgs e)
        {
            base.Act(card, e);

            Player player = e.Actee as Player;

            // Already been cancelled -- don't need to process this one
            if (e.Cancelled || !e.Actee.Hand.Contains(card) || e.HandledBy.Contains(card.CardType))
            {
                return;
            }

            // Bane token/card only protects against other attackers
            if (player == e.Actor)
            {
                return;
            }
            Choice       choice = Choice.CreateYesNoChoice(String.Format("Reveal Bane card {0} to block gaining a Curse card?", card.Name), card, e.ActingCard, player, e);
            ChoiceResult result = player.MakeChoice(choice);

            if (result.Options[0] == "Yes")
            {
                player.AddCardInto(DeckLocation.Revealed, e.Actee.RetrieveCardFrom(DeckLocation.Hand, card));
                e.Cancelled = true;
                player.AddCardInto(DeckLocation.Hand, e.Actee.RetrieveCardFrom(DeckLocation.Revealed, card));
            }
            e.HandledBy.Add(card.CardType);
        }
Ejemplo n.º 4
0
        public override void Play(Player player)
        {
            base.Play(player);

            Choice choice = new Choice("Choose 1:", this, new CardCollection()
            {
                this
            }, new List <string>()
            {
                "+3<nbsp/>Cards", "+2<nbsp/>Actions"
            }, player);
            ChoiceResult result = player.MakeChoice(choice);

            CardBenefit benefit = new CardBenefit();

            if (result.Options.Contains("+3<nbsp/>Cards"))
            {
                benefit.Cards = 3;
            }
            if (result.Options.Contains("+2<nbsp/>Actions"))
            {
                benefit.Actions = 2;
            }
            player.ReceiveBenefit(this, benefit);
        }
Ejemplo n.º 5
0
        public override void Play(Player player)
        {
            base.Play(player);

            Choice       choiceAction = new Choice("You may discard a card for +1 Action.", this, player.Hand, player, false, 0, 1);
            ChoiceResult resultAction = player.MakeChoice(choiceAction);

            if (resultAction.Cards.Count > 0)
            {
                player.Discard(DeckLocation.Hand, resultAction.Cards);
                player.ReceiveBenefit(this, new CardBenefit()
                {
                    Actions = 1
                });
            }

            Choice       choiceBuy = new Choice("You may discard a card for +1 Buy.", this, player.Hand, player, false, 0, 1);
            ChoiceResult resultBuy = player.MakeChoice(choiceBuy);

            if (resultBuy.Cards.Count > 0)
            {
                player.Discard(DeckLocation.Hand, resultBuy.Cards);
                player.ReceiveBenefit(this, new CardBenefit()
                {
                    Buys = 1
                });
            }
        }
Ejemplo n.º 6
0
        public override void Play(Player player)
        {
            base.Play(player);

            Choice choice = new Choice("Choose 2:", this, new CardCollection()
            {
                this
            }, new List <string>()
            {
                "+1<nbsp/>Card", "+1<nbsp/>Action", "+1<nbsp/>Buy", "+<coin>1</coin>"
            }, player, null, true, 2, 2);
            ChoiceResult result = player.MakeChoice(choice);

            foreach (String option in result.Options)
            {
                CardBenefit benefit = new CardBenefit();
                if (option == "+1<nbsp/>Card")
                {
                    benefit.Cards = 1;
                }
                if (option == "+1<nbsp/>Action")
                {
                    benefit.Actions = 1;
                }
                if (option == "+1<nbsp/>Buy")
                {
                    benefit.Buys = 1;
                }
                if (option == "+<coin>1</coin>")
                {
                    benefit.Currency += new Coin(1);
                }
                player.ReceiveBenefit(this, benefit);
            }
        }
Ejemplo n.º 7
0
 public override void Play(Player player)
 {
     base.Play(player);
     while (player.Hand.Count < 7 && player.CanDraw)
     {
         Card card = player.Draw(DeckLocation.Private);
         if ((card.Category & Category.Action) == Category.Action)
         {
             Choice       choice = Choice.CreateYesNoChoice(String.Format("Would you like to set aside {0}?", card.Name), this, card, player, null);
             ChoiceResult result = player.MakeChoice(choice);
             if (result.Options[0] == "Yes")
             {
                 player.AddCardInto(DeckLocation.Revealed, player.RetrieveCardFrom(DeckLocation.Private, card));
             }
             else if (result.Options[0] == "No")
             {
                 player.AddCardToHand(player.RetrieveCardFrom(DeckLocation.Private, card));
             }
         }
         else
         {
             player.AddCardToHand(player.RetrieveCardFrom(DeckLocation.Private, card));
         }
     }
     player.DiscardRevealed();
 }
Ejemplo n.º 8
0
        public override void Play(Player player)
        {
            base.Play(player);
            SupplyCollection gainableSupplies = player._Game.Table.Supplies.FindAll(supply => supply.CanGain() && supply.CurrentCost <= new Coin(4));
            Choice           choice           = new Choice("Gain a card costing up to <coin>4</coin>", this, gainableSupplies, player, false);
            ChoiceResult     result           = player.MakeChoice(choice);

            if (result.Supply != null)
            {
                CardBenefit benefit = new CardBenefit();

                if (player.Gain(result.Supply))
                {
                    if ((result.Supply.Category & Cards.Category.Action) == Cards.Category.Action)
                    {
                        benefit.Actions = 1;
                    }
                    if ((result.Supply.Category & Cards.Category.Treasure) == Cards.Category.Treasure)
                    {
                        benefit.Currency += new Coin(1);
                    }
                    if ((result.Supply.Category & Cards.Category.Victory) == Cards.Category.Victory)
                    {
                        benefit.Cards = 1;
                    }

                    player.ReceiveBenefit(this, benefit);
                }
            }
        }
Ejemplo n.º 9
0
        public override void Play(Player player)
        {
            this._CanCleanUp = true;

            base.Play(player);

            Choice       choice = new Choice(String.Format("Choose an Action card to play twice", player), this, player.Hand[Cards.Category.Action], player);
            ChoiceResult result = player.MakeChoice(choice);

            if (result.Cards.Count > 0)
            {
                result.Cards[0].ModifiedBy = this;
                player.Actions++;
                PlayerMode previousPlayerMode = player.PutCardIntoPlay(result.Cards[0], String.Empty);
                Card       logicalCard        = result.Cards[0].LogicalCard;
                player.PlayCard(result.Cards[0].LogicalCard, previousPlayerMode);
                player.Actions++;
                previousPlayerMode = player.PutCardIntoPlay(result.Cards[0], "again");
                player.PlayCard(logicalCard, previousPlayerMode);

                this._CanCleanUp = logicalCard.CanCleanUp;
            }
            else
            {
                player.PlayNothing();
            }
        }
        /// <summary>
        /// 在创建前
        /// </summary>
        /// <param name="args"></param>
        /// <param name="canContinue"></param>
        public override void BeforeCreating(BeforeCreatingAspectArgs args, ref bool canContinue)
        {
            IDevice selectedDevice = OpenFx.BaseApi.SelectedDevice;
            bool    _canContinue   = false;

            if (!VersionCheck(selectedDevice, ver))
            {
                args.Context.App.RunOnUIThread(() =>
                {
                    var fmt             = args.Context.App.GetPublicResouce <string>("OpenFxLowAndroidVersionFmt");
                    var btnIgnore       = args.Context.App.GetPublicResouce <string>("OpenFxLowAndroidBtnIgnore");
                    var btnOK           = args.Context.App.GetPublicResouce <string>("OpenFxLowAndroidBtnOK");
                    var btnCancel       = args.Context.App.GetPublicResouce <string>("OpenFxLowAndroidBtnCancel");
                    var msg             = string.Format(fmt, ver);
                    ChoiceResult result = args.Context.Ux.DoChoice(msg, btnIgnore, btnOK, btnCancel);
                    switch (result)
                    {
                    case ChoiceResult.Left:
                        _canContinue = true;
                        break;

                    default:
                        _canContinue = false;
                        break;
                    }
                });
            }
            canContinue = _canContinue;
        }
Ejemplo n.º 11
0
        private void Proxy_ChosenAnnounced(string id, ChoiceResult result)
        {
            var    friend = GetFriend(id);
            string title, content;

            switch (result)
            {
            case ChoiceResult.Undone:
                title   = "Wait!";
                content = $"{friend.Name} didn't make a choice.";
                break;

            case ChoiceResult.Successful:
                title   = "Congratulation!";
                content = $"{friend.Name} chose you.";
                break;

            case ChoiceResult.Failed:
                title   = "Sorry!";
                content = $"{friend.Name} didn't choose you.";
                break;

            case ChoiceResult.Done:
                title   = "Error!";
                content = "You completed your choice.";
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            NotificationRequestProvider.NotifyOnUiThread(title, content);
        }
Ejemplo n.º 12
0
        public override void Play(Player player)
        {
            Choice       choice = new Choice("Trash a card.", this, player.Hand, player);
            ChoiceResult result = player.MakeChoice(choice);

            if (result.Cards.Count > 0)
            {
                Card trash = player.RetrieveCardFrom(DeckLocation.Hand, result.Cards[0]);

                player.Trash(trash);
                if ((trash.Category & Category.Action) == Category.Action)
                {
                    player.Gain(player._Game.Table.Duchy);
                }
                if ((trash.Category & Category.Treasure) == Category.Treasure)
                {
                    player.Gain(player._Game.Table[Cards.Alchemy.TypeClass.Transmute]);
                }
                if ((trash.Category & Category.Victory) == Category.Victory)
                {
                    player.Gain(player._Game.Table.Gold);
                }
            }

            base.Play(player);
        }
Ejemplo n.º 13
0
        public override void Play(Player player)
        {
            base.Play(player);
            if (player.InPlay.Contains(this.PhysicalCard))
            {
                Choice       choice = Choice.CreateYesNoChoice("Do you want to set this card aside?", this, player);
                ChoiceResult result = player.MakeChoice(choice);
                if (result.Options[0] == "Yes")
                {
                    player.AddCardInto(TypeClass.PrinceSetAside, player.RetrieveCardFrom(DeckLocation.InPlay, this.PhysicalCard));

                    if (_TurnStartedEventHandler != null)
                    {
                        player.TurnStarted -= _TurnStartedEventHandler;
                    }
                    _TurnStartedPlayer              = player;
                    _TurnStartedEventHandler        = new Player.TurnStartedEventHandler(player_TurnStarted);
                    _TurnStartedPlayer.TurnStarted += _TurnStartedEventHandler;

                    Choice       setAsideChoice = new Choice("Choose a card to set aside", this, player.Hand[c => (c.Category & Cards.Category.Action) == Cards.Category.Action && player._Game.ComputeCost(c) <= new Coin(4)], player, false, 1, 1);
                    ChoiceResult setAsideResult = player.MakeChoice(setAsideChoice);
                    if (setAsideResult.Cards.Count > 0)
                    {
                        _SetAsideCard = player.RetrieveCardFrom(DeckLocation.Hand, setAsideResult.Cards[0]);
                        player.PlayerMats[TypeClass.PrinceSetAside].Refresh(player);
                        player._Game.SendMessage(player, this, this._SetAsideCard);
                    }
                }
            }
        }
Ejemplo n.º 14
0
        public ChoiceResult DoChoice(string message, string btnLeft = null, string btnRight = null, string btnCancel = null)
        {
            ChoiceResult result = ChoiceResult.Cancel;

            RunOnUIThread(() =>
            {
                dynamic window = sourceApi.CreateChoiceWindow(message, btnLeft, btnRight, btnCancel);
                window.ShowDialog();
                switch (window.DialogResult)
                {
                case true:
                    result = ChoiceResult.Right;
                    break;

                case false:
                    result = ChoiceResult.Left;
                    break;

                default:
                    result = ChoiceResult.Cancel;
                    break;
                }
            });
            return(result);
        }
Ejemplo n.º 15
0
        public override void Play(Player player)
        {
            base.Play(player);

            // discard 2 cards
            Choice       choiceDiscard = new Choice("Choose two cards to discard", this, player.Hand, player, false, 2, 2);
            ChoiceResult resultDiscard = player.MakeChoice(choiceDiscard);

            player.Discard(DeckLocation.Hand, resultDiscard.Cards);

            IEnumerator <Player> enumerator = player._Game.GetPlayersStartingWithEnumerator(player);

            enumerator.MoveNext();
            while (enumerator.MoveNext())
            {
                Player attackee = enumerator.Current;
                if (this.IsAttackBlocked[attackee])
                {
                    continue;
                }

                if (!attackee.TokenActOn(player, this))
                {
                    continue;
                }

                attackee.Gain(player._Game.Table.Curse);
            }
        }
Ejemplo n.º 16
0
        public override void Overpay(Player player, Currency amount)
        {
            for (int i = 0; i < amount.Coin.Value; i++)
            {
                if (!player.CanDraw)
                {
                    break;
                }
                Card   card   = player.Draw(DeckLocation.Private);
                Choice choice = new Choice(String.Format("Do you want to discard {0}, trash {0}, or put it back on top?", card.Name), this, new CardCollection()
                {
                    card
                }, new List <string>()
                {
                    "Discard", "Trash", "Put it back"
                }, player);
                ChoiceResult result = player.MakeChoice(choice);
                switch (result.Options[0])
                {
                case "Discard":
                    player.Discard(DeckLocation.Private);
                    break;

                case "Trash":
                    player.Trash(DeckLocation.Private, card);
                    break;

                default:
                    player.AddCardsToDeck(player.RetrieveCardsFrom(DeckLocation.Private), DeckPosition.Top);
                    break;
                }
            }
        }
Ejemplo n.º 17
0
        public override void Play(Player player)
        {
            base.Play(player);

            // Perform attack on every player
            IEnumerator <Player> enumerator = player._Game.GetPlayersStartingWithEnumerator(player);

            enumerator.MoveNext();             // skip active player
            while (enumerator.MoveNext())
            {
                Player attackee = enumerator.Current;
                // Skip if the attack is blocked (Moat, Lighthouse, etc.)
                if (this.IsAttackBlocked[attackee])
                {
                    continue;
                }

                if (attackee.CanDraw)
                {
                    Card card            = attackee.Draw(DeckLocation.Revealed);
                    Cost trashedCardCost = player._Game.ComputeCost(card);
                    attackee.Trash(attackee.RetrieveCardFrom(DeckLocation.Revealed, card));
                    SupplyCollection gainableSupplies = player._Game.Table.Supplies.FindAll(supply => supply.CanGain() && supply.CurrentCost == trashedCardCost);
                    Choice           choice           = new Choice(String.Format("Choose a card for {0} to gain", attackee), this, gainableSupplies, attackee, false);
                    ChoiceResult     result           = player.MakeChoice(choice);
                    if (result.Supply != null)
                    {
                        attackee.Gain(result.Supply);
                    }
                }
            }
        }
Ejemplo n.º 18
0
        public override void Overpay(Player player, Currency amount)
        {
            Choice       choice = new Choice("Choose cards to put on top of your deck", this, player.DiscardPile.LookThrough(c => true), player, false, amount.Coin.Value, amount.Coin.Value);
            ChoiceResult result = player.MakeChoice(choice);

            player.AddCardsInto(DeckLocation.Revealed, player.DiscardPile.Retrieve(player, c => result.Cards.Contains(c)));
            player.AddCardsToDeck(player.Revealed.Retrieve(player, c => result.Cards.Contains(c)), DeckPosition.Top);
        }
Ejemplo n.º 19
0
        public override void Play(Player player)
        {
            base.Play(player);

            // Perform attack on every player
            IEnumerator <Player> enumerator = player._Game.GetPlayersStartingWithEnumerator(player);

            enumerator.MoveNext();             // skip active player
            while (enumerator.MoveNext())
            {
                Player attackee = enumerator.Current;
                // Skip if the attack is blocked (Moat, Lighthouse, etc.)
                if (this.IsAttackBlocked[attackee])
                {
                    continue;
                }

                if (attackee.CanDraw)
                {
                    Card card = attackee.Draw(DeckLocation.Revealed);
                    attackee.DiscardRevealed();

                    if ((card.Category & Cards.Category.Victory) == Cards.Category.Victory)
                    {
                        attackee.Gain(player._Game.Table.Curse);
                    }
                    else
                    {
                        Supply supply = null;
                        if (player._Game.Table.Supplies.ContainsKey(card))
                        {
                            supply = player._Game.Table[card];
                        }
                        if (supply != null && supply.CanGain() && supply.TopCard.Name == card.Name)
                        {
                            Choice choice = new Choice(String.Format("Who should receive the copy of {0}?", card), this, new CardCollection()
                            {
                                card
                            },
                                                       new List <string>()
                            {
                                player.ToString(), attackee.ToString()
                            }, player);
                            ChoiceResult result = player.MakeChoice(choice);
                            if (result.Options[0] == player.ToString())
                            {
                                player.Gain(supply);
                            }
                            else
                            {
                                attackee.Gain(supply);
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 20
0
        public override void Play(Player player)
        {
            base.Play(player);

            Choice       choiceTrash = new Choice("Choose up to 4 cards to trash", this, player.Hand, player, false, 0, 4);
            ChoiceResult resultTrash = player.MakeChoice(choiceTrash);

            player.Trash(player.RetrieveCardsFrom(DeckLocation.Hand, resultTrash.Cards));
        }
Ejemplo n.º 21
0
        public override void Play(Player player)
        {
            base.Play(player);

            Choice choice = new Choice("Choose 1. You get the version in parenthesis; everyone else gets the other:", this, new CardCollection()
            {
                this
            }, new List <string>()
            {
                "+1 (+3) Cards", "Gain a Silver (Gold)", "You may trash a card from your hand and gain a card costing exactly <coin>1</coin> (<coin>2</coin>) more"
            }, player);
            ChoiceResult         result     = player.MakeChoice(choice);
            IEnumerator <Player> enumerator = player._Game.GetPlayersStartingWithEnumerator(player);

            while (enumerator.MoveNext())
            {
                Player actee = enumerator.Current;
                if (result.Options.Contains("+1 (+3) Cards"))
                {
                    // 3 or 1 cards, depending on who it is
                    actee.ReceiveBenefit(this, new CardBenefit()
                    {
                        Cards = (actee == player ? 3 : 1)
                    });
                }
                else if (result.Options.Contains("Gain a Silver (Gold)"))
                {
                    if (actee == player)
                    {
                        actee.Gain(player._Game.Table.Gold);
                    }
                    else
                    {
                        actee.Gain(player._Game.Table.Silver);
                    }
                }
                else
                {
                    Choice       choiceTrash = new Choice("You may choose a card to trash", this, actee.Hand, actee, false, 0, 1);
                    ChoiceResult resultTrash = actee.MakeChoice(choiceTrash);
                    actee.Trash(actee.RetrieveCardsFrom(DeckLocation.Hand, resultTrash.Cards));

                    if (resultTrash.Cards.Count > 0)
                    {
                        Cost             trashedCardCost  = actee._Game.ComputeCost(resultTrash.Cards[0]);
                        SupplyCollection gainableSupplies = actee._Game.Table.Supplies.FindAll(supply => supply.CanGain() && supply.CurrentCost == (trashedCardCost + new Coin(actee == player ? 2 : 1)));
                        Choice           choiceGain       = new Choice("Gain a card", this, gainableSupplies, actee, false);
                        ChoiceResult     resultGain       = actee.MakeChoice(choiceGain);
                        if (resultGain.Supply != null)
                        {
                            actee.Gain(resultGain.Supply);
                        }
                    }
                }
            }
        }
Ejemplo n.º 22
0
        public override void Play(Player player)
        {
            base.Play(player);
            SupplyCollection gainableSupplies = player._Game.Table.Supplies.FindAll(supply => supply.CanGain() && supply.CurrentCost <= new Coin(4));
            Choice           choice           = new Choice("Gain a card costing up to <coin>4</coin>", this, gainableSupplies, player, false);
            ChoiceResult     result           = player.MakeChoice(choice);

            if (result.Supply != null)
            {
                player.Gain(result.Supply);
            }
        }
Ejemplo n.º 23
0
        public override void Play(Player player)
        {
            base.Play(player);

            Choice       choice = new Choice("Choose a card to put on top of your deck", this, player.Hand, player);
            ChoiceResult result = player.MakeChoice(choice);

            if (result.Cards.Count > 0)
            {
                player.AddCardToDeck(player.RetrieveCardFrom(DeckLocation.Hand, result.Cards[0]), DeckPosition.Top);
            }
        }
Ejemplo n.º 24
0
        public override void BeforeCreating(BeforeCreatingAspectArgs args, ref bool canContinue)
        {
            string       message      = CoreLib.Current.Languages.Get("EDpmSetterRemoveLock");
            string       btnLeft      = CoreLib.Current.Languages.Get("EDpmSetterRemoveLockBtnLeft");
            string       btnRight     = CoreLib.Current.Languages.Get("EDpmSetterRemoveLockBtnRight");
            string       btnCancel    = CoreLib.Current.Languages.Get("EDpmSetterRemoveLockBtnCancel");
            ChoiceResult choiceResult = CoreLib.Context.Ux
                                        .DoChoice(message, btnLeft, btnRight, btnCancel);
            bool isRemoved = choiceResult == ChoiceResult.Accept;

            canContinue = isRemoved;
        }
Ejemplo n.º 25
0
        public override void Play(Player player)
        {
            base.Play(player);

            Choice       choiceTrash = new Choice("You may choose a Treasure card to trash", this, player.Hand[Cards.Category.Treasure], player, false, 0, 1);
            ChoiceResult resultTrash = player.MakeChoice(choiceTrash);

            player.Trash(player.RetrieveCardsFrom(DeckLocation.Hand, resultTrash.Cards));

            if (resultTrash.Cards.Count > 0)
            {
                Cost trashedCardCost = player._Game.ComputeCost(resultTrash.Cards[0]);

                IEnumerator <Player> enumerator = player._Game.GetPlayersStartingWithEnumerator(player);
                enumerator.MoveNext();
                while (enumerator.MoveNext())
                {
                    Player attackee = enumerator.Current;
                    // Skip if the attack is blocked (Moat, Lighthouse, etc.)
                    if (this.IsAttackBlocked[attackee])
                    {
                        continue;
                    }

                    if (attackee.Hand.Count < 5)
                    {
                        continue;
                    }

                    // If the player doesn't have any of this card, reveal the player's hand
                    if (attackee.Hand[resultTrash.Cards[0].CardType].Count == 0)
                    {
                        attackee.ReturnHand(attackee.RevealHand());
                    }
                    // Otherwise, the player automatically discards the card (no real choices to be made here)
                    else
                    {
                        attackee.Discard(DeckLocation.Hand, attackee.Hand[resultTrash.Cards[0].CardType].First());
                    }
                }

                SupplyCollection gainableSupplies = player._Game.Table.Supplies.FindAll(
                    supply => supply.CanGain() &&
                    ((supply.Category & Cards.Category.Treasure) == Cards.Category.Treasure) &&
                    supply.CurrentCost <= (trashedCardCost + new Coin(3)));
                Choice       choice = new Choice("Gain a card", this, gainableSupplies, player, false);
                ChoiceResult result = player.MakeChoice(choice);
                if (result.Supply != null)
                {
                    player.Gain(result.Supply, DeckLocation.Deck, DeckPosition.Top);
                }
            }
        }
Ejemplo n.º 26
0
    void UpdateDisplayForChoice(ItemChoice chosenItem, ChoiceResult result)
    {
        var choiceIdx = ((int)chosenItem);

        if (result == ChoiceResult.Correct)
        {
            _checks[choiceIdx].SetActive(true);
        }
        else
        {
            _crosses[choiceIdx].SetActive(true);
        }
    }
Ejemplo n.º 27
0
        public override void Play(Player player)
        {
            base.Play(player);
            Choice       choice = Choice.CreateYesNoChoice("You may immediately put your deck into your discard pile.", this, this, player, null);
            ChoiceResult result = player.MakeChoice(choice);

            if (result.Options[0] == "Yes")
            {
                player._Game.SendMessage(player, this);
                CardCollection cc = player.RetrieveCardsFrom(DeckLocation.Deck);
                player.AddCardsInto(DeckLocation.Discard, cc);
            }
        }
Ejemplo n.º 28
0
        public override void Play(Player player)
        {
            base.Play(player);
            Choice       choice = new Choice("You may choose a Treasure card to discard", this, player.Hand[Cards.Category.Treasure], player, false, 0, 1);
            ChoiceResult result = player.MakeChoice(choice);

            if (result.Cards.Count > 0)
            {
                player.Discard(DeckLocation.Hand, result.Cards[0]);

                player.AddToken(new CoinToken());
            }
        }
Ejemplo n.º 29
0
        public override void Play(Player player)
        {
            base.Play(player);
            Choice       choice = new Choice("Discard any number of cards.  +<coin>1</coin> per card discarded.", this, player.Hand, player, false, 0, player.Hand.Count);
            ChoiceResult result = player.MakeChoice(choice);

            player.Discard(DeckLocation.Hand, result.Cards);

            CardBenefit benefit = new CardBenefit();

            benefit.Currency += new Coin(result.Cards.Count);
            player.ReceiveBenefit(this, benefit);
        }
Ejemplo n.º 30
0
        /// <summary>
        /// 在那之前...
        /// </summary>
        /// <param name="args"></param>
        /// <param name="canContinue"></param>
        public override void BeforeCreating(BeforeCreatingAspectArgs args, ref bool canContinue)
        {
            IDevice selectDevice = OpenFx.BaseApi.SelectedDevice;

            if (!InstallApplication(selectDevice, value))
            {
                ChoiceResult choice = ChoiceResult.Deny;
                args.Context.App.RunOnUIThread(() =>
                {
                    choice = args.Context.Ux.DoChoice("OpenFxInstallAppFirst", "OpenFxInstallBtnIgnore", "OpenFxInstallBtnOk");
                });
                canContinue = (choice == ChoiceResult.Deny);
            }
        }
Ejemplo n.º 31
0
		public ChoiceResult MakeChoice(Choice choice)
		{
			PlayerMode previous = this.PlayerMode;
			PlayerMode = Players.PlayerMode.Choosing;

			CardCollection cards = null;
			ChoiceResult result = null;
			switch (choice.ChoiceType)
			{
				case ChoiceType.Options:
					if (!choice.IsOrdered && choice.Minimum >= choice.Options.Count)
						result = new ChoiceResult(choice.Options);
					break;

				case ChoiceType.Cards:
					//if (choice.IsSpecific && choice.Minimum == 1 && choice.Cards.Count() == 1)
					//    result = new ChoiceResult(new CardCollection(choice.Cards));
					//else 
					IEnumerable<Card> nonDummyCards = choice.Cards.Where(c => c.CardType != Cards.Universal.TypeClass.Dummy);
					if (nonDummyCards.Count() == 0)
						cards = new CardCollection();
					else if (!choice.IsOrdered && choice.Minimum >= nonDummyCards.Count())
						result = new ChoiceResult(new CardCollection(nonDummyCards));
					else if (choice.Maximum == 0)
						cards = new CardCollection();
					else if (choice.Maximum == choice.Minimum &&
							(!choice.IsOrdered || nonDummyCards.Count(card => card.CardType == nonDummyCards.ElementAt(0).CardType) == nonDummyCards.Count()))
						cards = new CardCollection(nonDummyCards);
					break;

				case ChoiceType.Supplies:
					if (choice.Supplies.Count == 1 && choice.Minimum > 0)
						result = new ChoiceResult(choice.Supplies.Values.First());
					else if (choice.Supplies.Count == 0)
						result = new ChoiceResult();
					break;

				case ChoiceType.SuppliesAndCards:
					if (choice.Supplies.Count == 1 && choice.Cards.Count() == 0)
						result = new ChoiceResult(choice.Supplies.Values.First());
					else if (choice.Supplies.Count == 0 && choice.Cards.Count() == 1)
						result = new ChoiceResult(new CardCollection { choice.Cards.First() });
					else if (choice.Supplies.Count == 0)
						result = new ChoiceResult();
					break;

				default:
					throw new Exception("Unable to do anything with this Choice Type!");
			}
			if (result == null && cards != null)
			{
				if (cards.All(delegate(Card c) { return c.CardType == cards[0].CardType; }))
					result = new ChoiceResult(new CardCollection(cards.Take(choice.Minimum)));
			}
			if (result == null)
			{
				Thread choiceThread = new Thread(delegate()
				{
					Choose.Invoke(this, choice);
				});
				choiceThread.Start();
				WaitEvent.WaitOne();
				choiceThread = null;

				if (_MessageRequestQueue.Count > 0)
				{
					lock (_MessageRequestQueue)
					{
						PlayerMessage message = _MessageRequestQueue.Dequeue();
						//System.Diagnostics.Trace.WriteLine(String.Format("Message: {0}", message.Message));
						PlayerMessage response = new PlayerResponseMessage();
						response.Message = "ACK";

						if (message is PlayerChoiceMessage)
							result = ((PlayerChoiceMessage)message).ChoiceResult;

						lock (_MessageResponseQueue)
						{
							_MessageResponseQueue.Enqueue(response);
						}
						if (message.ReturnEvent != null)
							message.ReturnEvent.Set();
					}
				}
			}

			this.PlayerMode = previous;
			return result;
		}
Ejemplo n.º 32
0
		public PlayerChoiceMessage(AutoResetEvent returnEvent, Player player, ChoiceResult choiceResult)
			: base(returnEvent)
		{
			Player = player;
			ChoiceResult = choiceResult;
		}
Ejemplo n.º 33
0
		public PlayerChoiceMessage(Player player, ChoiceResult choiceResult)
			: this(null, player, choiceResult)
		{
		}