Commit Graph

323 Commits

Author SHA1 Message Date
Guangcong Luo
d8d56163a6 Fix /savelearnsets
No one has reported its brokenness in ever! I guess I'm the only one
who scripts learnset changes with /eval...

Coming up next: A learnset change scripted using /eval!
2017-02-23 05:13:00 -06:00
Guangcong Luo
e99104b064 Refactor Hidden Power calculation to Tools
Hidden Power was previously in BattlePokemon's constructor, but it's
been moved to Tools where the calculation can be accessed externally
(relevant for team-validator).
2017-02-22 02:59:51 -06:00
Guangcong Luo
5c97a0a1a6 Improve fastUnpackTeam error handling
We now add split limits to the uses of String#split in fastUnpackTeam.

This helps slightly improve performance in certain weird scenarios, but
mostly isn't particularly consequential.
2017-02-21 01:24:44 -06:00
Guangcong Luo
402bb7bd84 Support HP type and Pokeball in packed teams
This is a refactor that doesn't really do much by itself. In the long
term, though, this will allow us to better support these things.
2017-02-20 02:13:28 -06:00
Guangcong Luo
6969290d67 Support passing format name to /learn 2016-12-06 20:31:32 -06:00
Guangcong Luo
b282f4358d Support new section syntax in formats.js
Sections can now be specified separately from formats.
2016-11-19 23:08:59 -05:00
Ivo Julca
7fd8283600 Introduce requiredItems as an alternative to requiredItem
The list of acceptable items can always be retrieved from `requiredItems`.
2016-11-19 15:44:57 -05:00
Ivo Julca
b3d443b660 Make sure that stats are floored 2016-11-19 01:36:55 -05:00
Ivo Julca
32412e5524 Refactor EV/IV/Nature stat modifiers to Tools#spreadModify 2016-11-17 21:00:05 -05:00
Ivo Julca
e3778ef820 Update missing default gen references to 7 2016-11-17 20:56:19 -05:00
Guangcong Luo
2770e5ee45 Properly default formats to gen6 2016-11-17 19:05:54 -06:00
Guangcong Luo
9e5bf532e0 Improve tools.js for the learnset importer 2016-11-17 15:26:21 -06:00
Guangcong Luo
b734d2f1c3 Make gen 7 the default mod
This makes gen 7 the default mod, updates the tests to match, and fixes
the corresponding build error.

Note that this only changes the default Tools mod, the default Formats
mod is now gen6. gen7 must be specified by name in a format, for that
format to be a gen 7 format.
2016-11-17 12:27:46 -06:00
Marty-D
ceca7aaa2d Implement Silvally's type changing
Plus add support for Z-Crystals working with Multitype and Fling powers
with Memories.
2016-11-17 11:06:13 -06:00
The Immortal
9e13cb1953 Set Alola forms as gen 7 2016-11-17 11:06:13 -06:00
The Immortal
da9bd8d96d Update Tools functions for gen 7 2016-11-17 11:06:13 -06:00
Guangcong Luo
305931ab18 Fix crash when calling dex.mod() from a mod 2016-10-23 22:00:16 -04:00
Guangcong Luo
02055d3d17 Fix mod loading order
Sometimes mods would mess up if they were loaded in the wrong order.
Specifically, some autogenerated properties of e.g. moves need to be
recalculated for mods.

Anyway, the entire cache system is replaced with a newer, faster,
slightly-more-memory-intensive-but-only-slightly cache system, which
no longer has these kinds of loading order issues.
2016-10-23 14:17:13 -05:00
Guangcong Luo
7d8d47c97c Refactor BattleEngine
Battle is now an ES6 class... mostly... it's complicated.

Battle's inheritance system has always been a mess. I tried to redo it
in a sensible way but it caused nondeterministic test failures. Not
even kidding; different things would fail each time I ran tests, even
without code changes. I'll investigate closer later, but this refactor
makes it use ES6 classes with only a small amount of hacking, which is
good enough. It is, at the very least, simpler than the previous mess.

BattleEngine.Battle.construct has been renamed BattleEngine.construct.
2016-10-22 23:11:26 -05:00
Guangcong Luo
47adaf0bde Minor refactor
Chat is now being included in battle processes, because Chat.escapeHTML
is convenient to have and because the recent Chat refactor makes it
relatively lightweight to include (it doesn't load chat commands
unless you call Chat.parse)
2016-10-21 15:47:06 -05:00
Guangcong Luo
2604780ec5 Refactor Tools
Tools will be renamed to Dex soon, which is why the code inside Tools
is calling itself "Dex" now, but right now we're just refactoring its
internal code and not officially renaming it yet.

In the meantime, Tools is now an ES6 Class.

A long-standing bug in learnset loading order (the one
test/chat-plugins/datasearch.js tests for) has finally been fixed, so
Tools.includeMods() is no longer necessary to accurately access modded
data.

Tools.mod has been split into Tools.mod(modid) and
Tools.format(format). The issue of Tools.mod being ambiguous about
whether it's passed a mod or a format hasn't been a _bug_ for a while,
but this is still more readable.

Other renames include:

Tools#isLoaded -> Tools#dataLoaded
Tools.includeMods() -> Tools.includeModData()
Tools.preloadMods() -> Tools.includeMods()
Tools.preloadedMods -> Tools.modsLoaded
Tools.moddedTools -> Tools.dexes

Do not just rename your calls of Tools.includeMods() to
Tools.includeModData(). With the learnset loading bug fixed, there's
no reason to use it unless you need direct access to
Tools.dexes[...].data for some reason (you don't, just use
Tools.mod(...).data)
2016-10-21 13:23:21 -05:00
The Immortal
e8940e56a5 Fix validator crash for non-existent templates 2016-10-11 02:07:04 +04:00
sirDonovan
fb4066d476 Fix 056e1a0b23
It broke tier validation and didn't work correctly due to a typo.
2016-10-05 18:17:56 -05:00
urkerab
056e1a0b23 Allow formats to override inherited formats or rulesets (#2547) 2016-10-05 14:38:49 -07:00
Guangcong Luo
4aa39301dd Improve Tools commenting 2016-10-02 23:45:12 -07:00
Guangcong Luo
da1b318707 Move text processing from Tools to CommandParser
The following functions have been renamed:

- Tools.html to CommandParser.html
- Tools.plural to CommandParser.plural
- Tools.escapeHTML to CommandParser.escapeHTML
- Tools.toDurationString to CommandParser.toDurationString
- Tools.toTimeStamp to CommandParser.toTimestamp
  (notice the lowercase 's')

This is in preparation for a rename of Tools to Dex (by removing the
non-dex-related functions) and a rename of CommandParser to either
Messages or Chat.
2016-09-30 18:04:13 -07:00
Guangcong Luo
07a1ca043a Stop shimming Array#includes
Our minimum requirement is now Node 6, which has native support for
Array#includes, so we no longer need to shim it.
2016-09-24 13:50:59 -07:00
urkerab
1a191a696a Allow the banlist to specify a numeric limit of team properties (#2773) 2016-09-24 12:35:57 -07:00
urkerab
b507af3cc4 Report complex bans using the original text (#2528) 2016-09-15 17:02:12 -07:00
Taylor Everding
1a1f64fe95 Remove .js extension from requires (#2725) 2016-08-30 00:04:40 -05:00
Marty-D
136ab7a3d2 Fix Tools.html 2016-08-29 15:16:03 -04:00
Guangcong Luo
54b672fe4e Start refactoring for template strings
This commit introduces Tools.html and Tools.plural, helper functions
for string construction.

Tools.html is a template tag function that escapes HTML inside the
template string.

Tools.plural is a helper function that takes a passed Number, Array,
Set, or Map and returns a string representing whether or not it's
plural.

It also starts doing some refactors of some files to make it clear how
I expect code style for template strings to look.

Previously, we used ' for IDs, " for English text, and ' for code.

We should now be using ' for IDs, ` for English text, and ` for code.
2016-08-28 04:35:43 -05:00
Guangcong Luo
bfa4e75c90 Add more guards for 'constructor' in Tools 2016-08-12 18:45:15 -04:00
Guangcong Luo
1cc6f39558 Fix bug in Tools.getTemplate('constructor') 2016-08-08 23:52:00 -05:00
Guangcong Luo
0cd4f5ad6b Fix another 'constructor' crash 2016-08-02 04:08:21 -04:00
Ivo Julca
af0fcd9a10 Tools: Add a Tools#installFormat method 2016-06-17 02:16:01 -05:00
Guangcong Luo
dbc88ee99f Fix comment spacing in tools.js 2016-06-09 04:19:50 -04:00
Marty-D
874ab9fb99 Support Berry names without an alias 2016-06-08 11:53:51 -04:00
Ivo Julca
ea9046ae0e Tools#getSpecies: Properly handle non-string argument 2016-05-13 21:37:59 -05:00
Ivo Julca
765f88559e Make shimmed Array#includes configurable 2016-05-13 20:55:34 -05:00
QuiteQuiet
63955aabd8 Add support for alternative models (#2539)
* Add aliases for alternate sprites

* Add support for alternate models for Pokemon
2016-05-04 11:20:50 -07:00
Guangcong Luo
4a995350bb Shim Array#includes
This also refactors everything to use Array#includes except data
and mods, which are large enough that I'll refactor them later
probably.
2016-05-04 02:55:18 -07:00
Ivo Julca
22779102cc Lint: Add miscellaneous extra rules
Among the newly added rules, there are quite a few intended to enforce
compliance of CONTRIBUTING.md-blessed idioms, as well as ensure
safe usage of classes and constant bindings.

We are also now enforcing usage of early return in commands.js,
which has 100% compliance as of fd2c45c.
2016-04-25 21:52:21 -05:00
Quinton Lee
dfa2ca22ae Add hh:mm:ss option in Tools#toDurationString (#2493) 2016-04-08 07:14:48 -05:00
Guangcong Luo
982b6eb8eb Fix style error 2016-03-21 14:08:24 -05:00
Guangcong Luo
52cc7f2e37 Remove Object.values external dependency
An external dependency is kind of overkill when the only
implementation we need is three lines.

This also lets us write a more performant implementation that
omits the parts irrelevant to us.
2016-03-21 10:15:55 -05:00
Ivo Julca
3a8e58c966 Revert "Forcibly replace Object.values implementation from Sugar.js"
This reverts commit 3cce56f as it is no longer needed.
2016-03-21 02:22:01 -05:00
Guangcong Luo
a125a3ed7b Remove sugar-deprecated 2016-03-16 09:51:23 -05:00
Ivo Julca
3cce56f6d2 Forcibly replace Object.values implementation from Sugar.js 2016-03-10 17:18:53 -05:00
Ivo Julca
12e9ca78da Remove usage of Date|Function methods implemented by Sugar.js
Implements Tools#toTimeStamp to support Node.js builds without ICU support,
which are currently the default. If/when that changes, we should be able to
use Date#toLocaleDateString, given that appropriate locale options are used.
2016-03-09 16:55:47 -05:00