Commit Graph

28 Commits

Author SHA1 Message Date
Karthik
e218cb9dbb
Properly implement Chloroblast recoil (#9648) 2023-07-15 14:54:49 -05:00
Kris Johnson
d50c8c249b
Add Gen 9 (#8997) 2022-11-17 20:46:29 -05:00
Karthik
42333b392b
Fix self-KO timing for Memento/Healing Wish/Lunar Dance (#8750) 2022-05-04 17:32:37 -04:00
Karthik
e9c8a1ce3f
Improve check for Sky Drop preventing Mega Evolution (#8680) 2022-03-03 21:55:33 -06:00
Annika
99fffe2e4b Remove unnecessary code
Found these thanks to LGTM.com
2022-03-02 20:02:29 -08:00
EvGym
5d8117302c
Refactor overriding stats used for damaging moves (#8373) 2021-11-08 13:48:26 -08:00
Guangcong Luo
d0ea290992 Rename pokemon to source in getDamage
This has been split off from #8373 to improve diff readability.
2021-11-02 18:05:53 -04:00
pacmanboss256
4186ef5f4f
Refactor Mold Breaker effect (#8291) 2021-05-14 08:32:41 -04:00
Guangcong Luo
f9fdc73133
Support per-pokemon Residual handlers in Side/Field conditions (#8222)
For side conditions, `onStart`/`onRestart`/`onResidual`/`onEnd`
have been renamed `onSideStart`/`onSideRestart`/`onSideResidual`/`onSideEnd`,
with the `onResidualOrder` properties renamed `onSideResidualOrder`.

For field conditions, `onStart`/`onRestart`/`onResidual`/`onEnd`
have been renamed `onFieldStart`/`onFieldRestart`/`onFieldResidual`/`onFieldEnd`,
with the `onResidualOrder` properties renamed `onFieldResidualOrder`.

(The `onField` and `onSide` part helps make it clear to the type system
that the first argument is a Field or Side, not a Pokemon.)

Side and field conditions can now use `onResidual` to tick separately
on each pokemon in Speed order. `onResidualOrder` (the per-pokemon
tick) can be timed separate from `onSideResidualOrder` (the
per-condition tick), allowing conditions to end at a different priority
than they tick per-pokemon.

Relatedly, `onTeamPreview` and `onStart` in formats now need to be
`onFieldTeamPreview` and `onFieldStart`.

Unrelatedly, `effectData` has been renamed `effectState`, and the
corresponding state containers (`pokemon.statusData`,
`pokemon.speciesData`, `pokemon.itemData`, `pokemon.abilityData`,
`field.weatherData`, `field.terrainData`) have been similarly renamed. I
renamed the types a while ago, but I was holding off renaming the fields
because it would be a breaking change. But this is a breaking change
anyway, so we might as well do it now.

Note: `onResidual` will tick even on `onSideEnd` turns, although
`onSideResidual` won't. When refactoring weather, remember to
check `this.state.duration` so you don't deal weather damage on the
ending turn.

Intended as a better fix for #8216
2021-04-25 10:55:54 -07:00
Guangcong Luo
13189fdb02
Update Dex API (#8181)
This is the change that renames:

- `Dex.getMove` -> `Dex.moves.get`
- `Dex.getAbility` -> `Dex.abilities.get`
- `Dex.getItem` -> `Dex.items.get`
- `Dex.getSpecies` -> `Dex.species.get`
- `Dex.getEffect` -> `Dex.conditions.get`
- `Dex.getNature` -> `Dex.natures.get`
- `Dex.getType` -> `Dex.types.get`
- `Dex.getFormat` -> `Dex.formats.get`

In addition, some other APIs have been updated:

- `getByID` methods have also been added to every other table.
- `Dex.moves.all()` now gets an array of all moves
  - Plus equivalent methods for `abilities`, `items`, `species`, `formats`, `natures`, `types`
  - Note: there's no `Dex.conditions.all()`
- new API: `Dex.stats` for naming/iterating stats
- `Dex.getEffectByID` -> `Dex.conditions.getByID`
- `Dex.getType` -> `Dex.types.get`
- `Dex.data.Formats` -> `Dex.data.Rulesets`
- `Dex.formats` -> now an array `Dex.formats.all()`
- `Dex.getRuleTable` -> `Dex.formats.getRuleTable`
- `Dex.validateFormat` -> `Dex.formats.validate`

Team functions have been split off into a new `sim/teams` package:

- `Dex.packTeam` -> `Teams.pack`
- `Dex.fastUnpackTeam` -> `Teams.unpack`
- `Dex.generateTeam` -> `Teams.generate`
- `Dex.stringifyTeam` -> `Teams.export`

`Teams.export` has also been rewritten to better match how it works in client.

This implements #8178
2021-04-08 03:00:37 -07:00
Guangcong Luo
3b5e8cbfc2
Refactor for multi battles (#8152) 2021-03-31 20:27:07 -07:00
Guangcong Luo
d18c0a4e1f Refactor more things to use pokemon.allies/foes
(This will make multi battles easier to implement.)
2021-03-28 20:06:18 -07:00
Guangcong Luo
ed454ef76a
Refactor scripts to battle-actions (#8138)
This introduces a new class, BattleActions, available as `battle.actions`,
moving all functions from `data/scripts.ts` to `sim/battle-actions.ts`.

This makes it so that "go to definition" will now work correctly for
functions previously in scripts; we no longer need UnimplementedError,
and there's now a clean conceptual separation between `battle` and
`battle-actions` (whereas the previous distinction between `battle` and
`scripts` was basically nonexistent).

This will be a difficult migration if you maintain a fork with custom
scripted mods. I'm sorry! Migration instructions are here:

https://github.com/smogon/pokemon-showdown/pull/8138
2021-03-28 12:01:38 -07:00
Annika
c2e97aaaed
Use optional chaining in more places (#8063) 2021-02-22 11:42:05 -08:00
Instruct
ae34b97c87
SSB: Change set generation to rely on weaknesses against types (#8032) 2021-02-14 16:32:46 -08:00
Instruct
0685e88e4f
SSB4: Balance changes and Bugfixes, pt 2 (#7954) 2021-01-30 23:34:41 +04:00
Instruct
0d1c9fe098
SSB4: Bugfixes and Balance Patches (#7889) 2021-01-22 14:56:26 +04:00
Instruct
1f9954b374
SSB4: Bug & crashfixes (#7837) 2020-12-24 21:51:11 -05:00
Instruct
5b441c2013
Super Staff Bros 4 (#7793)
Collaborative Project lead by @xInstruct with many contributors.

See the Special Thanks section of https://www.smogon.com/articles/super-staff-bros-4
2020-12-24 11:21:02 -05:00
Kris Johnson
8656d633ac
Format volatiles consistently (#7314) 2020-09-05 08:12:24 -07:00
Mia
deeed6c789
Remove sim/ and data/'s globals (#7091) 2020-08-07 06:44:15 -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
Mia
6839a1f4db
Add a library for utility functions (#6817) 2020-06-09 22:06:43 -07:00
Kirk Scheibelhut
2af7040270
Group zMove and maxMove attributes (#6652)
This mostly serves to provide cleaner and more consistent field
naming. maxMove currently doesn't have boosts or effects to group
together but who knows what will be thrown at us via DLC, and being
symmetrical with zMoves is a nice.
2020-05-04 20:21:27 -07:00
Guangcong Luo
800d8bd8f3 Remove Dex.getForme etc
The server now uses the same approach as the client of treating
cosmetic formes as real formes, as documented in `FORMES.md`.

This eliminates the need for the `.forme` and `.speciesid` properties
of `Pokemon`.

`pokemon.id` has also been removed: useful, since it turns out half
of its uses were bugs that should have used `pokemon.species.id`.
2020-04-28 17:38:54 -07:00
Guangcong Luo
c5faebd739 Remove extraneous properties from BasicEffect
BasicEffect always had a `status` property to support the pattern of
testing it to see if it's a move that sets status directly.

This is just a situation that TypeScript is bad at.

Another possibility would be to set `status: undefined` on PureEffect,
Ability, Item, and Species, but I think that's also ugly. Casting to
Move is probably the best approach, so that's what we do now.
2020-04-25 12:57:46 -07:00
Guangcong Luo
5d63b16d4d Fix botched merge in data/.ts refactor
The data/.ts refactor left a few .js files in, which weren't deleted
between 13 and 3 days ago:

c85f5bccb0

Because of this, the corresponding `.ts` files were considered new,
rather than renamed, and changes to the `.js` files got deleted rather
than merged.

Fortunately, this only affected `moves.js`, which has now been manually
re-merged with the changes.
2020-04-23 11:22:21 -07:00
Kris Johnson
28bf388b98
Typescript data (#6553) 2020-04-23 09:16:09 -07:00