@pkmn/engine 0.1.0-dev.bcb16a6c → 0.1.0-dev.be951af1
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/build/pkg/data/layout.json +2 -2
- package/build/pkg/gen1.js +2 -2
- package/build/pkg/gen1.js.map +1 -1
- package/package.json +17 -14
- package/src/lib/common/optional.zig +4 -6
- package/src/lib/common/protocol.zig +46 -19
- package/src/lib/gen1/README.md +28 -28
- package/src/lib/gen1/chance.zig +43 -41
- package/src/lib/gen1/data/moves.zig +14 -0
- package/src/lib/gen1/data.zig +6 -6
- package/src/lib/gen1/helpers.zig +1 -16
- package/src/lib/gen1/mechanics.zig +61 -94
- package/src/lib/gen2/README.md +1 -1
- package/src/lib/gen2/calc.zig +143 -0
- package/src/lib/gen2/chance.zig +1314 -0
- package/src/lib/gen2/data/moves.zig +27 -10
- package/src/lib/gen2/data/types.zig +3 -2
- package/src/lib/gen2/data.zig +11 -5
- package/src/lib/gen2/generated.zig +1239 -0
- package/src/lib/gen2/mechanics.zig +1712 -329
|
@@ -288,6 +288,8 @@ pub const Move = enum(u8) {
|
|
|
288
288
|
const Extra = packed struct(u8) {
|
|
289
289
|
/// Whether this move can be called via Metronome.
|
|
290
290
|
metronome: bool = true,
|
|
291
|
+
/// Whether this move can be called via Sleep Talk.
|
|
292
|
+
sleep_talk: bool = true,
|
|
291
293
|
/// Whether this move is considered to be "continuous".
|
|
292
294
|
continuous: bool = false,
|
|
293
295
|
/// Whether this move can hit a flying target.
|
|
@@ -295,7 +297,7 @@ pub const Move = enum(u8) {
|
|
|
295
297
|
/// Whether this move can hit an underground target.
|
|
296
298
|
underground: bool = false,
|
|
297
299
|
/// Protocol reason offset associated with this move.
|
|
298
|
-
protocol:
|
|
300
|
+
protocol: u3 = 0,
|
|
299
301
|
};
|
|
300
302
|
|
|
301
303
|
comptime {
|
|
@@ -410,7 +412,7 @@ pub const Move = enum(u8) {
|
|
|
410
412
|
.type = .Normal,
|
|
411
413
|
.accuracy = percent(75),
|
|
412
414
|
.target = .Foes,
|
|
413
|
-
.extra = .{ .continuous = true },
|
|
415
|
+
.extra = .{ .sleep_talk = false, .continuous = true },
|
|
414
416
|
},
|
|
415
417
|
// SwordsDance
|
|
416
418
|
.{
|
|
@@ -457,12 +459,12 @@ pub const Move = enum(u8) {
|
|
|
457
459
|
},
|
|
458
460
|
// Fly
|
|
459
461
|
.{
|
|
460
|
-
.effect = .
|
|
462
|
+
.effect = .FlyDig,
|
|
461
463
|
.bp = 70,
|
|
462
464
|
.type = .Flying,
|
|
463
465
|
.accuracy = percent(95),
|
|
464
466
|
.target = .Any,
|
|
465
|
-
.extra = .{ .continuous = true },
|
|
467
|
+
.extra = .{ .sleep_talk = false, .continuous = true },
|
|
466
468
|
},
|
|
467
469
|
// Bind
|
|
468
470
|
.{
|
|
@@ -941,7 +943,7 @@ pub const Move = enum(u8) {
|
|
|
941
943
|
.type = .Grass,
|
|
942
944
|
.accuracy = percent(100),
|
|
943
945
|
.target = .Other,
|
|
944
|
-
.extra = .{ .continuous = true },
|
|
946
|
+
.extra = .{ .sleep_talk = false, .continuous = true },
|
|
945
947
|
},
|
|
946
948
|
// PoisonPowder
|
|
947
949
|
.{
|
|
@@ -1065,11 +1067,12 @@ pub const Move = enum(u8) {
|
|
|
1065
1067
|
},
|
|
1066
1068
|
// Dig
|
|
1067
1069
|
.{
|
|
1068
|
-
.effect = .
|
|
1070
|
+
.effect = .FlyDig,
|
|
1069
1071
|
.bp = 60,
|
|
1070
1072
|
.type = .Ground,
|
|
1071
1073
|
.accuracy = percent(100),
|
|
1072
1074
|
.target = .Other,
|
|
1075
|
+
.extra = .{ .sleep_talk = false },
|
|
1073
1076
|
},
|
|
1074
1077
|
// Toxic
|
|
1075
1078
|
.{
|
|
@@ -1282,7 +1285,7 @@ pub const Move = enum(u8) {
|
|
|
1282
1285
|
.type = .Normal,
|
|
1283
1286
|
.accuracy = percent(100),
|
|
1284
1287
|
.target = .Self,
|
|
1285
|
-
.extra = .{ .continuous = true },
|
|
1288
|
+
.extra = .{ .sleep_talk = false, .continuous = true },
|
|
1286
1289
|
},
|
|
1287
1290
|
// Metronome
|
|
1288
1291
|
.{
|
|
@@ -1394,7 +1397,7 @@ pub const Move = enum(u8) {
|
|
|
1394
1397
|
.type = .Normal,
|
|
1395
1398
|
.accuracy = percent(100),
|
|
1396
1399
|
.target = .Other,
|
|
1397
|
-
.extra = .{ .continuous = true },
|
|
1400
|
+
.extra = .{ .sleep_talk = false, .continuous = true },
|
|
1398
1401
|
},
|
|
1399
1402
|
// SpikeCannon
|
|
1400
1403
|
.{
|
|
@@ -1500,7 +1503,7 @@ pub const Move = enum(u8) {
|
|
|
1500
1503
|
.type = .Flying,
|
|
1501
1504
|
.accuracy = percent(90),
|
|
1502
1505
|
.target = .Any,
|
|
1503
|
-
.extra = .{ .continuous = true },
|
|
1506
|
+
.extra = .{ .sleep_talk = false, .continuous = true },
|
|
1504
1507
|
},
|
|
1505
1508
|
// Transform
|
|
1506
1509
|
.{
|
|
@@ -2463,7 +2466,7 @@ pub const Move = enum(u8) {
|
|
|
2463
2466
|
FixedDamage,
|
|
2464
2467
|
FlameWheel,
|
|
2465
2468
|
FlinchChance,
|
|
2466
|
-
|
|
2469
|
+
FlyDig,
|
|
2467
2470
|
FocusEnergy,
|
|
2468
2471
|
ForceSwitch,
|
|
2469
2472
|
Foresight,
|
|
@@ -2847,6 +2850,20 @@ pub const Move = enum(u8) {
|
|
|
2847
2850
|
/// The number of Pokémon moves in this generation.
|
|
2848
2851
|
pub const size = 251;
|
|
2849
2852
|
|
|
2853
|
+
/// Pokémon moves that can be called by Metronome in this generation.
|
|
2854
|
+
pub const METRONOME = init: {
|
|
2855
|
+
var num = 0;
|
|
2856
|
+
var moves: [239]Move = undefined;
|
|
2857
|
+
for (1..Move.size + 1) |i| {
|
|
2858
|
+
if (Move.get(@enumFromInt(i)).extra.metronome) {
|
|
2859
|
+
moves[num] = @enumFromInt(i);
|
|
2860
|
+
num += 1;
|
|
2861
|
+
}
|
|
2862
|
+
}
|
|
2863
|
+
assert(num == moves.len);
|
|
2864
|
+
break :init moves;
|
|
2865
|
+
};
|
|
2866
|
+
|
|
2850
2867
|
/// Returns the `Data` corresponding to the move.
|
|
2851
2868
|
pub inline fn get(id: Move) Data {
|
|
2852
2869
|
assert(id != .None);
|
|
@@ -219,7 +219,8 @@ pub const Types = extern struct {
|
|
|
219
219
|
}
|
|
220
220
|
|
|
221
221
|
/// Whether this typing is immune to damage from Sandstorm.
|
|
222
|
-
pub inline fn sandstormImmune(self: Types)
|
|
223
|
-
return self.type1 <= @intFromEnum(Type.Steel) or
|
|
222
|
+
pub inline fn sandstormImmune(self: Types) bool {
|
|
223
|
+
return @intFromEnum(self.type1) <= @intFromEnum(Type.Steel) or
|
|
224
|
+
@intFromEnum(self.type2) <= @intFromEnum(Type.Steel);
|
|
224
225
|
}
|
|
225
226
|
};
|
package/src/lib/gen2/data.zig
CHANGED
|
@@ -336,12 +336,13 @@ pub const Volatiles = packed struct(u128) {
|
|
|
336
336
|
dirty: bool = false,
|
|
337
337
|
|
|
338
338
|
frozen: bool = false,
|
|
339
|
-
_:
|
|
339
|
+
_: u11 = 0,
|
|
340
|
+
// TODO?
|
|
341
|
+
transform: u4 = 0,
|
|
340
342
|
|
|
341
|
-
bind_reason: u4 = 0,
|
|
342
|
-
bind: u4 = 0,
|
|
343
343
|
bide: u16 = 0,
|
|
344
|
-
|
|
344
|
+
bind: Bind = .{},
|
|
345
|
+
disable: Disable = .{},
|
|
345
346
|
rage: u8 = 0,
|
|
346
347
|
substitute: u8 = 0,
|
|
347
348
|
toxic: u8 = 0,
|
|
@@ -353,7 +354,12 @@ pub const Volatiles = packed struct(u128) {
|
|
|
353
354
|
protect: u4 = 0,
|
|
354
355
|
attacks: u4 = 0, // bide/thrashing/rollout turns
|
|
355
356
|
|
|
356
|
-
const
|
|
357
|
+
const Bind = packed struct(u8) {
|
|
358
|
+
duration: u4 = 0,
|
|
359
|
+
reason: u4 = 0,
|
|
360
|
+
};
|
|
361
|
+
|
|
362
|
+
const Disable = packed struct(u8) {
|
|
357
363
|
move: u4 = 0,
|
|
358
364
|
duration: u4 = 0,
|
|
359
365
|
};
|