Ejemplo n.º 1
0
            private void PlayerDiscardsOneCard(IGame game, IEffectHandle handle, IPlayer player, IPlayerCard card)
            {
                if (player.Hand.Cards.Count() == 0)
                {
                    handle.Cancel(string.Format("{0} does not have any cards in their hand to discard", player.Name));
                    return;
                }

                player.DiscardFromHand(new List<IPlayerCard> { card });

                var controller = game.GetController(CardSource.Id);
                if (controller == null)
                {
                    handle.Cancel(string.Format("Could not determine the controller of {0}", CardSource.Title));
                    return;
                }

                var willpowerful = controller.CardsInPlay.OfType<IWillpowerfulInPlay>().Where(x => x.Card.Id == source.Id).FirstOrDefault();
                if (willpowerful == null)
                {
                    handle.Cancel(string.Format("'{0}' is no longer in play", CardSource.Title));
                    return;
                }

                game.AddEffect(new WillpowerModifier(game.CurrentPhase.Code, source, willpowerful, TimeScope.Phase, 1));

                handle.Resolve(string.Format("{0} discarded a card to give '{0}' +1 Willpower until the end of the phase", player.Name, CardSource.Title));
            }
Ejemplo n.º 2
0
        private IPlayerCard GetPlayerCard(string title)
        {
            var         key  = title;
            IPlayerCard card = null;

            if (playerCardMap.ContainsKey(key))
            {
                var prototype = playerCardMap[key];
                card = GetCard <IPlayerCard>(prototype);
            }
            else if (!title.Contains('('))
            {
                var allSets = (CardSet[])Enum.GetValues(typeof(CardSet));
                var lastSet = allSets[allSets.Length - 1];

                for (var i = 1; i <= (int)lastSet; i++)
                {
                    var cardSet = (CardSet)i;
                    key = string.Format("{0} ({1})", title, cardSet);
                    if (playerCardMap.ContainsKey(key))
                    {
                        var prototype = playerCardMap[key];
                        card = GetCard <IPlayerCard>(prototype);
                        break;
                    }
                }
            }

            return(card);
        }
Ejemplo n.º 3
0
    public void RemoveCardFromDeck(IPlayerCard card)
    {
        if (card == null)
        {
            return;
        }

        if (builtDeck.Remove(card))
        {
            int        numLeft = builtDeck.FindAll((obj) => { return(obj.Name == card.Name); }).Count;
            UICardView uiCardView;
            if (uiPlayerDeckCards.TryGetValue(card.Name, out uiCardView))
            {
                if (numLeft > 0)
                {
                    uiCardView.SetNumberOwned(numLeft);
                }
                else
                {
                    Destroy(uiCardView.gameObject);
                    uiPlayerDeckCards.Remove(card.Name);
                }
            }
        }
    }
Ejemplo n.º 4
0
    public bool ValidateAddCard(IPlayerCard card, out string reason)
    {
        if (builtDeck.Count >= maxDeckSize)
        {
            reason = "Your deck cannot have more than 21 cards in it.";
            return(false);
        }

        if (card.Driver != deckFaction && card.Driver != PlayerCardDriver.None)
        {
            IList <IPlayerCard> outOfFactionCards = builtDeck.FindAll((obj) => {
                return(obj.Driver != deckFaction &&
                       obj.Driver != PlayerCardDriver.None);
            });
            if (outOfFactionCards.Count >= maxOutOfFactionCards)
            {
                reason = "You cannot have more than 4 cards from different specialities.";
                return(false);
            }
        }

        IList <IPlayerCard> cards = builtDeck.FindAll((obj) => { return(obj.Name == card.Name); });

        if (cards.Count >= maxDuplicates)
        {
            reason = "You cannot have more than 2 copies of any card in your deck";
            return(false);
        }
        reason = "";
        return(true);
    }
Ejemplo n.º 5
0
 private static string GetPlayerCardTypeName(IPlayerCard card)
 {
     if (card is IHeroCard)
     {
         return("Hero");
     }
     else if (card is IAllyCard)
     {
         return("Ally");
     }
     else if (card is IAttachableCard)
     {
         return("Attachment");
     }
     else if (card is IEventCard)
     {
         return("Event");
     }
     else if (card is ITreasureCard)
     {
         return("Treasure");
     }
     else
     {
         return("Unknown");
     }
 }
Ejemplo n.º 6
0
        public void Setup(IPlayerCard card)
        {
            m_cardControlCostLayer.SetActive(true);

            UIPalette.CardTypeColourScheme scheme = UIPalette.Instance.GetCardTypeColorScheme(card.Driver);
            if (card.CardType == PlayerCardType.Damage)
            {
                scheme = UIPalette.Instance.DamageCardColours;
            }
            SetColourScheme(scheme);
            m_card = card;
            if (card.CardType != PlayerCardType.None)
            {
                m_cardTypeLayer.SetActive(true);
                m_cardTypeText.text = card.CardType.ToString();
            }
            else
            {
                m_cardTypeLayer.SetActive(false);
            }

            m_cardName.text        = card.Name;
            m_cardEffects.text     = card.Description;
            m_cardControlCost.text = card.ControlCost.ToString();
            m_cardImage.sprite     = card.CardImage;
            SetFlavourText(card.FlavourText);
        }
Ejemplo n.º 7
0
        private void CardRemovedFromHand(IPlayerCard card)
        {
            var viewModel = hand.Where(x => x.CardId == card.Id).FirstOrDefault();
            if (viewModel == null)
                return;

            Dispatch(() => hand.Remove(viewModel));
        }
Ejemplo n.º 8
0
        private void OnPlayerCardClicked(object sender, EventArgs e)
        {
            IPlayerCard clickedCard = (sender as GameObject)
                                      ?.GetComponent <UICardView>()
                                      ?.GetCard() as IPlayerCard;

            this.PlayerCardClicked?.Invoke(clickedCard);
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Queue an animation to show the drawing of a card into the player's hand.
        /// </summary>
        public void AnimateCardDraw(IPlayerCard card, Chase newState)
        {
            GameObject newCard    = this.SpawnCard(card, CardSpawnLocation.Hand);
            UICardView uiCardView = newCard.GetComponent <UICardView>();

            uiCardView.Anim.SetTrigger("PreDraw");
            AddAnimationToQueue(new QueuedAnimation(uiCardView.Anim, "Draw", null, null));
            this.PlayerDeckCountLabel.text = newState.PlayerDeck.Count.ToString("N0");
        }
        public PlayerCardViewModel(Dispatcher dispatcher, IPlayerCard card)
            : base(dispatcher)
        {
            if (card == null)
                throw new ArgumentNullException("card");

            this.card = card;
            this.cardFrontImageSource = string.Format("pack://application:,,,/Images/{0}_{1}.jpg", card.CardSet, card.CardNumber);
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Remove a specific card from the player's deck and add it to their hand.
        /// </summary>
        public ChaseMutator DrawSpecific(IPlayerCard card)
        {
            this.chase.Hand.Add(card);

            this.changesApplied.Add($"Drew {card.Name}.");

            this.uiManager.AnimateCardDraw(card, this.chase);

            return(this);
        }
        public PlayerCardViewModel(Dispatcher dispatcher, IPlayerCard card)
            : base(dispatcher)
        {
            if (card == null)
            {
                throw new ArgumentNullException("card");
            }

            this.card = card;
            this.cardFrontImageSource = string.Format("pack://application:,,,/Images/{0}_{1}.jpg", card.CardSet, card.CardNumber);
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Discard the specified card from the player's hand.
        /// </summary>
        public ChaseMutator DiscardFromHand(IPlayerCard card)
        {
            this.chase.Hand.Remove(card);
            this.chase.PlayerDiscard.Prepend(card);

            this.changesApplied.Add($"Discarded {card.Name} from player's hand.");

            this.uiManager.AnimateDiscard(card, this.chase);

            return(this);
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Exhaust the specified card from the player's hand.
        /// </summary>
        public ChaseMutator ExhaustFromHand(IPlayerCard card)
        {
            this.chase.Hand.Remove(card);
            this.chase.PlayerExhaust.Add(card);

            this.changesApplied.Add($"Exhausted {card.Name} from player's hand.");

            this.uiManager.AnimateExhaust(card, this.chase);

            return(this);
        }
Ejemplo n.º 15
0
        private void CardRemovedFromHand(IPlayerCard card)
        {
            var viewModel = hand.Where(x => x.CardId == card.Id).FirstOrDefault();

            if (viewModel == null)
            {
                return;
            }

            Dispatch(() => hand.Remove(viewModel));
        }
Ejemplo n.º 16
0
        /// <summary>
        /// Resurrect the specified card from the player's exhaust into their hand.
        /// </summary>
        public ChaseMutator ResurrectFromExhaustToHand(IPlayerCard card)
        {
            this.chase.PlayerExhaust.Remove(card);
            this.chase.Hand.Add(card);

            this.changesApplied.Add($"Resurrected {card.Name} from player's exhaust into their hand.");

            // TODO: Improve this.
            this.uiManager.AnimateCardDraw(card, this.chase);

            return(this);
        }
Ejemplo n.º 17
0
        /// <summary>
        /// Add damage cards to the player's discard pile, where they'll definitely not be a problem
        /// for ages, right?
        /// </summary>
        public ChaseMutator AddDamageToDiscardPile(int numDamage)
        {
            string[] damageNames = new string[numDamage];
            for (int i = 0; i < numDamage; ++i)
            {
                IPlayerCard addedDamage = this.chase.PossibleDamage.ChooseRandom(this.rng);
                this.chase.PlayerDiscard.Prepend(addedDamage);
                damageNames[i] = addedDamage.Name;
                this.uiManager.AnimateDamageToDiscard(addedDamage, this.chase);
            }

            this.changesApplied.Add($"Added {numDamage} damage to discard pile: " + String.Join(", ", damageNames));

            return(this);
        }
Ejemplo n.º 18
0
        /// <summary>
        /// Queue an animation to show a card being discarded from the player's hand.
        /// </summary>
        public void AnimateDiscard(IPlayerCard card, Chase newState)
        {
            UICardView uiCard = FindCard(this.Hand.transform, card);

            if (uiCard != null)
            {
                uiCard.CardRemoved = true;
                //queue card destroy
                AddAnimationToQueue(new QueuedAnimation(null, null, () => {
                    if (uiCard != null && uiCard.gameObject != null)
                    {
                        Destroy(uiCard.gameObject);
                    }
                    this.PlayerDiscardCountLabel.text = newState.PlayerDiscard.Count.ToString("N0");
                }, null));
            }
        }
Ejemplo n.º 19
0
        /// <summary>
        /// Search the player's draw pile for the first card that matches the provided predicate
        /// and, if it exists, draw it into their hand.
        /// </summary>
        public ChaseMutator TutorCard(Func <IPlayerCard, bool> predicate)
        {
            IPlayerCard card = this.chase.PlayerDeck.Tutor(predicate);

            if (card == null)
            {
                return(this);
            }

            this.chase.Hand.Add(card);

            this.changesApplied.Add($"Searched player draw pile for a card, found {card.Name} and drew it.");

            this.uiManager.AnimateCardDraw(card, this.chase);

            return(this);
        }
Ejemplo n.º 20
0
    public void AddCardToDeck(IPlayerCard card)
    {
        if (card == null)
        {
            return;
        }

        string failureReason;

        if (!ValidateAddCard(card, out failureReason))
        {
            if (errorMessage)
            {
                errorMessage.SetActive(true);
                StartCoroutine("HideErrorMessage");
            }
            if (errorMessageText)
            {
                errorMessageText.text = failureReason;
            }

            Debug.Log($"DeckBuilding validation failure : {failureReason}");
            return;
        }

        builtDeck.Add(card);
        UICardView uiCardView;

        if (uiPlayerDeckCards.TryGetValue(card.Name, out uiCardView))
        {
            IList <IPlayerCard> cards = builtDeck.FindAll((obj) => { return(obj.Name == card.Name); });
            uiCardView.SetNumberOwned(cards.Count);
        }
        else if (uiCardPoolCards.TryGetValue(card.Name, out uiCardView))
        {
            GameObject g    = Instantiate(uiCardView.gameObject);
            UICardView view = g.GetComponent <UICardView>();
            view.Setup(card);
            view.OnClick += OnUICardViewClicked;
            uiPlayerDeckCards.Add(card.Name, view);
            g.transform.parent = uiPlayerDeck;
        }
    }
Ejemplo n.º 21
0
        private void PlayCard(IPlayerCard card, List <ICard> targetCards)
        {
            if (!card.CanPlay(this.CurrentChaseState))
            {
                return;
            }

            this.PhaseManager.State = ChasePhase.PlayingAnimation;
            this.CurrentChaseState  = card.Play(this.CurrentChaseState, targetCards, this.UiManager);

            // Check if the player has won or lost as a result of playing this card.
            if (this.CheckForChaseEnd())
            {
                return;
            }

            this.UiManager.OnceAnimationQueueCompletes(() => {
                this.PhaseManager.State = ChasePhase.SelectingCard;
            });
        }
Ejemplo n.º 22
0
        /// <summary>
        /// Called when the player has selected a card to play.
        /// </summary>
        public void SelectCard(IPlayerCard card)
        {
            if (!card.CanPlay(this.CurrentChaseState))
            {
                return;
            }

            IProvidesCardParameters parameterProvider = card
                                                        .GetParameterProvider(this.CurrentChaseState);

            if (parameterProvider == null)
            {
                // If the card doesn't require any parameters, jut play it immediately.
                this.PlayCard(card, new List <ICard>());
                this.PhaseManager.State = ChasePhase.PlayingAnimation;
            }
            else
            {
                // Otherwise, fire up the parameter provider and play the card once parameter values
                // have been provided.
                this.PhaseManager.State = ChasePhase.SelectingParameters;

                parameterProvider.PromptForParameters(
                    this.CurrentChaseState,
                    this.UiManager,
                    targetCards => {
                    // Paramters provided, play the card.
                    this.PlayCard(card, targetCards);
                },
                    () => {
                    // User cancelled out of parameter dialogue, go back to selecting card to
                    // play.
                    this.PhaseManager.State = ChasePhase.SelectingCard;
                });
            }
        }
 protected ActionCharacterAbilityBase(string text, IPlayerCard source)
     : base("Action", text, source)
 {
 }
Ejemplo n.º 24
0
 public ResponseCharacterAbilityBase(string text, IPlayerCard source)
     : base("Response", text, source)
 {
 }
Ejemplo n.º 25
0
 protected CharacterAbilityBase(string type, string text, IPlayerCard playerCard)
     : base(type, text, playerCard)
 {
 }
Ejemplo n.º 26
0
 public RangedAbility(IPlayerCard source)
     : base("Ranged", "This character can attack enemies that are engaged with other players", source)
 {
 }
Ejemplo n.º 27
0
 public SentinelAbility(IPlayerCard source)
     : base("Sentinel", "This character can block enemies that are attacking other players", source)
 {
 }
 protected PassiveCharacterAbilityBase(string text, IPlayerCard source)
     : base("Passive", text, source)
 {
 }
Ejemplo n.º 29
0
 private void CardAddedToHand(IPlayerCard card)
 {
     Dispatch(() => hand.Add(new PlayerCardViewModel(dispatcher, card)));
 }
 private void AddChosenCardToHand(IGame game, IEffectHandle handle, IPlayer player, IPlayerCard card)
 {
     player.Hand.AddCards(new List <IPlayerCard> {
         card
     });
     player.Deck.RemoveFromDeck(card);
     handle.Resolve(string.Format("{0} added '{1}' to their hand", player.Name, card.Title));
 }
 protected ForcedCharacterAbilityBase(string description, IPlayerCard source)
     : base(description, source)
 {
 }
Ejemplo n.º 32
0
 private void CardAddedToHand(IPlayerCard card)
 {
     Dispatch(() => hand.Add(new PlayerCardViewModel(dispatcher, card)));
 }
Ejemplo n.º 33
0
 protected PassiveCharacterAbilityBase(string text, IPlayerCard source)
     : base("Passive", text, source)
 {
 }
 protected ForcedCharacterAbilityBase(string description, IPlayerCard source)
     : base(description, source)
 {
 }
 private void AddChosenCardToHand(IGame game, IEffectHandle handle, IPlayer player, IPlayerCard card)
 {
     player.Hand.AddCards(new List<IPlayerCard> { card });
     player.Deck.RemoveFromDeck(card);
     handle.Resolve(string.Format("{0} added '{1}' to their hand", player.Name, card.Title));
 }
 public ResponseCharacterAbilityBase(string text, IPlayerCard source)
     : base("Response", text, source)
 {
 }
 protected CharacterAbilityBase(string type, string text, IPlayerCard playerCard)
     : base(type, text, playerCard)
 {
 }
Ejemplo n.º 38
0
    public void Start()
    {
        //Error checks
        if (uiPlayerDeck == null)
        {
            Debug.LogError("UIPLAYERDECK NOT SETUP IN DECK BUILD MANAGER");
        }

        if (uiCardPool == null)
        {
            Debug.LogError("UICARDPOOL NOT SETUP IN DECK BUILD MANAGER");
        }

        if (cardUIPrefab == null)
        {
            Debug.LogError("CARD UI PREFAB NOT SETUP IN DECK BUILD MANAGER");
        }

        if (deckBuilderBackground == null)
        {
            Debug.LogError("DECK BUILDER BACKGROUND NOT SETUP IN DECK BUILD MANAGER");
        }

        if (initInfo == null)
        {
            Debug.LogError("CHASE START INFO NOT SETUP IN DECK BUILD MANAGER");
        }
        // ---

        if (errorMessage != null)
        {
            errorMessage.SetActive(false);
        }

        this.builtDeck    = new List <IPlayerCard>();
        uiPlayerDeckCards = new Dictionary <string, UICardView>();
        uiCardPoolCards   = new Dictionary <string, UICardView>();

        for (var i = 0; i < cardPool.Count; ++i)
        {
            IPlayerCard card         = cardPool[i];
            GameObject  uiCardObject = Instantiate(cardUIPrefab);
            UICardView  uICardView   = uiCardObject.GetComponent <UICardView>();
            uICardView.Setup(cardPool[i]);
            uICardView.transform.parent = uiCardPool;
            uICardView.OnClick         += OnUICardViewClicked;
            uiCardPoolCards.Add(uICardView.GetCard().Name, uICardView);
        }

        switch (initInfo.SelectedPlayerDriver)
        {
        case PlayerCardDriver.StuntDriver:
            ChangeDriverToStunt();
            break;

        case PlayerCardDriver.Navigator:
            ChangeDriverToNavigator();
            break;

        default:     //Intended to catch the none case
            ChangeDriverToMechanic();
            break;
        }

        if (initInfo.SelectedPlayerCards != null)
        {
            for (var i = 0; i < initInfo.SelectedPlayerCards.Length; ++i)
            {
                AddCardToDeck(initInfo.SelectedPlayerCards[i]);
            }
        }
    }
 protected ActionCharacterAbilityBase(string text, IPlayerCard source)
     : base("Action", text, source)
 {
 }
Ejemplo n.º 40
0
 private string GetPlayerCardKey(IPlayerCard card)
 {
     return(string.Format("{0} ({1})", card.Title, card.CardSet));
 }
Ejemplo n.º 41
0
 public SentinelAbility(IPlayerCard source)
     : base("Sentinel", "This character can block enemies that are attacking other players", source)
 {
 }
Ejemplo n.º 42
0
 private string GetPlayerCardKey(IPlayerCard card)
 {
     return string.Format("{0} ({1})", card.Title, card.CardSet);
 }