@pkmn/engine 0.1.0-dev.cbdbb719 → 0.1.0-dev.cdc837af
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/addon/browser.d.ts +3 -0
- package/build/pkg/addon/browser.js +44 -0
- package/build/pkg/addon/browser.js.map +1 -0
- package/build/pkg/addon/node.d.ts +3 -0
- package/build/pkg/addon/node.js +97 -0
- package/build/pkg/addon/node.js.map +1 -0
- package/build/pkg/addon/wasm.d.ts +2 -0
- package/build/pkg/addon/wasm.js +21 -0
- package/build/pkg/addon/wasm.js.map +1 -0
- package/build/pkg/addon.d.ts +22 -0
- package/build/pkg/addon.js +29 -51
- package/build/pkg/addon.js.map +1 -1
- package/build/pkg/data.d.ts +23 -1
- package/build/pkg/data.js.map +1 -1
- package/build/pkg/gen1.js +1 -1
- package/build/pkg/gen1.js.map +1 -1
- package/build/pkg/index.d.ts +21 -8
- package/build/pkg/index.js +15 -10
- package/build/pkg/index.js.map +1 -1
- package/build/pkg/protocol.d.ts +20 -1
- package/build/pkg/protocol.js +105 -103
- package/build/pkg/protocol.js.map +1 -1
- package/build/tools/debug.js +35 -68
- package/build/tools/debug.js.map +1 -1
- package/build/tools/display/debug.jsx +141 -0
- package/build/tools/display/debug.jsx.map +1 -0
- package/build/tools/display/index.js +141 -0
- package/build/tools/display/index.js.map +1 -0
- package/build/tools/display/ui.jsx +349 -0
- package/build/tools/display/ui.jsx.map +1 -0
- package/build/tools/display/util.js +18 -0
- package/build/tools/display/util.js.map +1 -0
- package/build.zig +89 -70
- package/package.json +49 -32
- package/src/bin/install-pkmn-engine +4 -2
- package/src/bin/pkmn-debug +1 -1
- package/src/lib/common/debug.zig +39 -8
- package/src/lib/common/options.zig +2 -0
- package/src/lib/common/protocol.zig +4 -8
- package/src/lib/common/rational.zig +7 -5
- package/src/lib/common/rng.zig +1 -3
- package/src/lib/gen1/calc.zig +200 -53
- package/src/lib/gen1/chance.zig +40 -22
- package/src/lib/gen1/data/moves.zig +2 -4
- package/src/lib/gen1/data/species.zig +1 -3
- package/src/lib/gen1/data/types.zig +1 -2
- package/src/lib/gen1/data.zig +9 -13
- package/src/lib/gen1/helpers.zig +5 -21
- package/src/lib/gen1/mechanics.zig +55 -61
- package/src/lib/gen2/calc.zig +10 -18
- package/src/lib/gen2/chance.zig +8 -13
- package/src/lib/gen2/data/items.zig +1 -3
- package/src/lib/gen2/data/moves.zig +2 -4
- package/src/lib/gen2/data/species.zig +1 -3
- package/src/lib/gen2/data/types.zig +1 -2
- package/src/lib/gen2/data.zig +11 -15
- package/src/lib/gen2/generated.zig +18 -23
- package/src/lib/gen2/helpers.zig +5 -16
- package/src/lib/gen2/mechanics.zig +22 -36
- package/src/lib/node.zig +2 -4
- package/src/lib/pkmn.zig +4 -0
- package/src/lib/wasm.zig +1 -2
- package/src/tools/display/dom.ts +96 -0
- package/src/tools/display/ui.css +354 -0
- package/build/test/display.js +0 -405
- package/build/test/display.js.map +0 -1
- package/src/test/display/pkmn.html.tmpl +0 -368
|
@@ -1,39 +1,28 @@
|
|
|
1
|
-
const
|
|
2
|
-
|
|
3
|
-
const pkmn = @import("../pkmn.zig");
|
|
1
|
+
const DEBUG = @import("../common/debug.zig").print;
|
|
4
2
|
|
|
3
|
+
const chance = @import("chance.zig");
|
|
5
4
|
const common = @import("../common/data.zig");
|
|
6
|
-
const
|
|
7
|
-
const
|
|
5
|
+
const data = @import("data.zig");
|
|
6
|
+
const pkmn = @import("../pkmn.zig");
|
|
8
7
|
const protocol = @import("../common/protocol.zig");
|
|
9
8
|
const rng = @import("../common/rng.zig");
|
|
10
|
-
|
|
11
|
-
const data = @import("data.zig");
|
|
12
|
-
const chance = @import("chance.zig");
|
|
9
|
+
const std = @import("std");
|
|
13
10
|
|
|
14
11
|
const assert = std.debug.assert;
|
|
15
|
-
|
|
16
|
-
const expectEqual = std.testing.expectEqual;
|
|
17
|
-
|
|
18
|
-
const showdown = pkmn.options.showdown;
|
|
19
|
-
|
|
20
|
-
const Choice = common.Choice;
|
|
21
|
-
const ID = common.ID;
|
|
22
|
-
const Player = common.Player;
|
|
23
|
-
const Result = common.Result;
|
|
24
|
-
|
|
25
12
|
const Boost = protocol.Boost;
|
|
13
|
+
const Choice = common.Choice;
|
|
26
14
|
const Damage = protocol.Damage;
|
|
15
|
+
const Effectiveness = data.Effectiveness;
|
|
16
|
+
const expectEqual = std.testing.expectEqual;
|
|
27
17
|
const Fail = protocol.Fail;
|
|
28
|
-
const Heal = protocol.Heal;
|
|
29
|
-
|
|
30
18
|
const Gen12 = rng.Gen12;
|
|
31
|
-
|
|
32
|
-
const
|
|
33
|
-
const Effectiveness = data.Effectiveness;
|
|
19
|
+
const Heal = protocol.Heal;
|
|
20
|
+
const ID = common.ID;
|
|
34
21
|
const Move = data.Move;
|
|
35
22
|
const MoveSlot = data.MoveSlot;
|
|
36
|
-
const
|
|
23
|
+
const Player = common.Player;
|
|
24
|
+
const Result = common.Result;
|
|
25
|
+
const showdown = pkmn.options.showdown;
|
|
37
26
|
const Side = data.Side;
|
|
38
27
|
const Species = data.Species;
|
|
39
28
|
const Stats = data.Stats;
|
|
@@ -564,11 +553,10 @@ fn beforeMove(
|
|
|
564
553
|
if (volatiles.Confusion) {
|
|
565
554
|
assert(volatiles.confusion > 0);
|
|
566
555
|
if (options.calc.overridden(player, .confusion)) |obs| switch (obs) {
|
|
567
|
-
.started => volatiles.confusion
|
|
556
|
+
.started, .ended => volatiles.confusion = 0,
|
|
568
557
|
.continuing => if (volatiles.confusion > 1) {
|
|
569
558
|
volatiles.confusion -= 1;
|
|
570
559
|
},
|
|
571
|
-
.ended => volatiles.confusion = 0,
|
|
572
560
|
.overwritten => {},
|
|
573
561
|
else => unreachable,
|
|
574
562
|
} else {
|
|
@@ -707,7 +695,11 @@ fn beforeMove(
|
|
|
707
695
|
// can be expected to recognize this pattern and pass the information only to the
|
|
708
696
|
// correct player)
|
|
709
697
|
try log.start(.{ battle.active(player), .ConfusionSilent });
|
|
710
|
-
options.chance.observe(.confusion, player, if (overwritten)
|
|
698
|
+
options.chance.observe(.confusion, player, if (overwritten)
|
|
699
|
+
if (pkmn.options.overwrite) .overwritten else .continuing
|
|
700
|
+
else
|
|
701
|
+
.started);
|
|
702
|
+
if (!overwritten) options.calc.confusion(player);
|
|
711
703
|
}
|
|
712
704
|
|
|
713
705
|
// This shouldn't actually set last_used_move, but Pokémon Showdown sets last
|
|
@@ -1035,22 +1027,20 @@ fn doMove(
|
|
|
1035
1027
|
try Effects.poison(battle, player, Move.get(.PoisonSting), options);
|
|
1036
1028
|
}
|
|
1037
1029
|
try log.hitcount(.{ battle.active(player.foe()), hit });
|
|
1038
|
-
} else if (showdown) {
|
|
1030
|
+
} else if (showdown and move.effect == .Binding) {
|
|
1039
1031
|
// This should be handled much earlier but Pokémon Showdown does it here... ¯\_(ツ)_/¯
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
try buildRage(battle, player.foe(), options);
|
|
1051
|
-
}
|
|
1052
|
-
return null;
|
|
1032
|
+
try Effects.binding(battle, player, rewrap, options);
|
|
1033
|
+
if (immune) {
|
|
1034
|
+
battle.last_damage = 0;
|
|
1035
|
+
assert(foe.stored().hp > 0);
|
|
1036
|
+
// Pokémon Showdown logs |-damage| here instead of |-immune| because logic...
|
|
1037
|
+
if (sub) {
|
|
1038
|
+
try log.activate(.{ battle.active(player.foe()), .Substitute });
|
|
1039
|
+
} else {
|
|
1040
|
+
try log.damage(.{ battle.active(player.foe()), foe.stored(), .None });
|
|
1041
|
+
try buildRage(battle, player.foe(), options);
|
|
1053
1042
|
}
|
|
1043
|
+
return null;
|
|
1054
1044
|
}
|
|
1055
1045
|
}
|
|
1056
1046
|
|
|
@@ -1317,7 +1307,7 @@ fn applyDamage(
|
|
|
1317
1307
|
subbed.active.volatiles.Substitute = false;
|
|
1318
1308
|
// battle.last_damage is not updated with the amount of HP the Substitute had
|
|
1319
1309
|
try options.log.end(.{ battle.active(sub_player), .Substitute });
|
|
1320
|
-
options.calc.capped(sub_player);
|
|
1310
|
+
if (reason != .Confusion) options.calc.capped(sub_player);
|
|
1321
1311
|
return true;
|
|
1322
1312
|
} else {
|
|
1323
1313
|
// Safe to truncate since less than subbed.volatiles.substitute which is a u8
|
|
@@ -1872,6 +1862,7 @@ pub const Effects = struct {
|
|
|
1872
1862
|
|
|
1873
1863
|
foe.active.volatiles.confusion = Rolls.confusionDuration(battle, player, options);
|
|
1874
1864
|
options.chance.observe(.confusion, player.foe(), .started);
|
|
1865
|
+
options.calc.confusion(player.foe());
|
|
1875
1866
|
|
|
1876
1867
|
try options.log.start(.{ battle.active(player.foe()), .Confusion });
|
|
1877
1868
|
}
|
|
@@ -2944,9 +2935,10 @@ pub const Rolls = struct {
|
|
|
2944
2935
|
}
|
|
2945
2936
|
|
|
2946
2937
|
fn sleepDuration(battle: anytype, player: Player, options: anytype) u3 {
|
|
2947
|
-
const duration: u3 = if (options.calc.overridden(player, .duration)) |val|
|
|
2948
|
-
@intCast(val)
|
|
2949
|
-
else
|
|
2938
|
+
const duration: u3 = (if (options.calc.overridden(player, .duration)) |val|
|
|
2939
|
+
if (val >= 1 and val <= 7) @as(u3, @intCast(val)) else null
|
|
2940
|
+
else
|
|
2941
|
+
null) orelse if (@hasDecl(@TypeOf(battle.rng), "sleepDuration"))
|
|
2950
2942
|
battle.rng.sleepDuration(player)
|
|
2951
2943
|
else if (showdown)
|
|
2952
2944
|
battle.rng.range(u3, 1, 8)
|
|
@@ -2963,9 +2955,10 @@ pub const Rolls = struct {
|
|
|
2963
2955
|
}
|
|
2964
2956
|
|
|
2965
2957
|
fn disableDuration(battle: anytype, player: Player, options: anytype) u4 {
|
|
2966
|
-
const duration: u4 = if (options.calc.overridden(player, .duration)) |val|
|
|
2967
|
-
val
|
|
2968
|
-
else
|
|
2958
|
+
const duration: u4 = (if (options.calc.overridden(player, .duration)) |val|
|
|
2959
|
+
if (val >= 1 and val <= 8) val else null
|
|
2960
|
+
else
|
|
2961
|
+
null) orelse if (@hasDecl(@TypeOf(battle.rng), "disableDuration"))
|
|
2969
2962
|
battle.rng.disableDuration(player)
|
|
2970
2963
|
else if (showdown)
|
|
2971
2964
|
battle.rng.range(u4, 1, 9)
|
|
@@ -2978,9 +2971,10 @@ pub const Rolls = struct {
|
|
|
2978
2971
|
}
|
|
2979
2972
|
|
|
2980
2973
|
fn confusionDuration(battle: anytype, player: Player, options: anytype) u3 {
|
|
2981
|
-
const duration: u3 = if (options.calc.overridden(player, .duration)) |val|
|
|
2982
|
-
@intCast(val)
|
|
2983
|
-
else
|
|
2974
|
+
const duration: u3 = (if (options.calc.overridden(player, .duration)) |val|
|
|
2975
|
+
if (val >= 2 and val <= 5) @as(u3, @intCast(val)) else null
|
|
2976
|
+
else
|
|
2977
|
+
null) orelse if (@hasDecl(@TypeOf(battle.rng), "confusionDuration"))
|
|
2984
2978
|
battle.rng.confusionDuration(player)
|
|
2985
2979
|
else if (showdown)
|
|
2986
2980
|
battle.rng.range(u3, 2, 6)
|
|
@@ -2993,9 +2987,10 @@ pub const Rolls = struct {
|
|
|
2993
2987
|
}
|
|
2994
2988
|
|
|
2995
2989
|
fn attackingDuration(battle: anytype, player: Player, options: anytype) u3 {
|
|
2996
|
-
const duration: u3 = if (options.calc.overridden(player, .duration)) |val|
|
|
2997
|
-
@intCast(val)
|
|
2998
|
-
else
|
|
2990
|
+
const duration: u3 = (if (options.calc.overridden(player, .duration)) |val|
|
|
2991
|
+
if (val >= 2 and val <= 3) @as(u3, @intCast(val)) else null
|
|
2992
|
+
else
|
|
2993
|
+
null) orelse if (@hasDecl(@TypeOf(battle.rng), "attackingDuration"))
|
|
2999
2994
|
battle.rng.attackingDuration(player)
|
|
3000
2995
|
else if (showdown)
|
|
3001
2996
|
battle.rng.range(u3, 2, 4)
|
|
@@ -3016,9 +3011,10 @@ pub const Rolls = struct {
|
|
|
3016
3011
|
options: anytype,
|
|
3017
3012
|
) !u3 {
|
|
3018
3013
|
const roll = if (effect == .Binding) .duration else .multi_hit;
|
|
3019
|
-
const n: u3 = if (options.calc.overridden(player, roll)) |val|
|
|
3020
|
-
@intCast(val)
|
|
3021
|
-
else
|
|
3014
|
+
const n: u3 = (if (options.calc.overridden(player, roll)) |val|
|
|
3015
|
+
if (val >= 2 and val <= 5) @as(u3, @intCast(val)) else null
|
|
3016
|
+
else
|
|
3017
|
+
null) orelse if (@hasDecl(@TypeOf(battle.rng), "distribution"))
|
|
3022
3018
|
battle.rng.distribution(player)
|
|
3023
3019
|
else if (showdown)
|
|
3024
3020
|
DISTRIBUTION[battle.rng.range(u3, 0, DISTRIBUTION.len)]
|
|
@@ -3044,15 +3040,13 @@ pub const Rolls = struct {
|
|
|
3044
3040
|
options: anytype,
|
|
3045
3041
|
) !u4 {
|
|
3046
3042
|
// TODO: consider throwing error instead of rerolling?
|
|
3047
|
-
const
|
|
3043
|
+
const slot: u4 = (if (options.calc.overridden(player, .move_slot)) |val|
|
|
3048
3044
|
if (moves[val - 1].id != .None and (check_pp == 0 or moves[val - 1].pp > 0))
|
|
3049
3045
|
val
|
|
3050
3046
|
else
|
|
3051
3047
|
null
|
|
3052
3048
|
else
|
|
3053
|
-
null
|
|
3054
|
-
|
|
3055
|
-
const slot: u4 = overridden orelse if (@hasDecl(@TypeOf(battle.rng), "moveSlot"))
|
|
3049
|
+
null) orelse if (@hasDecl(@TypeOf(battle.rng), "moveSlot"))
|
|
3056
3050
|
battle.rng.moveSlot(player, moves, check_pp)
|
|
3057
3051
|
else slot: {
|
|
3058
3052
|
if (showdown) {
|
package/src/lib/gen2/calc.zig
CHANGED
|
@@ -1,27 +1,19 @@
|
|
|
1
|
-
const
|
|
2
|
-
|
|
3
|
-
const pkmn = @import("../pkmn.zig");
|
|
4
|
-
|
|
1
|
+
const chance = @import("chance.zig");
|
|
5
2
|
const common = @import("../common/data.zig");
|
|
6
|
-
const util = @import("../common/util.zig");
|
|
7
|
-
|
|
8
3
|
const Optional = @import("../common/optional.zig").Optional;
|
|
4
|
+
const pkmn = @import("../pkmn.zig");
|
|
5
|
+
const std = @import("std");
|
|
6
|
+
const util = @import("../common/util.zig");
|
|
9
7
|
|
|
10
|
-
const
|
|
11
|
-
|
|
8
|
+
const Action = chance.Action;
|
|
9
|
+
const Actions = chance.Actions;
|
|
12
10
|
const assert = std.debug.assert;
|
|
13
|
-
|
|
11
|
+
const Criticals = chance.Criticals;
|
|
12
|
+
const Damages = chance.Damages;
|
|
14
13
|
const enabled = pkmn.options.calc;
|
|
15
|
-
|
|
14
|
+
const isPointerTo = util.isPointerTo;
|
|
16
15
|
const Player = common.Player;
|
|
17
|
-
|
|
18
16
|
const PointerType = util.PointerType;
|
|
19
|
-
const isPointerTo = util.isPointerTo;
|
|
20
|
-
|
|
21
|
-
const Actions = chance.Actions;
|
|
22
|
-
const Action = chance.Action;
|
|
23
|
-
const Criticals = chance.Criticals;
|
|
24
|
-
const Damages = chance.Damages;
|
|
25
17
|
|
|
26
18
|
const Int = if (@hasField(std.builtin.Type, "int")) .int else .Int;
|
|
27
19
|
const Enum = if (@hasField(std.builtin.Type, "enum")) .@"enum" else .Enum;
|
|
@@ -154,7 +146,7 @@ const Null = struct {
|
|
|
154
146
|
|
|
155
147
|
fn ReturnType(comptime field: Action.Field) type {
|
|
156
148
|
return ?(switch (field) {
|
|
157
|
-
.damages =>
|
|
149
|
+
.damages => u8,
|
|
158
150
|
.critical_hits => Optional(bool),
|
|
159
151
|
else => std.meta.FieldType(Action, field),
|
|
160
152
|
});
|
package/src/lib/gen2/chance.zig
CHANGED
|
@@ -8,7 +8,6 @@ const expectEqual = std.testing.expectEqual;
|
|
|
8
8
|
|
|
9
9
|
const options = @import("../common/options.zig");
|
|
10
10
|
const rational = @import("../common/rational.zig");
|
|
11
|
-
const rng = @import("../common/rng.zig");
|
|
12
11
|
const util = @import("../common/util.zig");
|
|
13
12
|
|
|
14
13
|
const Array = @import("../common/array.zig").Array;
|
|
@@ -20,8 +19,6 @@ const data = @import("data.zig");
|
|
|
20
19
|
const enabled = options.chance;
|
|
21
20
|
const showdown = options.showdown;
|
|
22
21
|
|
|
23
|
-
const Gen12 = rng.Gen12;
|
|
24
|
-
|
|
25
22
|
const PointerType = util.PointerType;
|
|
26
23
|
const isPointerTo = util.isPointerTo;
|
|
27
24
|
|
|
@@ -111,7 +108,7 @@ test Actions {
|
|
|
111
108
|
/// Observation made about a duration - whether the duration has started, been continued, or ended.
|
|
112
109
|
pub const Observation = enum { started, continuing, ended };
|
|
113
110
|
|
|
114
|
-
pub const Damages = Array(5,
|
|
111
|
+
pub const Damages = Array(5, u8);
|
|
115
112
|
pub const Criticals = Array(5, Optional(bool));
|
|
116
113
|
|
|
117
114
|
/// Information about the RNG that was observed during a Generation II battle `update` for a
|
|
@@ -164,10 +161,6 @@ pub const Action = packed struct(u128) {
|
|
|
164
161
|
/// If not 0, the value (2-5) to return for Rolls.distribution for multi hit.
|
|
165
162
|
multi_hit: u3 = 0,
|
|
166
163
|
|
|
167
|
-
_: u9 = 0,
|
|
168
|
-
|
|
169
|
-
/// If not 0, the value to by one of the Rolls.*Duration rolls.
|
|
170
|
-
duration: u4 = 0,
|
|
171
164
|
sleep: Optional(Observation) = .None,
|
|
172
165
|
/// TODO
|
|
173
166
|
confusion: Optional(Observation) = .None,
|
|
@@ -180,6 +173,8 @@ pub const Action = packed struct(u128) {
|
|
|
180
173
|
/// TODO
|
|
181
174
|
encore: Optional(Observation) = .None,
|
|
182
175
|
|
|
176
|
+
/// If not 0, the value to by one of the Rolls.*Duration rolls.
|
|
177
|
+
duration: u3 = 0,
|
|
183
178
|
/// If not None, the value to return for Rolls.conversion2.
|
|
184
179
|
conversion_2: Optional(Type) = .None,
|
|
185
180
|
|
|
@@ -292,7 +287,7 @@ pub fn Chance(comptime Rational: type) type {
|
|
|
292
287
|
|
|
293
288
|
try self.probability.update(1, 39);
|
|
294
289
|
var a = self.actions.get(player);
|
|
295
|
-
a.damages = Damages.set(a.damages, i,
|
|
290
|
+
a.damages = Damages.set(a.damages, i, roll);
|
|
296
291
|
}
|
|
297
292
|
|
|
298
293
|
pub fn confused(self: *Self, player: Player, cfz: bool) Error!void {
|
|
@@ -444,7 +439,7 @@ pub fn Chance(comptime Rational: type) type {
|
|
|
444
439
|
self.actions.get(player).multi_hit = n;
|
|
445
440
|
}
|
|
446
441
|
|
|
447
|
-
pub fn duration(self: *Self, player: Player, turns:
|
|
442
|
+
pub fn duration(self: *Self, player: Player, turns: u3) void {
|
|
448
443
|
if (!enabled) return;
|
|
449
444
|
|
|
450
445
|
self.actions.get(player).duration = if (options.key) 2 else turns;
|
|
@@ -514,7 +509,7 @@ test "Chance.damage" {
|
|
|
514
509
|
var chance: Chance(rational.Rational(u64)) = .{ .probability = .{} };
|
|
515
510
|
|
|
516
511
|
try chance.damage(.P1, 0, 219);
|
|
517
|
-
try expectValue(@as(
|
|
512
|
+
try expectValue(@as(u8, 219), Damages.get(chance.actions.p1.damages, 0));
|
|
518
513
|
try expectProbability(&chance.probability, 1, 39);
|
|
519
514
|
}
|
|
520
515
|
|
|
@@ -783,7 +778,7 @@ test "Chance.duration" {
|
|
|
783
778
|
var chance: Chance(rational.Rational(u64)) = .{ .probability = .{} };
|
|
784
779
|
|
|
785
780
|
chance.duration(.P1, 2);
|
|
786
|
-
try expectValue(@as(
|
|
781
|
+
try expectValue(@as(u3, 2), chance.actions.p1.duration);
|
|
787
782
|
}
|
|
788
783
|
|
|
789
784
|
pub fn expectProbability(r: anytype, p: u64, q: u64) !void {
|
|
@@ -901,7 +896,7 @@ const Null = struct {
|
|
|
901
896
|
_ = .{ self, player, move, n };
|
|
902
897
|
}
|
|
903
898
|
|
|
904
|
-
pub fn duration(self: Null, player: Player, turns:
|
|
899
|
+
pub fn duration(self: Null, player: Player, turns: u3) void {
|
|
905
900
|
_ = .{ self, player, turns };
|
|
906
901
|
}
|
|
907
902
|
};
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
//! Code generated by `tools/generate` - manual edits will be overwritten.
|
|
2
2
|
|
|
3
|
-
const std = @import("std");
|
|
4
|
-
|
|
5
3
|
const data = @import("../../gen2/data.zig");
|
|
4
|
+
const std = @import("std");
|
|
6
5
|
|
|
7
6
|
const assert = std.debug.assert;
|
|
8
|
-
|
|
9
7
|
const Type = data.Type;
|
|
10
8
|
|
|
11
9
|
/// Representation of a held item in Generation II Pokémon.
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
//! Code generated by `tools/generate` - manual edits will be overwritten.
|
|
2
2
|
|
|
3
|
-
const std = @import("std");
|
|
4
|
-
|
|
5
|
-
const rng = @import("../../common/rng.zig");
|
|
6
3
|
const gen2 = @import("../../gen2/data.zig");
|
|
4
|
+
const rng = @import("../../common/rng.zig");
|
|
5
|
+
const std = @import("std");
|
|
7
6
|
|
|
8
7
|
const assert = std.debug.assert;
|
|
9
|
-
|
|
10
8
|
const percent = rng.Gen12.percent;
|
|
11
9
|
const Type = gen2.Type;
|
|
12
10
|
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
//! Code generated by `tools/generate` - manual edits will be overwritten.
|
|
2
2
|
|
|
3
|
-
const std = @import("std");
|
|
4
|
-
|
|
5
3
|
const gen2 = @import("../../gen2/data.zig");
|
|
4
|
+
const std = @import("std");
|
|
6
5
|
|
|
7
6
|
const assert = std.debug.assert;
|
|
8
|
-
|
|
9
7
|
const Stats = gen2.Stats;
|
|
10
8
|
const Types = gen2.Types;
|
|
11
9
|
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
//! Code generated by `tools/generate` - manual edits will be overwritten.
|
|
2
2
|
|
|
3
|
-
const std = @import("std");
|
|
4
|
-
|
|
5
3
|
const gen1 = @import("../../gen1/data.zig");
|
|
4
|
+
const std = @import("std");
|
|
6
5
|
|
|
7
6
|
const assert = std.debug.assert;
|
|
8
7
|
const Effectiveness = gen1.Effectiveness;
|
package/src/lib/gen2/data.zig
CHANGED
|
@@ -1,24 +1,20 @@
|
|
|
1
|
-
const std = @import("std");
|
|
2
|
-
const builtin = @import("builtin");
|
|
3
|
-
|
|
4
|
-
const pkmn = @import("../pkmn.zig");
|
|
5
|
-
|
|
6
|
-
const data = @import("../common/data.zig");
|
|
7
1
|
const DEBUG = @import("../common/debug.zig").print;
|
|
8
|
-
const protocol = @import("../common/protocol.zig");
|
|
9
|
-
const rng = @import("../common/rng.zig");
|
|
10
|
-
const util = @import("../common/util.zig");
|
|
11
2
|
|
|
3
|
+
const builtin = @import("builtin");
|
|
4
|
+
const calc = @import("calc.zig");
|
|
5
|
+
const chance = @import("chance.zig");
|
|
6
|
+
const data = @import("../common/data.zig");
|
|
7
|
+
const gen1 = @import("../gen1/data.zig");
|
|
12
8
|
const items = @import("data/items.zig");
|
|
9
|
+
const mechanics = @import("mechanics.zig");
|
|
13
10
|
const moves = @import("data/moves.zig");
|
|
11
|
+
const pkmn = @import("../pkmn.zig");
|
|
12
|
+
const protocol = @import("../common/protocol.zig");
|
|
13
|
+
const rng = @import("../common/rng.zig");
|
|
14
14
|
const species = @import("data/species.zig");
|
|
15
|
+
const std = @import("std");
|
|
15
16
|
const types = @import("data/types.zig");
|
|
16
|
-
|
|
17
|
-
const gen1 = @import("../gen1/data.zig");
|
|
18
|
-
|
|
19
|
-
const calc = @import("calc.zig");
|
|
20
|
-
const chance = @import("chance.zig");
|
|
21
|
-
const mechanics = @import("mechanics.zig");
|
|
17
|
+
const util = @import("../common/util.zig");
|
|
22
18
|
|
|
23
19
|
const assert = std.debug.assert;
|
|
24
20
|
const expectEqual = std.testing.expectEqual;
|
|
@@ -1,37 +1,32 @@
|
|
|
1
1
|
//! Code generated by `tools/generate` - manual edits will be overwritten.
|
|
2
2
|
|
|
3
|
-
const std = @import("std");
|
|
4
|
-
|
|
5
3
|
const common = @import("../common/data.zig");
|
|
6
|
-
|
|
7
4
|
const data = @import("data.zig");
|
|
8
5
|
const mechanics = @import("mechanics.zig");
|
|
6
|
+
const std = @import("std");
|
|
9
7
|
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
const Effects = mechanics.Effects;
|
|
17
|
-
const State = mechanics.State;
|
|
18
|
-
|
|
19
|
-
const canMove = mechanics.canMove;
|
|
8
|
+
const adjustDamage = mechanics.adjustDamage;
|
|
9
|
+
const afterMove = mechanics.afterMove;
|
|
10
|
+
const applyDamage = mechanics.applyDamage;
|
|
11
|
+
const buildRage = mechanics.buildRage;
|
|
12
|
+
const calcDamage = mechanics.calcDamage;
|
|
20
13
|
const canCharge = mechanics.canCharge;
|
|
14
|
+
const canMove = mechanics.canMove;
|
|
15
|
+
const checkCriticalHit = mechanics.checkCriticalHit;
|
|
16
|
+
const checkHit = mechanics.checkHit;
|
|
21
17
|
const decrementPP = mechanics.decrementPP;
|
|
18
|
+
const destinyBond = mechanics.destinyBond;
|
|
22
19
|
const doMove = mechanics.doMove;
|
|
23
|
-
const checkHit = mechanics.checkHit;
|
|
24
|
-
const checkCriticalHit = mechanics.checkCriticalHit;
|
|
25
|
-
const calcDamage = mechanics.calcDamage;
|
|
26
|
-
const adjustDamage = mechanics.adjustDamage;
|
|
27
|
-
const randomizeDamage = mechanics.randomizeDamage;
|
|
28
|
-
const applyDamage = mechanics.applyDamage;
|
|
29
|
-
const reportOutcome = mechanics.reportOutcome;
|
|
30
20
|
const effectChance = mechanics.effectChance;
|
|
31
|
-
const
|
|
32
|
-
const
|
|
21
|
+
const Effectiveness = data.Effectiveness;
|
|
22
|
+
const Effects = mechanics.Effects;
|
|
33
23
|
const kingsRock = mechanics.kingsRock;
|
|
34
|
-
const
|
|
24
|
+
const Move = data.Move;
|
|
25
|
+
const Player = common.Player;
|
|
26
|
+
const randomizeDamage = mechanics.randomizeDamage;
|
|
27
|
+
const reportOutcome = mechanics.reportOutcome;
|
|
28
|
+
const Result = common.Result;
|
|
29
|
+
const State = mechanics.State;
|
|
35
30
|
|
|
36
31
|
const SECONDARY = true;
|
|
37
32
|
const KINGS = true;
|
package/src/lib/gen2/helpers.zig
CHANGED
|
@@ -1,31 +1,20 @@
|
|
|
1
|
-
const std = @import("std");
|
|
2
|
-
|
|
3
1
|
const common = @import("../common/data.zig");
|
|
2
|
+
const data = @import("data.zig");
|
|
3
|
+
const gen1 = @import("../gen1/data.zig");
|
|
4
4
|
const options = @import("../common/options.zig");
|
|
5
|
-
const protocol = @import("../common/protocol.zig");
|
|
6
5
|
const rng = @import("../common/rng.zig");
|
|
7
|
-
|
|
8
|
-
const gen1 = @import("../gen1/data.zig");
|
|
9
|
-
|
|
10
|
-
const data = @import("data.zig");
|
|
6
|
+
const std = @import("std");
|
|
11
7
|
|
|
12
8
|
const assert = std.debug.assert;
|
|
13
|
-
|
|
14
|
-
const expectEqual = std.testing.expectEqual;
|
|
15
|
-
|
|
16
9
|
const Choice = common.Choice;
|
|
17
|
-
|
|
18
|
-
const showdown = options.showdown;
|
|
19
|
-
|
|
20
|
-
const PSRNG = rng.PSRNG;
|
|
21
|
-
|
|
22
10
|
const DVs = data.DVs;
|
|
23
11
|
const Item = data.Item;
|
|
24
12
|
const Move = data.Move;
|
|
25
13
|
const MoveSlot = data.MoveSlot;
|
|
14
|
+
const PSRNG = rng.PSRNG;
|
|
15
|
+
const showdown = options.showdown;
|
|
26
16
|
const Species = data.Species;
|
|
27
17
|
const Stats = data.Stats;
|
|
28
|
-
const Status = data.Status;
|
|
29
18
|
|
|
30
19
|
const Struct = if (@hasField(std.builtin.Type, "struct")) .@"struct" else .Struct;
|
|
31
20
|
|
|
@@ -1,50 +1,36 @@
|
|
|
1
|
-
const std = @import("std");
|
|
2
|
-
|
|
3
|
-
const pkmn = @import("../pkmn.zig");
|
|
4
|
-
|
|
5
|
-
const common = @import("../common/data.zig");
|
|
6
1
|
const DEBUG = @import("../common/debug.zig").print;
|
|
7
|
-
const protocol = @import("../common/protocol.zig");
|
|
8
|
-
const rng = @import("../common/rng.zig");
|
|
9
|
-
const util = @import("../common/util.zig");
|
|
10
2
|
|
|
3
|
+
const common = @import("../common/data.zig");
|
|
11
4
|
const data = @import("data.zig");
|
|
12
5
|
const generated = @import("generated.zig");
|
|
13
|
-
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
const
|
|
17
|
-
const expectEqualSlices = std.testing.expectEqualSlices;
|
|
18
|
-
const expectEqualStrings = std.testing.expectEqualStrings;
|
|
19
|
-
|
|
20
|
-
const showdown = pkmn.options.showdown;
|
|
21
|
-
|
|
22
|
-
const Choice = common.Choice;
|
|
23
|
-
const ID = common.ID;
|
|
24
|
-
const Player = common.Player;
|
|
25
|
-
const Result = common.Result;
|
|
6
|
+
const pkmn = @import("../pkmn.zig");
|
|
7
|
+
const protocol = @import("../common/protocol.zig");
|
|
8
|
+
const rng = @import("../common/rng.zig");
|
|
9
|
+
const std = @import("std");
|
|
26
10
|
|
|
27
11
|
const Activate = protocol.Activate;
|
|
12
|
+
const ActivePokemon = data.ActivePokemon;
|
|
13
|
+
const assert = std.debug.assert;
|
|
28
14
|
const Boost = protocol.Boost;
|
|
15
|
+
const Boosts = data.Boosts;
|
|
16
|
+
const Choice = common.Choice;
|
|
29
17
|
const Damage = protocol.Damage;
|
|
18
|
+
const Effectiveness = data.Effectiveness;
|
|
30
19
|
const End = protocol.End;
|
|
20
|
+
const expectEqual = std.testing.expectEqual;
|
|
21
|
+
const expectEqualSlices = std.testing.expectEqualSlices;
|
|
22
|
+
const expectEqualStrings = std.testing.expectEqualStrings;
|
|
31
23
|
const Fail = protocol.Fail;
|
|
32
|
-
const Heal = protocol.Heal;
|
|
33
|
-
const Start = protocol.Start;
|
|
34
|
-
|
|
35
24
|
const Gen12 = rng.Gen12;
|
|
36
|
-
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
const ActivePokemon = data.ActivePokemon;
|
|
40
|
-
const Boosts = data.Boosts;
|
|
41
|
-
const Effectiveness = data.Effectiveness;
|
|
25
|
+
const Heal = protocol.Heal;
|
|
26
|
+
const ID = common.ID;
|
|
42
27
|
const Item = data.Item;
|
|
43
28
|
const Move = data.Move;
|
|
44
|
-
const
|
|
45
|
-
const
|
|
29
|
+
const Player = common.Player;
|
|
30
|
+
const Result = common.Result;
|
|
31
|
+
const showdown = pkmn.options.showdown;
|
|
46
32
|
const Side = data.Side;
|
|
47
|
-
const
|
|
33
|
+
const Start = protocol.Start;
|
|
48
34
|
const Stats = data.Stats;
|
|
49
35
|
const Status = data.Status;
|
|
50
36
|
const TriAttack = data.TriAttack;
|
|
@@ -2901,7 +2887,7 @@ pub const Rolls = struct {
|
|
|
2901
2887
|
fn damage(battle: anytype, player: Player, i: u3, options: anytype) !u8 {
|
|
2902
2888
|
_ = .{ player, options };
|
|
2903
2889
|
const roll = if (options.calc.overridden(player, i, .damages)) |val|
|
|
2904
|
-
|
|
2890
|
+
val
|
|
2905
2891
|
else roll: {
|
|
2906
2892
|
if (showdown) break :roll battle.rng.range(u8, 217, 256);
|
|
2907
2893
|
while (true) {
|
|
@@ -3357,11 +3343,11 @@ pub const Rolls = struct {
|
|
|
3357
3343
|
}
|
|
3358
3344
|
|
|
3359
3345
|
fn disableDuration(battle: anytype, player: Player, options: anytype) u4 {
|
|
3360
|
-
const duration:
|
|
3346
|
+
const duration: u3 = if (options.calc.overridden(player, 0, .duration)) |val|
|
|
3361
3347
|
@intCast(val)
|
|
3362
3348
|
else if (showdown)
|
|
3363
3349
|
// Pokémon Showdown incorrectly inherits Generation III's Disable duration
|
|
3364
|
-
battle.rng.range(
|
|
3350
|
+
battle.rng.range(u3, 2, 6)
|
|
3365
3351
|
else duration: {
|
|
3366
3352
|
while (true) {
|
|
3367
3353
|
const r = battle.rng.next() & 7;
|
package/src/lib/node.zig
CHANGED
package/src/lib/pkmn.zig
CHANGED
|
@@ -96,6 +96,10 @@ pub const gen1 = struct {
|
|
|
96
96
|
/// though damage calculator support should additionally be turned off
|
|
97
97
|
/// entirely via `options.calc`.
|
|
98
98
|
pub const NULL = @import("gen1/calc.zig").NULL;
|
|
99
|
+
/// TODO
|
|
100
|
+
pub const MAX_FRONTIER = @import("gen1/calc.zig").MAX_FRONTIER;
|
|
101
|
+
/// TODO
|
|
102
|
+
pub const Rolls = @import("gen1/calc.zig").Rolls;
|
|
99
103
|
};
|
|
100
104
|
/// Provides helpers for initializing Generation I Pokémon battles.
|
|
101
105
|
pub const helpers = @import("gen1/helpers.zig");
|