mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 11:18:01 +00:00
Merge branch 'master' of git.cardforge.org:core-developers/forge into agetian-master
This commit is contained in:
@@ -413,6 +413,8 @@ public class CardStorageReader {
|
||||
return reader.readCard(lines, Files.getNameWithoutExtension(file.getName()));
|
||||
} catch (final FileNotFoundException ex) {
|
||||
throw new RuntimeException("CardReader : run error -- file not found: " + file.getPath(), ex);
|
||||
} catch (final Exception ex) {
|
||||
throw ex;
|
||||
} finally {
|
||||
try {
|
||||
assert fileInputStream != null;
|
||||
|
||||
@@ -87,21 +87,27 @@ final class CardFace implements ICardFace {
|
||||
void setInitialLoyalty(int value) { this.initialLoyalty = value; }
|
||||
|
||||
void setPtText(String value) {
|
||||
final int slashPos = value.indexOf('/');
|
||||
if (slashPos == -1) {
|
||||
final String k[] = value.split("/");
|
||||
|
||||
if (k.length != 2) {
|
||||
throw new RuntimeException("Creature '" + this.getName() + "' has bad p/t stats");
|
||||
}
|
||||
boolean negPower = value.charAt(0) == '-';
|
||||
boolean negToughness = value.charAt(slashPos + 1) == '-';
|
||||
|
||||
this.power = negPower ? value.substring(1, slashPos) : value.substring(0, slashPos);
|
||||
this.toughness = negToughness ? value.substring(slashPos + 2) : value.substring(slashPos + 1);
|
||||
this.power = k[0];
|
||||
this.toughness = k[1];
|
||||
|
||||
this.iPower = StringUtils.isNumeric(this.power) ? Integer.parseInt(this.power) : 0;
|
||||
this.iToughness = StringUtils.isNumeric(this.toughness) ? Integer.parseInt(this.toughness) : 0;
|
||||
this.iPower = parsePT(k[0]);
|
||||
this.iToughness = parsePT(k[1]);
|
||||
}
|
||||
|
||||
if (negPower) { this.iPower *= -1; }
|
||||
if (negToughness) { this.iToughness *= -1; }
|
||||
static int parsePT(String val) {
|
||||
// normalize PT value
|
||||
if (val.contains("*")) {
|
||||
val = val.replace("+*", "");
|
||||
val = val.replace("-*", "");
|
||||
val = val.replace("*", "0");
|
||||
}
|
||||
return Integer.parseInt(val);
|
||||
}
|
||||
|
||||
// Raw fields used for Card creation
|
||||
|
||||
@@ -58,9 +58,6 @@ public class StaticEffect {
|
||||
private String chosenType;
|
||||
private Map<String, String> mapParams = Maps.newTreeMap();
|
||||
|
||||
// for P/T
|
||||
private final Map<Card, String> originalPT = Maps.newTreeMap();
|
||||
|
||||
// for types
|
||||
private boolean overwriteTypes = false;
|
||||
private boolean keepSupertype = false;
|
||||
@@ -101,7 +98,6 @@ public class StaticEffect {
|
||||
copy.xValueMap = this.xValueMap;
|
||||
copy.chosenType = this.chosenType;
|
||||
copy.mapParams = this.mapParams;
|
||||
map.fillKeyedMap(copy.originalPT, this.originalPT);
|
||||
copy.overwriteTypes = this.overwriteTypes;
|
||||
copy.keepSupertype = this.keepSupertype;
|
||||
copy.removeSubTypes = this.removeSubTypes;
|
||||
@@ -345,68 +341,6 @@ public class StaticEffect {
|
||||
this.originalKeywords.clear();
|
||||
}
|
||||
|
||||
// original power/toughness
|
||||
/**
|
||||
* <p>
|
||||
* addOriginalPT.
|
||||
* </p>
|
||||
*
|
||||
* @param c
|
||||
* a {@link forge.game.card.Card} object.
|
||||
* @param power
|
||||
* a int.
|
||||
* @param toughness
|
||||
* a int.
|
||||
*/
|
||||
public final void addOriginalPT(final Card c, final int power, final int toughness) {
|
||||
final String pt = power + "/" + toughness;
|
||||
if (!this.originalPT.containsKey(c)) {
|
||||
this.originalPT.put(c, pt);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* getOriginalPower.
|
||||
* </p>
|
||||
*
|
||||
* @param c
|
||||
* a {@link forge.game.card.Card} object.
|
||||
* @return a int.
|
||||
*/
|
||||
public final int getOriginalPower(final Card c) {
|
||||
int power = -1;
|
||||
if (this.originalPT.containsKey(c)) {
|
||||
power = Integer.parseInt(this.originalPT.get(c).split("/")[0]);
|
||||
}
|
||||
return power;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* getOriginalToughness.
|
||||
* </p>
|
||||
*
|
||||
* @param c
|
||||
* a {@link forge.game.card.Card} object.
|
||||
* @return a int.
|
||||
*/
|
||||
public final int getOriginalToughness(final Card c) {
|
||||
int tough = -1;
|
||||
if (this.originalPT.containsKey(c)) {
|
||||
tough = Integer.parseInt(this.originalPT.get(c).split("/")[1]);
|
||||
}
|
||||
return tough;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* clearAllOriginalPTs.
|
||||
* </p>
|
||||
*/
|
||||
public final void clearAllOriginalPTs() {
|
||||
this.originalPT.clear();
|
||||
}
|
||||
|
||||
// should we overwrite types?
|
||||
/**
|
||||
@@ -995,7 +929,7 @@ public class StaticEffect {
|
||||
}
|
||||
|
||||
// remove set P/T
|
||||
if (!params.containsKey("CharacteristicDefining") && setPT) {
|
||||
if (setPT) {
|
||||
affectedCard.removeNewPT(getTimestamp());
|
||||
}
|
||||
|
||||
|
||||
@@ -582,14 +582,7 @@ public final class StaticAbilityContinuous {
|
||||
|
||||
// set P/T
|
||||
if (layer == StaticAbilityLayer.SETPT) {
|
||||
if (params.containsKey("CharacteristicDefining")) {
|
||||
if (setPower != Integer.MAX_VALUE) {
|
||||
affectedCard.setBasePower(setPower);
|
||||
}
|
||||
if (setToughness != Integer.MAX_VALUE) {
|
||||
affectedCard.setBaseToughness(setToughness);
|
||||
}
|
||||
} else if ((setPower != Integer.MAX_VALUE) || (setToughness != Integer.MAX_VALUE)) {
|
||||
if ((setPower != Integer.MAX_VALUE) || (setToughness != Integer.MAX_VALUE)) {
|
||||
// non CharacteristicDefining
|
||||
if (setP.startsWith("AffectedX")) {
|
||||
setPower = CardFactoryUtil.xCount(affectedCard, AbilityUtils.getSVar(stAb, setP));
|
||||
|
||||
Reference in New Issue
Block a user