mirror of
https://github.com/magefree/mage.git
synced 2026-01-09 12:22:10 -08:00
moved {this} and {source} replacement to server
This commit is contained in:
parent
5bdfd1b467
commit
c8db6ba350
13 changed files with 62 additions and 52 deletions
|
|
@ -48,7 +48,7 @@ public class AbilityView extends CardView {
|
|||
this.sourceName = sourceName;
|
||||
this.sourceCard = sourceCard;
|
||||
this.rules = new ArrayList<String>();
|
||||
rules.add(formatRule(ability.getRule()));
|
||||
rules.add(ability.getRule(sourceName));
|
||||
this.power = "";
|
||||
this.toughness = "";
|
||||
this.loyalty = "";
|
||||
|
|
@ -60,13 +60,6 @@ public class AbilityView extends CardView {
|
|||
this.art = "";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String formatRule(String rule) {
|
||||
String newRule = rule.replace("{this}", this.sourceName);
|
||||
newRule.replace("{source}", this.sourceName);
|
||||
return newRule;
|
||||
}
|
||||
|
||||
public CardView getSourceCard() {
|
||||
return this.sourceCard;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ public class CardView implements Serializable {
|
|||
public CardView(Card card) {
|
||||
this.id = card.getId();
|
||||
this.name = card.getName();
|
||||
this.rules = formatRules(card.getRules());
|
||||
this.rules = card.getRules();
|
||||
if (card instanceof Permanent) {
|
||||
this.power = Integer.toString(card.getPower().getValue());
|
||||
this.toughness = Integer.toString(card.getToughness().getValue());
|
||||
|
|
@ -118,7 +118,7 @@ public class CardView implements Serializable {
|
|||
CardView(Token token) {
|
||||
this.id = token.getId();
|
||||
this.name = token.getName();
|
||||
this.rules = formatRules(token.getAbilities().getRules());
|
||||
this.rules = token.getAbilities().getRules(this.name);
|
||||
this.power = token.getPower().toString();
|
||||
this.toughness = token.getToughness().toString();
|
||||
this.loyalty = token.getLoyalty().toString();
|
||||
|
|
@ -143,19 +143,19 @@ public class CardView implements Serializable {
|
|||
}
|
||||
}
|
||||
|
||||
protected List<String> formatRules(List<String> rules) {
|
||||
List<String> newRules = new ArrayList<String>();
|
||||
for (String rule: rules) {
|
||||
newRules.add(formatRule(rule));
|
||||
}
|
||||
return newRules;
|
||||
}
|
||||
|
||||
protected String formatRule(String rule) {
|
||||
String replace = rule.replace("{this}", this.name);
|
||||
replace = replace.replace("{source}", this.name);
|
||||
return replace;
|
||||
}
|
||||
// protected List<String> formatRules(List<String> rules) {
|
||||
// List<String> newRules = new ArrayList<String>();
|
||||
// for (String rule: rules) {
|
||||
// newRules.add(formatRule(rule));
|
||||
// }
|
||||
// return newRules;
|
||||
// }
|
||||
//
|
||||
// protected String formatRule(String rule) {
|
||||
// String replace = rule.replace("{this}", this.name);
|
||||
// replace = replace.replace("{source}", this.name);
|
||||
// return replace;
|
||||
// }
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ public class StackAbilityView extends CardView {
|
|||
this.sourceName = sourceName;
|
||||
this.sourceCard = sourceCard;
|
||||
this.rules = new ArrayList<String>();
|
||||
rules.add(formatRule(ability.getRule()));
|
||||
rules.add(ability.getRule(sourceName));
|
||||
this.power = ability.getPower().toString();
|
||||
this.toughness = ability.getToughness().toString();
|
||||
this.loyalty = ability.getLoyalty().toString();
|
||||
|
|
@ -60,13 +60,6 @@ public class StackAbilityView extends CardView {
|
|||
setTargets(ability.getTargets());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String formatRule(String rule) {
|
||||
String newRule = rule.replace("{this}", this.sourceName);
|
||||
newRule.replace("{source}", this.sourceName);
|
||||
return newRule;
|
||||
}
|
||||
|
||||
public CardView getSourceCard() {
|
||||
return this.sourceCard;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue