Exemple #1
0
        public void ResoleveMove(IMove move, Avatar target)
        {
            bool found = false;

            switch (move.Target)
            {
            case Target.Self:
                if (move.MoveType == MoveType.Buff)
                {
                    found = false;
                    for (int i = 0; i < effects.Count; i++)
                    {
                        if (effects[i].Name == move.Name)
                        {
                            effects[i].Duration += move.Duration;
                            found = true;
                        }
                    }
                    if (!found)
                    {
                        effects.Add((IMove)move.Clone());
                    }
                }
                else if (move.MoveType == MoveType.Heal)
                {
                    currentHealth += move.Health;
                    if (currentHealth > health)
                    {
                        currentHealth = health;
                    }
                }
                else if (move.MoveType == MoveType.Status)
                {
                }
                break;

            case Target.Enemy:
                if (move.MoveType == MoveType.Debuff)
                {
                    found = false;
                    for (int i = 0; i < target.Effects.Count; i++)
                    {
                        if (target.Effects[i].Name == move.Name)
                        {
                            target.Effects[i].Duration += move.Duration;
                            found = true;
                        }
                    }
                    if (!found)
                    {
                        target.Effects.Add((IMove)move.Clone());
                    }
                }
                else if (move.MoveType == MoveType.Attack)
                {
                    float modifier = GetMoveModifier(move.MoveElement, target.Element);
                    float tDamage  = GetAttack() + move.Health * modifier -
                                     target.GetDefense();
                    if (tDamage < 1f)
                    {
                        tDamage = 1f;
                    }
                    target.ApplyDamage((int)tDamage);
                }
                break;
            }
        }