-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathparse_input_ui.js
More file actions
34 lines (26 loc) · 939 Bytes
/
parse_input_ui.js
File metadata and controls
34 lines (26 loc) · 939 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import { card_name_to_id_fuzzy, ready } from './card_name_to_id_fuzzy.js';
function parse_input(json) {
let jsonData = json;
if (jsonData.permute_a && jsonData.permute_b) {
console.error('Permuting both players not supported.');
process.exit(1);
}
if (jsonData.players) {
jsonData.a = jsonData.players[0];
jsonData.b = jsonData.players[1];
delete jsonData.players;
}
jsonData.a.max_hp = jsonData.a.hp + jsonData.a.physique;
jsonData.b.max_hp = jsonData.b.hp + jsonData.b.physique;
const deck_slots = jsonData.deck_slots || 8;
while (jsonData.a.cards.length < deck_slots) {
jsonData.a.cards.push('601011');
}
while (jsonData.b.cards.length < deck_slots) {
jsonData.b.cards.push('601011');
}
// jsonData.a.cards = jsonData.a.cards.map(card_name_to_id_fuzzy);
// jsonData.b.cards = jsonData.b.cards.map(card_name_to_id_fuzzy);
return jsonData;
}
export { parse_input, ready };