/// <summary>
 /// Calculate for selected Session.Party.Players stats for preview
 /// </summary>
 private void CalculateForPreview()
 {
     previewStatisticsModifier = new StatisticsValue();
     previewDamageRange        = new Int32Range();
     previewHealthDefenseRange = new Int32Range();
     previewMagicDefenseRange  = new Int32Range();
     if (isUseAllowed && !isGearUsed)
     {
         if (usedGear is Item)
         {
             // no preview for items
         }
         else if (usedGear is Armor)
         {
             Armor armor = usedGear as Armor;
             previewStatisticsModifier = armor.OwnerBuffStatistics;
             previewHealthDefenseRange = armor.OwnerHealthDefenseRange;
             previewMagicDefenseRange  = armor.OwnerMagicDefenseRange;
         }
         else if (usedGear is Weapon)
         {
             Weapon weapon = usedGear as Weapon;
             previewStatisticsModifier = weapon.OwnerBuffStatistics;
             previewDamageRange        = weapon.TargetDamageRange;
         }
     }
 }
 /// <summary>
 /// Reset Stats of previously selected Session.Party.Players stats from preview
 /// </summary>
 private void ResetFromPreview()
 {
     previewStatisticsModifier = new StatisticsValue();
     previewDamageRange        = new Int32Range();
     previewHealthDefenseRange = new Int32Range();
     previewMagicDefenseRange  = new Int32Range();
 }
        /// <summary>
        /// Apply the action's spell to the given target.
        /// </summary>
        /// <returns>True if there was any effect on the target.</returns>
        private bool ApplySpell(Combatant spellTarget)
        {
            StatisticsValue effectStatistics = CalculateSpellDamage(combatant, spell);

            if (spell.IsOffensive)
            {
                // calculate the defense
                Int32Range defenseRange = spellTarget.Character.MagicDefenseRange +
                                          spellTarget.Statistics.MagicalDefense;
                Int32 defense = defenseRange.GenerateValue(Session.Random);
                // subtract the defense
                effectStatistics -= new StatisticsValue(defense,
                                                        defense, defense, defense, defense, defense);
                // make sure that this only contains damage
                effectStatistics.ApplyMinimum(new StatisticsValue());
                // damage the target
                spellTarget.Damage(effectStatistics, spell.TargetDuration);
            }
            else
            {
                // make sure that this only contains healing
                effectStatistics.ApplyMinimum(new StatisticsValue());
                // heal the target
                spellTarget.Heal(effectStatistics, spell.TargetDuration);
            }

            return(!effectStatistics.IsZero);
        }
        /// <summary>
        /// Calculate the spell damage done by the given combatant and spell.
        /// </summary>
        public static StatisticsValue CalculateSpellDamage(Combatant combatant,
                                                           Spell spell)
        {
            // check the parameters
            if (combatant == null)
            {
                throw new ArgumentNullException("combatant");
            }
            if (spell == null)
            {
                throw new ArgumentNullException("spell");
            }

            // get the magical offense from the character's class, gear, and bonuses
            // -- note that this includes stat buffs
            int magicalOffense = combatant.Statistics.MagicalOffense;

            // add the magical offense to the spell
            StatisticsValue damage =
                spell.TargetEffectRange.GenerateValue(Session.Random);

            damage.HealthPoints    += (damage.HealthPoints != 0) ? magicalOffense : 0;
            damage.MagicPoints     += (damage.MagicPoints != 0) ? magicalOffense : 0;
            damage.PhysicalOffense += (damage.PhysicalOffense != 0) ? magicalOffense : 0;
            damage.PhysicalDefense += (damage.PhysicalDefense != 0) ? magicalOffense : 0;
            damage.MagicalOffense  += (damage.MagicalOffense != 0) ? magicalOffense : 0;
            damage.MagicalDefense  += (damage.MagicalDefense != 0) ? magicalOffense : 0;

            // add in the spell damage
            return(damage);
        }
        private async Task <SiteStatistics> SendSiteStatsRequest(StatisticsValue stats, DateTime rangeStart, DateTime rangeEnd)
        {
            var result = await PerformaAPIRequest(new SiteStatisticsRequest(_config, rangeStart, rangeEnd, stats));

            var response = JsonConvert.DeserializeObject <SiteStatisticsResponse>(result);

            return(new SiteStatistics(response));
        }
 /// <summary>
 /// Calculate the total of all unexpired entries.
 /// </summary>
 private void CalculateTotalStatistics()
 {
     totalStatistics = new StatisticsValue();
     foreach (StatisticsValueStackEntry entry in entries)
     {
         totalStatistics += entry.Statistics;
     }
 }
        /// <summary>
        /// Choose which defensive action to perform.
        /// </summary>
        /// <returns>The chosen action, or null if no action is desired.</returns>
        private CombatAction ChooseDefensiveAction()
        {
            List <CombatantMonster> monsters = CombatEngine.Monsters;

            // be sure that there is a valid combat in progress
            if ((monsters == null) || (monsters.Count <= 0))
            {
                return(null);
            }

            // find the monster with the least health
            CombatantMonster target = null;
            int leastHealthAmount   = Int32.MaxValue;

            foreach (CombatantMonster targetMonster in monsters)
            {
                // skip dead or dying targets
                if (targetMonster.IsDeadOrDying)
                {
                    continue;
                }
                // if the monster is damaged and it has the least health points,
                // then it becomes the new target
                StatisticsValue maxStatistics =
                    targetMonster.Monster.CharacterClass.GetStatisticsForLevel(
                        targetMonster.Monster.CharacterLevel);
                int targetMonsterHealthPoints = targetMonster.Statistics.HealthPoints;
                if ((targetMonsterHealthPoints < maxStatistics.HealthPoints) &&
                    (targetMonsterHealthPoints < leastHealthAmount))
                {
                    target            = targetMonster;
                    leastHealthAmount = targetMonsterHealthPoints;
                }
            }

            // if there is no target, then don't do anything
            if (target == null)
            {
                return(null);
            }

            // the action lists are sorted by descending potential,
            // so find the first eligible action
            foreach (CombatAction action in defensiveActions)
            {
                // check the restrictions on the action
                if (action.IsCharacterValidUser)
                {
                    action.Target = target;
                    return(action);
                }
            }

            // no eligible actions found
            return(null);
        }
Example #8
0
 /// <summary>
 /// Heals the combatant by the given amount.
 /// </summary>
 public override void Heal(StatisticsValue healingStatistics, int duration)
 {
     if (duration > 0)
     {
         CombatEffects.AddStatistics(healingStatistics, duration);
     }
     else
     {
         statistics += healingStatistics;
         statistics.ApplyMaximum(monster.CharacterStatistics);
     }
     base.Heal(healingStatistics, duration);
 }
Example #9
0
 /// <summary>
 /// Heals the combatant by the given amount.
 /// </summary>
 public override void Heal(StatisticsValue healingStatistics, int duration)
 {
     if (duration > 0)
     {
         CombatEffects.AddStatistics(healingStatistics, duration);
     }
     else
     {
         player.StatisticsModifiers += healingStatistics;
         player.StatisticsModifiers.ApplyMaximum(new StatisticsValue());
     }
     base.Heal(healingStatistics, duration);
 }
        private async Task <SiteStatistics> SendSiteStatsRequest(StatisticsValue stats, TimeRange range)
        {
            var result = await PerformaAPIRequest(new SiteStatisticsRequest(_config, range, stats));

            SiteStatisticsResponse response = null;

            try
            {
                response = JsonConvert.DeserializeObject <SiteStatisticsResponse>(result);
            }
            catch (Exception) { }

            return(new SiteStatistics(response));
        }
Example #11
0
 /// <summary>
 /// Damages the combatant by the given amount.
 /// </summary>
 public override void Damage(StatisticsValue damageStatistics, int duration)
 {
     if (duration > 0)
     {
         CombatEffects.AddStatistics(new StatisticsValue() - damageStatistics,
                                     duration);
     }
     else
     {
         player.StatisticsModifiers -= damageStatistics;
         player.StatisticsModifiers.ApplyMaximum(new StatisticsValue());
     }
     base.Damage(damageStatistics, duration);
 }
Example #12
0
 /// <summary>
 /// Damages the combatant by the given amount.
 /// </summary>
 public override void Damage(StatisticsValue damageStatistics, int duration)
 {
     if (duration > 0)
     {
         CombatEffects.AddStatistics(new StatisticsValue() - damageStatistics,
                                     duration);
     }
     else
     {
         statistics -= damageStatistics;
         statistics.ApplyMaximum(monster.CharacterStatistics);
     }
     base.Damage(damageStatistics, duration);
 }
        /// <summary>
        /// Add a new statistics, with a given duration, to the stack.
        /// </summary>
        /// <remarks>Entries with durations of 0 or less never expire.</remarks>
        public void AddStatistics(StatisticsValue statistics, int duration)
        {
            if (duration < 0)
            {
                throw new ArgumentOutOfRangeException("duration");
            }

            StatisticsValueStackEntry entry = new StatisticsValueStackEntry();
            entry.Statistics = statistics;
            entry.RemainingDuration = duration;

            entries.Add(entry);

            CalculateTotalStatistics();
        }
Example #14
0
        /// <summary>
        /// Creates a new PlayerData object from the given Player object.
        /// </summary>
        public PlayerSaveData(Player player)
            : this()
        {
            // check the parameter
            if (player == null)
            {
                throw new ArgumentNullException("player");
            }

            assetName = player.AssetName;
            characterLevel = player.CharacterLevel;
            experience = player.Experience;
            foreach (Equipment equipment in player.EquippedEquipment)
            {
                equipmentAssetNames.Add(equipment.AssetName);
            }
            statisticsModifiers = player.StatisticsModifiers;
        }
        /// <summary>
        /// Creates a new PlayerData object from the given Player object.
        /// </summary>
        public PlayerSaveData(Player player)
            : this()
        {
            // check the parameter
            if (player == null)
            {
                throw new ArgumentNullException("player");
            }

            assetName      = player.AssetName;
            characterLevel = player.CharacterLevel;
            experience     = player.Experience;
            foreach (Equipment equipment in player.EquippedEquipment)
            {
                equipmentAssetNames.Add(equipment.AssetName);
            }
            statisticsModifiers = player.StatisticsModifiers;
        }
Example #16
0
        /// <summary>
        /// Create a new CombatMonster object containing the given monster.
        /// </summary>
        /// <param name="monster"></param>
        public CombatantMonster(Monster monster) : base()
        {
            // check the parameter
            if (monster == null)
            {
                throw new ArgumentNullException("monster");
            }

            // assign the parameters
            this.monster      = monster;
            this.statistics  += monster.CharacterStatistics;
            this.combatSprite = monster.CombatSprite.Clone() as AnimatingSprite;
            this.State        = RolePlayingGameData.Character.CharacterState.Idle;
            this.CombatSprite.PlayAnimation("Idle");

            // create the AI data
            this.artificialIntelligence = new ArtificialIntelligence(this);
        }
Example #17
0
        /// <summary>
        /// Create a new CombatMonster object containing the given monster.
        /// </summary>
        /// <param name="monster"></param>
        public CombatantMonster(Monster monster)
            : base()
        {
            // check the parameter
            if (monster == null)
            {
                throw new ArgumentNullException("monster");
            }

            // assign the parameters
            this.monster = monster;
            this.statistics += monster.CharacterStatistics;
            this.combatSprite = monster.CombatSprite.Clone() as AnimatingSprite;
            this.State = RolePlayingGameData.Character.CharacterState.Idle;
            this.CombatSprite.PlayAnimation("Idle");

            // create the AI data
            this.artificialIntelligence = new ArtificialIntelligence(this);
        }
        /// <summary>
        /// Creates a new SpellbookScreen object for the given player and statistics.
        /// </summary>
        public SpellbookScreen(FightingCharacter fightingCharacter,
                               StatisticsValue statistics)
            : base()
        {
            // check the parameter
            if (fightingCharacter == null)
            {
                throw new ArgumentNullException("fightingCharacter");
            }
            this.fightingCharacter = fightingCharacter;
            this.statistics        = statistics;

            // sort the player's spell
            this.fightingCharacter.Spells.Sort(
                delegate(Spell spell1, Spell spell2)
            {
                // handle null values
                if (spell1 == null)
                {
                    return(spell2 == null ? 0 : 1);
                }
                else if (spell2 == null)
                {
                    return(-1);
                }

                // sort by name
                return(spell1.Name.CompareTo(spell2.Name));
            });

            // configure the menu text
            titleText        = "Spell Book";
            selectButtonText = "Cast";
            backButtonText   = "Back";
            xButtonText      = String.Empty;
            yButtonText      = String.Empty;
            leftTriggerText  = String.Empty;
            rightTriggerText = String.Empty;
        }
 /// <summary>
 /// Reset Stats of previously selected Session.Party.Players stats from preview
 /// </summary>
 private void ResetFromPreview()
 {
     previewStatisticsModifier = new StatisticsValue();
     previewDamageRange = new Int32Range();
     previewHealthDefenseRange = new Int32Range();
     previewMagicDefenseRange = new Int32Range();
 }
Example #20
0
 public SiteStatisticsRequest(IApplicationConfiguration config, TimeRange timeRange, StatisticsValue statsValues) : base(config)
 {
     TimeRange = timeRange;
     Stats     = statsValues;
 }
Example #21
0
 public SiteStatisticsRequest(IApplicationConfiguration config, DateTime rangeStart, DateTime rangeEnd, StatisticsValue statsValues) : this(config, TimeRange.Custom, statsValues)
 {
     StartTime = rangeStart.ToTotalMilliseconds();
     EndTime   = rangeEnd.ToTotalMilliseconds();
 }
Example #22
0
 /// <summary>
 /// Heal the combatant by the given amount.
 /// </summary>
 public virtual void Heal(StatisticsValue healingStatistics, int duration)
 {
     CombatEngine.AddNewHealingEffects(OriginalPosition, healingStatistics);
 }
Example #23
0
 /// <summary>
 /// Damages the combatant by the given amount.
 /// </summary>
 public virtual void Damage(StatisticsValue damageStatistics, int duration)
 {
     State = RolePlayingGameData.Character.CharacterState.Hit;
     CombatEngine.AddNewDamageEffects(OriginalPosition, damageStatistics);
 }
Example #24
0
 /// <summary>
 /// Heals the combatant by the given amount.
 /// </summary>
 public override void Heal(StatisticsValue healingStatistics, int duration)
 {
     if (duration > 0)
     {
         CombatEffects.AddStatistics(healingStatistics, duration);
     }
     else
     {
         statistics += healingStatistics;
         statistics.ApplyMaximum(monster.CharacterStatistics);
     }
     base.Heal(healingStatistics, duration);
 }
Example #25
0
 /// <summary>
 /// Damages the combatant by the given amount.
 /// </summary>
 public override void Damage(StatisticsValue damageStatistics, int duration)
 {
     if (duration > 0)
     {
         CombatEffects.AddStatistics(new StatisticsValue() - damageStatistics,
             duration);
     }
     else
     {
         statistics -= damageStatistics;
         statistics.ApplyMaximum(monster.CharacterStatistics);
     }
     base.Damage(damageStatistics, duration);
 }
        /// <summary>
        /// Draw a Player's stats
        /// </summary>
        /// <param name="player">Player whose stats have to be drawn</param>
        /// <param name="isSelected">Whether player is selected or not</param>
        /// <param name="position">Position as to
        /// where to start drawing the stats</param>
        private void DrawPlayerStats(Player player, bool isSelected,
                                     ref Vector2 position)
        {
            SpriteBatch spriteBatch = ScreenManager.SpriteBatch;

            Color  color;
            string detail1, detail2;
            float  length1, length2;

            StatisticsValue playersStatisticsModifier = new StatisticsValue();

            if (isSelected && isUseAllowed && !isGearUsed)
            {
                playersStatisticsModifier = previewStatisticsModifier;
                if (usedGear is Armor)
                {
                    Armor armor         = usedGear as Armor;
                    Armor existingArmor = player.GetEquippedArmor(armor.Slot);
                    if (existingArmor != null)
                    {
                        playersStatisticsModifier -= existingArmor.OwnerBuffStatistics;
                    }
                }
                else if (usedGear is Weapon)
                {
                    Weapon weapon         = usedGear as Weapon;
                    Weapon existingWeapon = player.GetEquippedWeapon();
                    if (existingWeapon != null)
                    {
                        playersStatisticsModifier -= existingWeapon.OwnerBuffStatistics;
                    }
                }
            }

            // Calculate HP and MP string Length
            detail1 = "HP: " + player.CurrentStatistics.HealthPoints + "/" +
                      player.CharacterStatistics.HealthPoints;
            length1 = Fonts.DescriptionFont.MeasureString(detail1).X;
            detail2 = "MP: " + player.CurrentStatistics.MagicPoints + "/" +
                      player.CharacterStatistics.MagicPoints;
            length2 = Fonts.DescriptionFont.MeasureString(detail2).X;

            StatisticsValue drawCurrentStatistics   = player.CurrentStatistics;
            StatisticsValue drawCharacterStatistics = player.CharacterStatistics;

            if (isSelected)
            {
                drawCurrentStatistics   += playersStatisticsModifier;
                drawCharacterStatistics += playersStatisticsModifier;
            }

            // Draw the character Health Points
            color = GetStatColor(playersStatisticsModifier.HealthPoints, isSelected);
            spriteBatch.DrawString(Fonts.DescriptionFont, "HP: " +
                                   drawCurrentStatistics.HealthPoints + "/" +
                                   drawCharacterStatistics.HealthPoints,
                                   position, color);

            // Draw the character Mana Points
            position.Y += Fonts.DescriptionFont.LineSpacing;
            color       = GetStatColor(playersStatisticsModifier.MagicPoints, isSelected);
            spriteBatch.DrawString(Fonts.DescriptionFont, "MP: " +
                                   drawCurrentStatistics.MagicPoints + "/" +
                                   drawCharacterStatistics.MagicPoints,
                                   position, color);

            // Draw the physical offense
            position.X += 150f * ScaledVector2.ScaleFactor;
            position.Y -= Fonts.DescriptionFont.LineSpacing;
            color       = GetStatColor(playersStatisticsModifier.PhysicalOffense, isSelected);
            spriteBatch.DrawString(Fonts.DescriptionFont, "PO: " +
                                   drawCurrentStatistics.PhysicalOffense, position, color);

            // Draw the physical defense
            position.Y += Fonts.DescriptionFont.LineSpacing;
            color       = GetStatColor(playersStatisticsModifier.PhysicalDefense, isSelected);
            spriteBatch.DrawString(Fonts.DescriptionFont, "PD: " +
                                   drawCurrentStatistics.PhysicalDefense, position, color);

            // Draw the Magic offense
            position.Y += Fonts.DescriptionFont.LineSpacing;
            color       = GetStatColor(playersStatisticsModifier.MagicalOffense, isSelected);
            spriteBatch.DrawString(Fonts.DescriptionFont, "MO: " +
                                   drawCurrentStatistics.MagicalOffense, position, color);

            // Draw the Magical defense
            position.Y += Fonts.DescriptionFont.LineSpacing;
            color       = GetStatColor(playersStatisticsModifier.MagicalDefense, isSelected);
            spriteBatch.DrawString(Fonts.DescriptionFont, "MD: " +
                                   drawCurrentStatistics.MagicalDefense, position, color);


            position.Y += Fonts.DescriptionFont.LineSpacing;
        }
        /// <summary>
        /// Draw a Player's stats 
        /// </summary>
        /// <param name="player">Player whose stats have to be drawn</param>
        /// <param name="isSelected">Whether player is selected or not</param>
        /// <param name="position">Position as to 
        /// where to start drawing the stats</param>
        private void DrawPlayerStats(Player player, bool isSelected,
            ref Vector2 position)
        {
            SpriteBatch spriteBatch = ScreenManager.SpriteBatch;

            Color color;
            string detail1, detail2;
            float length1, length2;

            StatisticsValue playersStatisticsModifier = new StatisticsValue();
            if (isSelected && isUseAllowed && !isGearUsed)
            {
                playersStatisticsModifier = previewStatisticsModifier;
                if (usedGear is Armor)
                {
                    Armor armor = usedGear as Armor;
                    Armor existingArmor = player.GetEquippedArmor(armor.Slot);
                    if (existingArmor != null)
                    {
                        playersStatisticsModifier -= existingArmor.OwnerBuffStatistics;
                    }
                }
                else if (usedGear is Weapon)
                {
                    Weapon weapon = usedGear as Weapon;
                    Weapon existingWeapon = player.GetEquippedWeapon();
                    if (existingWeapon != null)
                    {
                        playersStatisticsModifier -= existingWeapon.OwnerBuffStatistics;
                    }
                }
            }

            // Calculate HP and MP string Length
            detail1 = "HP: " + player.CurrentStatistics.HealthPoints + "/" + 
                player.CharacterStatistics.HealthPoints;
            length1 = Fonts.DescriptionFont.MeasureString(detail1).X;
            detail2 = "MP: " + player.CurrentStatistics.MagicPoints + "/" + 
                player.CharacterStatistics.MagicPoints;
            length2 = Fonts.DescriptionFont.MeasureString(detail2).X;

            StatisticsValue drawCurrentStatistics = player.CurrentStatistics;
            StatisticsValue drawCharacterStatistics = player.CharacterStatistics;
            if (isSelected)
            {
                drawCurrentStatistics += playersStatisticsModifier;
                drawCharacterStatistics += playersStatisticsModifier;
            }

            // Draw the character Health Points
            color = GetStatColor(playersStatisticsModifier.HealthPoints, isSelected);
            spriteBatch.DrawString(Fonts.DescriptionFont, "HP: " +
                drawCurrentStatistics.HealthPoints + "/" +
                drawCharacterStatistics.HealthPoints,
                position, color);

            // Draw the character Mana Points
            position.Y += Fonts.DescriptionFont.LineSpacing;
            color = GetStatColor(playersStatisticsModifier.MagicPoints, isSelected);
            spriteBatch.DrawString(Fonts.DescriptionFont, "MP: " +
                drawCurrentStatistics.MagicPoints + "/" +
                drawCharacterStatistics.MagicPoints,
                position, color);

            // Draw the physical offense
            position.X += 150f;
            position.Y -= Fonts.DescriptionFont.LineSpacing;
            color = GetStatColor(playersStatisticsModifier.PhysicalOffense, isSelected);
            spriteBatch.DrawString(Fonts.DescriptionFont, "PO: " +
                drawCurrentStatistics.PhysicalOffense, position, color);

            // Draw the physical defense
            position.Y += Fonts.DescriptionFont.LineSpacing;
            color = GetStatColor(playersStatisticsModifier.PhysicalDefense, isSelected);
            spriteBatch.DrawString(Fonts.DescriptionFont, "PD: " +
                drawCurrentStatistics.PhysicalDefense, position, color);

            // Draw the Magic offense
            position.Y += Fonts.DescriptionFont.LineSpacing;
            color = GetStatColor(playersStatisticsModifier.MagicalOffense, isSelected);
            spriteBatch.DrawString(Fonts.DescriptionFont, "MO: " +
                drawCurrentStatistics.MagicalOffense, position, color);

            // Draw the Magical defense
            position.Y += Fonts.DescriptionFont.LineSpacing;
            color = GetStatColor(playersStatisticsModifier.MagicalDefense, isSelected);
            spriteBatch.DrawString(Fonts.DescriptionFont, "MD: " +
                drawCurrentStatistics.MagicalDefense, position, color);
            

            position.Y += Fonts.DescriptionFont.LineSpacing;
        }
 public async Task <SiteStatistics> GetSiteStats(StatisticsValue stats, DateTime rangeStart, DateTime rangeEnd)
 {
     return(await SendSiteStatsRequest(stats, rangeStart, rangeEnd));
 }
 /// <summary>
 /// Calculate for selected Session.Party.Players stats for preview
 /// </summary>
 private void CalculateForPreview()
 {
     previewStatisticsModifier = new StatisticsValue();
     previewDamageRange = new Int32Range();
     previewHealthDefenseRange = new Int32Range();
     previewMagicDefenseRange = new Int32Range();
     if (isUseAllowed && !isGearUsed)
     {
         if (usedGear is Item)
         {
             // no preview for items
         }
         else if (usedGear is Armor)
         {
             Armor armor = usedGear as Armor;
             previewStatisticsModifier = armor.OwnerBuffStatistics;
             previewHealthDefenseRange = armor.OwnerHealthDefenseRange;
             previewMagicDefenseRange = armor.OwnerMagicDefenseRange;
         }
         else if (usedGear is Weapon)
         {
             Weapon weapon = usedGear as Weapon;
             previewStatisticsModifier = weapon.OwnerBuffStatistics;
             previewDamageRange = weapon.TargetDamageRange;
         }
     }
 }
 /// <summary>
 /// Heal the combatant by the given amount.
 /// </summary>
 public virtual void Heal(StatisticsValue healingStatistics, int duration)
 {
     CombatEngine.AddNewHealingEffects(OriginalPosition, healingStatistics);
 }
Example #31
0
 /// <summary>
 /// Damages the combatant by the given amount.
 /// </summary>
 public override void Damage(StatisticsValue damageStatistics, int duration)
 {
     if (duration > 0)
     {
         CombatEffects.AddStatistics(new StatisticsValue() - damageStatistics,
             duration);
     }
     else
     {
         player.StatisticsModifiers -= damageStatistics;
         player.StatisticsModifiers.ApplyMaximum(new StatisticsValue());
     }
     base.Damage(damageStatistics, duration);
 }
Example #32
0
        /// <summary>
        /// Adds a new healing combat effect to the scene.
        /// </summary>
        /// <param name="position">The position that the effect starts at.</param>
        /// <param name="damage">The healing statistics.</param>
        public static void AddNewHealingEffects(Vector2 position,
            StatisticsValue healing)
        {
            int startingRise = 0;

            CheckSingleton();

            if (healing.HealthPoints != 0)
            {
                CombatEffect combatEffect = new CombatEffect();
                combatEffect.OriginalPosition = position;
                combatEffect.Text = "HP\n" + healing.HealthPoints.ToString();
                combatEffect.Rise = startingRise;
                startingRise -= 5;
                singleton.healingCombatEffects.Add(combatEffect);
            }

            if (healing.MagicPoints != 0)
            {
                CombatEffect combatEffect = new CombatEffect();
                combatEffect.OriginalPosition = position;
                combatEffect.Text = "MP\n" + healing.MagicPoints.ToString();
                combatEffect.Rise = startingRise;
                startingRise -= 5;
                singleton.healingCombatEffects.Add(combatEffect);
            }

            if (healing.PhysicalOffense != 0)
            {
                CombatEffect combatEffect = new CombatEffect();
                combatEffect.OriginalPosition = position;
                combatEffect.Text = "PO\n" + healing.PhysicalOffense.ToString();
                combatEffect.Rise = startingRise;
                startingRise -= 5;
                singleton.healingCombatEffects.Add(combatEffect);
            }

            if (healing.PhysicalDefense != 0)
            {
                CombatEffect combatEffect = new CombatEffect();
                combatEffect.OriginalPosition = position;
                combatEffect.Text = "PD\n" + healing.PhysicalDefense.ToString();
                combatEffect.Rise = startingRise;
                startingRise -= 5;
                singleton.healingCombatEffects.Add(combatEffect);
            }

            if (healing.MagicalOffense != 0)
            {
                CombatEffect combatEffect = new CombatEffect();
                combatEffect.OriginalPosition = position;
                combatEffect.Text = "MO\n" + healing.MagicalOffense.ToString();
                combatEffect.Rise = startingRise;
                startingRise -= 5;
                singleton.healingCombatEffects.Add(combatEffect);
            }

            if (healing.MagicalDefense != 0)
            {
                CombatEffect combatEffect = new CombatEffect();
                combatEffect.OriginalPosition = position;
                combatEffect.Text = "MD\n" + healing.MagicalDefense.ToString();
                combatEffect.Rise = startingRise;
                startingRise -= 5;
                singleton.healingCombatEffects.Add(combatEffect);
            }
        }
        /// <summary>
        /// Apply the action's spell to the given target.
        /// </summary>
        /// <returns>True if there was any effect on the target.</returns>
        private bool ApplySpell(Combatant spellTarget)
        {
            StatisticsValue effectStatistics = CalculateSpellDamage(combatant, spell);
            if (spell.IsOffensive)
            {
                // calculate the defense
                Int32Range defenseRange = spellTarget.Character.MagicDefenseRange + 
                    spellTarget.Statistics.MagicalDefense;
                Int32 defense = defenseRange.GenerateValue(Session.Random);
                // subtract the defense
                effectStatistics -= new StatisticsValue(defense,
                    defense, defense, defense, defense, defense);
                // make sure that this only contains damage
                effectStatistics.ApplyMinimum(new StatisticsValue());
                // damage the target
                spellTarget.Damage(effectStatistics, spell.TargetDuration);
            }
            else
            {
                // make sure that this only contains healing
                effectStatistics.ApplyMinimum(new StatisticsValue());
                // heal the target
                spellTarget.Heal(effectStatistics, spell.TargetDuration);
            }

            return !effectStatistics.IsZero;
        }
Example #34
0
 /// <summary>
 /// Heals the combatant by the given amount.
 /// </summary>
 public override void Heal(StatisticsValue healingStatistics, int duration)
 {
     if (duration > 0)
     {
         CombatEffects.AddStatistics(healingStatistics, duration);
     }
     else
     {
         player.StatisticsModifiers += healingStatistics;
         player.StatisticsModifiers.ApplyMaximum(new StatisticsValue());
     }
     base.Heal(healingStatistics, duration);
 }
Example #35
0
 /// <summary>
 /// Damages the combatant by the given amount.
 /// </summary>
 public virtual void Damage(StatisticsValue damageStatistics, int duration)
 {
     State = RolePlayingGameData.Character.CharacterState.Hit;
     CombatEngine.AddNewDamageEffects(OriginalPosition, damageStatistics);
 }
 /// <summary>
 /// Damages the combatant by the given amount.
 /// </summary>
 public virtual void Damage(StatisticsValue damageStatistics, int duration)
 {
     State = RolePlayingGameData.Character.CharacterState.Hit;
     // TODO REMOVE
     if (this.GetType() == typeof(CombatantMonster))
     {
     //    damageStatistics.HealthPoints += 100;
       //  damageStatistics.MagicPoints  += 100;
     }
     CombatEngine.AddNewDamageEffects(OriginalPosition, damageStatistics);
 }
        public async Task <SiteStatistics> GetSiteStats(StatisticsValue stats, TimeRange range)
        {
            var siteSatistics = await SendSiteStatsRequest(stats, range);

            return(siteSatistics);
        }