public static string InterpolatedDescription(this CardTypeData card, Maybe <Member> owner)
    {
        var desc = card.Description;

        try
        {
            if (card.Actions == null || card.Actions.Length < 0)
            {
                return(desc);
            }

            var battleEffects = card.Actions
                                .Where(x => x != null)
                                .SelectMany(a => a.Actions
                                            .Where(c => c.Type == CardBattleActionType.Battle))
                                .Select(b => b.BattleEffect)
                                .ToArray();

            return(InterpolatedDescription(desc, battleEffects, owner));
        }
        catch (Exception e)
        {
            Log.Error($"Unable to Generate Interpolated Description for {card.Name}");
            Debug.LogException(e);
            return(desc);
        }
    }
Esempio n. 2
0
    public void Set(CardTypeData card, Action onClick, bool canHighlight = false)
    {
        gameObject.SetActive(true);
        canPlayHighlight.SetActive(false);
        highlight.SetActive(false);
        _canHighlight = canHighlight;
        _onClick      = onClick;
        _cardType     = card;

        nameLabel.text   = _cardType.Name;
        description.text = _cardType.InterpolatedDescription(Maybe <Member> .Missing());
        if (string.IsNullOrWhiteSpace(_cardType.TypeDescription))
        {
            Log.Error($"{_cardType} is missing it's Type Description");
        }
        type.text  = _cardType.TypeDescription;
        art.sprite = _cardType.Art;
        rarity.Set(card.Rarity);

        var cost    = card.Cost;
        var hasCost = !cost.ResourceType.Name.Equals("None") && cost.Amount > 0 || cost.IsXCost;

        costPanel.SetActive(hasCost);
        if (hasCost)
        {
            costLabel.text = cost.IsXCost ? "X" : cost.Amount.ToString();
            costResourceTypeIcon.sprite = cost.ResourceType.Icon;
        }

        card.LimitedToClass.IfPresent(c => tint.color = c.Tint);
    }
 public static bool IsPlayableBy(this CardTypeData c, Member member)
 {
     if (!member.IsConscious())
     {
         return(false);
     }
     if (member.State[TemporalStatType.TurnStun] > 0)
     {
         return(false);
     }
     return(member.CanAfford(c.Cost));
 }
 public TargetSelectionBegun(CardTypeData c) => Card = c;
Esempio n. 5
0
 public Card(int id, Member owner, CardTypeData type)
 {
     this.owner = owner;
     this.id    = id;
     this.type  = type;
 }
Esempio n. 6
0
 public void Clear()
 {
     gameObject.SetActive(false);
     _card     = null;
     _cardType = null;
 }
Esempio n. 7
0
 public static Card CreateInstance(this CardTypeData c, int id, Member owner) => new Card(id, owner, c);
Esempio n. 8
0
 public static bool Is(this CardTypeData c, params CardTag[] tags) => tags.All(tag => c.Tags.Contains(tag));