Commit Graph

1124 Commits

Author SHA1 Message Date
Guangcong Luo
e0490ef41f Mark custom rules as non-searchable
This is just a safety precaution that may simplify some future code; we
don't currently allow custom rules in the matchmaker at all.
2017-12-09 00:25:16 -06:00
Guangcong Luo
5260bf6ac3 Fix unreleased template checking
The old code, for allowing unreleased pokemon if they were obtainable
by breeding, was a workaround for a very specific case which as far
as I can tell is no longer necessary.

In the future, a template should just not be marked as unreleased if
it's available by breeding.
2017-12-08 22:41:53 -06:00
Guangcong Luo
5d11ec89f1 Fix base-pokemon banning 2017-12-08 22:27:30 -06:00
Guangcong Luo
0613939874 Refactor tournament rule validation
It was happening in two different places. It's been consolidated now.
2017-12-08 21:04:05 -06:00
Guangcong Luo
bb598ed6c2 Add rule validator for format rules 2017-12-07 22:07:12 -06:00
MacChaeger
801883c53a Implement Stomping Tantrum (#4175) 2017-12-07 18:36:19 -06:00
Guangcong Luo
c0da44c482 Refactor moveset -> moveSlots
pokemon.moveset is now pokemon.moveSlots, which is at least slightly
clearer about what it's doing (tracking move state, mainly PP).

Mostly, this gives a consistent naming scheme for `move` (a Move
object) vs `moveSlot` (a MoveSlot object).

This also refactors a lot of existing `moveSlot` accesses to be modern,
including using `for...of`.
2017-12-05 11:12:44 -06:00
Kris Johnson
06de38fe6d STABmons: Fix Necrozma type inheriting (#4214) 2017-12-05 15:49:07 +08:00
Guangcong Luo
08d079037d Pass source effect of switches to client
We are now tracking source effects for switch actions, if they're
initiated by effects such as U-turn or Baton Pass. This will lead
to better messages client-side.
2017-12-04 19:14:13 -06:00
Guangcong Luo
f3dbfbe685 Refactor Decision -> Action
"Decision" and "Choice" were always kind of unclear, so Decision is now
Action. It should now be a lot clearer.

Actions are also now strongly typed.
2017-12-02 11:34:55 -06:00
Marty-D
dc7c46b427 Update Ability-changing effects
Fixes #3230, closes #3245
2017-12-02 11:37:36 -05:00
Guangcong Luo
f97ab41cb6
FIx bug 2017-12-02 10:19:18 -06:00
Guangcong Luo
70a5f3cf6d Fix Pursuit KO canceling a switch in Gen 3 2017-12-02 08:27:44 -06:00
Guangcong Luo
1ac2745c3e Refactor Pursuit hack
Pursuit no longer uses `moveThisTurn`, but rather `willMove`, which
involves significantly fewer Pursuit hacks.
2017-12-01 15:59:13 -06:00
Guangcong Luo
461706baa5 Correct Gen 2 faint mechanics
Described by Marty here:

https://www.smogon.com/forums/threads/gen-3-on-ps-final-fixes.3527268/#post-5989318
2017-12-01 15:59:03 -06:00
Guangcong Luo
ba9a41c669 Skip switches in gen 2-3 upon faint 2017-12-01 13:06:11 -06:00
Guangcong Luo
f4e535bbd6 Enforce consistent key spacing
This was previously not enforced because we used `:1` in too many
places, but those places seem to all be refactored out at this point.
2017-12-01 08:16:23 -06:00
Guangcong Luo
9bdf674d5f Refactor more tables to arrays
See #4079

Now we're just missing oldgens.
2017-11-30 19:40:16 -06:00
Guangcong Luo
8473c3f4fa Improve test engine
New functions:

battle.makeChoices([side 1], [side 2]);

Intended to be a replacement for the previous .choose/.commitDecisions
API.

If we can get all the test code on it, we can maybe finally actually
deprecate LEGACY_API_DO_NOT_USE.

It's now used in Healing Wish, where I think it makes a very readable
test.
2017-11-30 10:56:01 -06:00
Guangcong Luo
97d773226a Support switching to pokemon by name 2017-11-30 10:56:01 -06:00
Guangcong Luo
80c9a7c5a1 Fix Healing Wish properly
Broken in #4120
2017-11-30 10:39:21 -06:00
urkerab
53ef680bcf Put Rockruff-Dusk's template into the cache (#4185) 2017-11-26 10:02:46 -06:00
urkerab
aea93f25db Fix set name in validation reasons (#4181) 2017-11-25 19:08:06 -06:00
CheeseMuffin
0b3e09b06a Fix generation for totem mons (#4177) 2017-11-24 18:56:33 -06:00
urkerab
802db51ea8 Use ModifyMove to handle Photon Geyser mechanics (#4179) 2017-11-24 18:54:56 -06:00
Guangcong Luo
022839335f Add Gen 2 Virtual Console moves 2017-11-24 18:51:32 -06:00
MacChaeger
b0ba793257 Fix Totem tiers (#4176) 2017-11-24 13:55:47 -05:00
Marty-D
ff16589722 Correct Photon Geyser mechanics 2017-11-23 22:47:20 -05:00
urkerab
c7f9aa009c Fix spread Z-Moves interaction with protection (#4163) 2017-11-18 14:41:47 -05:00
Marty-D
77039602e3
Release Hidden Ability Orange and White Flower Florges line
Thanks, Kaphotics!
2017-11-18 09:15:41 -05:00
Guangcong Luo
e716e9edc7 Implement Ultra Burst 2017-11-17 00:01:09 -06:00
Guangcong Luo
e25eeb9eb0 Correctly validate Rockruff-Dusk 2017-11-16 21:45:24 -06:00
Kris Johnson
f2caefba9b Ultra Sun and Ultra Moon update (#4151) 2017-11-16 20:34:43 -06:00
MacChaeger
6f82808c34 Fix clearing volatiles (#4120) 2017-11-12 22:09:52 -05:00
Guangcong Luo
b9ea17e014 TypeScript: Correctly mark args as optional 2017-11-12 01:57:53 -06:00
Guangcong Luo
9a1cb36882 Support three arguments in addVolatile 2017-11-12 01:22:31 -06:00
Guangcong Luo
6dc65e48cf MODULE_NOT_FOUND is now ENOENT in Node 8 2017-11-09 14:43:43 -06:00
Guangcong Luo
56190af620 Fix up TypeScript errors
Also suppress TypeScript validation of various files we don't want
validated right now.
2017-11-08 01:23:04 -06:00
Guangcong Luo
e377d69395 Fix core team-validation intersection check 2017-11-05 00:11:51 -07:00
Guangcong Luo
7904e7791b Fix Gen 2 Hidden Power IV validation 2017-11-05 00:11:51 -07:00
Kris Johnson
4c5518320b Use standard formatting for STABmons move checking (#4123) 2017-11-04 13:54:54 -07:00
Guangcong Luo
c5d438b7be Fix TypeScript error in validator
...we should probably add TypeScript to CI sometime soon...
2017-11-04 12:14:47 -07:00
Kris Johnson
475e70b822 STABmons: Fix move validation error (#4121) 2017-11-03 15:42:37 +08:00
Guangcong Luo
17015189f1 Don't crash when validating impossible moves 2017-11-02 14:35:26 -05:00
Kris Johnson
c7e11d5469 Fix error in STABmons (#4118) 2017-11-02 14:02:18 -05:00
Guangcong Luo
011528bd5a Fix Hidden Ability validation
Previously, a mix of past-gen and modern event sources for a move would
confuse the validator. This case is now properly handled.
2017-11-02 13:36:05 -05:00
Guangcong Luo
528a6745cb TypeScript: Use GenderName alias in Template 2017-11-02 13:00:41 -05:00
Guangcong Luo
fed55531f1 Make the dexes table null-prototype
Fixes a 'constructor' issue in Dex.mod()
2017-11-02 13:00:40 -05:00
Guangcong Luo
e8d245f97b Support Pomeg Glitch 2017-11-02 13:52:24 -04:00
whales
c28a387a2f Fix Dex#getType (#4116) 2017-11-02 10:29:49 -04:00
urkerab
d86b272145 Other Metagames of the Month November 2017 (#4108) 2017-11-02 14:44:21 +08:00
Guangcong Luo
2d9fc18280 TypeScript sim/team-validator.js 2017-11-02 00:15:04 -05:00
Guangcong Luo
0e728281e6 Move team-validator to sim/team-validator 2017-11-01 05:22:37 -05:00
Guangcong Luo
6a6bc18d44 Work around ESLint 4.1.0 trailing spaces bug 2017-10-23 09:22:30 -05:00
Guangcong Luo
246dfa1da3 Refactor in-object-literal to array-includes (#4079)
Previously, if we wanted to test if A was either 'B' or 'C', we would use
the pattern:

    A in {B:1, C:1}

I actually don't know how common this pattern is; I just started using
it because I was tired of typing `A === 'B' || A === 'C'` all the time.
I never really liked it, though; the `:1` part made it kind of
blatantly a hack.

I did some testing and `['B', 'C'].includes(A)` is overall faster.

(A switch statement is around 20x faster still, but who wants to type
that much code?)

Anyway, the new standard is

    ['B', 'C'].includes(A)

Something something progress!
2017-10-23 09:19:15 -05:00
Marty-D
97bb5af755 Fix crash in confusion damage 2017-10-21 09:28:40 -04:00
Guangcong Luo
c640a69ffc Don't send Rated text for normal rated battles 2017-10-21 03:43:12 -05:00
Marty-D
312f93c47c Revert "Fix confusion interaction with HP-checking items (#4045)"
This reverts commit
6651c5dadb.
2017-10-20 21:05:49 -04:00
Quinton Lee
a0b8228592 TypeScript: Improve Sim typing (#4069)
Also improves intellisense for Visual Studio and Visual Studio Code.
2017-10-20 07:53:26 -05:00
Guangcong Luo
a207147a48 Support custom rated battle message
Currently, the bold circled "Rated" marker in battle logs is only used
for rated battles. This change also supports using them to mark tour
battles.
2017-10-18 05:41:03 -05:00
QuiteQuiet
6651c5dadb Fix confusion interaction with HP-checking items (#4045) 2017-10-17 09:26:27 -04:00
Guangcong Luo
110b6a5511 Implement tiebreaker
This is the tiebreaker used for timeouts in Gen 6-7 (I think), but it's
not currently used anywhere.
2017-10-08 03:39:58 -05:00
Ben Davies
77b4c77864 Dex: constructor is not a format alias 2017-09-18 21:20:03 -03:00
Guangcong Luo
6b870967e0 Fix bug in support for >10 pokemon in Team Preview 2017-09-09 20:31:54 -04:00
Guangcong Luo
737d9dbba0 Support more than 10 Pokemon in Team Preview 2017-09-09 20:19:24 -04:00
Guangcong Luo
066d970b54 Fix >6-pokemon Custom Games 2017-09-09 19:41:55 -04:00
Guangcong Luo
b42a322ecb Support over 6 Pokemon in Custom Game 2017-09-09 18:25:26 -04:00
Guangcong Luo
1e87e989cc Hacky fix to the 6-move bug 2017-09-08 18:20:08 -04:00
Guangcong Luo
057e6b4e89 Alias formats without gen number to Gen 7 formats
Closes #3785
2017-09-08 10:27:20 -04:00
urkerab
bd6743bbe7 Reveal own Ability in Gen 7 (#3969) 2017-09-06 23:21:19 -04:00
Guangcong Luo
25d0079b4f Sim: Fix Berries not activating after weather
Previously, Berries would not activate after weather damage and before
other residual damage/healing.

According to: https://www.youtube.com/watch?v=FRI5PSekhR4

They should activate then. More research is needed to determine what
other situations Berries should activate but don't.
2017-09-05 07:00:55 -04:00
Guangcong Luo
7785375d14 Sim: Faint-switch in fainted pokemon Spe order
Now, if multiple Pokemon fainted in one turn, they will be switched
out in Speed order (of the fainted Pokemon).
2017-09-05 06:53:56 -04:00
Ghoulean Algebra
f067ee13ee Gen II: Fix Hidden Power's power calculation (#3925)
Before : HP_Power=(5*(v+2w+4x+8y)+min(Z, 3))/2 + 31 
After: HP_Power=(5*(v+2w+4x+8y)+(Z % 4))/2 + 31 

where 
* v is 1 if SpcIV>=8; otherwise 0, 
* w is 1 if SpeIV>=8; otherwise 0, 
* x is 1 if DefIV>=8; otherwise 0, 
* y is 1 if AtkIV>=8; otherwise 0, 
* Z = SpcIV

See: 
http://tasvideos.org/forum/viewtopic.php?p=361950#361950
https://github.com/pret/pokecrystal/blob/master/battle/hidden_power.asm#L52
2017-08-27 20:22:05 -04:00
Quinton Lee
0c94145c40 Fix remaining custom format issues (#3910)
Rules for custom formats are once again sanitized and can be passed
around more easily by attaching them to the format's id.

Fixes:
- "Rule:" being required to add or remove a rule
- ruleset changes not being shown in battles
- the display of custom rules being affected by user input
- custom formats being broken by /hotpatch formats
2017-08-23 22:27:09 -07:00
Guangcong Luo
18d656519c Fix chooseMove again 2017-08-09 21:52:30 -05:00
Guangcong Luo
29bfa41f79 Fix crash in autoChoose 2017-08-09 20:28:25 -05:00
Marty-D
5aa7045900 Fix Solar Blade redirection issue 2017-08-05 12:32:35 -04:00
Guangcong Luo
4df6548cf4 Fix bugs in VGC auto-move resolver 2017-08-02 07:02:32 -04:00
HoeenHero
4af068a710 Fix custom banlists (#3832) 2017-07-31 02:18:24 -04:00
Guangcong Luo
bbf7bc98d2 Fix random battle sets
(There were doubles sets in singles games)
2017-07-27 17:49:38 -04:00
Guangcong Luo
acc165d4db Fix bugs in previous commits 2017-07-27 17:24:55 -04:00
Guangcong Luo
7f72f09e5d Rename Dex.format -> Dex.forFormat 2017-07-27 17:10:44 -04:00
Guangcong Luo
0e792dad80 Update default gen for formats to gen 7 2017-07-25 03:37:55 -04:00
Guangcong Luo
4cdf39f13c Remove prototype hack for Battle
Simulator instances still get their scripts included somewhat hackily,
but it's overall much less hacky than before. In particular, the
init code is now an actual constructor, allowing TypeScript to perhaps
validate it one future day.
2017-07-25 02:59:59 -04:00
Guangcong Luo
0ba508bbd3 Support ./pokemon-showdown generate-team
I might regret supporting this syntax, but it's now possible to make
PS generate teams on the commandline using:

./pokemon-showdown generate-team [optional format name] [optional seed]

The output will be in packed team format (which can be pasted into
a teambuilder import box).

The seed-passing should make it significantly more straightforward to
debug team generation weirdness.
2017-07-25 02:59:59 -04:00
Guangcong Luo
3b4d8b3ff0 Split random-teams.js out of scripts.js
Random team generation scripts are no longer in scripts.js, but instead
in a new file random-teams.js.

The scripts are now also no longer run from inside battles, but in a
new team generator object. This makes it easier for external scripts
to generate random teams by running Dex.generateTeam(format).
2017-07-25 02:59:59 -04:00
Guangcong Luo
a86762e4ea Fix in-battle clauses 2017-07-23 22:20:42 -07:00
Guangcong Luo
f38de6d775 Remove padStart shim
The padStart shim is currently unused and commented out. If we ever do
need it, we should increase the minimum Node version to 8.0.
2017-07-23 22:17:07 -07: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
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
Konrad Borowski
212b99ed90 Remove Object.values shim (#3787)
It's not correct as far ES2017 specification is concerned, and Showdown
requires Node.js 7 anyway
2017-07-16 17:39:53 -05:00
asgdf
6dc5c877e3 Fix comment typos (#3757) 2017-07-10 16:57:07 +09:00
Guangcong Luo
58a1af0f0f Rename supplementaryBanlist -> customBanlist
It's shorter and clearer.
2017-07-04 09:36:37 +09:00
Guangcong Luo
3f6f9e61a5 Fix supplementary banlists
They're coded as nullable and are better treated that way.
2017-07-04 09:36:37 +09:00
Marty-D
3bf0ffdc97 Gen III: Fix Ingrain 2017-06-29 18:38:36 -04:00
Guangcong Luo
83f70fcf3a Export PRNG from sim/ 2017-06-22 20:57:51 -07:00
Quinton Lee
e3b964a65d Show correct rulesets in custom format battles (#3674)
Also add more format documentation
2017-06-22 15:25:31 -07:00
Quinton Lee
5ab919d858 Refactor supplementary banlists into custom formats (#3671) 2017-06-22 03:10:15 -07:00
Quinton Lee
ec10d30996 eslint: Lint sim/ directory (#3670) 2017-06-21 20:00:17 -07:00
Marty-D
d60c007f3d Update move flag descriptions 2017-06-17 09:36:52 -04:00
Guangcong Luo
cf7607cb90 Move cache tables out of Dex.data
Template/Item/Move/Ability caches are now direct properties of Dex,
instead of being inside Dex.data.
2017-06-13 21:45:53 -05:00
Guangcong Luo
00448ac865 TypeScript: Update for latest nightly
The latest nightly of TypeScript changes how the checks work, and I'm
tracking it because it also fixes several major bugs in --checkJs.
2017-06-11 12:03:38 -05:00
Caleb Young
9dab8e50e1 Implement DPP damage formula (#3583) 2017-06-11 10:18:34 -05:00
asgdf
f22963c718 Fix Last Will crash (#3561)
By moving BeforeFaint right before the faint message, so the move is done
by then.
2017-05-28 17:24:17 +09:00
urkerab
f24d7cbadb Move Illusion-breaking out of the battle engine (#3549) 2017-05-24 20:36:17 -04:00
asgdf
8a33238544 Fix statuses still being effective after being removed that turn (#3538) 2017-05-24 23:55:35 +09:00
urkerab
d212b9f128 Move, Ability and Item effects should inherit the name (#3547) 2017-05-24 23:12:38 +09:00
Guangcong Luo
cd3ac06987 Fix Hail/Sandstorm damage regression
(Also add a test for it since this isn't even the first time this
exact regression has happened.)
2017-05-18 06:29:25 -05:00
Guangcong Luo
109b2cfe1d Slightly refactor teamsize 2017-05-18 05:38:14 -05:00
QuiteQuiet
1be924f6e8 Send team size at the start of battles (#3512) 2017-05-18 05:09:38 -05:00
Guangcong Luo
149ca3759c Add classes for data
Having classes for data will make it better for documenting and make
for overall nicer code that's easier to statically analyze.
2017-05-17 04:10:01 -05:00
Guangcong Luo
fe5fa7889e Fix various TypeScript-related errors
Now that typescript@next fixes the major issue plaguing us, we can
start working on the other issues!
2017-05-17 04:10:01 -05:00
urkerab
b12d9cbf04 Give Natures a Generation (#3528) 2017-05-14 07:22:42 -05:00
urkerab
8ca39d65fc Properly report a near miss for an alias (#3532) 2017-05-14 07:22:20 -05:00
Charlie Kobayashi
78ed58d0c4 Dex: fix dataSearch (#3525)
Use the result's name first instead of inexact search term if search is found.
2017-05-12 17:12:07 -05:00
Charlie Kobayashi
196364adca Effect: don't override inherited properties from moreData (#3524)
- caused weather effects passed in through ``moreData`` to be marked as simply ``"Effect"``
    - as a result, sandstorm and hail will damage Rock/Ground/Steel and Ice types  respectively
- this fix makes ``Effect`` inherit the ``effectType`` from ``moreData`` if it doesn't exist in the primary ``data`` variable passed into the constructor
2017-05-12 14:23:05 -05:00
urkerab
59583ee113 Include aliases when searching the dex (#3475) 2017-05-09 23:58:32 -05:00
Guangcong Luo
e34c77930a Start creating classes for getEffect data
Currently, getEffect/getTemplate/getMove/etc return bare objects.
Refactoring their returns into classes will allow TypeScript to type
check them.
2017-05-09 16:00:11 -05:00
Guangcong Luo
a75282ea97 Fix crash in /weakness 2017-05-08 19:06:54 -05:00
Guangcong Luo
22186f1903 Improve TypeScript typing
sim/dex.js and sim/prng.js are now valid strict TypeScript! Also they
have slightly less "any" use than before.
2017-05-08 02:58:55 -05:00
Quinton Lee
fa1b45f7ab Support supplementary rulesets in battles (#3330) 2017-05-05 20:13:08 -05:00
Guangcong Luo
9e180e4fc1 Remove MockBattle
No MockBattle feature needs to be kept out of sim/...
2017-05-05 16:57:18 -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