All this code was done before the main battle-engine was reworked to have exceptions for past gens.
Furthermore, due to how inheritance works, it was messing up team preview in Stadium formats.
All what was dealt with this code is now dealt with in battle-engine.js and all future gen 2 exceptions should be there.
Unlike battle-engine.js, old gens did not check if move.ignoreImmunity was
undefined/false in their getDamage functions, causing crashes when numbers
were passed in to the function.
hasMove was not tracking moves properly, instead only tracking new moves
added in the object instead of its entire moveset. Also, there was a
line of code that caused all moves to be flagged as rejected.
While move.affectedByImmunities was always a Boolean value to denote if
the move was affected by immunities, move.ignoreImmunity can be a Boolean
value if it ignores or is affected by all type immunities, but also can
act as an object such that !!move.ignoreImmunity[type] means it ignores
immunities of that type.
Implement Gen 2 Random Battles as a challenge option.
This format is not going to have a ladder anytime soon.
This format is going to help ironing out Gen 2 mechanics.
The current team and set makers are pretty much basic, they are to be improved with player input over the time.
Right now it doesn't incorporate a full Gen 2 Pokémon pool and it intends to use more offensive items than Leftovers.
After a review of the disassembled code of gens 1 and 2, we've come to realise some very important stuff regarding secondary status.
On gens 1 and 2, Fire-types are not inherently immune to burn.
Ice-types are neither inherently immune to ice.
On gen 1, secondary status effects for paralyse, burn, and freeze will be ignored if the target Pokémon shares a type with the move-type.
On gen 2, the same happens but only for burn and freeze.
Poison-types are actually immune to poisons.
On gen 2, tri-attack can burn fire-types and freeze ice-types.
On gen 1, body slam cannot paralyse normal-types.
Also, Lick cannot paralyse ghost-types.
And thunderbolt/thunder can't paralyse electric-types.
Normal damage is calculated with boosts, screens, and burn.
If a critical hit happens, then:
Stat level modifications are ignored if they are neutral to or favour the defender.
Reflect and Light Screen defensive boosts are only ignored if stat level modifications were also ignored as a result thereof.
If the attacker is burned, stat level modifications are always ignored.
The attack drop from the burn is only applied when attacker's attack level is higher than defender's defense level (boost).
Therefor:
A critical hit will ignore defensive and offensive buffs/debuffs if the attacker and the defender have the same boost level or the defender has higher boost.
The boosts will be ignored if the attacker is burned, but if the attacker has more boost than the defender, burn reduction still applies.
Burn reduction won't apply on the first case, buffs being the same or defender having more.
This fixes issues with a lot of moves, including but not limited to Acid, Beat Up, Bone Rush, Crunch, Dig, Extreme Speed, Fake Out, Future Sight, High Jump Kick, Hypnosis and Petal Dance.