-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathCardBuffer.java
More file actions
102 lines (91 loc) · 3.26 KB
/
CardBuffer.java
File metadata and controls
102 lines (91 loc) · 3.26 KB
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
package sayTheSpire.buffers;
import com.megacrit.cardcrawl.cards.AbstractCard;
import com.megacrit.cardcrawl.helpers.GameDictionary;
import sayTheSpire.TextParser;
import sayTheSpire.utils.CardUtils;
public class CardBuffer extends Buffer {
private AbstractCard card;
private Boolean isUpgradePreview;
private boolean noFurtherUpgrade;
public CardBuffer(String name) {
this(name, false);
}
public CardBuffer(String name, Boolean isUpgradePreview) {
super("card", name);
this.card = null;
this.isUpgradePreview = isUpgradePreview;
this.noFurtherUpgrade = false;
}
public String getLabel() {
switch (this.getKey()) {
case "current card":
return this.context.localize("localizedName");
case "upgrade preview":
return this.context.localize("localizedNameUpgraded");
default:
return super.getLabel();
}
}
public Object getObject() {
return this.card;
}
public void setObject(Object object) {
AbstractCard card = (AbstractCard) object;
if (card == null) {
this.card = null;
return;
}
if (this.isUpgradePreview) {
if (!card.canUpgrade()) {
this.noFurtherUpgrade = true;
} else {
this.noFurtherUpgrade = false;
AbstractCard upgradedCard = card.makeStatEquivalentCopy();
upgradedCard.upgrade();
upgradedCard.isLocked = card.isLocked;
upgradedCard.isFlipped = card.isFlipped;
card = upgradedCard;
}
}
this.card = card;
}
public void update() {
this.clear();
if (this.card == null) {
this.addLocalized("noObj");
return;
} else if (this.card.isLocked) {
this.add(this.card.LOCKED_STRING);
return;
} else if (this.card.isFlipped) {
this.addLocalized("faceDown");
return;
} else if (this.isUpgradePreview && this.noFurtherUpgrade) {
this.addLocalized("noFurtherUpgrade");
return;
}
this.context.put("cost", CardUtils.getCardCostString(card));
this.context.put("type", CardUtils.getCardTypeString(this.card));
this.context.put("rarity", CardUtils.getCardRarityString(this.card));
this.add(card.name);
this.addLocalized("content.cost");
// add card type and rarity as one buffer item.
this.addLocalized("content.typeAndRarity");
this.add(CardUtils.getCardDescriptionString(card));
for (String keyword : card.keywords) {
String name = TextParser.parse(keyword);
if (name.equals("")) {
name = keyword; // to prevent any weird instances of orbs being treated as keywords for example
// and being omited
}
String body = GameDictionary.keywords.get(keyword);
if (body == null) {
this.context.put("unknownKeyword", name);
this.addLocalized("content.unknownKeyword");
} else {
body = TextParser.parse(body);
this.add(name + "\n" + body);
}
}
}
}