Damage halving Berries were being used on Substitute being hit.
This was not correct, so if the user has a Substitue volatile
the berry will not be consumed.
Analysis of a heap dump from the live main server disclosed that over 20,000
`Connection` objects were present in the heap. A `Connection` object should
only exist for a current connection to the server, so this indicated a
rather large memory leak.
The problem turned out to be that all `Connection` objects are retained in
a global `connections` array in users.js and never deleted from that arary,
and hence, are never garbage collected, even after no `User` object is using
the connection. Each `Connection` object was also retaining a
`SockJSConnection` for additional memory leakage.
In the heap snapshot, `Connection` objects were using ~11% of the server's
memory, and this was on a server that had been running for only 9 hours.
After running for days, the `Connection` objects were probably taking up a
very large ratio of the server's memory.
Explosion should only not faint the user in case a Substitue
fainted. If there's a Substitute but the target is Ghost-
type, the user will faint.
Attack category is dealt with in moves.js, no need to hardcode
it in the getDamage function.
This is simple stuff to bring it in line with PS's coding style.
Mod-specific rules are getting moved to mods/gen1/formats.js and
formats are condensed into one Custom Game format.
Damage categories are now read using .getCategory, which gen 3 overrides.
move.category can still be read directly to check if something's a status
move, but it should never be used for reading damage categories.
This also fixes a crash in gen 3 and makes it playable again.
Type changes have been moved out of ModifyPokemon, and now are only
updated manually such as at clearVolatile or during forme changes.
This fixes interaction between: Transform, forme changes,
Conversion, Conversion2, Soak, Camouflage, Reflect Type, and
Color Change.
We're now one more step closer to getting rid of the ModifyPokemon
event.
Type changes in gen3 and gen4 will need to be redone for the new
typechange system.
- Stats are now cached and recalculated every clearVolatile (switchout)
- Power Trick, Power Split, Guard Split, Transform, forme changes now
modify the cached stat value
- This eliminates the need for pokemon.baseSet, so it's been removed
- pokemon.transformInto has been split into transformInto and formeChange
- pokemon.baseBoosts have also been eliminated, boost changes are now
calculated on-the-fly like stats themselves
- Overall, stat changes should be a lot more like the cartridge games now
- We're also one step closer to finally getting rid of the ModifyPokemon
event