@pkmn/engine 0.1.0-dev.1220fbc5 → 0.1.0-dev.12e7292c
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -5
- package/build/pkg/protocol.js +1 -1
- package/build/pkg/protocol.js.map +1 -1
- package/build/tools/debug.js +3 -1
- package/build/tools/debug.js.map +1 -1
- package/package.json +14 -13
- package/src/lib/common/protocol.zig +335 -333
- package/src/lib/common/rational.zig +1 -1
- package/src/lib/gen1/mechanics.zig +197 -201
- package/src/lib/gen2/README.md +0 -1
- package/src/lib/gen2/data.zig +1 -1
- package/src/lib/gen2/generated.zig +14 -21
- package/src/lib/gen2/mechanics.zig +660 -383
package/src/lib/gen2/README.md
CHANGED
|
@@ -49,7 +49,6 @@ The following information is required to simulate a Generation II Pokémon battl
|
|
|
49
49
|
| `volatiles.bind` | `PlayerWrapCount` | `volatiles.partiallytrapped.duration` |
|
|
50
50
|
| `volatiles.bind_reason` | `PlayerTrappingMove` | `volatiles.effectState.sourceEffect` |
|
|
51
51
|
| | `PlayerCharging` | |
|
|
52
|
-
| `volatiles.trapped FIXME` | `FIXME` | `pokemon.trapped` |
|
|
53
52
|
| `volatiles.switched` | `TODO` | `pokemon.switchFlag` |
|
|
54
53
|
| `volatiles.switching` | `PlayerIsSwitching` | `pokemon.switchFlag` |
|
|
55
54
|
| `volatiles.frozen` | `PlayerJustGotFrozen` | `volatiles.frozen` |
|
package/src/lib/gen2/data.zig
CHANGED
|
@@ -314,8 +314,8 @@ pub const Volatiles = packed struct(u128) {
|
|
|
314
314
|
Encore: bool = false,
|
|
315
315
|
LockOn: bool = false,
|
|
316
316
|
DestinyBond: bool = false,
|
|
317
|
+
Trapped: bool = false,
|
|
317
318
|
|
|
318
|
-
trapped: bool = false,
|
|
319
319
|
switched: bool = false,
|
|
320
320
|
// TODO: replace with simply looking at Choice on Battle
|
|
321
321
|
switching: bool = false,
|
|
@@ -175,7 +175,7 @@ pub fn runMove(battle: anytype, player: Player, state: *State, options: anytype)
|
|
|
175
175
|
if (!skip_pp) _ = decrementPP(side, state.move, state.mslot); // TODO if no pp return
|
|
176
176
|
// TODO rampage
|
|
177
177
|
// usedmovetext
|
|
178
|
-
try log.move(ident, state.move, foe_ident); // FIXME self? from?
|
|
178
|
+
try log.move(.{ ident, state.move, foe_ident }); // FIXME self? from?
|
|
179
179
|
try checkHit(battle, player, state, options);
|
|
180
180
|
try checkCriticalHit(battle, player, state, options);
|
|
181
181
|
try calcDamage(battle, player, state, options);
|
|
@@ -260,7 +260,7 @@ pub fn runMove(battle: anytype, player: Player, state: *State, options: anytype)
|
|
|
260
260
|
try Effects.hyperBeam(battle, player, state, options);
|
|
261
261
|
_ = try afterMove(!KINGS, battle, player, state, options);
|
|
262
262
|
},
|
|
263
|
-
.Counter => {
|
|
263
|
+
.MirrorCoat, .Counter => {
|
|
264
264
|
if (!try canMove(battle, player, state, options)) return;
|
|
265
265
|
try Effects.counter(battle, player, state, options);
|
|
266
266
|
try applyDamage(battle, player, state, options);
|
|
@@ -344,13 +344,17 @@ pub fn runMove(battle: anytype, player: Player, state: *State, options: anytype)
|
|
|
344
344
|
if (!try canMove(battle, player, state, options)) return;
|
|
345
345
|
try Effects.heal(battle, player, state, options);
|
|
346
346
|
},
|
|
347
|
+
.LightScreen => {
|
|
348
|
+
if (!try canMove(battle, player, state, options)) return;
|
|
349
|
+
try Effects.lightScreen(battle, player, state, options);
|
|
350
|
+
},
|
|
347
351
|
.Haze => {
|
|
348
352
|
if (!try canMove(battle, player, state, options)) return;
|
|
349
353
|
try Effects.haze(battle, player, state, options);
|
|
350
354
|
},
|
|
351
|
-
.
|
|
355
|
+
.Reflect => {
|
|
352
356
|
if (!try canMove(battle, player, state, options)) return;
|
|
353
|
-
try Effects.
|
|
357
|
+
try Effects.reflect(battle, player, state, options);
|
|
354
358
|
},
|
|
355
359
|
.FocusEnergy => {
|
|
356
360
|
if (!try canMove(battle, player, state, options)) return;
|
|
@@ -364,7 +368,7 @@ pub fn runMove(battle: anytype, player: Player, state: *State, options: anytype)
|
|
|
364
368
|
(volatiles.BeatUp or volatiles.Thrashing or volatiles.Bide);
|
|
365
369
|
if (!skip_pp) _ = decrementPP(side, state.move, state.mslot); // TODO if no pp return
|
|
366
370
|
// usedmovetext
|
|
367
|
-
try log.move(ident, state.move, foe_ident); // FIXME self? from?
|
|
371
|
+
try log.move(.{ ident, state.move, foe_ident }); // FIXME self? from?
|
|
368
372
|
try Effects.bide.unleash(battle, player, state, options);
|
|
369
373
|
|
|
370
374
|
if (state.immune()) {
|
|
@@ -544,19 +548,19 @@ pub fn runMove(battle: anytype, player: Player, state: *State, options: anytype)
|
|
|
544
548
|
try Effects.sandstorm(battle, player, state, options);
|
|
545
549
|
},
|
|
546
550
|
.Rollout => {
|
|
547
|
-
|
|
551
|
+
try Effects.rollout.check(battle, player, state, options);
|
|
548
552
|
// doturn
|
|
549
553
|
const charging = false; // TODO
|
|
550
554
|
const skip_pp = charging or state.move == .Struggle or
|
|
551
555
|
(volatiles.BeatUp or volatiles.Thrashing or volatiles.Bide);
|
|
552
556
|
if (!skip_pp) _ = decrementPP(side, state.move, state.mslot); // TODO if no pp return
|
|
553
557
|
// usedmovetext
|
|
554
|
-
try log.move(ident, state.move, foe_ident); // FIXME self? from?
|
|
558
|
+
try log.move(.{ ident, state.move, foe_ident }); // FIXME self? from?
|
|
555
559
|
try checkCriticalHit(battle, player, state, options);
|
|
556
560
|
try calcDamage(battle, player, state, options);
|
|
557
561
|
try adjustDamage(battle, player, state, options);
|
|
558
562
|
try checkHit(battle, player, state, options);
|
|
559
|
-
|
|
563
|
+
try Effects.rollout.power(battle, player, state, options);
|
|
560
564
|
try randomizeDamage(battle, player, state, options);
|
|
561
565
|
try applyDamage(battle, player, state, options);
|
|
562
566
|
try reportOutcome(battle, player, state, options);
|
|
@@ -577,12 +581,7 @@ pub fn runMove(battle: anytype, player: Player, state: *State, options: anytype)
|
|
|
577
581
|
.Swagger => {
|
|
578
582
|
if (!try canMove(battle, player, state, options)) return;
|
|
579
583
|
try checkHit(battle, player, state, options);
|
|
580
|
-
|
|
581
|
-
// TODO attackup2
|
|
582
|
-
// TODO switchturn
|
|
583
|
-
// TODO failuretext
|
|
584
|
-
// TODO switchturn
|
|
585
|
-
// TODO switchturn
|
|
584
|
+
try Effects.boost(battle, player.foe(), state, options);
|
|
586
585
|
try Effects.confusionChance(battle, player, state, options);
|
|
587
586
|
},
|
|
588
587
|
.FuryCutter => {
|
|
@@ -656,7 +655,7 @@ pub fn runMove(battle: anytype, player: Player, state: *State, options: anytype)
|
|
|
656
655
|
.Magnitude => {
|
|
657
656
|
if (!try canMove(battle, player, state, options)) return;
|
|
658
657
|
try checkCriticalHit(battle, player, state, options);
|
|
659
|
-
|
|
658
|
+
try Effects.magnitude(battle, player, state, options);
|
|
660
659
|
try calcDamage(battle, player, state, options);
|
|
661
660
|
try adjustDamage(battle, player, state, options);
|
|
662
661
|
try randomizeDamage(battle, player, state, options);
|
|
@@ -731,12 +730,6 @@ pub fn runMove(battle: anytype, player: Player, state: *State, options: anytype)
|
|
|
731
730
|
if (!try canMove(battle, player, state, options)) return;
|
|
732
731
|
try Effects.sunnyDay(battle, player, state, options);
|
|
733
732
|
},
|
|
734
|
-
.MirrorCoat => {
|
|
735
|
-
if (!try canMove(battle, player, state, options)) return;
|
|
736
|
-
try Effects.mirrorCoat(battle, player, state, options);
|
|
737
|
-
try applyDamage(battle, player, state, options);
|
|
738
|
-
_ = try afterMove(KINGS, battle, player, state, options);
|
|
739
|
-
},
|
|
740
733
|
.PsychUp => {
|
|
741
734
|
if (!try canMove(battle, player, state, options)) return;
|
|
742
735
|
try Effects.psychUp(battle, player, state, options);
|