koffing 0.5.0 → 2.0.0
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/LICENSE +2 -2
- package/README.md +64 -151
- package/dist/data-CP51LAc9.cjs +404 -0
- package/dist/data-CRHBhbCJ.js +345 -0
- package/dist/index.cjs +441 -0
- package/dist/index.d.cts +29 -0
- package/dist/index.d.ts +29 -0
- package/dist/index.js +433 -0
- package/dist/types-BVzP_Ko4.d.cts +62 -0
- package/dist/types-BVzP_Ko4.d.ts +62 -0
- package/dist/validator.cjs +3563 -0
- package/dist/validator.d.cts +14 -0
- package/dist/validator.d.ts +14 -0
- package/dist/validator.js +3562 -0
- package/package.json +46 -41
- package/Makefile +0 -21
- package/build/asset-manifest.json +0 -22
- package/build/favicon.png +0 -0
- package/build/index.html +0 -1
- package/build/precache-manifest.5382b78dea2866c8a94cee003da35d84.js +0 -26
- package/build/robots.txt +0 -3
- package/build/service-worker.js +0 -39
- package/build/static/css/main.102b9840.chunk.css +0 -2
- package/build/static/css/main.102b9840.chunk.css.map +0 -1
- package/build/static/js/2.4b3dd85a.chunk.js +0 -3
- package/build/static/js/2.4b3dd85a.chunk.js.LICENSE.txt +0 -67
- package/build/static/js/2.4b3dd85a.chunk.js.map +0 -1
- package/build/static/js/main.07f66bec.chunk.js +0 -2
- package/build/static/js/main.07f66bec.chunk.js.map +0 -1
- package/build/static/js/runtime-main.525bb0ff.js +0 -2
- package/build/static/js/runtime-main.525bb0ff.js.map +0 -1
- package/public/favicon.png +0 -0
- package/public/index.html +0 -30
- package/public/robots.txt +0 -3
- package/src/App.test.js +0 -9
- package/src/components/App.js +0 -18
- package/src/components/AppFooter/AppFooter.css.js +0 -12
- package/src/components/AppFooter/AppFooter.js +0 -31
- package/src/components/AppFooter/index.js +0 -3
- package/src/components/AppHeader/AppHeader.css.js +0 -21
- package/src/components/AppHeader/AppHeader.js +0 -34
- package/src/components/AppHeader/index.js +0 -3
- package/src/components/Board/Board.css.js +0 -21
- package/src/components/Board/Board.js +0 -110
- package/src/components/Board/index.js +0 -3
- package/src/components/BoardInput/BoardInput.css.js +0 -14
- package/src/components/BoardInput/BoardInput.js +0 -36
- package/src/components/BoardInput/index.js +0 -3
- package/src/components/BoardOutput/BoardOutput.css.js +0 -17
- package/src/components/BoardOutput/BoardOutput.js +0 -36
- package/src/components/BoardOutput/index.js +0 -3
- package/src/components/Code/Code.css.js +0 -10
- package/src/components/Code/Code.js +0 -28
- package/src/components/Code/index.js +0 -3
- package/src/components/StyledComponent.js +0 -24
- package/src/components/ThemedApp.js +0 -25
- package/src/core/Koffing.js +0 -71
- package/src/core/Pokemon.js +0 -181
- package/src/core/PokemonTeam.js +0 -78
- package/src/core/PokemonTeamSet.js +0 -52
- package/src/core/ShowdownParser.js +0 -280
- package/src/core/index.js +0 -7
- package/src/img/koffing-shiny.png +0 -0
- package/src/img/koffing.png +0 -0
- package/src/index.css +0 -42
- package/src/index.js +0 -17
- package/src/serviceWorker.js +0 -141
- package/src/setupTests.js +0 -5
- package/src/teams/example.koffing.js +0 -25
- package/src/tools/base64.js +0 -25
- package/src/tools/history.js +0 -17
- package/src/tools/index.js +0 -4
- package/src/variables.json +0 -5
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import PropTypes from "prop-types";
|
|
3
|
-
import Paper from "@material-ui/core/Paper";
|
|
4
|
-
import QRCode from "qrcode.react";
|
|
5
|
-
import Code from "../Code";
|
|
6
|
-
import useStyles from "./BoardOutput.css";
|
|
7
|
-
import logo from "../../img/koffing.png";
|
|
8
|
-
|
|
9
|
-
const qrIconSettings = {
|
|
10
|
-
src: logo,
|
|
11
|
-
height: 48,
|
|
12
|
-
width: 48,
|
|
13
|
-
excavate: true
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
function BoardOutput({qrValue, jsonValue}) {
|
|
17
|
-
const classes = useStyles();
|
|
18
|
-
|
|
19
|
-
return (
|
|
20
|
-
<Paper className={classes.root} elevation={1}>
|
|
21
|
-
<Paper className={classes.qrContainer}>
|
|
22
|
-
<QRCode value={qrValue} size={320} renderAs="canvas" imageSettings={qrIconSettings}/>
|
|
23
|
-
</Paper>
|
|
24
|
-
<Paper className={classes.jsonContainer}>
|
|
25
|
-
<Code code={jsonValue} language={'json'}/>
|
|
26
|
-
</Paper>
|
|
27
|
-
</Paper>
|
|
28
|
-
);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
BoardOutput.propTypes = {
|
|
32
|
-
qrValue: PropTypes.string.isRequired,
|
|
33
|
-
jsonValue: PropTypes.string.isRequired
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export default BoardOutput;
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
import StyledComponent from "../StyledComponent";
|
|
4
|
-
import styles from "./Code.css";
|
|
5
|
-
|
|
6
|
-
class Code extends StyledComponent {
|
|
7
|
-
static propTypes = Object.assign({}, super.propTypes, {
|
|
8
|
-
language: PropTypes.string.isRequired,
|
|
9
|
-
code: PropTypes.string.isRequired,
|
|
10
|
-
})
|
|
11
|
-
|
|
12
|
-
render() {
|
|
13
|
-
const formattedCode = this.props.code;
|
|
14
|
-
const codeClassName = `language-${this.props.language}`;
|
|
15
|
-
const {classes} = this.props;
|
|
16
|
-
return (
|
|
17
|
-
<div className={classes.root}>
|
|
18
|
-
<pre className={classes.pre}>
|
|
19
|
-
<code className={codeClassName}>
|
|
20
|
-
<div dangerouslySetInnerHTML={{__html: formattedCode}}/>
|
|
21
|
-
</code>
|
|
22
|
-
</pre>
|
|
23
|
-
</div>
|
|
24
|
-
);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export default Code.styled(styles);
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import {Component} from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
import {withStyles} from '@material-ui/core/styles';
|
|
4
|
-
// eslint-disable-next-line no-unused-vars
|
|
5
|
-
import {StyledComponentProps} from '@material-ui/styles/withStyles'
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* @link https://material-ui.com/es/styles/basics/#higher-order-component-api
|
|
9
|
-
*/
|
|
10
|
-
class StyledComponent extends Component {
|
|
11
|
-
static propTypes = {
|
|
12
|
-
classes: PropTypes.object.isRequired
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* @param {object} styles
|
|
17
|
-
* @returns {React.ComponentType<any & StyledComponentProps<T>>}
|
|
18
|
-
*/
|
|
19
|
-
static styled(styles) {
|
|
20
|
-
return withStyles(styles)(this);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export default StyledComponent;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import {createMuiTheme, MuiThemeProvider} from '@material-ui/core/styles';
|
|
3
|
-
import App from "./App";
|
|
4
|
-
|
|
5
|
-
const theme = createMuiTheme({
|
|
6
|
-
typography: {
|
|
7
|
-
fontFamily: '"Exo 2","Helvetica Neue",Arial,sans-serif',
|
|
8
|
-
},
|
|
9
|
-
palette: {
|
|
10
|
-
primary: {main: '#6B71B8'},
|
|
11
|
-
secondary: {main: '#F6F79D'},
|
|
12
|
-
},
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const ThemedApp = () => (
|
|
17
|
-
<div className="koffing-app-container">
|
|
18
|
-
{/*<CssBaseline/>*//* MUI adds the reset at the end, which is not what we want*/}
|
|
19
|
-
<MuiThemeProvider theme={theme}>
|
|
20
|
-
<App/>
|
|
21
|
-
</MuiThemeProvider>
|
|
22
|
-
</div>
|
|
23
|
-
);
|
|
24
|
-
|
|
25
|
-
export default ThemedApp;
|
package/src/core/Koffing.js
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import Pokemon from "./Pokemon";
|
|
2
|
-
import PokemonTeam from "./PokemonTeam";
|
|
3
|
-
import PokemonTeamSet from "./PokemonTeamSet";
|
|
4
|
-
import ShowdownParser from "./ShowdownParser";
|
|
5
|
-
|
|
6
|
-
class Koffing {
|
|
7
|
-
/**
|
|
8
|
-
* Converts from Showdown to a PokemonTeamSet object.
|
|
9
|
-
*
|
|
10
|
-
* @param {String|Pokemon|PokemonTeam|PokemonTeamSet|ShowdownParser} data Showdown code or object
|
|
11
|
-
* @returns {PokemonTeamSet}
|
|
12
|
-
*/
|
|
13
|
-
static parse(data) {
|
|
14
|
-
if (
|
|
15
|
-
data instanceof PokemonTeamSet
|
|
16
|
-
|| data instanceof PokemonTeam
|
|
17
|
-
|| data instanceof Pokemon
|
|
18
|
-
) {
|
|
19
|
-
return data;
|
|
20
|
-
}
|
|
21
|
-
if (data instanceof ShowdownParser) {
|
|
22
|
-
return data.parse();
|
|
23
|
-
}
|
|
24
|
-
return (new ShowdownParser(data)).parse();
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Prettifies and sanitizes the given Showdown code.
|
|
29
|
-
*
|
|
30
|
-
* @param {String|Pokemon|PokemonTeam|PokemonTeamSet|ShowdownParser} data Showdown code or object
|
|
31
|
-
* @returns {String}
|
|
32
|
-
*/
|
|
33
|
-
static format(data) {
|
|
34
|
-
return this.parse(data).toShowdown();
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Converts from Showdown to JSON code.
|
|
39
|
-
*
|
|
40
|
-
* @param {String|Pokemon|PokemonTeam|PokemonTeamSet|ShowdownParser} data Showdown code or object
|
|
41
|
-
* @returns {String}
|
|
42
|
-
*/
|
|
43
|
-
static toJson(data) {
|
|
44
|
-
return this.parse(data).toJson();
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Converts from JSON to Showdown code.
|
|
49
|
-
*
|
|
50
|
-
* @param {String|Object|Pokemon|PokemonTeam|PokemonTeamSet|ShowdownParser} data JSON code or object
|
|
51
|
-
* @returns {String}
|
|
52
|
-
*/
|
|
53
|
-
static toShowdown(data) {
|
|
54
|
-
if (
|
|
55
|
-
data instanceof PokemonTeamSet
|
|
56
|
-
|| data instanceof PokemonTeam
|
|
57
|
-
|| data instanceof Pokemon
|
|
58
|
-
) {
|
|
59
|
-
return data.toShowdown();
|
|
60
|
-
}
|
|
61
|
-
if (data instanceof ShowdownParser) {
|
|
62
|
-
return data.parse().format();
|
|
63
|
-
}
|
|
64
|
-
if (typeof data === 'string' || data instanceof String) {
|
|
65
|
-
data = JSON.parse(data);
|
|
66
|
-
}
|
|
67
|
-
return PokemonTeamSet.fromObject(JSON.parse(data)).toShowdown();
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
export default Koffing;
|
package/src/core/Pokemon.js
DELETED
|
@@ -1,181 +0,0 @@
|
|
|
1
|
-
class Pokemon {
|
|
2
|
-
constructor() {
|
|
3
|
-
/**
|
|
4
|
-
* @type {String}
|
|
5
|
-
*/
|
|
6
|
-
this.name = undefined;
|
|
7
|
-
/**
|
|
8
|
-
* @type {String}
|
|
9
|
-
*/
|
|
10
|
-
this.nickname = undefined;
|
|
11
|
-
/**
|
|
12
|
-
* @type {String}
|
|
13
|
-
*/
|
|
14
|
-
this.gender = undefined;
|
|
15
|
-
/**
|
|
16
|
-
* @type {String}
|
|
17
|
-
*/
|
|
18
|
-
this.item = undefined;
|
|
19
|
-
/**
|
|
20
|
-
* @type {String}
|
|
21
|
-
*/
|
|
22
|
-
this.ability = undefined;
|
|
23
|
-
/**
|
|
24
|
-
* @type {Number}
|
|
25
|
-
*/
|
|
26
|
-
this.level = undefined;
|
|
27
|
-
/**
|
|
28
|
-
* @type {boolean}
|
|
29
|
-
*/
|
|
30
|
-
this.shiny = undefined;
|
|
31
|
-
/**
|
|
32
|
-
* @type {Number}
|
|
33
|
-
*/
|
|
34
|
-
this.happiness = undefined;
|
|
35
|
-
/**
|
|
36
|
-
* @type {String}
|
|
37
|
-
*/
|
|
38
|
-
this.teratype = undefined;
|
|
39
|
-
/**
|
|
40
|
-
* @type {String}
|
|
41
|
-
*/
|
|
42
|
-
this.nature = undefined;
|
|
43
|
-
/**
|
|
44
|
-
* @type {{ hp:Number, atk:Number, def: Number, spa: Number, spd: Number, spe: Number}}
|
|
45
|
-
*/
|
|
46
|
-
this.evs = undefined;
|
|
47
|
-
/**
|
|
48
|
-
* @type {{ hp:Number, atk:Number, def: Number, spa: Number, spd: Number, spe: Number}}
|
|
49
|
-
*/
|
|
50
|
-
this.ivs = undefined;
|
|
51
|
-
/**
|
|
52
|
-
* @type {String[]}
|
|
53
|
-
*/
|
|
54
|
-
this.moves = [];
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* @param {object|Pokemon} obj
|
|
59
|
-
* @returns {Pokemon}
|
|
60
|
-
*/
|
|
61
|
-
static fromObject(obj) {
|
|
62
|
-
let p = new Pokemon();
|
|
63
|
-
p.name = obj.name;
|
|
64
|
-
p.nickname = obj.nickname;
|
|
65
|
-
p.gender = obj.gender;
|
|
66
|
-
p.item = obj.item;
|
|
67
|
-
p.ability = obj.ability;
|
|
68
|
-
p.level = obj.level;
|
|
69
|
-
p.shiny = obj.shiny;
|
|
70
|
-
p.happiness = obj.happiness;
|
|
71
|
-
p.teratype = obj.teratype;
|
|
72
|
-
p.nature = obj.nature;
|
|
73
|
-
p.evs = obj.evs;
|
|
74
|
-
p.ivs = obj.ivs;
|
|
75
|
-
p.moves = obj.moves;
|
|
76
|
-
|
|
77
|
-
return p;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* @param {Number} indentation
|
|
82
|
-
* @returns {string}
|
|
83
|
-
*/
|
|
84
|
-
toJson(indentation = 2) {
|
|
85
|
-
return JSON.stringify(this, null, indentation);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* @returns {string}
|
|
90
|
-
*/
|
|
91
|
-
toShowdown() {
|
|
92
|
-
let str = '';
|
|
93
|
-
|
|
94
|
-
if (this.nickname) {
|
|
95
|
-
str += `${this.nickname} (${this.name})`;
|
|
96
|
-
} else {
|
|
97
|
-
str += `${this.name}`;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
if (this.gender && this.gender.match(/^[MF]$/i)) {
|
|
101
|
-
str += ` (${this.gender.toUpperCase()})`;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
if (this.item) {
|
|
105
|
-
str += ` @ ${this.item}`;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
str += "\n";
|
|
109
|
-
|
|
110
|
-
if (!isNaN(this.level)) {
|
|
111
|
-
str += `Level: ${this.level}\n`;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
if (this.ability) {
|
|
115
|
-
str += `Ability: ${this.ability}\n`;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
if (this.shiny === true) {
|
|
119
|
-
str += `Shiny: Yes\n`;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
if (!isNaN(this.happiness)) {
|
|
123
|
-
str += `Happiness: ${this.happiness}\n`;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
if (this.teratype) {
|
|
127
|
-
str += `Tera Type: ${this.teratype}\n`;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
if (this.nature) {
|
|
131
|
-
str += `${this.nature} Nature\n`;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
if (this.evs) {
|
|
135
|
-
let evs = this.evs;
|
|
136
|
-
str += `EVs: ` + ['HP', 'Atk', 'Def', 'SpA', 'SpD', 'Spe']
|
|
137
|
-
.filter(function (prop) {
|
|
138
|
-
return !isNaN(evs[prop.toLowerCase()]);
|
|
139
|
-
})
|
|
140
|
-
.map(
|
|
141
|
-
function (prop) {
|
|
142
|
-
let val = evs[prop.toLowerCase()];
|
|
143
|
-
return `${val} ${prop}`;
|
|
144
|
-
}
|
|
145
|
-
)
|
|
146
|
-
.join(' / ') + '\n';
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
if (this.ivs) {
|
|
150
|
-
let ivs = this.ivs;
|
|
151
|
-
str += `IVs: ` + ['HP', 'Atk', 'Def', 'SpA', 'SpD', 'Spe']
|
|
152
|
-
.filter(function (prop) {
|
|
153
|
-
return !isNaN(ivs[prop.toLowerCase()]);
|
|
154
|
-
})
|
|
155
|
-
.map(
|
|
156
|
-
function (prop) {
|
|
157
|
-
let val = ivs[prop.toLowerCase()];
|
|
158
|
-
return `${val} ${prop}`;
|
|
159
|
-
}
|
|
160
|
-
)
|
|
161
|
-
.join(' / ') + '\n';
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
if (this.moves) {
|
|
165
|
-
str += this.moves.map(function (move) {
|
|
166
|
-
return `- ${move}`;
|
|
167
|
-
}).join("\n") + "\n";
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
return str.trim();
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
/**
|
|
174
|
-
* @returns {string}
|
|
175
|
-
*/
|
|
176
|
-
toString() {
|
|
177
|
-
return this.toShowdown();
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
export default Pokemon;
|
package/src/core/PokemonTeam.js
DELETED
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import Pokemon from "./Pokemon";
|
|
2
|
-
|
|
3
|
-
class PokemonTeam {
|
|
4
|
-
/**
|
|
5
|
-
* @param {string} format
|
|
6
|
-
* @param {string} name
|
|
7
|
-
* @param {string|undefined} folder
|
|
8
|
-
*/
|
|
9
|
-
constructor(format = 'gen7', name = 'Untitled', folder = undefined) {
|
|
10
|
-
/**
|
|
11
|
-
*
|
|
12
|
-
* @type {string}
|
|
13
|
-
*/
|
|
14
|
-
this.name = name;
|
|
15
|
-
/**
|
|
16
|
-
*
|
|
17
|
-
* @type {string}
|
|
18
|
-
*/
|
|
19
|
-
this.format = format;
|
|
20
|
-
/**
|
|
21
|
-
*
|
|
22
|
-
* @type {string|undefined}
|
|
23
|
-
*/
|
|
24
|
-
this.folder = folder;
|
|
25
|
-
/**
|
|
26
|
-
*
|
|
27
|
-
* @type {Pokemon[]}
|
|
28
|
-
*/
|
|
29
|
-
this.pokemon = [];
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* @param {object|PokemonTeam} obj
|
|
34
|
-
* @returns {PokemonTeam}
|
|
35
|
-
*/
|
|
36
|
-
static fromObject(obj) {
|
|
37
|
-
let team = new PokemonTeam();
|
|
38
|
-
team.name = obj.name;
|
|
39
|
-
team.format = obj.format;
|
|
40
|
-
team.folder = obj.folder;
|
|
41
|
-
team.pokemon = obj.pokemon ? obj.pokemon.map(function (pokemon) {
|
|
42
|
-
return Pokemon.fromObject(pokemon);
|
|
43
|
-
}) : [];
|
|
44
|
-
|
|
45
|
-
return team;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* @param {Number} indentation
|
|
50
|
-
* @returns {string}
|
|
51
|
-
*/
|
|
52
|
-
toJson(indentation = 2) {
|
|
53
|
-
return JSON.stringify(this, null, indentation);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* @returns {string}
|
|
58
|
-
*/
|
|
59
|
-
toShowdown() {
|
|
60
|
-
let name = this.folder ? `${this.folder}/${this.name}` : this.name;
|
|
61
|
-
let str = `=== [${this.format}] ${name} ===\n\n`;
|
|
62
|
-
|
|
63
|
-
str += this.pokemon.map(function (p) {
|
|
64
|
-
return p.toString();
|
|
65
|
-
}).join('\n\n');
|
|
66
|
-
|
|
67
|
-
return str.trim();
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* @returns {string}
|
|
72
|
-
*/
|
|
73
|
-
toString() {
|
|
74
|
-
return this.toShowdown();
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
export default PokemonTeam;
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import PokemonTeam from "./PokemonTeam";
|
|
2
|
-
|
|
3
|
-
class PokemonTeamSet {
|
|
4
|
-
/**
|
|
5
|
-
* @param {PokemonTeam[]} teams
|
|
6
|
-
*/
|
|
7
|
-
constructor(teams = []) {
|
|
8
|
-
this.teams = teams;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* @param {object|PokemonTeamSet} obj
|
|
13
|
-
* @returns {PokemonTeamSet}
|
|
14
|
-
*/
|
|
15
|
-
static fromObject(obj) {
|
|
16
|
-
let teamSet = new PokemonTeamSet();
|
|
17
|
-
teamSet.teams = obj.teams ? obj.teams.map(function (team) {
|
|
18
|
-
return PokemonTeam.fromObject(team);
|
|
19
|
-
}) : [];
|
|
20
|
-
|
|
21
|
-
return teamSet;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* @param {Number} indentation
|
|
26
|
-
* @returns {string}
|
|
27
|
-
*/
|
|
28
|
-
toJson(indentation = 2) {
|
|
29
|
-
return JSON.stringify(this, null, indentation);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* @returns {string}
|
|
34
|
-
*/
|
|
35
|
-
toShowdown() {
|
|
36
|
-
return this.teams
|
|
37
|
-
.map(function (p) {
|
|
38
|
-
return p.toString();
|
|
39
|
-
})
|
|
40
|
-
.join('\n\n')
|
|
41
|
-
.trim();
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* @returns {string}
|
|
46
|
-
*/
|
|
47
|
-
toString() {
|
|
48
|
-
return this.toShowdown();
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export default PokemonTeamSet;
|