@pkmn/engine 0.1.0-dev.5ea92492 → 0.1.0-dev.6195e056
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 +2 -30
- package/build/pkg/data.d.ts +2 -1
- package/build/pkg/data.js +5 -3
- package/build/pkg/data.js.map +1 -1
- package/build/pkg/index.d.ts +1 -1
- package/build/pkg/index.js +1 -1
- package/build/pkg/index.js.map +1 -1
- package/build/pkg/protocol.js +1 -1
- package/build/pkg/protocol.js.map +1 -1
- package/build.zig +12 -9
- package/package.json +25 -36
- package/src/bin/install-pkmn-engine +30 -57
- package/src/lib/gen1/README.md +24 -38
- package/src/lib/gen1/data.zig +2 -3
- package/src/lib/gen1/helpers.zig +4 -0
- package/src/lib/gen1/mechanics.zig +2193 -2345
- package/build/pkg/addon.d.ts +0 -7
- package/build/pkg/addon.js +0 -111
- package/build/pkg/addon.js.map +0 -1
- package/build/test/display.js +0 -382
- package/build/test/display.js.map +0 -1
- package/build/tools/debug.js +0 -133
- package/build/tools/debug.js.map +0 -1
- package/src/bin/pkmn-debug +0 -62
- package/src/lib/common/debug.zig +0 -64
- package/src/test/display/pkmn.html.tmpl +0 -368
package/build/tools/debug.js
DELETED
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.run = exports.display = void 0;
|
|
27
|
-
const fs = __importStar(require("fs"));
|
|
28
|
-
const data_1 = require("@pkmn/data");
|
|
29
|
-
const pkg_1 = require("../pkg");
|
|
30
|
-
const addon = __importStar(require("../pkg/addon"));
|
|
31
|
-
const data_2 = require("../pkg/data");
|
|
32
|
-
const gen1 = __importStar(require("../pkg/gen1"));
|
|
33
|
-
const display_1 = require("../test/display");
|
|
34
|
-
class SpeciesNames {
|
|
35
|
-
gen;
|
|
36
|
-
battle;
|
|
37
|
-
constructor(gen, battle) {
|
|
38
|
-
this.gen = gen;
|
|
39
|
-
this.battle = battle;
|
|
40
|
-
}
|
|
41
|
-
get p1() {
|
|
42
|
-
const [p1] = Array.from(this.battle.sides);
|
|
43
|
-
const team = Array.from(p1.pokemon)
|
|
44
|
-
.sort((a, b) => a.position - b.position)
|
|
45
|
-
.map(p => ({ species: p.stored.species }));
|
|
46
|
-
return new pkg_1.SideInfo(this.gen, { name: 'Player 1', team });
|
|
47
|
-
}
|
|
48
|
-
get p2() {
|
|
49
|
-
const [, p2] = Array.from(this.battle.sides);
|
|
50
|
-
const team = Array.from(p2.pokemon)
|
|
51
|
-
.sort((a, b) => a.position - b.position)
|
|
52
|
-
.map(p => ({ species: p.stored.species }));
|
|
53
|
-
return new pkg_1.SideInfo(this.gen, { name: 'Player 2', team });
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
function display(gens, data, error, seed) {
|
|
57
|
-
if (!data.length)
|
|
58
|
-
throw new Error('Invalid input');
|
|
59
|
-
const view = data_2.Data.view(data);
|
|
60
|
-
let offset = 0;
|
|
61
|
-
const showdown = !!view.getUint8(offset++);
|
|
62
|
-
const gen = gens.get(view.getUint8(offset++));
|
|
63
|
-
const lookup = data_2.Lookup.get(gen);
|
|
64
|
-
const size = data_2.LAYOUT[gen.num - 1].sizes.Battle;
|
|
65
|
-
const deserialize = (buf) => {
|
|
66
|
-
// We don't care about the native addon, we just need to load it so other checks don't fail
|
|
67
|
-
void addon.supports(true);
|
|
68
|
-
switch (gen.num) {
|
|
69
|
-
case 1: return new gen1.Battle(lookup, data_2.Data.view(buf), { showdown });
|
|
70
|
-
default: throw new Error(`Unsupported gen: ${gen.num}`);
|
|
71
|
-
}
|
|
72
|
-
};
|
|
73
|
-
const battle = deserialize(data.subarray(offset, offset += size));
|
|
74
|
-
const names = new SpeciesNames(gen, battle);
|
|
75
|
-
const log = new pkg_1.Log(gen, lookup, names);
|
|
76
|
-
let partial = undefined;
|
|
77
|
-
const frames = [];
|
|
78
|
-
while (offset < view.byteLength) {
|
|
79
|
-
partial = { parsed: [] };
|
|
80
|
-
const it = log.parse(data_2.Data.view(data.subarray(offset)))[Symbol.iterator]();
|
|
81
|
-
let r = it.next();
|
|
82
|
-
while (!r.done) {
|
|
83
|
-
partial.parsed.push(r.value);
|
|
84
|
-
r = it.next();
|
|
85
|
-
}
|
|
86
|
-
offset += r.value;
|
|
87
|
-
if (offset >= view.byteLength)
|
|
88
|
-
break;
|
|
89
|
-
partial.battle = deserialize(data.subarray(offset, offset += size));
|
|
90
|
-
if (offset >= view.byteLength)
|
|
91
|
-
break;
|
|
92
|
-
partial.result = pkg_1.Result.decode(data[offset++]);
|
|
93
|
-
if (offset >= view.byteLength)
|
|
94
|
-
break;
|
|
95
|
-
partial.c1 = pkg_1.Choice.decode(data[offset++]);
|
|
96
|
-
if (offset >= view.byteLength)
|
|
97
|
-
break;
|
|
98
|
-
partial.c2 = pkg_1.Choice.decode(data[offset++]);
|
|
99
|
-
frames.push(partial);
|
|
100
|
-
partial = undefined;
|
|
101
|
-
}
|
|
102
|
-
return (0, display_1.render)(gen, showdown, error, seed, frames, partial);
|
|
103
|
-
}
|
|
104
|
-
exports.display = display;
|
|
105
|
-
async function run(gens) {
|
|
106
|
-
let input;
|
|
107
|
-
if (process.argv.length > 2) {
|
|
108
|
-
if (process.argv.length > 3) {
|
|
109
|
-
console.error('Invalid input');
|
|
110
|
-
process.exit(1);
|
|
111
|
-
}
|
|
112
|
-
input = fs.readFileSync(process.argv[2]);
|
|
113
|
-
}
|
|
114
|
-
else {
|
|
115
|
-
let length = 0;
|
|
116
|
-
const result = [];
|
|
117
|
-
for await (const chunk of process.stdin) {
|
|
118
|
-
result.push(chunk);
|
|
119
|
-
length += chunk.length;
|
|
120
|
-
}
|
|
121
|
-
input = Buffer.concat(result, length);
|
|
122
|
-
}
|
|
123
|
-
process.stdout.write(display(gens, input));
|
|
124
|
-
}
|
|
125
|
-
exports.run = run;
|
|
126
|
-
if (require.main === module) {
|
|
127
|
-
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
128
|
-
run(new data_1.Generations(require('@pkmn/sim').Dex)).catch(err => {
|
|
129
|
-
console.error(err.message);
|
|
130
|
-
process.exit(1);
|
|
131
|
-
});
|
|
132
|
-
}
|
|
133
|
-
//# sourceMappingURL=debug.js.map
|
package/build/tools/debug.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"debug.js","sourceRoot":"","sources":["../../src/tools/debug.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAyB;AAEzB,qCAAmD;AAEnD,gCAAmE;AACnE,oDAAsC;AACtC,sCAAiD;AACjD,kDAAoC;AACpC,6CAA8C;AAE9C,MAAM,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AG,CAAC,IAAI,kBAAW,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE;QACzD,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QAC3B,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC,CAAC,CAAC;CACJ"}
|
package/src/bin/pkmn-debug
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
'use strict';
|
|
3
|
-
|
|
4
|
-
try {
|
|
5
|
-
require('source-map-support').install();
|
|
6
|
-
} catch (err) {
|
|
7
|
-
if (err.code !== 'MODULE_NOT_FOUND') throw err;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
const {execFileSync} = require('child_process');
|
|
11
|
-
const {readFileSync} = require('fs');
|
|
12
|
-
const {join, resolve} = require('path');
|
|
13
|
-
|
|
14
|
-
const ROOT = resolve(__dirname, '..', '..');
|
|
15
|
-
const packageJSON = JSON.parse(readFileSync(join(ROOT, 'package.json'), 'utf8'));
|
|
16
|
-
|
|
17
|
-
const missing = [];
|
|
18
|
-
for (const dep of ['@pkmn/img', 'html-minifier', 'mustache']) {
|
|
19
|
-
try {
|
|
20
|
-
require.resolve(dep);
|
|
21
|
-
} catch (e) {
|
|
22
|
-
if (e.code !== 'MODULE_NOT_FOUND') throw e;
|
|
23
|
-
missing.push(`${dep}@${packageJSON.devDependencies[dep]}`);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
let Dex = undefined;
|
|
28
|
-
try {
|
|
29
|
-
Dex = require('@pkmn/sim').Dex;
|
|
30
|
-
} catch (err) {
|
|
31
|
-
if (err.code !== 'MODULE_NOT_FOUND') throw err;
|
|
32
|
-
try {
|
|
33
|
-
Dex = require('@pkmn/dex').Dex;
|
|
34
|
-
} catch (e) {
|
|
35
|
-
if (e.code !== 'MODULE_NOT_FOUND') throw e;
|
|
36
|
-
missing.push(`@pkmn/dex@${packageJSON.dependencies['@pkmn/data']}`);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
if (missing.length) {
|
|
41
|
-
if (+/^v(\d+)/.exec(process.version)[1] < 16) {
|
|
42
|
-
console.error('pkmn-debug requires Node v16+');
|
|
43
|
-
process.exit(1);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
execFileSync('npm', ['install', ...missing, '--global'], {encoding: 'utf8'});
|
|
47
|
-
|
|
48
|
-
const node_modules = execFileSync('npm', ['root', '--global'], {encoding: 'utf8'}).trim();
|
|
49
|
-
if (!process.env.NODE_PATH || !process.env.NODE_PATH.includes(node_modules)) {
|
|
50
|
-
console.error(`NODE_PATH must include npm's global node_modules directory: '${node_modules}'`);
|
|
51
|
-
process.exit(1);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
const {Generations} = require('@pkmn/data');
|
|
56
|
-
|
|
57
|
-
const {run} = require('../../build/tools/debug');
|
|
58
|
-
|
|
59
|
-
run(new Generations(Dex)).catch(err => {
|
|
60
|
-
console.error(err.message);
|
|
61
|
-
process.exit(1);
|
|
62
|
-
});
|
package/src/lib/common/debug.zig
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
const std = @import("std");
|
|
2
|
-
|
|
3
|
-
const debug = std.debug;
|
|
4
|
-
const io = std.io;
|
|
5
|
-
|
|
6
|
-
pub fn print(value: anytype) void {
|
|
7
|
-
debug.getStderrMutex().lock();
|
|
8
|
-
defer debug.getStderrMutex().unlock();
|
|
9
|
-
const stderr = io.getStdErr().writer();
|
|
10
|
-
|
|
11
|
-
nosuspend {
|
|
12
|
-
stderr.writeAll("\x1b[41m") catch return;
|
|
13
|
-
switch (@typeInfo(@TypeOf(value))) {
|
|
14
|
-
.Struct => |info| {
|
|
15
|
-
if (info.is_tuple) {
|
|
16
|
-
inline for (info.fields, 0..) |f, i| {
|
|
17
|
-
inspect(@field(value, f.name));
|
|
18
|
-
if (i < info.fields.len - 1) stderr.writeAll(" ") catch return;
|
|
19
|
-
}
|
|
20
|
-
} else {
|
|
21
|
-
inspect(value);
|
|
22
|
-
}
|
|
23
|
-
},
|
|
24
|
-
else => inspect(value),
|
|
25
|
-
}
|
|
26
|
-
stderr.writeAll("\x1b[K\x1b[0m\n") catch return;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
fn inspect(value: anytype) void {
|
|
31
|
-
const stderr = io.getStdErr().writer();
|
|
32
|
-
|
|
33
|
-
nosuspend {
|
|
34
|
-
const err = "Unable to format type '" ++ @typeName(@TypeOf(value)) ++ "'";
|
|
35
|
-
switch (@typeInfo(@TypeOf(value))) {
|
|
36
|
-
.Array => |info| {
|
|
37
|
-
if (info.child == u8) return stderr.print("{s}", .{value}) catch return;
|
|
38
|
-
@compileError(err);
|
|
39
|
-
},
|
|
40
|
-
.Pointer => |ptr_info| switch (ptr_info.size) {
|
|
41
|
-
.One => switch (@typeInfo(ptr_info.child)) {
|
|
42
|
-
.Array => |info| {
|
|
43
|
-
if (info.child == u8) return stderr.print("{s}", .{value}) catch return;
|
|
44
|
-
@compileError(err);
|
|
45
|
-
},
|
|
46
|
-
.Enum, .Union, .Struct => return inspect(value.*),
|
|
47
|
-
else => @compileError(err),
|
|
48
|
-
},
|
|
49
|
-
.Many, .C => {
|
|
50
|
-
if (ptr_info.sentinel) |_| return inspect(std.mem.span(value));
|
|
51
|
-
if (ptr_info.child == u8) {
|
|
52
|
-
return stderr.print("{s}", .{std.mem.span(value)}) catch return;
|
|
53
|
-
}
|
|
54
|
-
@compileError(err);
|
|
55
|
-
},
|
|
56
|
-
.Slice => {
|
|
57
|
-
if (ptr_info.child == u8) return stderr.print("{s}", .{value}) catch return;
|
|
58
|
-
@compileError(err);
|
|
59
|
-
},
|
|
60
|
-
},
|
|
61
|
-
else => stderr.print("{}", .{value}) catch return,
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
}
|
|
@@ -1,368 +0,0 @@
|
|
|
1
|
-
<!doctype html>
|
|
2
|
-
<html lang=en>
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="utf-8">
|
|
5
|
-
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
6
|
-
<link rel="icon" href="https://pkmn.cc/favicon.ico">
|
|
7
|
-
<title>@pkmn/engine</title>
|
|
8
|
-
<style>
|
|
9
|
-
#content {
|
|
10
|
-
font-family: "Roboto", "Helvetica Neue", "Helvetica", "Arial", sans-serif;
|
|
11
|
-
margin: 4em auto;
|
|
12
|
-
max-width: 1300px;
|
|
13
|
-
line-height: 1.4em;
|
|
14
|
-
--hp-bar: 151px;
|
|
15
|
-
--hp-text: 32px;
|
|
16
|
-
}
|
|
17
|
-
details > summary {
|
|
18
|
-
list-style: none;
|
|
19
|
-
}
|
|
20
|
-
details > summary::-webkit-details-marker {
|
|
21
|
-
display: none;
|
|
22
|
-
}
|
|
23
|
-
.battle > .details {
|
|
24
|
-
background: #eee;
|
|
25
|
-
border-bottom: 3px solid black;
|
|
26
|
-
padding: 0 0.5em;
|
|
27
|
-
display: flex;
|
|
28
|
-
justify-content: space-between;
|
|
29
|
-
}
|
|
30
|
-
.inner {
|
|
31
|
-
display: flex;
|
|
32
|
-
justify-content: center;
|
|
33
|
-
flex-direction: column;
|
|
34
|
-
}
|
|
35
|
-
.side > .details {
|
|
36
|
-
padding: 0.5em;
|
|
37
|
-
display: flex;
|
|
38
|
-
justify-content: space-between;
|
|
39
|
-
text-align: center;
|
|
40
|
-
flex: 0 1 auto;
|
|
41
|
-
}
|
|
42
|
-
.active {
|
|
43
|
-
flex: 1 1 auto;
|
|
44
|
-
}
|
|
45
|
-
details {
|
|
46
|
-
flex: 0 1 auto;
|
|
47
|
-
}
|
|
48
|
-
.sides {
|
|
49
|
-
display: flex;
|
|
50
|
-
}
|
|
51
|
-
.side {
|
|
52
|
-
flex: 1;
|
|
53
|
-
display: flex;
|
|
54
|
-
flex-flow: column;
|
|
55
|
-
}
|
|
56
|
-
.side.p1 {
|
|
57
|
-
border-right: 1px solid black;
|
|
58
|
-
}
|
|
59
|
-
.battle {
|
|
60
|
-
border: 3px solid black;
|
|
61
|
-
}
|
|
62
|
-
summary {
|
|
63
|
-
border-top: 1px solid black;
|
|
64
|
-
text-align: center;
|
|
65
|
-
padding: 0.25em;
|
|
66
|
-
}
|
|
67
|
-
.good {
|
|
68
|
-
color: green;
|
|
69
|
-
}
|
|
70
|
-
.bad {
|
|
71
|
-
color: red;
|
|
72
|
-
}
|
|
73
|
-
.pokemon {
|
|
74
|
-
position: relative;
|
|
75
|
-
padding: 0.5em;
|
|
76
|
-
border-top: 1px solid black;
|
|
77
|
-
display: flex;
|
|
78
|
-
}
|
|
79
|
-
table {
|
|
80
|
-
border-collapse: collapse;
|
|
81
|
-
border-style: hidden;
|
|
82
|
-
border-spacing: 0px;
|
|
83
|
-
line-height: 1.5em;
|
|
84
|
-
}
|
|
85
|
-
th, td {
|
|
86
|
-
border: 1px solid black;
|
|
87
|
-
padding: 0 0.5em;
|
|
88
|
-
}
|
|
89
|
-
.statbar {
|
|
90
|
-
display: none;
|
|
91
|
-
width: calc(var(--hp-bar) + var(--hp-text));
|
|
92
|
-
padding: 2px 0;
|
|
93
|
-
line-height: normal;
|
|
94
|
-
}
|
|
95
|
-
.statbar .name {
|
|
96
|
-
display: block;
|
|
97
|
-
text-align: center;
|
|
98
|
-
line-height: 1.25em;
|
|
99
|
-
}
|
|
100
|
-
.statbar strong {
|
|
101
|
-
color: #222222;
|
|
102
|
-
text-shadow:
|
|
103
|
-
#FFFFFF 1px 1px 0, #FFFFFF 1px -1px 0,
|
|
104
|
-
#FFFFFF -1px 1px 0, #FFFFFF -1px -1px 0;
|
|
105
|
-
}
|
|
106
|
-
.statbar strong small {
|
|
107
|
-
font-weight: normal;
|
|
108
|
-
}
|
|
109
|
-
.statbar .hpbar {
|
|
110
|
-
position: relative;
|
|
111
|
-
border: 1px solid #777777;
|
|
112
|
-
background: #FCFEFF;
|
|
113
|
-
padding: 1px;
|
|
114
|
-
height: 8px;
|
|
115
|
-
margin: 0 0 0 0;
|
|
116
|
-
width: calc(var(--hp-bar) + var(--hp-text) + 1px);
|
|
117
|
-
border-radius: 4px;
|
|
118
|
-
}
|
|
119
|
-
.statbar .hpbar .hp {
|
|
120
|
-
height: 4px;
|
|
121
|
-
border-top: 2px solid #00dd60;
|
|
122
|
-
background: #00bb51;
|
|
123
|
-
border-bottom: 2px solid #007734;
|
|
124
|
-
border-right: 1px solid #007734;
|
|
125
|
-
border-radius: 3px;
|
|
126
|
-
}
|
|
127
|
-
.statbar .hpbar .hp-yellow {
|
|
128
|
-
border-top-color: #f8e379;
|
|
129
|
-
background-color: #f5d538;
|
|
130
|
-
border-bottom-color: #be9f0a;
|
|
131
|
-
border-right-color: #be9f0a;
|
|
132
|
-
}
|
|
133
|
-
.statbar .hpbar .hp-red {
|
|
134
|
-
border-top-color: #f37f67;
|
|
135
|
-
background-color: #ee4928;
|
|
136
|
-
border-bottom-color: #a3260d;
|
|
137
|
-
border-right-color: #a3260d;
|
|
138
|
-
}
|
|
139
|
-
.statbar .hpbar .prevhp {
|
|
140
|
-
background: #BBEECC;
|
|
141
|
-
height: 8px;
|
|
142
|
-
border-radius: 3px;
|
|
143
|
-
}
|
|
144
|
-
.statbar .hpbar .prevhp-yellow {
|
|
145
|
-
background-color: #fcf4ca;
|
|
146
|
-
}
|
|
147
|
-
.statbar .hpbar .prevhp-red {
|
|
148
|
-
background-color: #facec5;
|
|
149
|
-
}
|
|
150
|
-
.statbar .hpbar .hptext {
|
|
151
|
-
position: absolute;
|
|
152
|
-
background: #777777;
|
|
153
|
-
color: #EEEEEE;
|
|
154
|
-
text-shadow: #000000 0 1px 0;
|
|
155
|
-
font-size: 10px;
|
|
156
|
-
width: 32px;
|
|
157
|
-
height: 12px;
|
|
158
|
-
top: -1px;
|
|
159
|
-
text-align: center;
|
|
160
|
-
}
|
|
161
|
-
.status, .volatile {
|
|
162
|
-
padding: 0px 1px;
|
|
163
|
-
border: 1px solid #FF4400;
|
|
164
|
-
border-radius: 3px;
|
|
165
|
-
}
|
|
166
|
-
.status {
|
|
167
|
-
min-height: 10px;
|
|
168
|
-
font-size: 7pt;
|
|
169
|
-
vertical-align: middle;
|
|
170
|
-
padding: 1px 2px;
|
|
171
|
-
border: 0;
|
|
172
|
-
border-radius: 3px;
|
|
173
|
-
text-transform: uppercase;
|
|
174
|
-
margin: 0 2px;
|
|
175
|
-
}
|
|
176
|
-
.status.brn {
|
|
177
|
-
background: #EE5533;
|
|
178
|
-
color: #FFFFFF;
|
|
179
|
-
}
|
|
180
|
-
.status.psn {
|
|
181
|
-
background: #A4009A;
|
|
182
|
-
color: #FFFFFF;
|
|
183
|
-
}
|
|
184
|
-
.status.par {
|
|
185
|
-
background: #9AA400;
|
|
186
|
-
color: #FFFFFF;
|
|
187
|
-
}
|
|
188
|
-
.status.slp {
|
|
189
|
-
background: #AA77AA;
|
|
190
|
-
color: #FFFFFF;
|
|
191
|
-
}
|
|
192
|
-
.status.frz {
|
|
193
|
-
background: #009AA4;
|
|
194
|
-
color: #FFFFFF;
|
|
195
|
-
}
|
|
196
|
-
.volatile {
|
|
197
|
-
display: inline-block;
|
|
198
|
-
padding: 0 5px;
|
|
199
|
-
margin: 2px
|
|
200
|
-
}
|
|
201
|
-
.volatile.bad {
|
|
202
|
-
background: #FFE5E0;
|
|
203
|
-
color: #FF4400;
|
|
204
|
-
border-color: #FF4400;
|
|
205
|
-
}
|
|
206
|
-
.volatile.good {
|
|
207
|
-
background: #E5FFE0;
|
|
208
|
-
color: #33AA00;
|
|
209
|
-
border-color: #33AA00;
|
|
210
|
-
}
|
|
211
|
-
.volatile.neutral {
|
|
212
|
-
background: #F0F0F0;
|
|
213
|
-
color: #555555;
|
|
214
|
-
border-color: #555555;
|
|
215
|
-
}
|
|
216
|
-
.rstatbar .hpbar .hptext {
|
|
217
|
-
right: 0px;
|
|
218
|
-
border-radius: 0 4px 4px 0;
|
|
219
|
-
}
|
|
220
|
-
.moves ul {
|
|
221
|
-
column-count: 2;
|
|
222
|
-
column-gap: 2em;
|
|
223
|
-
}
|
|
224
|
-
.left {
|
|
225
|
-
padding-right: 32px;
|
|
226
|
-
display: flex;
|
|
227
|
-
flex-direction: column;
|
|
228
|
-
align-items: center;
|
|
229
|
-
}
|
|
230
|
-
.stats {
|
|
231
|
-
display: flex;
|
|
232
|
-
padding: 0 1em;
|
|
233
|
-
justify-content: space-between;
|
|
234
|
-
text-align: center;
|
|
235
|
-
width: 100%;
|
|
236
|
-
}
|
|
237
|
-
.types {
|
|
238
|
-
display: inherit;
|
|
239
|
-
}
|
|
240
|
-
.disabled {
|
|
241
|
-
color: #AAAAAA;
|
|
242
|
-
}
|
|
243
|
-
.log {
|
|
244
|
-
display: flex;
|
|
245
|
-
justify-content: center;
|
|
246
|
-
padding-bottom: 2em;
|
|
247
|
-
}
|
|
248
|
-
.position {
|
|
249
|
-
position: absolute;
|
|
250
|
-
right: 10px;
|
|
251
|
-
color: #AAAAAA;
|
|
252
|
-
}
|
|
253
|
-
.left .position {
|
|
254
|
-
display: none;
|
|
255
|
-
}
|
|
256
|
-
.right .position {
|
|
257
|
-
display: block;
|
|
258
|
-
}
|
|
259
|
-
.teamicons {
|
|
260
|
-
display: inline-block;
|
|
261
|
-
}
|
|
262
|
-
@media(max-width: 1300px) {
|
|
263
|
-
#content {
|
|
264
|
-
font-size: 0.85em;
|
|
265
|
-
max-width: 95%;
|
|
266
|
-
margin: 2em auto;
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
@media(max-width: 1200px) {
|
|
270
|
-
.moves ul {
|
|
271
|
-
column-count: 1;
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
@media(max-width: 1100px) {
|
|
275
|
-
.pokemon {
|
|
276
|
-
flex-direction: column;
|
|
277
|
-
}
|
|
278
|
-
.stats {
|
|
279
|
-
justify-content: center;
|
|
280
|
-
padding: 0;
|
|
281
|
-
}
|
|
282
|
-
.boosts {
|
|
283
|
-
margin-left: 5px;
|
|
284
|
-
}
|
|
285
|
-
.moves ul {
|
|
286
|
-
column-count: 2;
|
|
287
|
-
}
|
|
288
|
-
.left {
|
|
289
|
-
padding-right: 0;
|
|
290
|
-
}
|
|
291
|
-
.right {
|
|
292
|
-
padding-top: 1em;
|
|
293
|
-
}
|
|
294
|
-
.volatiles {
|
|
295
|
-
display: flex;
|
|
296
|
-
justify-content: center;
|
|
297
|
-
flex-wrap: wrap;
|
|
298
|
-
}
|
|
299
|
-
.left .position {
|
|
300
|
-
display: block;
|
|
301
|
-
}
|
|
302
|
-
.right .position {
|
|
303
|
-
display: none;
|
|
304
|
-
}
|
|
305
|
-
}
|
|
306
|
-
@media(max-width: 800px) {
|
|
307
|
-
.moves {
|
|
308
|
-
display: flex;
|
|
309
|
-
justify-content: center;
|
|
310
|
-
}
|
|
311
|
-
.moves ul {
|
|
312
|
-
column-count: 1;
|
|
313
|
-
display: inline-block;
|
|
314
|
-
padding: 0;
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
@media(max-width: 680px) {
|
|
318
|
-
.stats {
|
|
319
|
-
flex-direction: column;
|
|
320
|
-
padding: 0;
|
|
321
|
-
}
|
|
322
|
-
.boosts {
|
|
323
|
-
display: flex;
|
|
324
|
-
justify-content: space-between;
|
|
325
|
-
margin-top: 0.5em;
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
@media(max-width: 550px) {
|
|
329
|
-
#content {
|
|
330
|
-
font-size: 0.65em;
|
|
331
|
-
max-width: 95%;
|
|
332
|
-
margin: 1em auto;
|
|
333
|
-
--hp-bar: 101px;
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
|
-
@media(max-width: 425px) {
|
|
337
|
-
.stats {
|
|
338
|
-
font-size: 0.9em;
|
|
339
|
-
}
|
|
340
|
-
}
|
|
341
|
-
h1 {
|
|
342
|
-
text-align: center;
|
|
343
|
-
}
|
|
344
|
-
.error {
|
|
345
|
-
overflow: auto;
|
|
346
|
-
scrollbar-width: none;
|
|
347
|
-
padding: 10px 20px;
|
|
348
|
-
border: 3px solid #DD4422;
|
|
349
|
-
background: #FFF8F2;
|
|
350
|
-
}
|
|
351
|
-
.error::-webkit-scrollbar {
|
|
352
|
-
display: none;
|
|
353
|
-
}
|
|
354
|
-
</style>
|
|
355
|
-
</head>
|
|
356
|
-
<body>
|
|
357
|
-
<div id="content">{{{ content }}}</div>
|
|
358
|
-
<script>
|
|
359
|
-
for (const details of document.getElementsByTagName('details')) {
|
|
360
|
-
details.addEventListener('toggle', e => {
|
|
361
|
-
for (const d of details.parentElement.parentElement.getElementsByTagName('details')) {
|
|
362
|
-
if (d.open !== details.open) d.open = details.open;
|
|
363
|
-
}
|
|
364
|
-
});
|
|
365
|
-
}
|
|
366
|
-
</script>
|
|
367
|
-
</body>
|
|
368
|
-
</html>
|