コード例 #1
0
        private void ParseMessage(string messageReceived, Thunderstorm player)
        {
            char[]   separators = new[] { '\n', '\r', '\f', '\0', (char)3 };
            string[] strings    = messageReceived.Split(separators, StringSplitOptions.RemoveEmptyEntries);

            IEnumerable <KeyValuePair <string, string> > lines = GetLines(strings);

            foreach (KeyValuePair <string, string> line in lines)
            {
                if (state == null)
                {
                    continue;
                }

                if (line.Key.Equals("WIND"))
                {
                    SendMessage(player.Wind(ParseVector(line.Value)) ? "OK\n" : "IGNORED\n");
                }

                if (line.Key.Equals("GET_STATE"))
                {
                    this.SendMessage(StateProtocol.Create(state.player, state.world, state.iteration));
                }
            }
        }
コード例 #2
0
 public void Update(Thunderstorm thunderstorm, World world, int iteration)
 {
     while (eventQueue.Any())
     {
         Vector position = eventQueue.Dequeue();
         Vector wind     = (position - thunderstorm.position);
         wind.Normalize();
         wind *= 50;
         thunderstorm.Wind(wind);
     }
 }
コード例 #3
0
ファイル: MonsterXmlReader.cs プロジェクト: Codinablack/Tibia
        private static Thunderstorm ParseThunderstormCombatData(XElement element)
        {
            Thunderstorm thunderstorm = new Thunderstorm();

            if (element.Attribute("min") is XAttribute minAttribute)
            {
                thunderstorm.Min = short.Parse(minAttribute.Value);
            }

            if (element.Attribute("max") is XAttribute maxAttribute)
            {
                thunderstorm.Max = short.Parse(maxAttribute.Value);
            }

            return(thunderstorm);
        }
コード例 #4
0
ファイル: StateProtocol.cs プロジェクト: janmagnet/CloudWars
        public static string Create(Thunderstorm player, World world, int ticks)
        {
            StringBuilder builder = new StringBuilder();

            builder.AppendLine(beginStateLine(ticks));
            builder.AppendLine(youIndexLine(world, player));
            foreach (Thunderstorm cloud in world.Thunderstorms)
            {
                builder.AppendLine(cloudLine("THUNDERSTORM", cloud));
            }
            foreach (RainCloud cloud in world.RainClouds)
            {
                builder.AppendLine(cloudLine("RAINCLOUD", cloud));
            }
            builder.AppendLine(endStateLine());
            return(builder.ToString());
        }
コード例 #5
0
    /// <summary>
    /// Returns a specific Weather class based on the value of parameter iRange
    /// </summary>
    /// <param name="iRange">Specific choice of Weather Object</param>
    /// <returns>wTempWeather</returns>
    public Weather RandomWeatherRange(int iRange)
    {
        Weather wTempWeather = new Weather();

        switch (iRange)
        {
        case 0:     //Rain
            wTempWeather = new Sunny();
            return(wTempWeather);

        case 1:     //Sunny
            wTempWeather = new Rain();
            return(wTempWeather);

        case 2:     //Cloudy
            wTempWeather = new Cloudy();
            return(wTempWeather);

        case 3:     //Snow
            wTempWeather = new Snow();
            return(wTempWeather);

        case 4:     //Windy
            wTempWeather = new Windy();
            return(wTempWeather);

        case 5:     //Thunderstorm
            wTempWeather = new Thunderstorm();
            return(wTempWeather);

        case 6:     //Hail
            wTempWeather = new Hail();
            return(wTempWeather);

        case 7:     //Fog
            wTempWeather = new Fog();
            return(wTempWeather);

        case 8:     //HeatWave
            wTempWeather = new HeatWave();
            return(wTempWeather);
        }

        return(wTempWeather);
    }
コード例 #6
0
        public void Update(Thunderstorm thunderstorm, World world, int iteration)
        {
            if (thunderstorm.IsDead() || !IsConnected())
            {
                Dispose();
                return;
            }

            thunderstorm.Name = playerName;

            state = new
            {
                player = thunderstorm,
                world,
                iteration
            };

            while (commandQueue.Any())
            {
                ParseMessage(commandQueue.Dequeue(), thunderstorm);
            }
        }
コード例 #7
0
ファイル: Estimation.cs プロジェクト: edekk/rawr-2.3.23
        public static void solve(CharacterCalculationsElemental calculatedStats, CalculationOptionsElemental calcOpts, BossOptions bossOpts)
        {
            Stats         stats     = calculatedStats.BasicStats;
            Character     character = calculatedStats.LocalCharacter;
            ShamanTalents talents   = character.ShamanTalents;

            /* Effects:
             * Clearcasting (-40% mana cost next 2 spells)
             * Glyph of flame shock or not
             * Clearcasting (5/10% more total damage)
             * Elemental Mastery (+15% haste chance, 15 sec/3 min cd)
             * Trinkets
             *
             * Assume LvB used on CD and FS either after LvB, on dot drop or before LvB
             * Filler: LB
             * NYI Optional: use of CL
             */
            Estimation e;
            Rotation   rot;
            float      damage;
            Stats      procStats;

#if RAWR3 || SILVERLIGHT
            float FightDuration = bossOpts.BerserkTimer;
#else
            float FightDuration = calcOpts.FightDuration;
#endif

            // WITHOUT PROCS
            e   = new Estimation(stats, new Stats {
            }, talents, calcOpts);
            rot = e.getPriorityRotation(calcOpts.RotationType);
            // WITH PROCS
            int nPasses = 2, k;
            for (k = 0; k < nPasses; k++)
            {
                procStats = DoSpecialEffects(character, stats, rot, FightDuration);
                //procStats = getTrinketStats(character, stats, calcOpts.FightDuration, rot);
                e.Update(stats, procStats, talents, calcOpts);
                rot = e.getPriorityRotation(calcOpts.RotationType);
            }

            // Thunderstorm usage
            float thunderstormRegen = 0f;
            #region Thunderstorm
            if (calcOpts.UseThunderstorm)
            {
                float procsPerSecond = Thunderstorm.getProcsPerSecond(talents.GlyphofThunder, (int)FightDuration);
                thunderstormRegen += (talents.GlyphofThunderstorm ? .1f : .08f) * stats.Mana * procsPerSecond * 5;
            }
            #endregion

            /* Regen variables: (divide by 5 for regen per second)
             * While casting: ManaRegInFSR
             * During regen: ManaRegOutFSR */
            #region Calculate Regen
            float spiRegen       = 5 * StatConversion.GetSpiritRegenSec(stats.Spirit, stats.Intellect);
            float replenishRegen = 5 * stats.Mana * stats.ManaRestoreFromMaxManaPerSecond;
            float judgementRegen = 5 * rot.GetBaseCastTime() / rot.Duration * stats.ManaRestoreFromBaseManaPPM / 60f * BaseStats.GetBaseStats(character).Mana;
            float ManaRegInFSR   = spiRegen * stats.SpellCombatManaRegeneration + stats.Mp5 + replenishRegen + judgementRegen + thunderstormRegen;
            float ManaRegOutFSR  = spiRegen + stats.Mp5 + replenishRegen + thunderstormRegen;
            float ManaRegen      = ManaRegInFSR;
            #endregion

            // TotalDamage, CastFraction, TimeUntilOOM
            #region Calculate total damage in the fight
            float TimeUntilOOM = 0;
            float effectiveMPS = rot.MPS - ManaRegen / 5f;
            if (effectiveMPS <= 0)
            {
                TimeUntilOOM = FightDuration;
            }
            else
            {
                TimeUntilOOM = (calculatedStats.BasicStats.Mana) / effectiveMPS;
            }
            if (TimeUntilOOM > FightDuration)
            {
                TimeUntilOOM = FightDuration;
            }

            #region SpecialEffects from procs etc.
            procStats = DoSpecialEffects(character, stats, rot, FightDuration);
            //procStats = getTrinketStats(character, stats, calcOpts.FightDuration, rot);
            //damage procs (Thunder Capacitor etc.) are effected by spellcrit and damage debuffs
            damage = procStats.ArcaneDamage * (1 + stats.BonusArcaneDamageMultiplier) + procStats.NatureDamage * (1 + stats.BonusNatureDamageMultiplier) + procStats.FireDamage * (1 + stats.BonusFireDamageMultiplier) + procStats.ShadowDamage * (1 + stats.BonusShadowDamageMultiplier);
            if (damage > 0)
            {
                damage  *= (1 + stats.SpellCrit * .5f); // but only with the normal 50% dmg bonus
                rot.DPS += damage;
            }
            #endregion

            float TotalDamage     = TimeUntilOOM * rot.DPS;
            float TimeToRegenFull = 5f * calculatedStats.BasicStats.Mana / ManaRegOutFSR;
            float TimeToBurnAll   = calculatedStats.BasicStats.Mana / effectiveMPS;
            float CastFraction    = 1f;
            if (ManaRegOutFSR > 0 && FightDuration > TimeUntilOOM)
            {
                float timeLeft = FightDuration - TimeUntilOOM;
                if (TimeToRegenFull + TimeToBurnAll == 0)
                {
                    CastFraction = 0;
                }
                else
                {
                    CastFraction = TimeToBurnAll / (TimeToRegenFull + TimeToBurnAll);
                }
                TotalDamage += timeLeft * rot.DPS * CastFraction;
            }
            #endregion

            float bsRatio = ((float)calcOpts.BSRatio) * 0.01f;
            calculatedStats.BurstPoints     = (1f - bsRatio) * 2f * rot.DPS;
            calculatedStats.SustainedPoints = bsRatio * 2f * TotalDamage / FightDuration;
            calculatedStats.OverallPoints   = calculatedStats.BurstPoints + calculatedStats.SustainedPoints;

            calculatedStats.CombatStats = stats.Clone();
            calculatedStats.CombatStats.Accumulate(procStats);

            calculatedStats.ManaRegenInFSR    = ManaRegInFSR;
            calculatedStats.ManaRegenOutFSR   = ManaRegOutFSR;
            calculatedStats.ReplenishMP5      = replenishRegen;
            calculatedStats.LightningBolt     = rot.LB;
            calculatedStats.ChainLightning    = rot.CL;
            calculatedStats.FlameShock        = rot.FS;
            calculatedStats.LavaBurst         = rot.LvB;
            calculatedStats.EarthShock        = rot.ES;
            calculatedStats.FrostShock        = rot.FrS;
            calculatedStats.FireNova          = rot.FN;
            calculatedStats.SearingTotem      = rot.ST;
            calculatedStats.MagmaTotem        = rot.MT;
            calculatedStats.TimeToOOM         = TimeUntilOOM;
            calculatedStats.CastRegenFraction = CastFraction;
            calculatedStats.CastsPerSecond    = rot.getCastsPerSecond();
            calculatedStats.CritsPerSecond    = rot.getWeightedCritchance() * rot.getCastsPerSecond();
            calculatedStats.MissesPerSecond   = rot.getCastsPerSecond() * (1f - rot.getWeightedHitchance());
            calculatedStats.LvBPerSecond      = rot.getCastsPerSecond(typeof(LavaBurst));
            calculatedStats.LBPerSecond       = rot.getCastsPerSecond(typeof(LightningBolt));
            calculatedStats.FSPerSecond       = rot.getCastsPerSecond(typeof(FlameShock));
            calculatedStats.LatencyPerSecond  = rot.LatencyPerSecond;
            calculatedStats.RotationDPS       = rot.DPS;
            calculatedStats.RotationMPS       = rot.MPS;
            calculatedStats.TotalDPS          = TotalDamage / FightDuration;
            rot.ClearCasting.TryGetValue(typeof(FlameShock), out calculatedStats.ClearCast_FlameShock);
            rot.ClearCasting.TryGetValue(typeof(LavaBurst), out calculatedStats.ClearCast_LavaBurst);
            rot.ClearCasting.TryGetValue(typeof(LightningBolt), out calculatedStats.ClearCast_LightningBolt);
            calculatedStats.Rotation        = rot.ToString();
            calculatedStats.RotationDetails = rot.ToDetailedString();
        }
コード例 #8
0
ファイル: StateProtocol.cs プロジェクト: janmagnet/CloudWars
 private static string youIndexLine(World world, Thunderstorm player)
 {
     return("YOU {0}".Format(world.Thunderstorms.IndexOf(player)));
 }