Exemplo n.º 1
0
        private void CalcMight(long timeMS, StringBuilder infoBuilder)
        {
            long num = 0L;

            if (this.State.PremiumBoni.TotalMightIsUnlocked)
            {
                using (List <Might> .Enumerator enumerator = this.State.AllMights.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        Might might = enumerator.Current;
                        if (might.ShadowCloneCount > 0)
                        {
                            long value = timeMS;
                            if (num > 0L)
                            {
                                value = num;
                                num   = 0L;
                            }
                            int  num2 = might.ShadowCloneCount.ToInt();
                            long num3 = might.DurationInMS(1, this.State);
                            long num4 = num3 / (might.Level.ToLong() + 1L);
                            if (num3 < 30L)
                            {
                                num3 = 30L;
                            }
                            if (num4 < 30L)
                            {
                                num4 = 30L;
                            }
                            CDouble rightSide = might.Level * (num3 - num4) / 2 + might.CurrentDuration;
                            CDouble leftSide  = value * might.ShadowCloneCount + rightSide;
                            CDouble cDouble   = Math.Sqrt((leftSide / num4).Double) * 1.414215;
                            int     num5      = (cDouble.Floored - might.Level).ToInt();
                            if (num5 > 0)
                            {
                                if (might.NextAt > 0 && might.Level + num5 >= might.NextAt)
                                {
                                    int num6 = num5;
                                    num5 = 0;
                                    if (might.Level < might.NextAt)
                                    {
                                        num5 = might.NextAt - might.Level.ToInt();
                                    }
                                    num6 -= num5;
                                    num   = (num4 * might.Level.ToLong() * (long)num6 + num4 * (might.Level.ToLong() + (long)num5 + (long)num6) * (long)num6) / 2L / (long)num2;
                                    might.RemoveCloneCount(num2);
                                    Might might2 = this.State.AllMights.FirstOrDefault((Might x) => x.TypeEnum == might.TypeEnum + 1);
                                    if (might2 == null)
                                    {
                                        might2 = this.State.AllMights[0];
                                    }
                                    might2.AddCloneCount(num2);
                                }
                                if (num5 > 0)
                                {
                                    might.CurrentDuration              = (num3 * (cDouble - cDouble.Floored)).ToLong();
                                    might.Level                       += num5;
                                    this.State.PremiumBoni.TotalMight += (long)num5;
                                    infoBuilder.Append("- gained ").Append(num5).Append(" levels in ' ").Append(might.Name).Append(" '\n");
                                }
                            }
                            if (num5 == 0 && might.Level < might.NextAt)
                            {
                                might.CurrentDuration += timeMS * (long)num2;
                            }
                        }
                        if (might.DurationLeft > 0L)
                        {
                            might.DurationLeft -= timeMS;
                            if (might.DurationLeft <= 0L)
                            {
                                might.DurationLeft = 0L;
                                might.UseCoolDown  = 3600000L;
                            }
                        }
                        if (might.UseCoolDown > 0L)
                        {
                            might.UseCoolDown -= timeMS;
                            if (might.UseCoolDown <= 0L)
                            {
                                might.UseCoolDown = 0L;
                            }
                        }
                    }
                }
            }
        }