Commit Graph

291 Commits

Author SHA1 Message Date
Guangcong Luo
7f72f09e5d Rename Dex.format -> Dex.forFormat 2017-07-27 17:10:44 -04:00
Konrad Borowski
b91c3cff90 Make battle rule clauses work recursively
This is an ugly fix, there is likely a better one, but this fixes
a problem with clauses like Species Clause not working.
2017-07-24 20:27:11 +02:00
Guangcong Luo
6c1a60df2e Fix limit rules in ruleTable team validation 2017-07-20 19:35:02 -05:00
Guangcong Luo
2b1d7b2cc3 Properly fix crash in /learn 2017-07-20 16:33:40 -05:00
Guangcong Luo
155d8ee314 Fix crash in Validator 2017-07-20 13:13:28 -05:00
Guangcong Luo
d79e348ebc Refactor banlistTable -> ruleTable
PS's rule table has been renamed from banlistTable, and works a bit
differently now. It's a Map instead of an object now, and the keys
work a bit differently.

The original banlistTable was designed to store bans, and later
additions shoved rules and then unbans in there. The new table is
designed to support all of these.
2017-07-20 12:50:41 -05:00
The Immortal
b112e22f85 STABmons: Make Arceus work 2017-07-18 02:22:58 +04:00
Guangcong Luo
58a1af0f0f Rename supplementaryBanlist -> customBanlist
It's shorter and clearer.
2017-07-04 09:36:37 +09:00
Guangcong Luo
95e8bebeaf Revert "ProcessManager: refactor, fix memory leak, use Typescript (#3706)"
This reverts commit c9b93d3529.
2017-07-02 08:11:18 -04:00
The Immortal
c67454768b Add new OM of the Month 2017-07-01 19:32:52 +04:00
Ben Davies
c9b93d3529 ProcessManager: refactor, fix memory leak, use Typescript (#3706)
- spawning and setting up child processes is now handled by
ProcessManager#constructor rather than needing to be done manually for
each module that uses ProcessManager
- direct references to ProcessManager in ProcessWrapper were removed to
prevent dead ProcessWrapper instances from being leaked when hotpatching
- process-manager.js and verifier.js now use Typescript
2017-06-30 09:09:13 +09:00
Guangcong Luo
82431d9afe Fix validator issue
Bringing no item caused the validator to break (which, of course,
made it nearly impossible to play gen 1).

I really wish full TypeScript coverage could come ASAP, so these
sorts of bugs would come less often.
2017-06-23 06:46:38 -04:00
Quinton Lee
5ab919d858 Refactor supplementary banlists into custom formats (#3671) 2017-06-22 03:10:15 -07:00
Ben Davies
015dd8db65 REPL: add Config.repl, refactor, Typescript (#3609)
- `Config.repl` enables/disables using REPL sockets since it doesn't
make as much sense to configure whether or not it's enabled with the
REPL_ENABLED const
- exports.start takes a filename parametre rather than a prefix and a
suffix one to avoid having to mutate parametres
- dead REPL sockets are removed from the sockets list when the server
emits an error, and the server closes on error now before respawning
the server
- made the file ready for Typescript
2017-06-11 10:40:38 -05:00
Ivo Julca
351550350f Refactor Allow Tradeback to a rule
Follow-up to 9da05b8635 (#3470)
2017-05-27 21:36:57 -05:00
HoeenHero
36b56f5c44 Finish renaming tools to dex (#3526) 2017-05-12 17:11:30 -05:00
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
Spandan Punwatkar
7e4adeeebc Add new OMs of the Month (#3493) 2017-05-01 19:26:30 +04:00
MacChaeger
48a66adb03 Battle Bond isn't event-only in AAA (#3491) 2017-04-30 00:47:06 -07:00
QuiteQuiet
6167797a10 Gen 2: Check for inconsistent SpA/SpD DV (#3467) 2017-04-22 11:19:37 -04:00
MacChaeger
9da05b8635 Refactor nonstandard banlists into rulesets (#3470) 2017-04-22 03:19:39 -04:00
The Immortal
2155b0ca12 Greninja-Ash is male only
Closes #3452
2017-04-14 20:42:03 +04:00
Guangcong Luo
aabcb8ed06 Show supplementaryBanlist in validator crashes 2017-03-05 10:13:26 -05:00
Guangcong Luo
e115891b09 Fix string standards in team-validator.js 2017-03-05 10:13:13 -05:00
Ivo Julca
e52c06f504 Warn for 0 EVs in all formats 2017-03-04 19:29:00 -05:00
Ivo Julca
11554fc146 Fix IV/DV validation in Gen 2 and Hackmons 2017-03-04 19:26:25 -05:00
Guangcong Luo
156325d44c Fix past-gen event validator
Future-gen events were previously allowed in past gens.
2017-03-01 02:13:08 -05:00
Guangcong Luo
1daa700434 Validator: Validate incomplete teams
In VGC and Battle Spot, the validator wouldn't do any validation at all
if you didn't bring the minimum number of Pokemon. Now, it still gives
other error messages in addition to "You need at least X Pokemon".

This is mostly nice for validating a single Pokemon for VGC etc without
needing to fill the rest of the team with junk.
2017-03-01 02:13:08 -05:00
Guangcong Luo
e8b60c1e90 Fix Gen 1-2 DV/EV/shiny/gender validation
The old code tried to validate by changing incorrect values to correct
values, but had lots of bugs. Even if it didn't have bugs, it would have
various flaws like stats being different from what you would expect from
the teambuilder, so the new code just tells you when your HP DV,
shininess, gender, and Hidden Power type are inconsistent with your
other DVs.

(The one exception is SD Thick Club Marowak, which still automatically
fixes its Atk IV, since we still don't have teambuilder UI for that.)
2017-03-01 02:13:08 -05:00
Quinton Lee
01a029172d Tournaments: support rulesets in /tour banlist (#3300)
* Validator: fully support overriding rulesets

* Tournaments: support rulesets in /tour banlist
2017-02-27 02:32:01 -04:00
Guangcong Luo
c2ae5c5354 Fix validator crashes 2017-02-25 02:36:00 -05:00
Guangcong Luo
220d9cf7d9 Add more useful errors for Validator#validateSource 2017-02-24 06:55:11 -06:00
Guangcong Luo
2bc476d9a2 Fix crash in validator 2017-02-24 04:57:52 -05:00
Guangcong Luo
d9b431b7c2 Stop converting set values to names
Because of the way fastUnpackTeam works, it's currently a reasonable
assumption that all the values in a `set` are IDs, and various parts
of the code have started to rely on that assumption.

Removing some old code to try to guarantee that the values in a `set`
are names allow us to work towards a new guarantee that `set` values
are IDs.

Closes #2553
2017-02-24 01:38:45 -06:00
Guangcong Luo
5a95f6f247 Remove unnecessary code
The Diancie check is now implemented in Diancie's event data.
2017-02-24 00:41:48 -06:00
Guangcong Luo
4052b28cec Refactor event validator
This is a huge refactor that consolidates many different places event,
DW, and VC moves are validated, so that they're now validated in the
single place Validator#validateEvent. DW and VC moves are now treated
as special cases of events.

Validator#checkLearnset now does zero validation of event, DW, and VC
moves; it now simply passes the list of possible sources back to
Validator#validateSet, and it's validateSet's job to determine if the
Pokemon meets the requirements for any of those sources.

(In addition to simplifying checkLearnset, this also means more
useful error messages if you fail to meet the requirements for an
event move or DW move.)

validateSet should also be a decent margin simpler, due to a lot of
its code being folded into validateEvent.
2017-02-24 00:38:47 -06:00
Guangcong Luo
e7e3520d99 Fix Virtual Console validation
Virtual Console validation wasn't happening for Pokemon who learn a
move from Virtual Console from multiple Pokemon in its evo family.

This is most relevant for No Guard Fissure Machamp, which shouldn't
be legal.
2017-02-23 17:32:32 -06:00
Guangcong Luo
4d2e36e30c Fix crash in validator 2017-02-23 17:23:54 -06:00
Guangcong Luo
f2319da74e Fix Hidden Power Dark validation 2017-02-23 18:31:13 -05:00
Guangcong Luo
54df5c857d Validator: Support Gen 1 Virtual Console moves
This adds validator support for Gen 1 Virtual Console moves.

Fixes #3208

If anyone wants the quick-and-dirty eval script I used to update
Learnsets:

```
Object.entries(Tools.mod('gen1').data.Learnsets).forEach(([speciesid, lset]) => {
	Object.entries(lset.learnset).forEach(([moveid, sources]) => {
		if (sources.some(s => s.startsWith('1L') || s.startsWith('1M'))) {
			let newLset = Tools.data.Learnsets[speciesid].learnset;
			if (!newLset[moveid]) newLset[moveid] = [];
			let i = 0;
			while (i < newLset[moveid].length && newLset[moveid][i].startsWith('7')) i++;
			newLset[moveid].splice(i, 0, '7V');
		}
	})
})
```
2017-02-23 05:23:14 -06:00
Guangcong Luo
151bbf5b41 Slightly refactor event validation
Now with slightly less redundant code!
2017-02-22 05:06:39 -06:00
Guangcong Luo
2d6bd87c0b Improve Hidden Power validator
Now that we now store Hidden Power type separately from IVs, we can
make some major changes to how Hidden Power is validated.

Instead of Hidden Power type being calculated from the IVs, it's now
sent separately as part of the set. This allows us to warn in the
validator if the Hidden Power type specified by the moveset is
different from the one calculated from the IVs, and give a validation
error if so.

This also allows us to validate the Hidden Power type (pre-bottle-cap
IVs) separately from the set IVs (post-bottle-cap IVs) when doing
event validation, which fixes some validation issues relating to
Hidden Power.
2017-02-22 04:39:03 -06:00
Guangcong Luo
2b75907975 Validator: Allow Gen 6 Pokemon in Battle Spot
Previously, "requirePentagon" meant "only allow current-gen Pokemon".

Now, "requirePentagon" means "allow Gen 6 Pokemon and later", and
"requirePlus" means "allow Gen 7 Pokemon and later".
2017-02-16 01:17:54 -06:00
Guangcong Luo
0bcad8de6c Validator: Refactor and comment validator flags 2017-02-16 01:17:54 -06:00
Guangcong Luo
6423c3f1e4 Validator: Pokebank has been released 2017-02-16 01:17:54 -06:00
Guangcong Luo
bcebbf1e7b Validator: Revert Pokebank changes
The last 7 commits to team-validator take the code in the wrong
direction. While it's possible that the latest one fixes the validation
issues for VGC, they misuse variable names and in general need to be
redone from scratch.
2017-02-16 01:17:54 -06:00
The Immortal
b8c56f0ffc Fix egg validation 2017-02-12 04:32:36 +04:00
The Immortal
31291ee957 Fix Mergemons 2017-02-06 15:00:39 +04:00
The Immortal
3cd71a105e Validator: Fix crash 2017-02-02 17:50:43 +04:00
The Immortal
642b916b9f Fix Mergemons crash 2017-02-01 23:05:36 +04:00