Commit Graph

13 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
698fb2ad9a Refactor choices
PS's choice system has now been majorly rewritten!

Battle#parseChoice has been eliminated, and Battle#choose is now a
very lightweight wrapper around the BattleSide#choose* functions, which
now handle validation.

Partial decisions have been mostly removed. You can manually construct
decisions partially with the side.choose* functions, but there's no
other support for them. Partial undo has been removed completely.

Choice tracking has been renamed from side.choiceData to side.choice.
side.choices has been removed and is now autogenerated from side.choice
when needed.

side.choiceData.decisions has been renamed side.choice.actions. In the
future, "decision" is a deprecated term and should be called "action"
wherever it shows up.

side.choiceData.waiting and side.getDecisionsFinished() have been
merged into side.isChoiceDone().

Other values in side.choiceData have either been rendered unnecessary
or renamed to something clearer.

The "skip" and "pass" choices have been merged together. Passes can
still be filled in automatically (so you can just use `/move 1` in
doubles when you have only one Pokémon left).
2017-03-17 23:14:52 -05:00
Ivo Julca
ec572891a5 Fix typing information leak 2016-06-20 11:38:06 -05:00
Ivo Julca
59c667337b Refactor Team Preview to support per-Pokémon decisions 2016-06-20 10:49:21 -05:00
Ivo Julca
543bbf5ccc Refactor switching to support per-Pokémon decisions
- Implements `skip` choice, which acts as a placeholder in the player
choices. This is relevant to double-KOs, since in-game you are allowed
to specify switch-ins in any order.
2016-06-19 23:45:57 -05:00
panpawn
a331b5d41c Test: fix iteration index (#2594) 2016-06-20 05:25:52 +02:00
Ivo Julca
50fcd02b6d Tighten move validation
The target location is checked on chooseMove(), rather than
after the decision has entered the queue.
2016-06-19 07:53:58 -05:00
Ivo Julca
2861463b48 Test: Increase coverage of /undo
Among the added tests, are included:
- A skipped test for an edge case in which usage of Reflect Type
causes a typing information leak via the presence/absence of the
"maybe-trapped" warning and cancel prevention.
- Two skipped tests related to partial decisions functionality.
2016-06-19 05:49:23 -05:00
Ivo Julca
3b1749eccf Add basic support for per-Pokémon decisions
- Basically, support is added only for `move` requests here, and
behind a flag (`battle.supportsPartialDecision`).
- Switching is mostly supported, except for the multiple-KOs case.
- Team Preview needs a rework in order to enable this feature.
2016-06-17 12:26:56 -05:00
Ivo Julca
76604daf58 Test: Cover /team and /shift decisions 2016-06-17 11:48:07 -05:00
Ivo Julca
be8ba884c8 Test: Increase coverage of decisions 2016-06-17 08:48:22 -05:00
Ivo Julca
67da1a1221 Test: Use the new common#createBattle method
- This cuts down tons of code that define player names, avatars,
and deal with Team Preview.
2016-06-17 05:45:22 -05:00
Ivo Julca
b242e86c04 Test: rearrange tests for decisions 2016-06-16 08:22:07 -05:00