-
Notifications
You must be signed in to change notification settings - Fork 4
/
Card.js
117 lines (117 loc) · 3.77 KB
/
Card.js
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.CardClass = exports.Card = exports.ChainCard = void 0;
const Coin_1 = require("./Coin");
class ChainCard {
static from(json) {
return Object.assign(new ChainCard(), json);
}
toCard() {
let card = new Card();
if (this.content) {
let content = JSON.parse(this.content);
let cardType = Object.keys(content)[0];
card.CardName = content[cardType].CardName;
card.FlavourText = content[cardType].FlavourText;
card.Tags = content[cardType].Tags;
card.Class = Object.assign(new CardClass(), content[cardType].Class);
card.CastingCost = parseInt(content[cardType].CastingCost);
card.Abilities = content[cardType].Abilities;
card.AdditionalCost = content[cardType].AdditionalCost;
card.Health = parseInt(content[cardType].Health);
card.Attack = parseInt(content[cardType].Attack);
card.Delay = parseInt(content[cardType].Delay);
card.RulesTexts = content[cardType].RulesTexts;
card.Keywords = [];
content[cardType].Keywords.forEach(keyword => {
card.Keywords.push(JSON.parse(keyword));
});
card.type = cardType;
card.owner = this.owner;
card.status = this.status;
card.artist = this.artist;
card.Content = content;
card.image = this.image;
card.fullArt = this.fullArt;
card.nerflevel = parseInt(this.nerflevel);
card.notes = this.notes;
card.fairEnoughVotes = parseInt(this.fairEnoughVotes);
card.inappropriateVotes = parseInt(this.inappropriateVotes);
card.overpoweredVotes = parseInt(this.overpoweredVotes);
card.underpoweredVotes = parseInt(this.underpoweredVotes);
card.votePool = Object.assign(new Coin_1.Coin(), this.votePool);
card.voters = this.voters;
console.log("parsed card: ", card);
}
return card;
}
}
exports.ChainCard = ChainCard;
class Card {
constructor() {
this.notes = "";
this.type = "";
this.owner = "";
this.status = "";
this.artist = "";
this.Content = {};
this.image = "";
this.voters = [];
this.tagDummy = "";
this.fullArt = true;
this.nerflevel = 0;
this.fairEnoughVotes = 0;
this.inappropriateVotes = 0;
this.overpoweredVotes = 0;
this.underpoweredVotes = 0;
this.votePool = new Coin_1.Coin();
this.Abilities = [];
this.CardName = "";
this.FlavourText = "";
this.Tags = [];
this.Class = new CardClass();
this.CastingCost = -1;
this.AdditionalCost = {};
this.Health = 0;
this.Attack = 0;
this.Delay = 0;
this.RulesTexts = [];
this.Keywords = [];
}
static from(json) {
return Object.assign(new ChainCard(), json);
}
}
exports.Card = Card;
class CardClass {
constructor(type) {
this.Culture = false;
this.Mysticism = false;
this.Technology = false;
this.Nature = false;
if (type) {
this[type] = true;
}
}
static culture() {
let obj = new CardClass();
obj.Culture = true;
return obj;
}
static mysticism() {
let obj = new CardClass();
obj.Mysticism = true;
return obj;
}
static technology() {
let obj = new CardClass();
obj.Technology = true;
return obj;
}
static nature() {
let obj = new CardClass();
obj.Nature = true;
return obj;
}
}
exports.CardClass = CardClass;