/// <summary> /// Sam = Stat after multiplier. /// Use Aesam() for accuracy + evasion, as it follows a different system for multiplier calculations. /// </summary> /// <param name="modifier"></param> /// <returns></returns> public float Sam(int value, int modifier, GetStat stat, bool crit) { if (modifier == -6) { return(value * (2f / 8f)); } if (modifier == -5) { return(value * (2f / 7f)); } if (modifier == -4) { return(value * (2f / 6f)); } if (modifier == -3) { return(value * (2f / 5f)); } if (modifier == -2) { return(value * (2f / 4f)); } if (modifier == -1) { return(value * (2f / 3f)); } if (modifier == 0) { return(value * (2f / 2f)); } if (modifier == 1) { return(value * (3f / 2f)); } if (modifier == 2) { return(value * (4f / 2f)); } if (modifier == 3) { return(value * (5f / 2f)); } if (modifier == 4) { return(value * (6f / 2f)); } if (modifier == 5) { return(value * (7f / 2f)); } if (modifier == 6) { return(value * (8f / 2f)); } return(value); }
private void Awake() { Instance = this; _time = 1; SubscribeEvents(); if (GetStat != null) { GetStat.Invoke(); } }
public override void Visit(GetStat getStat) { InstructionStream.Add(new string[] { $"addi r5, r14, {getStat.Variable.stackOffset}", $"lw r5, 0(r5)", $"jl r15, geti_func" }); if (getStat.Variable.SemanticalType == "float") { InstructionStream.Add(new string[] { $"addi r5, r14, {getStat.Variable.stackOffset + 4}", $"lw r5, 0(r5)", $"jl r15, geti_func" }); } }
private object NoASS() { string first = "if for get put return"; this.SkipErrors(first); var lookaheadToken = this.TokenStream.Peek(); string lookahead = lookaheadToken.AToCCFormat(); if ("if".HasToken(lookahead)) { this.ApplyDerivation("noASS -> 'if' '(' expr ')' 'then' statBlock 'else' statBlock ';'"); var ifStatement = new IfStat(lookaheadToken.SourceLocation); Match("if"); Match("("); var expr = Expr(); Match(")"); Match("then"); var trueBlock = StatBlock(); Match("else"); var elseBlock = StatBlock(); Match(";"); ifStatement.Condition = expr; ifStatement.TrueBlock = trueBlock; ifStatement.ElseBlock = elseBlock; return(ifStatement); } if ("for".HasToken(lookahead)) { this.ApplyDerivation("noASS -> 'for' '(' type 'id' '=' expr ';' relExpr ';' assignStat ')' statBlock ';'"); var forStat = new ForStat(lookaheadToken.SourceLocation); Match("for"); Match("("); string type = Type(); var idLocation = this.TokenStream.Peek().SourceLocation; string id = Match("id"); Match("="); var initExpr = Expr(); Match(";"); var condition = RelExpr(); Match(";"); var assignStat = AssignStat(); Match(")"); var statBlock = StatBlock(); Match(";"); forStat.Type = type; forStat.Id = id; forStat.Initialization = initExpr; forStat.Condition = condition; forStat.Update = assignStat; forStat.LoopBlock = statBlock; forStat.IdLocation = idLocation; return(forStat); } if ("get".HasToken(lookahead)) { this.ApplyDerivation("noASS -> 'get' '(' variable ')' ';'"); var getStatement = new GetStat(lookaheadToken.SourceLocation); Match("get"); Match("("); var variable = Variable(); Match(")"); Match(";"); getStatement.Variable = variable; return(getStatement); } if ("put".HasToken(lookahead)) { this.ApplyDerivation("noASS -> 'put' '(' expr ')' ';'"); var putStatement = new PutStat(lookaheadToken.SourceLocation); Match("put"); Match("("); var expr = Expr(); Match(")"); Match(";"); putStatement.Expression = expr; return(putStatement); } if ("return".HasToken(lookahead)) { this.ApplyDerivation("noASS -> 'return' '(' expr ')' ';'"); var returnStatement = new ReturnStat(lookaheadToken.SourceLocation); Match("return"); Match("("); var expr = Expr(); Match(")"); Match(";"); returnStatement.ReturnValueExpression = expr; return(returnStatement); } return(null); }
/// <summary> /// Adjusts modifier of the given stat for a target /// Returns string like "Bulbasaur's defense rose sharply!". /// </summary> /// <param name="pokemon">The Pokemon data of the target</param> /// <param name="target">The Pokemon projectile of the target</param> /// <param name="stat">String value of the stat to be adjusted</param> /// <param name="modifier">How many points to modify</param> /// <param name="state">The current BattleState</param> /// <param name="opponent">Whether or not this being called from wild Pokemon or trainer</param> public ILocalisedBindableString ModifyStat(PokemonData pokemon, ParentPokemon target, GetStat stat, int modifier, BattleState state, bool opponent) { ILocalisedBindableString text; string statname = ""; string adjustment = ""; if (opponent) { text = TerramonMod.Localisation.GetLocalisedString(new LocalisedString(("moves.modifyStatText", "{0}'s {1} {2}"))); } else { text = TerramonMod.Localisation.GetLocalisedString(new LocalisedString(("moves.modifyStatText", "Wild {0}'s {1} {2}"))); } if (modifier == -3) { adjustment = "severely fell!"; } if (modifier == -2) { adjustment = "harshly fell!"; } if (modifier == -1) { adjustment = "fell!"; } if (modifier == 1) { adjustment = "rose!"; } if (modifier == 2) { adjustment = "sharply rose!"; } if (modifier == 3) { adjustment = "drastically rose!"; } if (stat == GetStat.Defense) { statname = "Defense"; if (pokemon.CustomData.ContainsKey("PhysDefModifier")) { if (int.Parse(pokemon.CustomData["PhysDefModifier"]) == 6 && modifier > 0) { pokemon.CustomData["PhysDefModifier"] = "6"; adjustment = "won't go higher!"; text.Args = new object[] { pokemon.PokemonName, statname, adjustment }; return(text); // Cant go any higher! } else if (int.Parse(pokemon.CustomData["PhysDefModifier"]) == -6 && modifier < 0) { pokemon.CustomData["PhysDefModifier"] = "-6"; adjustment = "won't go lower!"; text.Args = new object[] { pokemon.PokemonName, statname, adjustment }; return(text); // Cant go any lower! } } if (pokemon.CustomData.ContainsKey("PhysDefModifier")) { int a = int.Parse(pokemon.CustomData["PhysDefModifier"]); int b = modifier; pokemon.CustomData["PhysDefModifier"] = (a + b).ToString(); if (modifier > 0) { Main.PlaySound(ModContent.GetInstance <TerramonMod>().GetLegacySoundSlot(SoundType.Custom, "Sounds/UI/BattleSFX/StatRise").WithVolume(.8f)); target.statModifiedUp = true; } else { Main.PlaySound(ModContent.GetInstance <TerramonMod>().GetLegacySoundSlot(SoundType.Custom, "Sounds/UI/BattleSFX/StatFall").WithVolume(.8f)); target.statModifiedDown = true; } } else { pokemon.CustomData.Add("PhysDefModifier", modifier.ToString()); if (modifier > 0) { Main.PlaySound(ModContent.GetInstance <TerramonMod>().GetLegacySoundSlot(SoundType.Custom, "Sounds/UI/BattleSFX/StatRise").WithVolume(.8f)); target.statModifiedUp = true; } else { Main.PlaySound(ModContent.GetInstance <TerramonMod>().GetLegacySoundSlot(SoundType.Custom, "Sounds/UI/BattleSFX/StatFall").WithVolume(.8f)); target.statModifiedDown = true; } } if (int.Parse(pokemon.CustomData["PhysDefModifier"]) > 6) { pokemon.CustomData["PhysDefModifier"] = "6"; } if (int.Parse(pokemon.CustomData["PhysDefModifier"]) < -6) { pokemon.CustomData["PhysDefModifier"] = "-6"; } text.Args = new object[] { pokemon.PokemonName, statname, adjustment }; return(text); } if (stat == GetStat.SpDef) { statname = "Special Defense"; if (pokemon.CustomData.ContainsKey("SpDefModifier")) { if (int.Parse(pokemon.CustomData["SpDefModifier"]) == 6 && modifier > 0) { pokemon.CustomData["SpDefModifier"] = "6"; adjustment = "won't go higher!"; text.Args = new object[] { pokemon.PokemonName, statname, adjustment }; return(text); // Cant go any higher! } else if (int.Parse(pokemon.CustomData["SpDefModifier"]) == -6 && modifier < 0) { pokemon.CustomData["SpDefModifier"] = "-6"; adjustment = "won't go lower!"; text.Args = new object[] { pokemon.PokemonName, statname, adjustment }; return(text); // Cant go any lower! } } if (pokemon.CustomData.ContainsKey("SpDefModifier")) { int a = int.Parse(pokemon.CustomData["SpDefModifier"]); int b = modifier; pokemon.CustomData["SpDefModifier"] = (a + b).ToString(); if (modifier > 0) { Main.PlaySound(ModContent.GetInstance <TerramonMod>().GetLegacySoundSlot(SoundType.Custom, "Sounds/UI/BattleSFX/StatRise").WithVolume(.8f)); target.statModifiedUp = true; } else { Main.PlaySound(ModContent.GetInstance <TerramonMod>().GetLegacySoundSlot(SoundType.Custom, "Sounds/UI/BattleSFX/StatFall").WithVolume(.8f)); target.statModifiedDown = true; } } else { pokemon.CustomData.Add("SpDefModifier", modifier.ToString()); if (modifier > 0) { Main.PlaySound(ModContent.GetInstance <TerramonMod>().GetLegacySoundSlot(SoundType.Custom, "Sounds/UI/BattleSFX/StatRise").WithVolume(.8f)); target.statModifiedUp = true; } else { Main.PlaySound(ModContent.GetInstance <TerramonMod>().GetLegacySoundSlot(SoundType.Custom, "Sounds/UI/BattleSFX/StatFall").WithVolume(.8f)); target.statModifiedDown = true; } } if (int.Parse(pokemon.CustomData["SpDefModifier"]) > 6) { pokemon.CustomData["SpDefModifier"] = "6"; } if (int.Parse(pokemon.CustomData["SpDefModifier"]) < -6) { pokemon.CustomData["SpDefModifier"] = "-6"; } text.Args = new object[] { pokemon.PokemonName, statname, adjustment }; return(text); } if (stat == GetStat.Speed) { statname = "Speed"; if (pokemon.CustomData.ContainsKey("SpeedModifier")) { if (int.Parse(pokemon.CustomData["SpeedModifier"]) == 6 && modifier > 0) { pokemon.CustomData["SpeedModifier"] = "6"; adjustment = "won't go higher!"; text.Args = new object[] { pokemon.PokemonName, statname, adjustment }; return(text); // Cant go any higher! } else if (int.Parse(pokemon.CustomData["SpeedModifier"]) == -6 && modifier < 0) { pokemon.CustomData["SpeedModifier"] = "-6"; adjustment = "won't go lower!"; text.Args = new object[] { pokemon.PokemonName, statname, adjustment }; return(text); // Cant go any lower! } } if (pokemon.CustomData.ContainsKey("SpeedModifier")) { int a = int.Parse(pokemon.CustomData["SpeedModifier"]); int b = modifier; pokemon.CustomData["SpeedModifier"] = (a + b).ToString(); if (modifier > 0) { Main.PlaySound(ModContent.GetInstance <TerramonMod>().GetLegacySoundSlot(SoundType.Custom, "Sounds/UI/BattleSFX/StatRise").WithVolume(.8f)); target.statModifiedUp = true; } else { Main.PlaySound(ModContent.GetInstance <TerramonMod>().GetLegacySoundSlot(SoundType.Custom, "Sounds/UI/BattleSFX/StatFall").WithVolume(.8f)); target.statModifiedDown = true; } } else { pokemon.CustomData.Add("SpeedModifier", modifier.ToString()); if (modifier > 0) { Main.PlaySound(ModContent.GetInstance <TerramonMod>().GetLegacySoundSlot(SoundType.Custom, "Sounds/UI/BattleSFX/StatRise").WithVolume(.8f)); target.statModifiedUp = true; } else { Main.PlaySound(ModContent.GetInstance <TerramonMod>().GetLegacySoundSlot(SoundType.Custom, "Sounds/UI/BattleSFX/StatFall").WithVolume(.8f)); target.statModifiedDown = true; } } if (int.Parse(pokemon.CustomData["SpeedModifier"]) > 6) { pokemon.CustomData["SpeedModifier"] = "6"; } if (int.Parse(pokemon.CustomData["SpeedModifier"]) < -6) { pokemon.CustomData["SpeedModifier"] = "-6"; } text.Args = new object[] { pokemon.PokemonName, statname, adjustment }; return(text); } // Pseudo-statistic if (stat == GetStat.CritRatio) { if (opponent) { text = TerramonMod.Localisation.GetLocalisedString(new LocalisedString(("moves.modifyStatText", "{0} is getting pumped!"))); } else { text = TerramonMod.Localisation.GetLocalisedString(new LocalisedString(("moves.modifyStatText", "The wild {0} is getting pumped!"))); } Main.PlaySound(ModContent.GetInstance <TerramonMod>().GetLegacySoundSlot(SoundType.Custom, "Sounds/UI/BattleSFX/StatRise").WithVolume(.8f)); if (pokemon.CustomData.ContainsKey("CritRatioModifier")) { if (int.Parse(pokemon.CustomData["CritRatioModifier"]) + modifier > 5) // Going past maximum { if (opponent) { text = TerramonMod.Localisation.GetLocalisedString(new LocalisedString(("moves.modifyStatText", "{0} is overflowing with energy!"))); } else { text = TerramonMod.Localisation.GetLocalisedString(new LocalisedString(("moves.modifyStatText", "The wild {0} is overflowing with energy!"))); } text.Args = new object[] { pokemon.PokemonName }; target.gettingPumped = true; return(text); } pokemon.CustomData["CritRatioModifier"] = (int.Parse(pokemon.CustomData["CritRatioModifier"]) + modifier).ToString(); text.Args = new object[] { pokemon.PokemonName }; target.gettingPumped = true; return(text); } else { pokemon.CustomData.Add("CritRatioModifier", modifier.ToString()); text.Args = new object[] { pokemon.PokemonName }; target.gettingPumped = true; return(text); } } return(text); }
public virtual void Visit(GetStat getStat) { }
void WriteData(GetStat getStat) { const int itCount = 50; double kvantil = Convert.ToDouble(kvantilTextBox.Text); double accuracy = Convert.ToDouble(accuracyTextBox.Text) / 100; int index = Convert.ToInt32(ShipTypeTextBox.Text); double dispercion = 0; double[] times = new double[itCount]; double itCountFinal = 0; double time = 0.0; int shipsCount = 0; var simulationTime = Convert.ToDouble(timeTextBox.Text); for (var i = 0; i < itCount; i++) // расчёт числа реализаций { var statistic = getStat(simulationTime); //var thisMathTime = statistic.MiddleFullTime; var thisMathTime = statistic.GetInDockMiddleShipTime(index); //Добавляем в список times[i] = thisMathTime; //Считаем матожидание time += thisMathTime / itCount; //time += statistic.GetFullMiddleShipTime(Convert.ToInt32(ShipTypeTextBox.Text)) / statistic.GetShipCount(Convert.ToInt32(ShipTypeTextBox.Text)); } for (int i = 0; i < itCount; i++) { dispercion += (times[i] * times[i] - time * time); } dispercion /= itCount - 1; itCountFinal = Math.Ceiling(dispercion * dispercion * kvantil * kvantil / (accuracy * accuracy)); KEK.count1 = KEK.count2 = KEK.count3 = KEK.count4 = 0; time = 0; shipsCount = 0; double queueTime = 0; for (var i = 0; i < itCountFinal; i++) { var statistic = getStat(simulationTime); var thisMathTime = statistic.MiddleFullTime; time += thisMathTime / itCountFinal; shipsCount += statistic.Count; queueTime += statistic.GetWaitingMiddleShipTime(index) / shipsCount; } shipsCount /= (int)itCountFinal; ShipTimeTextBox.Text = Math.Round(time, 5).ToString(); shipsTextBox.Text = shipsCount.ToString(); ITTextBox.Text = itCountFinal.ToString(); textBox1.Text = Math.Round((KEK.count1 / itCountFinal)).ToString(); textBox2.Text = Math.Round((KEK.count2 / itCountFinal)).ToString(); textBox3.Text = Math.Round((KEK.count3 / itCountFinal)).ToString(); textBox4.Text = Math.Round((KEK.count4 / itCountFinal)).ToString(); QueveTextBox.Text = Math.Round(queueTime, 2).ToString(); }