forked from SkyeStarfall/BaseMod
-
Notifications
You must be signed in to change notification settings - Fork 123
Expand file tree
/
Copy pathAbstractCardModifier.java
More file actions
285 lines (230 loc) · 9.29 KB
/
AbstractCardModifier.java
File metadata and controls
285 lines (230 loc) · 9.29 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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
package basemod.abstracts;
import basemod.helpers.CardBorderGlowManager;
import basemod.helpers.TooltipInfo;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.megacrit.cardcrawl.actions.AbstractGameAction;
import com.megacrit.cardcrawl.actions.utility.UseCardAction;
import com.megacrit.cardcrawl.cards.AbstractCard;
import com.megacrit.cardcrawl.cards.CardGroup;
import com.megacrit.cardcrawl.cards.DamageInfo;
import com.megacrit.cardcrawl.core.AbstractCreature;
import com.megacrit.cardcrawl.dungeons.AbstractDungeon;
import com.megacrit.cardcrawl.monsters.AbstractMonster;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
public abstract class AbstractCardModifier implements Comparable<AbstractCardModifier> {
public int priority = 0;
/**
* Methods determine times when the card mod will be removed from the card.
* Any number of these can be set to return true, and are implemented as methods
* to give the user more control of the case-by-case.
*/
public boolean removeOnCardPlayed(AbstractCard card) {
return false;
}
//note: this method behaves the same way the game treats temporary costs. Any time a "costForTurn" would be reset, this is called.
public boolean removeAtEndOfTurn(AbstractCard card) {
return false;
}
/**
* method determines whether this modifier should be counted as a permanent part of the card. For example, if you
* create a modifier that would be applied to a card in its own constructor, and it's to be considered an immutable
* part of it, not removable by effects that can remove card modifiers, have this method return true.
*/
public boolean isInherent(AbstractCard card) {
return false;
}
/**
* Methods modify the relevant stat as it's being calculated on the game's end, without
* interfering with normal card stats. The return is the new value used by the game.
* all card parameters pass the instance of the card which the mod is applied to.
* AbstractMonster parameters will pass null when called from ApplyPowers.
*/
//called before any damage increases, will also render outside the hand
public float modifyBaseDamage(float damage, DamageInfo.DamageType type, AbstractCard card, AbstractMonster target) {
return damage;
}
//called before related power functions, for flat increases, to happen before vulnerable.
public float modifyDamage(float damage, DamageInfo.DamageType type, AbstractCard card, AbstractMonster target) {
return damage;
}
//called before "final" power functions, to apply percentage increases, but before things like intangible.
public float modifyDamageFinal(float damage, DamageInfo.DamageType type, AbstractCard card, AbstractMonster target) {
return damage;
}
//called before any block increases, will also render outside the hand
public float modifyBaseBlock(float block, AbstractCard card) {
return block;
}
//called before power functions, for flat increases.
public float modifyBlock(float block, AbstractCard card) {
return block;
}
//called after power functions, for percentage and immutable(panic button-like) changes.
public float modifyBlockFinal(float block, AbstractCard card) {
return block;
}
//called before any magic number increases, will also render outside the hand
public float modifyBaseMagic(float magic, AbstractCard card) {
return magic;
}
/**
* Intercepts the creation of a card's description at the time that initializeDescription is called.
* rawDescription can be manipulated freely at this point, and then the game will parse it as normal.
*/
public String modifyDescription(String rawDescription, AbstractCard card) {
return rawDescription;
}
/**
* Intercepts the rendering of a card's name at the time that renderTitle is called.
* cardName can be manipulated freely at this point, and then the game will parse it as normal.
*/
public String modifyName(String cardName, AbstractCard card) {
return cardName;
}
/**
* Called just before Basemod renders the other additional tooltips the card may have,
* at the end of the card's renderKeywords method.
*/
public List<TooltipInfo> additionalTooltips(AbstractCard card) {
return null;
}
/**
* Called when the card is used, same timing as onUseCard hooks in powers and relics.
* If the card has no target, target will be null.
*/
public void onUse(AbstractCard card, AbstractCreature target, UseCardAction action) {
}
/**
* called when the card is drawn.
*/
public void onDrawn(AbstractCard card) {
}
/**
* called when the card is exhausted.
*/
public void onExhausted(AbstractCard card) {
}
/**
* called when the mod is initially applied to the card, including when
* a new instance of a card is created, and mods are copied to that new card.
*/
public void onInitialApplication(AbstractCard card) {
}
public void onRemove(AbstractCard card) {
}
/**
* called whenever applyPowers is called on a card. Useful for if you want an
* effect to be tied to the existence of a power, or otherwise somehow dynamic.
*/
public void onApplyPowers(AbstractCard card) {
}
public void onCalculateCardDamage(AbstractCard card, AbstractMonster mo) {
}
/**
* update/render hooks. Can be used to attach particle systems to a card, or a bottle icon, or similar.
*/
public void onUpdate(AbstractCard card) {
}
public void onRender(AbstractCard card, SpriteBatch sb) {
}
public void onSingleCardViewRender(AbstractCard card, SpriteBatch sb) {
}
/**
* triggers at the end of the player's turn. The group passed is the current location of the card at the
* time that this method is called.
*/
public void atEndOfTurn(AbstractCard card, CardGroup group) {
}
/**
* triggers when another card is played.
* @param card - the card which this modifier is applied to
* @param otherCard - the card that was played
* @param group - the current location of the card at the time this method is called.
*/
public void onOtherCardPlayed(AbstractCard card, AbstractCard otherCard, CardGroup group) {
}
/**
* return false to make the card unplayable.
*/
public boolean canPlayCard(AbstractCard card) {
return true;
}
/**
* triggers whenever the card is retained. Same conditions as AbstractCard.onRetained.
*/
public void onRetained(AbstractCard card) {
}
/**
* needs to be overridden by all CardModifiers, since CardModifiers are, by default, copied between instances.
*/
public abstract AbstractCardModifier makeCopy();
/**
* for use with hasModifier and getModifier methods. If you have no reason to use those methods,
* then there's no need to establish an ID.
*/
public String identifier(AbstractCard card) {
return "";
}
/**
* return false to make the modifier not apply to the passed card.
*/
public boolean shouldApply(AbstractCard card) {
return true;
}
/**
* return a list of words to be rendered with the card's card type
*/
public List<String> extraDescriptors(AbstractCard card) {
return Collections.emptyList();
}
/**
* triggers on every modifier present on a card after any changes to the list of modifiers on a card changes.
*/
public void onCardModified(AbstractCard card) {
}
/**
* Behaves the same as StSLib's StartupCard.
* Triggers at the start of battle. Return true to have the card flash on the screen.
*/
public boolean onBattleStart(AbstractCard card) {
return false;
}
/**
* return a Color if the cardmod should cause the card to glow a different color than it usually does. This should return
* null if it doesn't want the card to be affected.
*/
public Color getGlow(AbstractCard card) {
return null;
}
/**
* lower number = calculates first. For list sorting purposes. Don't override. Or do, I'm a comment, not a cop.
*/
@Override
public int compareTo(AbstractCardModifier other) {
return priority - other.priority;
}
/**
* By default, card modifiers are saved when placed on a master deck card. This does, however, mean that if a field
* exists in a modifier that cannot be saved, the game will crash as soon as you try to load any game, no matter if
* that modifier is used anywhere. To prevent this issue, a Card Modifier can be flagged as not savable with this
* annotation.
*/
@Target({ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
public @interface SaveIgnore
{
}
public void addToTop(AbstractGameAction action) {
AbstractDungeon.actionManager.addToTop(action);
}
public void addToBot(AbstractGameAction action) {
AbstractDungeon.actionManager.addToBottom(action);
}
}