@pkmn/engine 0.1.0-dev.d716e940 → 0.1.0-dev.d952b7c9

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.
Files changed (79) hide show
  1. package/LICENSE +1 -3
  2. package/README.md +97 -59
  3. package/build/pkg/addon/browser.d.ts +3 -0
  4. package/build/pkg/addon/browser.js +43 -0
  5. package/build/pkg/addon/browser.js.map +1 -0
  6. package/build/pkg/addon/node.d.ts +3 -0
  7. package/build/pkg/addon/node.js +96 -0
  8. package/build/pkg/addon/node.js.map +1 -0
  9. package/build/pkg/addon.d.ts +2 -0
  10. package/build/pkg/addon.js +35 -57
  11. package/build/pkg/addon.js.map +1 -1
  12. package/build/pkg/data/ids.json +12 -12
  13. package/build/pkg/data/layout.json +26 -4
  14. package/build/pkg/data/protocol.json +69 -12
  15. package/build/pkg/data.d.ts +27 -5
  16. package/build/pkg/data.js.map +1 -1
  17. package/build/pkg/gen1.js +16 -19
  18. package/build/pkg/gen1.js.map +1 -1
  19. package/build/pkg/index.d.ts +24 -10
  20. package/build/pkg/index.js +15 -10
  21. package/build/pkg/index.js.map +1 -1
  22. package/build/pkg/protocol.d.ts +20 -1
  23. package/build/pkg/protocol.js +123 -102
  24. package/build/pkg/protocol.js.map +1 -1
  25. package/build/tools/debug.js +36 -68
  26. package/build/tools/debug.js.map +1 -1
  27. package/build/tools/display/debug.jsx +128 -0
  28. package/build/tools/display/debug.jsx.map +1 -0
  29. package/build/tools/display/index.js +132 -0
  30. package/build/tools/display/index.js.map +1 -0
  31. package/build/tools/display/ui.jsx +349 -0
  32. package/build/tools/display/ui.jsx.map +1 -0
  33. package/build/tools/display/util.js +18 -0
  34. package/build/tools/display/util.js.map +1 -0
  35. package/build.zig +286 -131
  36. package/package.json +73 -31
  37. package/src/bin/install-pkmn-engine +39 -24
  38. package/src/bin/pkmn-debug +1 -1
  39. package/src/lib/common/array.zig +77 -0
  40. package/src/lib/common/battle.zig +17 -0
  41. package/src/lib/common/data.zig +19 -31
  42. package/src/lib/common/debug.zig +30 -16
  43. package/src/lib/common/js.zig +120 -0
  44. package/src/lib/common/optional.zig +71 -0
  45. package/src/lib/common/options.zig +13 -0
  46. package/src/lib/common/protocol.zig +911 -367
  47. package/src/lib/common/rational.zig +447 -0
  48. package/src/lib/common/rng.zig +31 -22
  49. package/src/lib/common/util.zig +61 -0
  50. package/src/lib/gen1/calc.zig +950 -0
  51. package/src/lib/gen1/chance.zig +1169 -0
  52. package/src/lib/gen1/data/moves.zig +202 -190
  53. package/src/lib/gen1/data/species.zig +5 -5
  54. package/src/lib/gen1/data/types.zig +10 -10
  55. package/src/lib/gen1/data.zig +92 -79
  56. package/src/lib/gen1/helpers.zig +141 -28
  57. package/src/lib/gen1/mechanics.zig +1118 -773
  58. package/src/lib/gen2/calc.zig +161 -0
  59. package/src/lib/gen2/chance.zig +902 -0
  60. package/src/lib/gen2/data/items.zig +14 -20
  61. package/src/lib/gen2/data/moves.zig +664 -570
  62. package/src/lib/gen2/data/species.zig +2 -2
  63. package/src/lib/gen2/data/types.zig +137 -34
  64. package/src/lib/gen2/data.zig +125 -86
  65. package/src/lib/gen2/generated.zig +806 -0
  66. package/src/lib/gen2/helpers.zig +54 -32
  67. package/src/lib/gen2/mechanics.zig +3564 -15
  68. package/src/lib/node.zig +131 -0
  69. package/src/lib/pkmn.zig +81 -5
  70. package/src/lib/wasm.zig +13 -0
  71. package/src/tools/display/dom.ts +96 -0
  72. package/src/tools/display/ui.css +351 -0
  73. package/build/test/display.js +0 -400
  74. package/build/test/display.js.map +0 -1
  75. package/src/lib/binding/node.zig +0 -229
  76. package/src/lib/binding/wasm.zig +0 -10
  77. package/src/lib/gen1/README.md +0 -812
  78. package/src/lib/gen2/README.md +0 -309
  79. package/src/test/display/pkmn.html.tmpl +0 -368
@@ -0,0 +1,131 @@
1
+ const std = @import("std");
2
+
3
+ const pkmn = @import("pkmn.zig");
4
+
5
+ const js = @import("common/js.zig");
6
+
7
+ const assert = std.debug.assert;
8
+
9
+ const c = @cImport({
10
+ @cDefine("NAPI_VERSION", "8");
11
+ @cInclude("node_api.h");
12
+ });
13
+
14
+ export fn napi_register_module_v1(env: c.napi_env, exports: c.napi_value) c.napi_value {
15
+ const properties = [_]c.napi_property_descriptor{
16
+ js.Property.init("engine", .{ .value = register(env) }),
17
+ };
18
+ assert(c.napi_define_properties(env, exports, properties.len, &properties) == c.napi_ok);
19
+ return exports;
20
+ }
21
+
22
+ pub fn register(env: c.napi_env) c.napi_value {
23
+ const object = js.Object.init(env);
24
+ const properties = [_]c.napi_property_descriptor{
25
+ js.Property.init("options", .{ .value = options(env) }),
26
+ js.Property.init("bindings", .{ .value = bindings(env) }),
27
+ };
28
+ assert(c.napi_define_properties(env, object, properties.len, &properties) == c.napi_ok);
29
+ return object;
30
+ }
31
+
32
+ fn options(env: c.napi_env) c.napi_value {
33
+ const object = js.Object.init(env);
34
+ const properties = [_]c.napi_property_descriptor{
35
+ js.Property.init("showdown", .{ .value = js.Boolean.init(env, pkmn.options.showdown) }),
36
+ js.Property.init("log", .{ .value = js.Boolean.init(env, pkmn.options.log) }),
37
+ js.Property.init("chance", .{ .value = js.Boolean.init(env, pkmn.options.chance) }),
38
+ js.Property.init("calc", .{ .value = js.Boolean.init(env, pkmn.options.calc) }),
39
+ };
40
+ assert(c.napi_define_properties(env, object, properties.len, &properties) == c.napi_ok);
41
+ return object;
42
+ }
43
+
44
+ fn bindings(env: c.napi_env) c.napi_value {
45
+ const array = js.Array.init(env, .{ .length = 1 });
46
+ js.Array.set(env, array, 0, bind(env, pkmn.gen1));
47
+ return array;
48
+ }
49
+
50
+ fn bind(env: c.napi_env, gen: anytype) c.napi_value {
51
+ const choices_size: u32 = @intCast(gen.CHOICES_SIZE);
52
+ const logs_size: u32 = @intCast(gen.LOGS_SIZE);
53
+ const object = js.Object.init(env);
54
+ const properties = [_]c.napi_property_descriptor{
55
+ js.Property.init("CHOICES_SIZE", .{ .value = js.Number.init(env, choices_size) }),
56
+ js.Property.init("LOGS_SIZE", .{ .value = js.Number.init(env, logs_size) }),
57
+ js.Property.init("update", .{ .method = update(gen) }),
58
+ js.Property.init("choices", .{ .method = choices(gen) }),
59
+ };
60
+ assert(c.napi_define_properties(env, object, properties.len, &properties) == c.napi_ok);
61
+ return object;
62
+ }
63
+
64
+ fn update(gen: anytype) c.napi_callback {
65
+ return struct {
66
+ fn call(env: c.napi_env, info: c.napi_callback_info) callconv(.C) c.napi_value {
67
+ var argc: usize = 4;
68
+ var argv: [4]c.napi_value = undefined;
69
+ assert(c.napi_get_cb_info(env, info, &argc, &argv, null, null) == c.napi_ok);
70
+ assert(argc == 4);
71
+
72
+ var data: ?*anyopaque = undefined;
73
+ var len: usize = 0;
74
+ assert(c.napi_get_arraybuffer_info(env, argv[0], &data, &len) == c.napi_ok);
75
+ assert(len == @sizeOf(gen.Battle(gen.PRNG)));
76
+
77
+ var battle: *gen.Battle(gen.PRNG) = @alignCast(@ptrCast(data.?));
78
+ const c1: pkmn.Choice = @bitCast(js.Number.get(env, argv[1], u8));
79
+ const c2: pkmn.Choice = @bitCast(js.Number.get(env, argv[2], u8));
80
+
81
+ var vtype: c.napi_valuetype = undefined;
82
+ assert(c.napi_typeof(env, argv[3], &vtype) == c.napi_ok);
83
+ const result = switch (vtype) {
84
+ c.napi_undefined, c.napi_null => battle.update(c1, c2, &gen.NULL),
85
+ else => result: {
86
+ assert(c.napi_get_arraybuffer_info(env, argv[3], &data, &len) == c.napi_ok);
87
+ assert(len == gen.LOGS_SIZE);
88
+
89
+ const buf = @as([*]u8, @ptrCast(data.?))[0..gen.LOGS_SIZE];
90
+ var stream: pkmn.protocol.ByteStream = .{ .buffer = buf };
91
+ // TODO: extract out
92
+ var opts = pkmn.battle.options(
93
+ pkmn.protocol.FixedLog{ .writer = stream.writer() },
94
+ gen.chance.NULL,
95
+ gen.calc.NULL,
96
+ );
97
+ break :result battle.update(c1, c2, &opts);
98
+ },
99
+ } catch unreachable;
100
+
101
+ return js.Number.init(env, @as(u8, @bitCast(result)));
102
+ }
103
+ }.call;
104
+ }
105
+
106
+ fn choices(gen: anytype) c.napi_callback {
107
+ return struct {
108
+ fn call(env: c.napi_env, info: c.napi_callback_info) callconv(.C) c.napi_value {
109
+ var argc: usize = 4;
110
+ var argv: [4]c.napi_value = undefined;
111
+ assert(c.napi_get_cb_info(env, info, &argc, &argv, null, null) == c.napi_ok);
112
+ assert(argc == 4);
113
+
114
+ var data: ?*anyopaque = undefined;
115
+ var len: usize = 0;
116
+ assert(c.napi_get_arraybuffer_info(env, argv[0], &data, &len) == c.napi_ok);
117
+ assert(len == @sizeOf(gen.Battle(gen.PRNG)));
118
+
119
+ var battle: *gen.Battle(gen.PRNG) = @alignCast(@ptrCast(data.?));
120
+ const player: pkmn.Player = @enumFromInt(js.Number.get(env, argv[1], u8));
121
+ const request: pkmn.Choice.Type = @enumFromInt(js.Number.get(env, argv[2], u8));
122
+
123
+ assert(c.napi_get_arraybuffer_info(env, argv[3], &data, &len) == c.napi_ok);
124
+ assert(len == gen.CHOICES_SIZE);
125
+
126
+ const out = @as([*]pkmn.Choice, @ptrCast(data.?))[0..gen.CHOICES_SIZE];
127
+ const n = battle.choices(player, request, out);
128
+ return js.Number.init(env, @as(u8, @bitCast(n)));
129
+ }
130
+ }.call;
131
+ }
package/src/lib/pkmn.zig CHANGED
@@ -1,4 +1,4 @@
1
- /// Configurated Options for the pkmn package.
1
+ /// Configured Options for the pkmn package.
2
2
  pub const options = @import("common/options.zig");
3
3
  /// Configures the behavior of the pkmn package.
4
4
  pub const Options = options.Options;
@@ -22,13 +22,16 @@ pub const Choice = @import("common/data.zig").Choice;
22
22
  /// considered terminal.
23
23
  pub const Result = @import("common/data.zig").Result;
24
24
 
25
+ // TODO
26
+ pub const Array = @import("common/array.zig").Array;
27
+ // TODO
28
+ pub const Optional = @import("common/optional.zig").Optional;
29
+
25
30
  /// Pokémon Showdown's RNG (backed by a Generation V & VI RNG).
26
31
  pub const PSRNG = @import("common/rng.zig").PSRNG;
27
32
 
28
33
  /// Namespace for helpers related to protocol message logging.
29
- pub const protocol = if (options.internal) struct {
30
- pub usingnamespace @import("common/protocol.zig");
31
- } else struct {
34
+ pub const protocol = if (options.internal) @import("common/protocol.zig") else struct {
32
35
  /// Logs protocol information to its `Writer` during a battle update when
33
36
  /// `options.log` is enabled.
34
37
  pub const Log = @import("common/protocol.zig").Log;
@@ -46,9 +49,82 @@ pub const protocol = if (options.internal) struct {
46
49
  pub const NULL = @import("common/protocol.zig").NULL;
47
50
  };
48
51
 
49
- /// Namespace for Generation I Pokémon
52
+ pub usingnamespace @import("common/rational.zig");
53
+
54
+ /// Namespace for cross-generation battle-related types.
55
+ pub const battle = @import("common/battle.zig");
56
+
57
+ /// Namespace for Generation I Pokémon.
50
58
  pub const gen1 = struct {
51
59
  pub usingnamespace @import("gen1/data.zig");
60
+ /// Tracks chance actions and their associated probability during a
61
+ /// Generation I battle update when `options.chance` is enabled.
62
+ pub const Chance = @import("gen1/chance.zig").Chance;
63
+ /// Namespace for types associated with tracking Generation I Pokémon chance outcomes.
64
+ pub const chance = struct {
65
+ /// Actions taken by a hypothetical "chance player" that convey
66
+ /// information about which RNG events were observed during a Generation
67
+ /// I battle `update`. This can additionally be provided as input to the
68
+ /// `update` call via the `Calc` when `options.calc` is enabled to
69
+ /// override the normal behavior of the RNG in order to force specific
70
+ /// outcomes.
71
+ pub const Actions = @import("gen1/chance.zig").Actions;
72
+ /// Information about the RNG that was observed during a Generation I
73
+ /// battle `update` for a single player.
74
+ pub const Action = @import("gen1/chance.zig").Action;
75
+ /// TODO
76
+ pub const Durations = @import("gen1/chance.zig").Durations;
77
+ /// TODO
78
+ pub const Duration = @import("gen1/chance.zig").Duration;
79
+ /// Null object pattern implementation of Generation I `Chance` which
80
+ /// does nothing, though chance tracking should additionally be turned
81
+ /// off entirely via `options.chance`.
82
+ pub const NULL = @import("gen1/chance.zig").NULL;
83
+ };
84
+ /// Allows for forcing the value of specific RNG events during a Generation I battle `update`
85
+ /// via `overrides` and tracks `summaries` of information relevant to damage calculation.
86
+ pub const Calc = @import("gen1/calc.zig").Calc;
87
+ /// Namespace for types associated with supported Generation I Pokémon damage calc features.
88
+ pub const calc = if (options.internal) @import("gen1/calc.zig") else struct {
89
+ /// Information relevant to damage calculation that occured during a Generation I
90
+ /// battle `update`.
91
+ pub const Summaries = @import("gen1/calc.zig").Summaries;
92
+ /// Information relevant to damage calculation that occured during a Generation I
93
+ /// battle `update` for a single player.
94
+ pub const Summary = @import("gen1/calc.zig").Summary;
95
+ /// Null object pattern implementation of Generation I `Calc` which does nothing,
96
+ /// though damage calculator support should additionally be turned off
97
+ /// entirely via `options.calc`.
98
+ pub const NULL = @import("gen1/calc.zig").NULL;
99
+ };
52
100
  /// Provides helpers for initializing Generation I Pokémon battles.
53
101
  pub const helpers = @import("gen1/helpers.zig");
54
102
  };
103
+
104
+ /// TODO
105
+ pub const gen2 = struct {
106
+ pub usingnamespace @import("gen2/data.zig");
107
+ pub const Chance = @import("gen2/chance.zig").Chance;
108
+ pub const chance = struct {
109
+ pub const Actions = @import("gen2/chance.zig").Actions;
110
+ pub const Action = @import("gen2/chance.zig").Action;
111
+ pub const Durations = @import("gen2/chance.zig").Durations;
112
+ pub const Duration = @import("gen2/chance.zig").Duration;
113
+ pub const NULL = @import("gen2/chance.zig").NULL;
114
+ };
115
+ pub const Calc = @import("gen2/calc.zig").Calc;
116
+ pub const calc = if (options.internal) @import("gen2/calc.zig") else struct {
117
+ pub const Summaries = @import("gen2/calc.zig").Summaries;
118
+ pub const Summary = @import("gen2/calc.zig").Summary;
119
+ pub const NULL = @import("gen2/calc.zig").NULL;
120
+ };
121
+ pub const helpers = @import("gen2/helpers.zig");
122
+ };
123
+
124
+ // Internal APIs used by other pkmn libraries, not actually part of the public API.
125
+ // NOTE: `pub usingnamespace struct { ... }` here results in a (false?) dependency loop
126
+ pub const js = if (options.internal) @import("common/js.zig") else {};
127
+ pub const bindings = if (options.internal) struct {
128
+ pub const node = @import("node.zig");
129
+ pub const wasm = @import("wasm.zig");
130
+ } else {};
@@ -0,0 +1,13 @@
1
+ const std = @import("std");
2
+
3
+ const pkmn = @import("pkmn.zig");
4
+
5
+ export const SHOWDOWN = pkmn.options.showdown;
6
+ export const LOG = pkmn.options.log;
7
+ export const CHANCE = pkmn.options.chance;
8
+ export const CALC = pkmn.options.calc;
9
+
10
+ export const GEN1_CHOICES_SIZE =
11
+ std.math.ceilPowerOfTwo(u32, @as(u32, @intCast(pkmn.gen1.CHOICES_SIZE))) catch unreachable;
12
+ export const GEN1_LOGS_SIZE =
13
+ std.math.ceilPowerOfTwo(u32, @as(u32, @intCast(pkmn.gen1.LOGS_SIZE))) catch unreachable;
@@ -0,0 +1,96 @@
1
+ /** @license MIT modified from Vadim Demedes's https://github.com/vadimdemedes/dom-chef */
2
+ type Attributes = JSX.IntrinsicElements['div'];
3
+ type DocumentFragmentConstructor = typeof DocumentFragment;
4
+ type ElementFunction = (props?: any) => HTMLElement;
5
+
6
+ declare global {
7
+ namespace JSX {
8
+ interface Element extends HTMLElement, DocumentFragment {
9
+ addEventListener: HTMLElement['addEventListener'];
10
+ removeEventListener: HTMLElement['removeEventListener'];
11
+ className: HTMLElement['className'];
12
+ }
13
+ }
14
+ }
15
+
16
+ interface JSXElementClassDocumentFragment extends DocumentFragment, JSX.ElementClass { }
17
+ interface Fragment {
18
+ prototype: JSXElementClassDocumentFragment;
19
+ new(): JSXElementClassDocumentFragment;
20
+ }
21
+
22
+ // https://github.com/preactjs/preact/blob/1bbd687c/src/constants.js#L3
23
+ const IS_NON_DIMENSIONAL = /acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i;
24
+
25
+ const isFragment = (type: DocumentFragmentConstructor | ElementFunction):
26
+ type is DocumentFragmentConstructor => type === DocumentFragment;
27
+
28
+ const setCSSProps = (element: HTMLElement, style: CSSStyleDeclaration) => {
29
+ for (const [name, value] of Object.entries(style)) {
30
+ if (name.startsWith('-')) {
31
+ element.style.setProperty(name, value);
32
+ } else if (typeof value === 'number' && !IS_NON_DIMENSIONAL.test(name)) {
33
+ element.style[name as any] = `${value as string}px`;
34
+ } else {
35
+ element.style[name as any] = value;
36
+ }
37
+ }
38
+ };
39
+
40
+ const setAttribute = (element: HTMLElement, name: string, value: string) => {
41
+ if (value !== undefined && value !== null) element.setAttribute(name, value);
42
+ };
43
+
44
+ const addChildren = (parent: Element | DocumentFragment, children: Node[]) => {
45
+ for (const child of children) {
46
+ if (child instanceof Node) {
47
+ parent.appendChild(child);
48
+ } else if (Array.isArray(child)) {
49
+ addChildren(parent, child);
50
+ } else if (typeof child !== 'boolean' && typeof child !== 'undefined' && child !== null) {
51
+ parent.appendChild(document.createTextNode(child));
52
+ }
53
+ }
54
+ };
55
+
56
+ // https://github.com/facebook/react/blob/3f899089/packages/react-dom/src/shared/DOMProperty.js#L288-L322
57
+ const FALSIFIABLE_ATTRIBUTES = ['contentEditable', 'draggable', 'spellCheck', 'value'];
58
+
59
+ export const h = (
60
+ type: DocumentFragmentConstructor | ElementFunction | string,
61
+ attributes?: Attributes,
62
+ ...children: Node[]
63
+ ) => {
64
+ if (typeof type !== 'string') {
65
+ const element = isFragment(type) ? document.createDocumentFragment() : type(attributes);
66
+ addChildren(element, children);
67
+ return element;
68
+ }
69
+
70
+ const element = document.createElement(type);
71
+ addChildren(element, children);
72
+ if (!attributes) return element;
73
+
74
+ for (let [name, value] of Object.entries(attributes)) {
75
+ if (name === 'htmlFor') name = 'for';
76
+
77
+ if (name === 'class' || name === 'className') {
78
+ const existingClassname = element.getAttribute('class') ?? '';
79
+ setAttribute(element, 'class', (existingClassname + ' ' + String(value)).trim());
80
+ } else if (name === 'style') {
81
+ setCSSProps(element, value);
82
+ } else if (name.startsWith('on')) {
83
+ const eventName = name.slice(2).toLowerCase().replace(/^-/, '');
84
+ element.addEventListener(eventName, value);
85
+ } else if (name === 'dangerouslySetInnerHTML' && '__html' in value) {
86
+ element.innerHTML = value.__html;
87
+ } else if (name !== 'key' && (FALSIFIABLE_ATTRIBUTES.includes(name) || value !== false)) {
88
+ setAttribute(element, name, value === true ? '' : value);
89
+ }
90
+ }
91
+
92
+ return element;
93
+ };
94
+
95
+ export const Fragment =
96
+ (typeof DocumentFragment === 'function' ? DocumentFragment : () => {}) as Fragment;
@@ -0,0 +1,351 @@
1
+ #content {
2
+ font-family: "Roboto", "Helvetica Neue", "Helvetica", "Arial", sans-serif;
3
+ margin: 4em auto;
4
+ max-width: 1300px;
5
+ line-height: 1.4em;
6
+ --hp-bar: 151px;
7
+ --hp-text: 32px;
8
+ --radius: 10px;
9
+ }
10
+ details > summary {
11
+ list-style: none;
12
+ }
13
+ details > summary::-webkit-details-marker {
14
+ display: none;
15
+ }
16
+ .battle > .details {
17
+ background: #eee;
18
+ border-bottom: 3px solid black;
19
+ border-radius: var(--radius) var(--radius) 0 0;
20
+ padding: 0 1em;
21
+ display: flex;
22
+ justify-content: space-between;
23
+ }
24
+ .inner {
25
+ display: flex;
26
+ justify-content: center;
27
+ flex-direction: column;
28
+ }
29
+ .side > .details {
30
+ padding: 0.5em 1em;
31
+ display: flex;
32
+ justify-content: space-between;
33
+ text-align: center;
34
+ flex: 0 1 auto;
35
+ }
36
+ .active {
37
+ flex: 1 1 auto;
38
+ }
39
+ details {
40
+ flex: 0 1 auto;
41
+ }
42
+ .sides {
43
+ display: flex;
44
+ }
45
+ .side {
46
+ flex: 1;
47
+ display: flex;
48
+ flex-flow: column;
49
+ }
50
+ .side.p1 {
51
+ border-right: 1px solid black;
52
+ }
53
+ .battle {
54
+ border: 3px solid black;
55
+ border-radius: var(--radius);
56
+ }
57
+ summary {
58
+ border-top: 1px solid #eee;
59
+ text-align: center;
60
+ padding: 0.25em;
61
+ }
62
+ .good {
63
+ color: green;
64
+ }
65
+ .bad {
66
+ color: red;
67
+ }
68
+ .pokemon {
69
+ position: relative;
70
+ padding: 0.5em 1em;
71
+ border-top: 1px solid black;
72
+ display: flex;
73
+ }
74
+ .active > .pokemon {
75
+ border-top: 1px solid #eee;
76
+ }
77
+ table {
78
+ border-collapse: collapse;
79
+ border-style: hidden;
80
+ border-spacing: 0px;
81
+ line-height: 1.5em;
82
+ }
83
+ th, td {
84
+ border: 1px solid black;
85
+ padding: 0 0.5em;
86
+ }
87
+ .statbar {
88
+ display: none;
89
+ width: calc(var(--hp-bar) + var(--hp-text));
90
+ padding: 2px 0;
91
+ line-height: normal;
92
+ }
93
+ .statbar .name {
94
+ display: block;
95
+ text-align: center;
96
+ line-height: 1.25em;
97
+ }
98
+ .statbar strong {
99
+ color: #222222;
100
+ text-shadow:
101
+ #FFFFFF 1px 1px 0, #FFFFFF 1px -1px 0,
102
+ #FFFFFF -1px 1px 0, #FFFFFF -1px -1px 0;
103
+ }
104
+ .statbar strong small {
105
+ font-weight: normal;
106
+ }
107
+ .statbar .hpbar {
108
+ position: relative;
109
+ border: 1px solid #777777;
110
+ background: #FCFEFF;
111
+ padding: 1px;
112
+ height: 8px;
113
+ margin: 0 0 0 0;
114
+ width: calc(var(--hp-bar) + var(--hp-text) + 1px);
115
+ border-radius: 4px;
116
+ }
117
+ .statbar .hpbar .hp {
118
+ height: 4px;
119
+ border-top: 2px solid #00dd60;
120
+ background: #00bb51;
121
+ border-bottom: 2px solid #007734;
122
+ border-right: 1px solid #007734;
123
+ border-radius: 3px;
124
+ }
125
+ .statbar .hpbar .hp-yellow {
126
+ border-top-color: #f8e379;
127
+ background-color: #f5d538;
128
+ border-bottom-color: #be9f0a;
129
+ border-right-color: #be9f0a;
130
+ }
131
+ .statbar .hpbar .hp-red {
132
+ border-top-color: #f37f67;
133
+ background-color: #ee4928;
134
+ border-bottom-color: #a3260d;
135
+ border-right-color: #a3260d;
136
+ }
137
+ .statbar .hpbar .prevhp {
138
+ background: #BBEECC;
139
+ height: 8px;
140
+ border-radius: 3px;
141
+ }
142
+ .statbar .hpbar .prevhp-yellow {
143
+ background-color: #fcf4ca;
144
+ }
145
+ .statbar .hpbar .prevhp-red {
146
+ background-color: #facec5;
147
+ }
148
+ .statbar .hpbar .hptext {
149
+ position: absolute;
150
+ background: #777777;
151
+ color: #EEEEEE;
152
+ text-shadow: #000000 0 1px 0;
153
+ font-size: 10px;
154
+ width: 32px;
155
+ height: 12px;
156
+ top: -1px;
157
+ text-align: center;
158
+ }
159
+ .status, .volatile {
160
+ padding: 0px 1px;
161
+ border: 1px solid #FF4400;
162
+ border-radius: 3px;
163
+ }
164
+ .status {
165
+ min-height: 10px;
166
+ font-size: 7pt;
167
+ vertical-align: middle;
168
+ padding: 1px 2px;
169
+ border: 0;
170
+ border-radius: 3px;
171
+ text-transform: uppercase;
172
+ margin: 0 2px;
173
+ }
174
+ .status.brn {
175
+ background: #EE5533;
176
+ color: #FFFFFF;
177
+ }
178
+ .status.psn {
179
+ background: #A4009A;
180
+ color: #FFFFFF;
181
+ }
182
+ .status.par {
183
+ background: #9AA400;
184
+ color: #FFFFFF;
185
+ }
186
+ .status.slp {
187
+ background: #AA77AA;
188
+ color: #FFFFFF;
189
+ }
190
+ .status.frz {
191
+ background: #009AA4;
192
+ color: #FFFFFF;
193
+ }
194
+ .volatile {
195
+ display: inline-block;
196
+ padding: 0 5px;
197
+ margin: 2px
198
+ }
199
+ .volatile.bad {
200
+ background: #FFE5E0;
201
+ color: #FF4400;
202
+ border-color: #FF4400;
203
+ }
204
+ .volatile.good {
205
+ background: #E5FFE0;
206
+ color: #33AA00;
207
+ border-color: #33AA00;
208
+ }
209
+ .volatile.neutral {
210
+ background: #F0F0F0;
211
+ color: #555555;
212
+ border-color: #555555;
213
+ }
214
+ .rstatbar .hpbar .hptext {
215
+ right: 0px;
216
+ border-radius: 0 4px 4px 0;
217
+ }
218
+ .moves ul {
219
+ display: grid;
220
+ grid-template-columns: repeat(2, auto);
221
+ gap: 0 2em;
222
+ }
223
+ .left {
224
+ padding-right: 32px;
225
+ display: flex;
226
+ flex-direction: column;
227
+ align-items: center;
228
+ }
229
+ .stats {
230
+ display: flex;
231
+ padding: 0 1em;
232
+ justify-content: space-between;
233
+ text-align: center;
234
+ width: 100%;
235
+ }
236
+ .types {
237
+ display: inherit;
238
+ }
239
+ .disabled {
240
+ color: #AAAAAA;
241
+ }
242
+ .log {
243
+ display: flex;
244
+ justify-content: center;
245
+ padding-bottom: 2em;
246
+ }
247
+ .position {
248
+ position: absolute;
249
+ right: 10px;
250
+ color: #AAAAAA;
251
+ }
252
+ .left .position {
253
+ display: none;
254
+ }
255
+ .right .position {
256
+ display: block;
257
+ }
258
+ .teamicons {
259
+ display: inline-block;
260
+ }
261
+ @media(max-width: 1300px) {
262
+ #content {
263
+ font-size: 0.85em;
264
+ max-width: 95%;
265
+ margin: 2em auto;
266
+ }
267
+ }
268
+ @media(max-width: 1200px) {
269
+ .moves ul {
270
+ grid-template-columns: repeat(1, auto);
271
+ }
272
+ }
273
+ @media(max-width: 1100px) {
274
+ .pokemon {
275
+ flex-direction: column;
276
+ }
277
+ .stats {
278
+ justify-content: center;
279
+ padding: 0;
280
+ }
281
+ .boosts {
282
+ margin-left: 5px;
283
+ }
284
+ .moves ul {
285
+ grid-template-columns: repeat(2, auto);
286
+ }
287
+ .left {
288
+ padding-right: 0;
289
+ }
290
+ .right {
291
+ padding-top: 1em;
292
+ }
293
+ .volatiles {
294
+ display: flex;
295
+ justify-content: center;
296
+ flex-wrap: wrap;
297
+ }
298
+ .left .position {
299
+ display: block;
300
+ }
301
+ .right .position {
302
+ display: none;
303
+ }
304
+ }
305
+ @media(max-width: 800px) {
306
+ .moves {
307
+ display: flex;
308
+ justify-content: center;
309
+ }
310
+ .moves ul {
311
+ display: inline-block;
312
+ padding: 0;
313
+ }
314
+ }
315
+ @media(max-width: 680px) {
316
+ .stats {
317
+ flex-direction: column;
318
+ padding: 0;
319
+ }
320
+ .boosts {
321
+ display: flex;
322
+ justify-content: space-between;
323
+ margin-top: 0.5em;
324
+ }
325
+ }
326
+ @media(max-width: 550px) {
327
+ #content {
328
+ font-size: 0.65em;
329
+ max-width: 95%;
330
+ margin: 1em auto;
331
+ --hp-bar: 101px;
332
+ }
333
+ }
334
+ @media(max-width: 425px) {
335
+ .stats {
336
+ font-size: 0.9em;
337
+ }
338
+ }
339
+ h1 {
340
+ text-align: center;
341
+ }
342
+ .error {
343
+ overflow: auto;
344
+ scrollbar-width: none;
345
+ padding: 10px 20px;
346
+ border: 3px solid #DD4422;
347
+ background: #FFF8F2;
348
+ }
349
+ .error::-webkit-scrollbar {
350
+ display: none;
351
+ }