Commit Graph

21 Commits

Author SHA1 Message Date
Guangcong Luo
6dd58b40d3 Refactor simulator into new sim/ directory
This is a surprisingly minor refactor considering how many files it
touches, but most of this is only renames.

In terms of file renames:
- `tools.js` is now `sim/dex.js`
- `battle-engine.js` is now `sim/index.js` and its three classes are
  in `sim/battle.js`, `sim/side.js`, and `sim/pokemon.js`
- `prng.js` is now `sim/prng.js`

In terms of variable renames:
- `Tools` is now `Dex`
- `BattleEngine` is now `Sim`
- `BattleEngine.Battle` is now `Sim.Battle`
- `BattleEngine.BattleSide` is now `Sim.Side`
- `BattleEngine.BattlePokemon` is now `Sim.Pokemon`
2017-05-05 16:48:38 -05:00
Guangcong Luo
22cdab1b1f Fix crash in Gen 1 Stadium 2016-12-26 19:00:04 -05:00
Marty-D
e5aa26028b Gen I, Stadium: Correct drain/recoil after breaking a sub
- Also apply the fix from fc86e0ef0a to
Stadium
2016-05-06 20:43:47 -04:00
Guangcong Luo
cc7ccd2efe Stop unnecessarily calling update()
pokemon.update() used to be called after pretty much everything, but
now that we've refactored pretty much everything out of it, it's no
longer necessary for most of the situations we call it for.

It currently only updates pokemon.speed, so I've renamed it updateSpeed
for clarity.

We now only update pokemon.speed on switch-in, right before the
residual event, and at the beginning of every turn. This gives
something like a 30% speed-up.
2016-02-17 01:07:22 -06:00
Guangcong Luo
2ec179dcae Fix Stadium Substitute detection
No longer leaves an unused variable, and is now better commented.
2016-02-16 01:08:55 -05:00
Konrad Borowski
81f602b8d8 Always use trailing comma for multiline objects 2016-01-01 00:20:07 +01:00
Guangcong Luo
3c6909c414 Stop suppressing eslint warning for targetHadSub
This warning is legitimate.
2015-11-07 23:17:40 -06:00
Ivo Julca
7dddb66253 Migrate build system to ESLint
JSHint's ES6 support is shaky, and its development has stalled as of late.
Since ESLint can do by itself both JSHint and JSCS' jobs, this commit replaces them.
Gulp and its related dependencies are also hereby removed.
2015-11-07 21:36:49 -05:00
Ivo Julca
90973d5c0c Style fixes
- Cut down excessive spacing
- Add braces to missing conditionals
2015-11-07 17:08:09 -05:00
Juanma Serrano
c4ac8d6e2f Use strict mode and let and const instead of var
This commit also fixes some duplicated variable declarations.
2015-11-06 21:56:52 -05:00
Marty-D
29e56b1043 Fix confusion timing after rampage moves
- Gen 1, 2, 5, and 6 cause confusion immediately after the move on the
last turn
- Gen 3 and 4 cause confusion at the end of the turn on the last turn
2015-06-04 09:55:30 -04:00
Juanma Serrano
0f99628d00 Stadium: Apply proper stat modifying mechanics
As gen 1, Stadium has its own stat modifying mechanics.
It's basically an extension of gen 1's, only it changes the approach and runs a recalculation on all changes only for the proper Pokémon.
2015-05-13 10:31:39 +02:00
Juanma Serrano
125144e07e Gen 1: Fix self-destructing moves on immunity
Forgot to mention this change for c53d022e4b
2015-05-05 10:48:56 +02:00
Marty-D
c53d022e4b Fix OHKO moves
- Fix Gen 1/Stadium's accuracy and immunity order
- Fix OHKO moves ignoring Phantom Force
- Add OHKO messages
2015-04-30 13:06:45 -04:00
Kevin Lau
b6808d4476 Fix ignoreImmunity crashes in earlier gens
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.
2015-04-14 15:22:06 -07:00
Kevin Lau
2e56120ad9 Move refactor: affectedByImmunities -> ignoreImmunity
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.
2015-04-08 00:17:12 -07:00
Marty-D
ed074532c6 Make sure the flags object always exists 2015-03-21 14:29:07 -04:00
Juanma Serrano
d9c367ff65 Fix more Travis Build Errors
Add a spaces after tests.
2015-01-15 09:31:36 +01:00
Juanma Serrano
30614d0c6c Gen 1: Fix Substitute interaction with partial trapping 2015-01-14 13:44:34 +01:00
Juanma Serrano
c72606276b Delete last minute error tab 2015-01-09 10:01:11 +01:00
Juanma Serrano
defedeb162 Implement Stadium format
This commit implements at its full the Stadium format.
Stadium is a half-generation between Gen 1 and Gen 2, widely regarded as a Gen 1 game without the major gen 1 bugs.

The main changes of this game are:
Sleep lasts between 1 and 3 turns.
Hyper Beam does recharge after a faint.
Critical hits happen way less.
Substitute now blocks all status ailments and draining.
It allows tradebacks.
Partial trapping moves miss and stop their duration upon target switch.
Focus Energy actually works.
Stat calculations are done properly, burn and para drop are lost if you lose status.
2015-01-09 09:48:50 +01:00