public void PayCost(Action action)
 {
     foreach (var kvp in action.Cost)
     {
         Stats[kvp.Key].Value -= kvp.Value;
     }
 }
        public void AddSituationalModifiers(Deck deck, Mechanics.Action action, Character user, Position posTarget, Character charTarget)
        {
            foreach (var tag in action.Tags)
            {
                switch (tag)
                {
                case Mechanics.Action.AbilityType.Attack:
                    if (IsFlanking(user, charTarget))
                    {
                        var flank = new Card("Flanking", Card.CardType.Hit);
                        deck.AddCards(flank, 2);     //TODO: magic number
                    }
                    var userOn = map.GetTile(user.Pos);
                    userOn.AddSituationalModifiers(deck, action, user, posTarget, charTarget, false);
                    var targetOn = map.GetTile(charTarget.Pos);
                    targetOn.AddSituationalModifiers(deck, action, user, posTarget, charTarget, true);

                    //cramped fighting
                    var freeSquares = GetEmptyAdjacentSquares(user.Pos).Count;
                    if (freeSquares < 4 && !user.Gear.Contains("Cruel Knife"))
                    {
                        //TODO: better gear system
                        var cramped = new Card("Cramped", Card.CardType.Miss);
                        deck.AddCards(cramped, 1);
                    }
                    break;

                default:
                    break;
                }
            }
        }
        public void AddDodgeCards(Deck deck, DungeonMaster DM, Character attacker, Action action)
        {
            //TODO: no magic numbers
            var defense = new Card("Defense", Card.CardType.Miss);

            deck.AddCards(defense, 2);

            //TODO: pass to condition and query
            var dodging = Conditions.FirstOrDefault(c => c.Name == "Dodging");

            if (dodging != null)
            {
                var dodge = new Card("Dodge", Card.CardType.Miss);
                deck.AddCards(dodge, dodging.Value);
            }
        }
        public void AddArmorCards(Deck deck, DungeonMaster DM, Character attacker, Action action)
        {
            var hit   = new Card("Hit", Card.CardType.Hit);
            var armor = Card.CreateReplacementCard("Glancing Blow", Card.CardType.Armor, hit);

            deck.AddCards(armor, ArmorCoverage); //armor card causes hit to be redirected to character for resolution?

            if (HasTrait("Split"))
            {
                var split = Card.CreateReplacementCard("Split", Card.CardType.Armor, hit);
                deck.AddCards(split, 1); //TODO: magic number
            }

            if (HasTrait("Made of Flame"))
            {
                var burn = Card.CreateReplacementCard("Burn", Card.CardType.Armor, hit);
                deck.AddCards(burn, 3); //TODO: magic number
            }
        }
        public void CanPayTest()
        {
            var guy  = DebugData.GetDebugCharacter();
            var cost = new Dictionary <Character.StatType, int>()
            {
                { Character.StatType.Stamina, 1 }
            };
            var effects     = new Dictionary <Card, Effect>();
            var Recipe      = new Dictionary <Action.CardSource, Card>();
            var cheapAction = new Action("test", cost, Recipe, null, ShrinelandsTactics.Mechanics.Action.RangeType.Melee,
                                         1);
            var cost2 = new Dictionary <Character.StatType, int>()
            {
                { Character.StatType.Stamina, 999 }
            };
            var expensiveAction = new Action("test", cost2, Recipe, null, ShrinelandsTactics.Mechanics.Action.RangeType.Melee,
                                             1);

            Assert.IsTrue(guy.CanPay(cheapAction));
            Assert.IsFalse(guy.CanPay(expensiveAction));
        }
Example #6
0
    private void FleshOutActions(Character newChar)
    {
        for (int i = 0; i < newChar.Actions.Count; i++)
        {
            Action action = GetActionByName(newChar.Actions[i].Name);
            newChar.Actions[i] = action;
        }

        if (newChar.HasTrait("Combat Trained"))
        {
            GiveAction("Dodge", newChar);
            GiveAction("Attack", newChar);
            GiveAction("Exert", newChar);
        }

        //TODO: can always attack
        if (!newChar.Actions.Any(c => c.Name == "Attack"))
        {
            GiveAction("Attack", newChar);
        }
    }
        public void AddModifiers(Deck deck, DungeonMaster DM, Character user, Character target, Action action, bool isTarget)
        {
            foreach (var tag in action.Tags)
            {
                switch (tag)
                {
                case Mechanics.Action.AbilityType.Attack:
                    if (isTarget)
                    {
                        AddDodgeCards(deck, DM, user, action);
                        AddArmorCards(deck, DM, user, action);
                        //add dodge
                    }
                    else
                    {
                        //check for buffs to attack
                        var empowered = Conditions.FirstOrDefault(c => c.Name == "Empowered");
                        if (empowered != null)
                        {
                            deck.AddCards(new Card("Empowered", Card.CardType.Hit), empowered.Value);
                        }

                        var exertion = Conditions.FirstOrDefault(c => c.Name == "Exertion");
                        if (exertion != null)
                        {
                            deck.AddCards(new Card("Exertion", Card.CardType.Hit), exertion.Value);
                        }

                        if (target != null)
                        {
                            if (HasTrait("Thirst for Magic"))
                            {
                                deck.AddCards(new Card("Thirst", Card.CardType.Hit), target.Mana.Value);
                            }
                        }
                    }
                    break;

                default:
                    break;
                }
            }
        }
 public List <Position> GetValidTargetsFor(Character guy, Mechanics.Action action)
 {
     return(action.GetValidTargets(this, guy));
 }
Example #9
0
        public static Action GetDebugAttackAction()
        {
            string Name = "Attack";
            Dictionary <Character.StatType, int> Cost = new Dictionary <Character.StatType, int>()
            {
                { Character.StatType.Stamina, 1 }
            };

            Card hit = new Card("Hit", Card.CardType.Hit);

            Dictionary <Action.CardSource, Card> DeckRecipe = new Dictionary <Mechanics.Action.CardSource, Card>()
            {
                { Action.CardSource.UserBaseAttack, hit },
            };

            var hitEffect = new DamageEffect(DamageEffect.DamageType.Slashing,
                                             new List <Action.CardSource>()
            {
                Mechanics.Action.CardSource.UserBaseDamage
            });
            var critEffect = new DamageEffect(DamageEffect.DamageType.Slashing,
                                              new List <Action.CardSource>()
            {
                Mechanics.Action.CardSource.UserBaseDamage,
                Mechanics.Action.CardSource.UserStrength
            });

            //TODO: have numeric resolver?
            var criticalEffects = new Dictionary <Card.CardType, List <Effect> >()
            {
                { Card.CardType.Hit, new List <Effect>()
                  {
                      critEffect
                  } },
                { Card.CardType.Armor, new List <Effect>()
                  {
                      hitEffect
                  } },
                { Card.CardType.Miss, new List <Effect>()
                  {
                      hitEffect
                  } },
            };


            var effects = new Dictionary <Card.CardType, List <Effect> >()
            {
                { Card.CardType.Miss, new List <Effect>()
                  {
                      new NullEffect()
                  } },
                { Card.CardType.Hit, new List <Effect>()
                  {
                      new RedrawEffect(criticalEffects)
                  } },
                { Card.CardType.Armor, new List <Effect>()
                  {
                      new ResolveByTargetEffect(new List <Effect>()
                        {
                            hitEffect
                        })
                  } }
            };

            var action = new Action(Name, Cost, DeckRecipe, effects,
                                    Mechanics.Action.RangeType.Melee, 1);

            action.Tags.Add(Mechanics.Action.AbilityType.Attack);
            return(action);
        }