Commit Graph

161 Commits

Author SHA1 Message Date
ACakeWearingAHat
46733b2fd5
Gen 3 Random Battle updates (#8102) 2021-03-06 14:59:51 -08:00
ACakeWearingAHat
d0eeeac7f0
Random Battles: Improve documentation (#8096) 2021-03-05 14:18:00 -08:00
Annika
591eb345ce
Random Battles: Refactor LGPE and Gens 1-3 (#8060) 2021-02-23 10:27:19 -08:00
Annika
c2e97aaaed
Use optional chaining in more places (#8063) 2021-02-22 11:42:05 -08:00
ACakeWearingAHat
c9e431ed48
Random Battles: Bugfixes for Doubles and old generations (#8058) 2021-02-19 16:08:27 -08:00
Kris Johnson
31856b698e
ADV: Move Breloom to OU and Regice to UUBL
https://www.smogon.com/forums/threads/adv-ou-tiering-changes.3652636/#post-8757221
2021-02-17 16:54:34 -07:00
Annika
bb4cbf3394
Random Battles: Refactor for code standards and readability (#8021)
This PR
- Brings all Random Battles code up to the standard 120-charaacter line length limit
- Improves readability for all Random Battles code
- Refactors current-gen Random Battles team generation to be more modular and readable

Documentation thanks to @ACakeWearingAHat!
2021-02-12 15:50:04 -08:00
Dawnofares
e7f7260927
Show OHKO message if OHKO move breaks substitute (#7171) 2021-01-12 12:16:17 -05:00
Marty-D
a228f9eded
Gen II-III: Fix Conversion 2 2021-01-08 13:40:48 -05:00
urkerab
0cbfeeba09
Fix Snatch in Gen 3 (#7812) 2020-12-15 19:25:59 -05:00
Marty-D
1ed4d58b7e
Gen III: Fix Weather Ball
I realize this isn't actually correct, but at least it's less incorrect for now.
2020-11-20 18:24:29 -05:00
The Immortal
944d27ff55 Gen 2 Random: Prevent crashes with Monotype rule
Gen 2 has types with less than 6 Pokemon. These are fine to be rolled if someone plays this format via custom challenge and shouldn't crash.
2020-11-19 05:00:16 +04:00
The Immortal
6f44c6b4f8 Allow Same Type Clause in gens 3 & 2 Randoms 2020-11-19 02:41:48 +04:00
Kris Johnson
7877b95e67 Random Battle: Fix typo and remove redundant check 2020-11-16 22:40:48 -07:00
Marty-D
2d0e06e497 Past Gens: Fix Fury Cutter 2020-11-09 18:10:05 -05:00
ACakeWearingAHat
3037781e1d
Revamp Gen 2 Random Battle (#7610) 2020-11-02 01:13:11 +04:00
Kris Johnson
ba4c9d7a2a
Add November's OMotM, LCotM and RoA Spotlight (#7615) 2020-11-01 15:36:24 +04:00
Guangcong Luo
9d87616176
Add more style linting rules (#7537)
* Lint arrow-body-style

* Lint prefer-object-spread

Object spread is faster _and_ more readable.

This also fixes a few unnecessary object clones.

* Enable no-parameter-properties

This isn't currently used, but this makes clear that it shouldn't be.

* Refactor more Promises to async/await

* Remove unnecessary code from getDataMoveHTML etc

* Lint prefer-string-starts-ends-with

* Stop using no-undef

According to the typescript-eslint FAQ, this is redundant with
TypeScript, and they're not wrong. This will save us from needing to
specify globals in two different places which will be nice.
2020-10-19 02:42:28 -07:00
Kris Johnson
6699a57f4d
Fix spread move mechanics in ADV Doubles (#7523) 2020-10-16 11:22:48 -04:00
The Immortal
f32b7c3b4f Gen 3: Random Battle fixes 2020-09-20 03:16:20 +04:00
urkerab
bcc6fddff5
Remove duplicate fail message from Encore (#7339) 2020-09-09 04:32:28 +04:00
Strahm, Jeffrey S.(S&T-Student)
188426490b Rename FormatsData to FormatData
(The name FormatsData is inconsistent with how we name other things;
especially since it's supposed to be data for a single format. It was
probably originally a typo. -Zarel)
2020-09-07 19:35:14 -07:00
Guangcong Luo
ea8f52ce97
Move descriptions to data/text/ files (#7036)
This adds some new `data/text/` files, which are the new home for
item/move/ability descriptions, as well as in-game messages, in one
place for ease of translation.
2020-09-06 22:00:11 -07:00
The Immortal
78d85c6790 Gen 3: Fix Lightning Rod rating 2020-09-02 12:43:12 +04:00
Kris Johnson
324ad0425a
Fix various GSC/ADV mechanics (#7247) 2020-08-22 01:29:41 -07:00
Guangcong Luo
4d09f7acde Rename more instances of Effect to Condition 2020-07-26 11:26:23 -07:00
Guangcong Luo
2f805c93a2
Remove "Battle" prefix from data exports (#7039)
`BattlePokedex` is now `Pokedex`, `BattleItems` is now `Items`, etc.

I also renamed `Movedex` to `Moves` and `Statuses` to `Conditions`.

`TypeChart` isn't `Types` yet, because unlike the others, it's not
indexed by ID. That should probably be fixed one day.
2020-07-24 12:42:26 -07:00
The Immortal
b2387ad20d Gen 3: Random Battle updates 2020-07-05 19:34:41 +04:00
The Immortal
45329dd44c Gen 3: Random Battle updates 2020-07-03 14:30:12 +04:00
urkerab
17e4cb49a4
Adjust fractional priority for latest research (#6928) 2020-06-29 12:09:10 -07:00
urkerab
f69ebf4f77
Fix Gen 3 Metal Coat's description (#6919) 2020-06-26 04:52:42 -07:00
Mia
6839a1f4db
Add a library for utility functions (#6817) 2020-06-09 22:06:43 -07:00
The Immortal
0199852386 Gen 3: Random Battle improvements 2020-06-04 16:57:55 +04:00
The Immortal
f9791abba9 Random Battles: Fix cosmetic formes 2020-06-04 03:06:07 +04:00
The Immortal
d8364dc952 Gen 3: Random Battle updates 2020-05-28 02:08:28 +04:00
Marty-D
324a5bfa1a Gen III-IV: Fix Abilities' interaction with 0 damage
Thanks BKC for pointing out Rough Skin
2020-05-23 11:52:52 -04:00
The Immortal
f8ecce8096 Gen 3: Random Battle improvements 2020-05-21 22:45:38 +04:00
Leonard Craft III
3496491d4f
Fix Farfetch'd / Sirfetch'd with new apostrophe (#6721)
Also fixes Stick's behavior
2020-05-19 21:56:35 -07:00
The Immortal
0e80285a5e Gen 3 Random Battle: More improvements 2020-05-16 08:13:27 +04:00
The Immortal
0227db4ba4 Gen 3: Random Battle fixes 2020-05-15 01:12:20 +04:00
The Immortal
8be031bb6d Gen 3 Random Battle: Overhaul set generation 2020-05-14 07:58:36 +04:00
The Immortal
073672962c Gen 3: Update random battle moves
This is the first part of the gen 3 random battle overhaul. A complete rewrite of the set generator will follow.
2020-05-12 07:44:47 +04:00
Guangcong Luo
e0f6453b60 Refactor data definitions
- `Modded[Effect]Data` are now correctly defined: they must either have
  `inherit: true` and be partial, or not have `inherit: true` and be a
	complete `[Effect]Data` entry

- `id` is no longer allowed; instead, it's calculated directly from
  `toID(name)`. The one exception, Hidden Power, gets a `realMove`
	property to track this (it's still used to set `.id`, though;
	TODO: really fix it properly).

- `num` is still required in `data/pokedex.ts` (dex number),
  `data/moves.ts` (move index number, for Metronome), and
	`data/items.ts` (minisprite sprite-sheet location). It's still not
	required for mod-only items and moves.

- `num` is no longer allowed for PureEffects (in `statuses.ts`) where
  it's always been meaningless.

- `color` and `heightm`, being completely flavor, are still not
  required for `pokedex.ts` in mods. They're still required in the base
	pokedex.
2020-04-30 21:39:29 -07:00
Guangcong Luo
549ef7edb1 Fix MoveData interface definition
For historical reasons, move property definitions have been very blurry
across `EffectData`. Fortunately, recent refactors have made it
possible to put them all where they're supposed to be.
2020-04-25 12:57:46 -07:00
Guangcong Luo
31a81a91a2 Fix @type in .ts files
Some JSDoc type assertions failed to get converted during various .ts
refactors. This commit takes care of them.
2020-04-24 14:19:08 -07:00
Marty-D
e03d6e9020
Gen III: Remove obsolete code 2020-04-24 15:03:04 -04:00
Kris Johnson
28bf388b98
Typescript data (#6553) 2020-04-23 09:16:09 -07:00
Guangcong Luo
6884c7ee81 Remove unnecessarily quoted keys in data/
(By pulling this out from the rest of the TypeScript refactor, this
should make the diffs for the TypeScript refactor more readable.)
2020-04-16 01:32:18 -07:00
urkerab
d32aa6f8d6
Properly override onFractionalPriority in past gens (#6542) 2020-04-08 15:31:39 -07:00
The Immortal
9db0c00375 Use double quotes 2020-04-06 00:09:07 +04:00
The Immortal
387dd7ce2d Refactor unavailable items
Items that are not available in-game are now consolidated into `isNonstandard`. 'Past' indicates that the item no longer works in the current generation. 'Unobtainable' indicates that the item works but can only be obtained through hacking.

Credit to @lusamine for testing many of these items in Sw/Sh.
2020-04-05 23:54:57 +04:00
The Immortal
659a878e5d Random Battle updates 2020-03-27 22:58:10 +04:00
Kris Johnson
ea1b028950
Rename cosmeticFormeName to forme (#6492) 2020-03-26 18:13:31 +04:00
Kris Johnson
994fc60aed
Rename Template to Species (#6478) 2020-03-25 23:29:27 -07:00
The Immortal
d7348167a9 Formats-Data: Do not inherit in older gens
It was used to inherit `eventPokemon` so as to not have duplicated data. Event data is now in Learnsets so this inheriting is unneeded.
2020-03-19 16:59:11 +04:00
The Immortal
51ccfd844d Fix Arceus items in past gens 2020-03-18 22:30:55 +04:00
The Immortal
bbb4da0131 Refactor forme data 2020-03-18 15:17:55 +04:00
Kris Johnson
3e26318758
Refactor learnsets.js (#6466) 2020-03-18 00:59:29 -07:00
The Immortal
ffc88e833f Random Battle: Improve error handling 2020-03-17 14:23:38 +04:00
Kris Johnson
83ebdb27da
Add Dex#getOutOfBattleSpecies (#6463) 2020-03-16 20:31:38 +04:00
The Immortal
a61d7080e3 Fix usage of inheritsFrom 2020-03-10 21:31:06 +04:00
Guangcong Luo
64ff1da81f Refactor more things to use inheritsFrom 2020-03-10 09:59:36 -07:00
Kris Johnson
03f2378d8c
Correct validation for UU NFE Clause/Little Cup (#6395) 2020-02-24 21:19:17 -08:00
Guangcong Luo
72976d1001 Fix Gen 3 Quick Claw 2020-02-24 19:27:50 -08:00
The Immortal
bd262b726c Fix ADV UU NFE Clause 2020-02-23 22:25:35 +04:00
Kris Johnson
fd63ee2a3b
Add ADV UU NFE Clause (#6386) 2020-02-23 00:15:35 -08:00
Guangcong Luo
652c7163cf
Refactor queue to new BattleQueue class (#6358)
Previously, battle queue stuff was just strewn around `battle.ts`.
This gives it a new home: `battle-queue.ts`.

This was intended to make `battle.ts` slightly more tractable, although
the difference is so small that maybe I shouldn't bother. Oh, well,
every little bit helps.
2020-02-12 16:20:17 -08:00
Guangcong Luo
55cbc52bba Fix bugs with secondary/ability order
Fixes #6346

The `AfterDamage` event has been replaced with `DamagingHit`, which
which happens for damaging moves after secondaries.

The `AfterHit` event has also been moved after `DamagingHit`, to make
sure Knock Off still procs after Rocky Helmet.

`AfterHit` is no longer a valid event on `secondary` and `self` blocks,
because it's meaningless in those blocks, anyway. All `self.onAfterHit`
and `secondary.onAfterHit` handlers have been moved to `onHit`, which
should have the same timing in practice.
2020-02-08 08:07:39 -08:00
urkerab
d1a66cbe07 Simplify handling of Encore volatile (#6292) 2020-01-20 17:00:37 +04:00
urkerab
351089c3d9 Always use getAbility to get a Pokémon's Ability (#6293) 2020-01-18 19:37:01 -07:00
Guangcong Luo
b48733cb7a Rename resolveTarget -> getRandomTarget
Should be much clearer in terms of what it's actually doing.
2020-01-18 15:43:34 -07:00
Guangcong Luo
138fccbaa8 Consolidate more rules into Standard
- `Obtainable` and `Team Preview` are now part of `Standard`

- `minSourceGen: 8` is now a part of `-Unreleased` (which is part of
  `Obtainable`) in Gen 8. Instead, it's NatDex that overrides it with
	`minSourceGen: 1`. This allows `!Standard, Standard NatDex` and
	`!Standard NatDex, Standard` to work as intended.

- Duplicate rules are now checked for (does not apply to subrules, so
  multiple inheritance is still possible)

- It is now possible to inherit `minSourceGen` from rules.
2020-01-03 23:42:48 -05:00
Kris Johnson
59154fadad Rename Vice Grip to Vise Grip (#6240) 2019-12-31 13:56:41 +09:00
Guangcong Luo
9b943fb62f Fix Dynamax stat handling
We now track `baseMaxhp`, the pre-Dynamax max HP. We also have a new
function `getUndynamaxedHP` for use by moves that use it (famously,
Endeavor).

- `baseStoredStats` is unused outside of the mouseover stats display.
  I updated its implementation to reflect this.

- Power Construct doesn't have a defined behavior during Dynamax. I
  ended up implementing an approximation of what it should probably do.

- Endeavor, Pain Split, Super Fang, and Nature's Madness now work on
  undynamaxed HP.

- Moves that deal or heal percentage damage now do it based on
  undynamaxed max HP, other than G-Max Finale.

Fixes #6131

Fixes #6087
2019-12-04 09:25:46 +09:00
The Immortal
36b0e6e6a5 Random Battle improvements 2019-11-27 01:57:43 +04:00
The Immortal
a0e94eb2ca RandomTeams mods: Shorten path 2019-11-15 19:50:17 +04:00
Marty-D
ea5d9d70dd Gen III-IV: Correct Intimidate boost attribution 2019-10-30 19:36:03 -04:00
urkerab
bae434e606 Add a single event for a move's own immunity to a specific target (#5904) 2019-10-24 11:00:28 +10:30
urkerab
5b9d0c8db6 Centralise invulnerability checks for No Guard and Lock-On (#5894) 2019-10-17 22:32:44 -04:00
urkerab
3bfec7bf2f Rename TryImmunity to Invulnerability (#5877)
It's a check for semi-invulnerability rather than any sort of immunity.
2019-10-16 20:12:12 -04:00
Guangcong Luo
7a023746ba
Refactor battle.dex out of battle (#5851)
In most other similar systems, like TeamValidator, we use `thing.dex` instead of having it extend `ModdedDex`. Battle has always extended `ModdedDex`, though. This changes Battle to match the others.

This should fix an issue with `Battle.data` not being cached.

This also frees up Battle to extend ObjectReadWriteStream<string> in a future update.
2019-10-06 07:38:08 +11:00
Guangcong Luo
71498d451d
New validator (#5840)
* Refactor validator

This is a major refactor intended to make the default rules easier to
understand, and also easier for OMs to bypass.

Removed rules:
- `Pokemon`: This is now `-Nonexistent`. Its previous name was intended
  to be interpreted as "simulate the Pokémon games exactly, and only
  allow what they allow". The new name should make it clearer that it
  mainly bans CAPs and other nonexistent Pokémon and functionality.
- `-Illegal`: This is now `Obtainable` (see below).
- `Allow CAP`: This is now `+CAP`. Instead of having a hardcoded rule,
  OMs can now be manually whitelist any pokemon/item/etc or group of
  them, overriding `-Nonexistent`.
- `Ignore Illegal Abilities`: This is now `!Obtainable Abilities` (see
  below).

`Obtainable` was previously `-Illegal`, and does the same thing: Makes
sure you have a regular Pokémon game with only Pokémon that can be
obtained without hacking.

But instead of being a ban, it's now a rule that does nothing by
itself, except contain more rules:
- `Obtainable Moves`
- `Obtainable Abilities`
- `Obtainable Formes`
- `Obtainable Misc`
- `-Nonexistent`
- `-Unreleased`

This allows OMs to piecemeal repeal and unban any of these individual
rules, instead of the previous approach of unbanning them all and
manually reimplementing every single validation you wanted to keep.

* Refactor PokemonSources into a class

This mostly just makes a lot of the weirder checks in the validator
substantially more readable.

This also renames `lsetData` to `setSources`, which should also help
readability.

* Validate Bottle Cap HP types

Fixes an issue reported here:

https://github.com/Zarel/Pokemon-Showdown/issues/5742#issuecomment-533850288

* Fix several move validation issues

Fixes #5742

We have a new MoveSource type: R for Restricted. R moves work like
level-up/tutor/TM moves, except you're limited to one R move.

- Shedinja move stolen from Ninjask in Gen 3-4 are now R moves instead
  of event moves. This allows them to coexist with Nincada egg moves.

- Necrozma-DW/DM now inherit moves/events from Necrozma (like Rotom,
  but with event validation). This allows them to be shiny.

- Pokemon can now get egg moves from their own evolutions. This fixes
  some Tyrogue, Charmander, and Treecko sets mentioned in #5742

- Some more C moves were added, fixing some Hitmontop and Chatot sets
  mentioned in #5742

* Improve ability/move compatibility validator
2019-10-06 04:21:30 +11:00
The Immortal
f005a5bfcf Random Battle updates 2019-09-25 17:14:39 +04:00
TheTiksiBranch
5550ef5155 Gen 3 Random Battle: Minor Move Generation Improvements (#5788)
* Gen 3 Random Battle: Minor Move Generation Improvements

* fix typo

* fix duplicate case
2019-09-17 17:50:34 +04:00
TheTiksiBranch
5451887047 Gen 3 Random Battle: Improve Movesets (#5787)
* Gen 3 Random Battle: Improve Movesets

* Revert removing Shadow Ball from Gengar
2019-09-17 17:49:39 +04:00
Guangcong Luo
0fdaeea3db Fix spread move messages
In certain cases, a spread move that KOed an opponent would send an
incorrect message which could crash the client. This fixes that while
also simplifying the code.
2019-08-28 20:47:15 -05:00
Marty-D
4c1ee02de6
Gen 3 OU: Move Moltres to OU and Raikou to UUBL
https://www.smogon.com/forums/threads/adv-tier-changes-moltres-raikou.3652636/
2019-07-18 19:27:36 -04:00
Guangcong Luo
413bf26d0d Correct .tier/.isNonstandard for future gens
Fixes #5243
2019-07-09 06:31:42 -05:00
Guangcong Luo
01804f988e Fix spread hit animation
Properly fixes https://github.com/Zarel/Pokemon-Showdown-Client/pull/1267
2019-05-16 12:52:13 +04:00
Kirk Scheibelhut
29430984f6 Only add the '-status slp' message in statuses (#5486) 2019-05-08 11:52:44 -04:00
Kirk Scheibelhut
a0734bde6f Redo Endless Battle Clause with a new specification (#5472) 2019-05-07 11:18:06 +09:30
Kirk Scheibelhut
10c744f733 Introduce an ID type to sim (#5468) 2019-05-04 13:13:12 +12:00
Kirk Scheibelhut
e632bd1991 Fixes crash in gen3doubles due to missing target (#5465)
Fixes #5654
2019-04-26 19:47:38 -04:00
Kirk Scheibelhut
7e4929a39f Change protocol for '|split' message type (#5331) (#5332) 2019-04-22 09:20:47 +09:30
Marty-D
9428d274cc Gen III: Improve Truant implementation 2019-04-17 16:36:25 -04:00
Marty-D
9b28525f4e Gen III: Correct Truant mechanics 2019-04-15 17:15:51 -04:00
Guangcong Luo
a33fc11d26 Refactor Actions, RandomTeamsTypes to namespace
They were previously some weird interface where their actual types
were properties. I guess whoever wrote this was unaware that TypeScript
namespaces were designed for this exact use-case.
2019-04-10 19:58:56 +09:30
Kevin Lau
cd9694cd20 Random Battle Gen 3: Update ability selection (#5402)
This updates the gen to use the ability selection algorithm from future
gens, where it defaults to the highest rated ability if all are rejected.
2019-04-04 15:50:17 +04:00
Slayer95
694cd47e7b Fix target resolution (#5363) 2019-03-30 22:34:44 +08:00
Slayer95
628f32e8fb Stricter type definitions for dex data (#5375)
BattleStatuses switched to PureEffectData
2019-03-30 22:31:04 +08:00