mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-14 17:58:01 +00:00
Small code speed up: Avoid calling getFirstAbility() redundantly.
This was showing up in simulation AI profiles.
This commit is contained in:
@@ -185,7 +185,8 @@ public final class AbilityFactory {
|
|||||||
String cost = mapParams.get("Cost");
|
String cost = mapParams.get("Cost");
|
||||||
if (cost == null) {
|
if (cost == null) {
|
||||||
if (type == AbilityRecordType.Spell) {
|
if (type == AbilityRecordType.Spell) {
|
||||||
if (state.getFirstAbility() != null && state.getFirstAbility().isSpell()) {
|
SpellAbility firstAbility = state.getFirstAbility();
|
||||||
|
if (firstAbility != null && firstAbility.isSpell()) {
|
||||||
// TODO might remove when Enchant Keyword is refactored
|
// TODO might remove when Enchant Keyword is refactored
|
||||||
System.err.println(state.getName() + " already has Spell using mana cost");
|
System.err.println(state.getName() + " already has Spell using mana cost");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2442,14 +2442,14 @@ public class Card extends GameEntity implements Comparable<Card>, IHasSVars {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// add As an additional cost to Permanent spells
|
// add As an additional cost to Permanent spells
|
||||||
if (state.getFirstAbility() != null && type.isPermanent()) {
|
SpellAbility first = state.getFirstAbility();
|
||||||
SpellAbility first = state.getFirstAbility();
|
if (first != null && type.isPermanent()) {
|
||||||
if (first.isSpell()) {
|
if (first.isSpell()) {
|
||||||
Cost cost = first.getPayCosts();
|
Cost cost = first.getPayCosts();
|
||||||
if (cost != null && !cost.isOnlyManaCost()) {
|
if (cost != null && !cost.isOnlyManaCost()) {
|
||||||
String additionalDesc = "";
|
String additionalDesc = "";
|
||||||
if (state.getFirstAbility().hasParam("AdditionalDesc")) {
|
if (first.hasParam("AdditionalDesc")) {
|
||||||
additionalDesc = state.getFirstAbility().getParam("AdditionalDesc");
|
additionalDesc = first.getParam("AdditionalDesc");
|
||||||
}
|
}
|
||||||
sb.append(cost.toString().replace("\n", "")).append(" ").append(additionalDesc);
|
sb.append(cost.toString().replace("\n", "")).append(" ").append(additionalDesc);
|
||||||
sb.append(linebreak);
|
sb.append(linebreak);
|
||||||
@@ -3757,7 +3757,7 @@ public class Card extends GameEntity implements Comparable<Card>, IHasSVars {
|
|||||||
public final CardTypeView getOriginalType() {
|
public final CardTypeView getOriginalType() {
|
||||||
return getOriginalType(currentState);
|
return getOriginalType(currentState);
|
||||||
}
|
}
|
||||||
public final CardTypeView getOriginalType(CardState state) {
|
public final CardTypeView getOriginalType(CardState state) {
|
||||||
return state.getType();
|
return state.getType();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user