public static double GetEffectiveness(PBEType attackingType, PBEType defendingType1, PBEType defendingType2, bool ignoreGhost = false, bool ignoreDark = false) { double d = GetEffectiveness(attackingType, defendingType1, ignoreGhost: ignoreGhost, ignoreDark: ignoreDark); d *= GetEffectiveness(attackingType, defendingType2, ignoreGhost: ignoreGhost, ignoreDark: ignoreDark); return(d); }
public void Camouflage_Works(PBEBattleTerrain battleTerrain, PBEType expectedType, PBESpecies species) { #region Setup PBERandom.SetSeed(0); PBESettings settings = PBESettings.DefaultSettings; var p0 = new TestPokemonCollection(1); p0[0] = new TestPokemon(settings, species, 0, 100, PBEMove.Camouflage); var p1 = new TestPokemonCollection(1); p1[0] = new TestPokemon(settings, PBESpecies.Magikarp, 0, 100, PBEMove.Splash); var battle = new PBEBattle(PBEBattleFormat.Single, settings, new PBETrainerInfo(p0, "Trainer 0"), new PBETrainerInfo(p1, "Trainer 1"), battleTerrain: battleTerrain); battle.OnNewEvent += PBEBattle.ConsoleBattleEventHandler; battle.Begin(); PBETrainer t0 = battle.Trainers[0]; PBETrainer t1 = battle.Trainers[1]; PBEBattlePokemon camouflager = t0.Party[0]; PBEBattlePokemon magikarp = t1.Party[0]; #endregion #region Use Camouflage and check Assert.True(PBEBattle.SelectActionsIfValid(t0, new PBETurnAction(camouflager, PBEMove.Camouflage, PBETurnTarget.AllyCenter))); Assert.True(PBEBattle.SelectActionsIfValid(t1, new PBETurnAction(magikarp, PBEMove.Splash, PBETurnTarget.AllyCenter))); battle.RunTurn(); Assert.True(camouflager.Type1 == expectedType && camouflager.Type2 == PBEType.None); #endregion #region Cleanup battle.OnNewEvent -= PBEBattle.ConsoleBattleEventHandler; #endregion }
private void TypeCheck(PBEPokemon user, PBEPokemon target, PBEType moveType, out PBEEffectiveness moveEffectiveness, ref double moveEffectivenessMultiplier, bool ignoreWonderGuard) { double m = PBEPokemonData.TypeEffectiveness[moveType][target.Type1]; m *= PBEPokemonData.TypeEffectiveness[moveType][target.Type2]; if (m <= 0) // (-infinity, 0] { moveEffectiveness = PBEEffectiveness.Ineffective; } else if (m < 1) // (0, 1) { moveEffectiveness = PBEEffectiveness.NotVeryEffective; } else if (m == 1.0) // [1, 1] { moveEffectiveness = PBEEffectiveness.Normal; } else // (1, infinity) { moveEffectiveness = PBEEffectiveness.SuperEffective; } moveEffectivenessMultiplier *= m; if (moveEffectiveness != PBEEffectiveness.Ineffective) { if ((target.Ability == PBEAbility.Levitate && moveType == PBEType.Ground) || (!ignoreWonderGuard && target.Ability == PBEAbility.WonderGuard && moveEffectiveness != PBEEffectiveness.SuperEffective)) { moveEffectiveness = PBEEffectiveness.Ineffective; moveEffectivenessMultiplier = 0; BroadcastAbility(target, target, target.Ability, PBEAbilityAction.Damage); } } }
private double CalculateAttack(PBEPokemon user, PBEPokemon target, PBEType moveType, double initialAttack) { double attack = initialAttack; if (user.Ability == PBEAbility.HugePower || user.Ability == PBEAbility.PurePower) { attack *= 2.0; } if (user.Item == PBEItem.ThickClub && (user.OriginalSpecies == PBESpecies.Cubone || user.OriginalSpecies == PBESpecies.Marowak)) { attack *= 2.0; } if (user.Item == PBEItem.LightBall && user.OriginalSpecies == PBESpecies.Pikachu) { attack *= 2.0; } if (moveType == PBEType.Fire && user.Ability == PBEAbility.Blaze && user.HP <= user.MaxHP / 3) { attack *= 1.5; } if (moveType == PBEType.Grass && user.Ability == PBEAbility.Overgrow && user.HP <= user.MaxHP / 3) { attack *= 1.5; } if (moveType == PBEType.Water && user.Ability == PBEAbility.Torrent && user.HP <= user.MaxHP / 3) { attack *= 1.5; } if (user.Ability == PBEAbility.Hustle) { attack *= 1.5; } if (user.Ability == PBEAbility.Guts && user.Status1 != PBEStatus1.None) { attack *= 1.5; } if (user.Item == PBEItem.ChoiceBand) { attack *= 1.5; } if (!user.HasCancellingAbility() && ShouldDoWeatherEffects() && Weather == PBEWeather.HarshSunlight && Array.Exists(user.Team.ActiveBattlers, p => p.Ability == PBEAbility.FlowerGift)) { attack *= 1.5; } if ((moveType == PBEType.Fire || moveType == PBEType.Ice) && target.Ability == PBEAbility.ThickFat && !user.HasCancellingAbility()) { attack *= 0.5; } if (user.Ability == PBEAbility.Defeatist && user.HP <= user.MaxHP / 2) { attack *= 0.5; } if (user.Ability == PBEAbility.SlowStart && user.SlowStart_HinderTurnsLeft > 0) { attack *= 0.5; } return(attack); }
public static bool HasType_Known(this IPBEPokemonKnownTypes pkmn, PBEType type) { if (type >= PBEType.MAX) { throw new ArgumentOutOfRangeException(nameof(type)); } return(pkmn.KnownType1 == type || pkmn.KnownType2 == type); }
public static double GetEffectiveness_Known(PBEType attackingType, IPBEPokemonKnownTypes defendingTypes, bool ignoreGhost = false, bool ignoreDark = false) { if (defendingTypes == null) { throw new ArgumentNullException(nameof(defendingTypes)); } return(GetEffectiveness(attackingType, defendingTypes.KnownType1, defendingTypes.KnownType2, ignoreGhost: ignoreGhost, ignoreDark: ignoreDark)); }
/// <summary>Returns True if the Pokémon has <paramref name="type"/>, False otherwise.</summary> /// <param name="type">The type to check.</param> public bool HasType(PBEType type) { if (type >= PBEType.MAX) { throw new ArgumentOutOfRangeException(nameof(type)); } return(Type1 == type || Type2 == type); }
private PBEMoveData(PBEType type, PBEMoveCategory category, sbyte priority, byte ppTier, byte power, byte accuracy, PBEMoveEffect effect, int effectParam, PBEMoveTarget targets, PBEMoveFlag flags) { Type = type; Category = category; Priority = priority; PPTier = ppTier; Power = power; Accuracy = accuracy; Effect = effect; EffectParam = effectParam; Targets = targets; Flags = flags; }
public static PBELocalizedString GetTypeName(PBEType type) { if (type >= PBEType.MAX) { throw new ArgumentOutOfRangeException(nameof(type)); } return(new PBELocalizedString(PBEUtils.QueryDatabase <SearchResult>(string.Format(QueryId, "TypeNames", (byte)type))[0])); }
internal PBETypeChangedPacket(byte[] data, EndianBinaryReader r, PBEBattle battle) { Data = new ReadOnlyCollection <byte>(data); PokemonTrainer = battle.Trainers[r.ReadByte()]; Pokemon = r.ReadEnum <PBEFieldPosition>(); Type1 = r.ReadEnum <PBEType>(); Type2 = r.ReadEnum <PBEType>(); }
// None of these moves are multi-target private void FixedDamageHit(PBEBattlePokemon user, PBEBattlePokemon[] targets, IPBEMoveData mData, Func <PBEBattlePokemon, int> damageFunc, Func <PBEBattlePokemon, PBEResult>?failFunc = null, Action?beforePostHit = null) { PBEType moveType = user.GetMoveType(mData); // Endeavor fails if the target's HP is <= the user's HP // One hit knockout moves fail if the target's level is > the user's level Hit_GetVictims(user, targets, mData, moveType, out List <PBEAttackVictim> victims, failFunc: failFunc); if (victims.Count == 0) { return; } // BUG: Gems activate for these moves despite base power not being involved if (!Settings.BugFix) { _ = CalculateBasePower(user, targets, mData, moveType); } void CalcDamage(PBEAttackVictim victim) { PBEBattlePokemon target = victim.Pkmn; // FinalGambit user faints here victim.Damage = DealDamage(user, target, damageFunc.Invoke(target)); } void DoSub(List <PBEAttackVictim> subs) { foreach (PBEAttackVictim victim in subs) { CalcDamage(victim); PBEBattlePokemon target = victim.Pkmn; if (target.SubstituteHP == 0) { BroadcastStatus2(target, user, PBEStatus2.Substitute, PBEStatusAction.Ended); } } } void DoNormal(List <PBEAttackVictim> normals) { foreach (PBEAttackVictim victim in normals) { CalcDamage(victim); } foreach (PBEAttackVictim victim in normals) { PBEBattlePokemon target = victim.Pkmn; // "It's a one-hit KO!" beforePostHit?.Invoke(); DoPostHitEffects(user, target, mData, moveType); } Hit_FaintCheck(normals); } Hit_HitTargets(user.Team, DoSub, DoNormal, victims, out List <PBEAttackVictim> allies, out List <PBEAttackVictim> foes); DoPostAttackedEffects(user, allies, foes, false, colorChangeType: moveType); }
public static double GetEffectiveness <T>(PBEType attackingType, T defendingTypes, bool useKnownInfo, bool ignoreGhost = false, bool ignoreDark = false) where T : IPBEPokemonTypes, IPBEPokemonKnownTypes { if (defendingTypes == null) { throw new ArgumentNullException(nameof(defendingTypes)); } return(GetEffectiveness(attackingType, useKnownInfo ? defendingTypes.KnownType1 : defendingTypes.Type1, useKnownInfo ? defendingTypes.KnownType2 : defendingTypes.Type2, ignoreGhost: ignoreGhost, ignoreDark: ignoreDark)); }
public static Color GetColor(PBEType type1, PBEType type2) { Color color = TypeColors[type1]; if (type2 != PBEType.None) { color = color.Blend(TypeColors[type2]); } return(color); }
internal PBEReflectTypePacket(byte[] data, EndianBinaryReader r, PBEBattle battle) { Data = new ReadOnlyCollection <byte>(data); UserTrainer = battle.Trainers[r.ReadByte()]; User = r.ReadEnum <PBEFieldPosition>(); TargetTrainer = battle.Trainers[r.ReadByte()]; Target = r.ReadEnum <PBEFieldPosition>(); Type1 = r.ReadEnum <PBEType>(); Type2 = r.ReadEnum <PBEType>(); }
[InlineData(PBESpecies.Gyarados, false)] // Flying dual-type-secondary public void Roost_Works(PBESpecies species, bool swapTypes) // Swap types around since there's no primary flying-type { #region Setup PBEDataProvider.GlobalRandom.Seed = 0; PBESettings settings = PBESettings.DefaultSettings; var p0 = new TestPokemonCollection(1); p0[0] = new TestPokemon(settings, PBESpecies.Lucario, 0, 50, PBEMove.Earthquake, PBEMove.VacuumWave); var p1 = new TestPokemonCollection(1); p1[0] = new TestPokemon(settings, species, 0, 100, PBEMove.Roost, PBEMove.Splash); var battle = new PBEBattle(PBEBattleFormat.Single, settings, new PBETrainerInfo(p0, "Trainer 0"), new PBETrainerInfo(p1, "Trainer 1")); battle.OnNewEvent += PBEBattle.ConsoleBattleEventHandler; PBETrainer t0 = battle.Trainers[0]; PBETrainer t1 = battle.Trainers[1]; PBEBattlePokemon lucario = t0.Party[0]; PBEBattlePokemon rooster = t1.Party[0]; PBEType type1 = rooster.Type1; PBEType type2 = rooster.Type2; if (swapTypes) { rooster.Type1 = type2; rooster.Type2 = type1; rooster.KnownType1 = type2; rooster.KnownType2 = type1; } battle.Begin(); #endregion #region Use VacuumWave to lower HP Assert.Null(t0.SelectActionsIfValid(new PBETurnAction(lucario, PBEMove.VacuumWave, PBETurnTarget.FoeCenter))); Assert.Null(t1.SelectActionsIfValid(new PBETurnAction(rooster, PBEMove.Splash, PBETurnTarget.AllyCenter))); battle.RunTurn(); #endregion #region Use Roost and check Assert.Null(t0.SelectActionsIfValid(new PBETurnAction(lucario, PBEMove.Earthquake, PBETurnTarget.FoeCenter))); Assert.Null(t1.SelectActionsIfValid(new PBETurnAction(rooster, PBEMove.Roost, PBETurnTarget.AllyCenter))); battle.RunTurn(); Assert.True(!battle.VerifyMoveResultHappened(lucario, rooster, PBEResult.Ineffective_Type) && // Earthquake hit !rooster.Status2.HasFlag(PBEStatus2.Roost) && // Roost ended properly rooster.Type1 == type1 && rooster.Type2 == type2 && // Types restored properly rooster.KnownType1 == type1 && rooster.KnownType2 == type2); #endregion #region Cleanup battle.OnNewEvent -= PBEBattle.ConsoleBattleEventHandler; #endregion }
public async Task Info([Remainder] string typeName) { PBEType?nType = PBELocalizedString.GetTypeByName(typeName); if (!nType.HasValue || nType.Value == PBEType.None) { await Context.Channel.SendMessageAsync($"{Context.User.Mention} ― Invalid type!"); } else { PBEType type = nType.Value; string description = $"{_tableStart}{_tableStart}"; // Build columns for (PBEType other = PBEType.None + 1; other < PBEType.MAX; other++) { description += $"|{Utils.TypeEmotes[other]}"; } // Build rows for (int i = 0; i < 2; i++) { bool doOffense = i == 0; description += $"\n{(doOffense ? _offense : _defense)}{Utils.TypeEmotes[type]}"; for (PBEType other = PBEType.None + 1; other < PBEType.MAX; other++) { double d = PBETypeEffectiveness.GetEffectiveness(doOffense ? type : other, doOffense ? other : type); string s; if (d <= 0) // (-infinity, 0] { s = _ineffective; } else if (d < 1) // (0, 1) { s = _notVeryEffective; } else if (d == 1) // [1, 1] { s = _effective; } else // (1, infinity) { s = _superEffective; } description += $"|{s}"; } } EmbedBuilder embed = new EmbedBuilder() .WithAuthor(Context.User) .WithColor(Utils.TypeColors[type]) .WithTitle(PBELocalizedString.GetTypeName(type).English) .WithUrl(Utils.URL) .WithDescription(description); await Context.Channel.SendMessageAsync(string.Empty, embed : embed.Build()); } }
private PBEDDBerryData(byte naturalGiftPower, PBEType naturalGiftType, byte bitterness = 0, byte dryness = 0, byte sourness = 0, byte spicyness = 0, byte sweetness = 0) { Bitterness = bitterness; Dryness = dryness; Sourness = sourness; Spicyness = spicyness; Sweetness = sweetness; NaturalGiftPower = naturalGiftPower; NaturalGiftType = naturalGiftType; }
internal PBETypeChangedPacket(PBEBattlePokemon pokemon, PBEType type1, PBEType type2) { using (var ms = new MemoryStream()) using (var w = new EndianBinaryWriter(ms, encoding: EncodingType.UTF16)) { w.Write(Code); w.Write((PokemonTrainer = pokemon.Trainer).Id); w.Write(Pokemon = pokemon.FieldPosition); w.Write(Type1 = type1); w.Write(Type2 = type2); Data = new ReadOnlyCollection <byte>(ms.GetBuffer()); } }
private double CalculateSpAttack(PBEPokemon user, PBEPokemon target, PBEType moveType, double initialSpAttack) { double spAttack = initialSpAttack; if (user.Item == PBEItem.DeepSeaTooth && user.OriginalSpecies == PBESpecies.Clamperl) { spAttack *= 2.0; } if (user.Item == PBEItem.LightBall && user.OriginalSpecies == PBESpecies.Pikachu) { spAttack *= 2.0; } if (moveType == PBEType.Fire && user.Ability == PBEAbility.Blaze && user.HP <= user.MaxHP / 3) { spAttack *= 1.5; } if (moveType == PBEType.Grass && user.Ability == PBEAbility.Overgrow && user.HP <= user.MaxHP / 3) { spAttack *= 1.5; } if (moveType == PBEType.Water && user.Ability == PBEAbility.Torrent && user.HP <= user.MaxHP / 3) { spAttack *= 1.5; } if (ShouldDoWeatherEffects() && Weather == PBEWeather.HarshSunlight && user.Ability == PBEAbility.SolarPower) { spAttack *= 1.5; } if (user.Item == PBEItem.SoulDew && (user.OriginalSpecies == PBESpecies.Latias || user.OriginalSpecies == PBESpecies.Latios)) { spAttack *= 1.5; } if (user.Item == PBEItem.ChoiceSpecs) { spAttack *= 1.5; } if ((user.Ability == PBEAbility.Minus || user.Ability == PBEAbility.Plus) && Array.Exists(user.Team.ActiveBattlers, p => p != user && (p.Ability == PBEAbility.Minus || p.Ability == PBEAbility.Plus))) { spAttack *= 1.5; } if ((moveType == PBEType.Fire || moveType == PBEType.Ice) && target.Ability == PBEAbility.ThickFat && !user.HasCancellingAbility()) { spAttack *= 0.5; } if (user.Ability == PBEAbility.Defeatist && user.HP <= user.MaxHP / 2) { spAttack *= 0.5; } return(spAttack); }
double CalculateAttack(PBEPokemon user, PBEPokemon target, PBEType moveType, double initialAttack) { double attack = initialAttack; if (user.Ability == PBEAbility.HugePower || user.Ability == PBEAbility.PurePower) { attack *= 2.0; } if (user.Item == PBEItem.ThickClub && (user.Shell.Species == PBESpecies.Cubone || user.Shell.Species == PBESpecies.Marowak)) { attack *= 2.0; } if (user.Item == PBEItem.LightBall && user.Shell.Species == PBESpecies.Pikachu) { attack *= 2.0; } if (moveType == PBEType.Fire && user.Ability == PBEAbility.Blaze && user.HP <= user.MaxHP / 3) { attack *= 1.5; } if (moveType == PBEType.Grass && user.Ability == PBEAbility.Overgrow && user.HP <= user.MaxHP / 3) { attack *= 1.5; } if (moveType == PBEType.Water && user.Ability == PBEAbility.Torrent && user.HP <= user.MaxHP / 3) { attack *= 1.5; } if (user.Ability == PBEAbility.Hustle) { attack *= 1.5; } if (user.Ability == PBEAbility.Guts && user.Status1 != PBEStatus1.None) { attack *= 1.5; } if (user.Item == PBEItem.ChoiceBand) { attack *= 1.5; } if ((moveType == PBEType.Fire || moveType == PBEType.Ice) && target.Ability == PBEAbility.ThickFat) { attack *= 0.5; } if (user.Ability == PBEAbility.Defeatist && user.HP <= user.MaxHP / 2) { attack *= 0.5; } return(attack); }
private bool TypeCheck(PBEPokemon user, PBEPokemon target, PBEType moveType, out PBEResult result, out double damageMultiplier, bool statusMove = false) { result = target.IsAffectedByMove(user, moveType, out damageMultiplier, statusMove: statusMove); if (result == PBEResult.Ineffective_Ability) { BroadcastAbility(target, target, target.Ability, PBEAbilityAction.Damage); } if (result != PBEResult.NotVeryEffective_Type && result != PBEResult.Success && result != PBEResult.SuperEffective_Type) { BroadcastMoveResult(user, target, result); return(false); } return(true); }
public static PBEReadOnlyLocalizedString GetTypeName(PBEType type) { if (type >= PBEType.MAX) { throw new ArgumentOutOfRangeException(nameof(type)); } List <SearchResult> results = PBEDefaultDataProvider.Instance.QueryDatabase <SearchResult>(string.Format(QueryId, "TypeNames", type)); if (results.Count == 1) { return(new PBEReadOnlyLocalizedString(results[0])); } throw new InvalidDataException(); }
internal PBEReflectTypePacket(PBEBattlePokemon user, PBEBattlePokemon target) { using (var ms = new MemoryStream()) using (var w = new EndianBinaryWriter(ms, encoding: EncodingType.UTF16)) { w.Write(Code); w.Write((UserTrainer = user.Trainer).Id); w.Write(User = user.FieldPosition); w.Write((TargetTrainer = target.Trainer).Id); w.Write(Target = target.FieldPosition); w.Write(Type1 = target.Type1); w.Write(Type2 = target.Type2); Data = new ReadOnlyCollection <byte>(ms.ToArray()); } }
public static double GetStealthRockMultiplier(PBEType type1, PBEType type2) { if (type1 >= PBEType.MAX) { throw new ArgumentOutOfRangeException(nameof(type1)); } if (type2 >= PBEType.MAX) { throw new ArgumentOutOfRangeException(nameof(type2)); } double d = 0.125; d *= _table[PBEType.Rock][type1]; d *= _table[PBEType.Rock][type2]; return(d); }
ushort CalculateDamage(PBEPokemon user, PBEPokemon target, PBEMove move, PBEType moveType, PBEMoveCategory moveCategory, double basePower, bool criticalHit) { ushort damage; double a = 0, d = 0; switch (move) { case PBEMove.FoulPlay: { a = CalculateAttack(user, target, moveType, target.Attack * GetStatChangeModifier(criticalHit ? Math.Max((sbyte)0, target.AttackChange) : target.AttackChange, false)); d = CalculateDefense(user, target, target.Defense * GetStatChangeModifier(criticalHit ? Math.Min((sbyte)0, target.DefenseChange) : target.DefenseChange, false)); break; } case PBEMove.Psyshock: case PBEMove.Psystrike: case PBEMove.SecretSword: { a = CalculateSpAttack(user, target, moveType, user.SpAttack * GetStatChangeModifier(criticalHit ? Math.Max((sbyte)0, user.SpAttackChange) : user.SpAttackChange, false)); d = CalculateDefense(user, target, target.Defense * GetStatChangeModifier(criticalHit ? Math.Min((sbyte)0, target.DefenseChange) : target.DefenseChange, false)); break; } default: { if (moveCategory == PBEMoveCategory.Physical) { a = CalculateAttack(user, target, moveType, user.Attack * GetStatChangeModifier(criticalHit ? Math.Max((sbyte)0, user.AttackChange) : user.AttackChange, false)); d = CalculateDefense(user, target, target.Defense * GetStatChangeModifier(criticalHit ? Math.Min((sbyte)0, target.DefenseChange) : target.DefenseChange, false)); } else if (moveCategory == PBEMoveCategory.Special) { a = CalculateSpAttack(user, target, moveType, user.SpAttack * GetStatChangeModifier(criticalHit ? Math.Max((sbyte)0, user.SpAttackChange) : user.SpAttackChange, false)); d = CalculateSpDefense(user, target, target.SpDefense * GetStatChangeModifier(criticalHit ? Math.Min((sbyte)0, target.SpDefenseChange) : target.SpDefenseChange, false)); } break; } } damage = (ushort)(2 * user.Shell.Level / 5 + 2); damage = (ushort)(damage * a * basePower / d); damage /= 50; damage += 2; return((ushort)(damage * PBEUtils.RNG.Next(85, 101) / 100)); }
public static double GetEffectiveness(PBEType attackingType, PBEType defendingType, bool ignoreGhost = false, bool ignoreDark = false) { if (attackingType >= PBEType.MAX) { throw new ArgumentOutOfRangeException(nameof(attackingType)); } if (defendingType >= PBEType.MAX) { throw new ArgumentOutOfRangeException(nameof(defendingType)); } double d = _table[attackingType][defendingType]; if (d <= 0 && ((ignoreGhost && defendingType == PBEType.Ghost) || (ignoreDark && defendingType == PBEType.Dark))) { return(1); } return(d); }
public PBEPkmnFormChangedPacket(PBEFieldPosition pokemonPosition, PBETeam pokemonTeam, ushort newAttack, ushort newDefense, ushort newSpAttack, ushort newSpDefense, ushort newSpeed, PBEAbility newAbility, PBEAbility newKnownAbility, PBESpecies newSpecies, PBEType newType1, PBEType newType2, double newWeight) { var bytes = new List <byte>(); bytes.AddRange(BitConverter.GetBytes(Code)); bytes.Add((byte)(Pokemon = pokemonPosition)); bytes.Add((PokemonTeam = pokemonTeam).Id); bytes.AddRange(BitConverter.GetBytes(NewAttack = newAttack)); bytes.AddRange(BitConverter.GetBytes(NewDefense = newDefense)); bytes.AddRange(BitConverter.GetBytes(NewSpAttack = newSpAttack)); bytes.AddRange(BitConverter.GetBytes(NewSpDefense = newSpDefense)); bytes.AddRange(BitConverter.GetBytes(NewSpeed = newSpeed)); bytes.Add((byte)(NewAbility = newAbility)); bytes.Add((byte)(NewKnownAbility = newKnownAbility)); bytes.AddRange(BitConverter.GetBytes((uint)(NewSpecies = newSpecies))); bytes.Add((byte)(NewType1 = newType1)); bytes.Add((byte)(NewType2 = newType2)); bytes.AddRange(BitConverter.GetBytes(NewWeight = newWeight)); Buffer = BitConverter.GetBytes((short)bytes.Count).Concat(bytes); }
/// <summary>Checks if <see cref="PBEMoveEffect.ThunderWave"/>'s type affects the target, taking into account <see cref="PBEAbility.Normalize"/>.</summary> public static PBEResult ThunderWaveTypeCheck(PBEBattlePokemon user, PBEBattlePokemon target, PBEMove move, bool useKnownInfo = false) { if (user == null) { throw new ArgumentNullException(nameof(user)); } if (target == null) { throw new ArgumentNullException(nameof(target)); } PBEType moveType = user.GetMoveType(move); double d = GetEffectiveness(moveType, target, useKnownInfo); if (d <= 0) { return(PBEResult.Ineffective_Type); } return(PBEResult.Success); }
private PBEPkmnFormChangedPacket(PBEFieldPosition pokemonPosition, PBETeam pokemonTeam, ushort newAttack, ushort newDefense, ushort newSpAttack, ushort newSpDefense, ushort newSpeed, PBEAbility newAbility, PBEAbility newKnownAbility, PBESpecies newSpecies, PBEType newType1, PBEType newType2, double newWeight) { using (var ms = new MemoryStream()) using (var w = new EndianBinaryWriter(ms, encoding: EncodingType.UTF16)) { w.Write(Code); w.Write(Pokemon = pokemonPosition); w.Write((PokemonTeam = pokemonTeam).Id); w.Write(NewAttack = newAttack); w.Write(NewDefense = newDefense); w.Write(NewSpAttack = newSpAttack); w.Write(NewSpDefense = newSpDefense); w.Write(NewSpeed = newSpeed); w.Write(NewAbility = newAbility); w.Write(NewKnownAbility = newKnownAbility); w.Write(NewSpecies = newSpecies); w.Write(NewType1 = newType1); w.Write(NewType2 = newType2); w.Write(NewWeight = newWeight); Data = new ReadOnlyCollection <byte>(ms.ToArray()); } }
public BaseStats(JToken j) { HP = j[nameof(HP)].Value <byte>(); Attack = j[nameof(Attack)].Value <byte>(); Defense = j[nameof(Defense)].Value <byte>(); SpAttack = j[nameof(SpAttack)].Value <byte>(); SpDefense = j[nameof(SpDefense)].Value <byte>(); Speed = j[nameof(Speed)].Value <byte>(); Type1 = j[nameof(Type1)].ReadEnumValue <PBEType>(); Type2 = j[nameof(Type2)].ReadEnumValue <PBEType>(); CatchRate = j[nameof(CatchRate)].Value <byte>(); BaseFriendship = j[nameof(BaseFriendship)].Value <byte>(); EggCycles = j[nameof(EggCycles)].Value <byte>(); GenderRatio = j[nameof(GenderRatio)].ReadEnumValue <PBEGenderRatio>(); GrowthRate = j[nameof(GrowthRate)].ReadEnumValue <PBEGrowthRate>(); BaseEXPYield = j[nameof(BaseEXPYield)].Value <ushort>(); EggGroup1 = j[nameof(EggGroup1)].ReadEnumValue <EggGroup>(); EggGroup2 = j[nameof(EggGroup2)].ReadEnumValue <EggGroup>(); Ability1 = j[nameof(Ability1)].ReadEnumValue <PBEAbility>(); Ability2 = j[nameof(Ability2)].ReadEnumValue <PBEAbility>(); AbilityH = j[nameof(AbilityH)].ReadEnumValue <PBEAbility>(); FleeRate = j[nameof(FleeRate)].Value <byte>(); Weight = j[nameof(Weight)].Value <double>(); }