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()));
|
return reader.readCard(lines, Files.getNameWithoutExtension(file.getName()));
|
||||||
} catch (final FileNotFoundException ex) {
|
} catch (final FileNotFoundException ex) {
|
||||||
throw new RuntimeException("CardReader : run error -- file not found: " + file.getPath(), ex);
|
throw new RuntimeException("CardReader : run error -- file not found: " + file.getPath(), ex);
|
||||||
|
} catch (final Exception ex) {
|
||||||
|
throw ex;
|
||||||
} finally {
|
} finally {
|
||||||
try {
|
try {
|
||||||
assert fileInputStream != null;
|
assert fileInputStream != null;
|
||||||
|
|||||||
@@ -87,21 +87,27 @@ final class CardFace implements ICardFace {
|
|||||||
void setInitialLoyalty(int value) { this.initialLoyalty = value; }
|
void setInitialLoyalty(int value) { this.initialLoyalty = value; }
|
||||||
|
|
||||||
void setPtText(String value) {
|
void setPtText(String value) {
|
||||||
final int slashPos = value.indexOf('/');
|
final String k[] = value.split("/");
|
||||||
if (slashPos == -1) {
|
|
||||||
|
if (k.length != 2) {
|
||||||
throw new RuntimeException("Creature '" + this.getName() + "' has bad p/t stats");
|
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.power = k[0];
|
||||||
this.toughness = negToughness ? value.substring(slashPos + 2) : value.substring(slashPos + 1);
|
this.toughness = k[1];
|
||||||
|
|
||||||
this.iPower = StringUtils.isNumeric(this.power) ? Integer.parseInt(this.power) : 0;
|
this.iPower = parsePT(k[0]);
|
||||||
this.iToughness = StringUtils.isNumeric(this.toughness) ? Integer.parseInt(this.toughness) : 0;
|
this.iToughness = parsePT(k[1]);
|
||||||
|
}
|
||||||
|
|
||||||
if (negPower) { this.iPower *= -1; }
|
static int parsePT(String val) {
|
||||||
if (negToughness) { this.iToughness *= -1; }
|
// 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
|
// Raw fields used for Card creation
|
||||||
|
|||||||
@@ -58,9 +58,6 @@ public class StaticEffect {
|
|||||||
private String chosenType;
|
private String chosenType;
|
||||||
private Map<String, String> mapParams = Maps.newTreeMap();
|
private Map<String, String> mapParams = Maps.newTreeMap();
|
||||||
|
|
||||||
// for P/T
|
|
||||||
private final Map<Card, String> originalPT = Maps.newTreeMap();
|
|
||||||
|
|
||||||
// for types
|
// for types
|
||||||
private boolean overwriteTypes = false;
|
private boolean overwriteTypes = false;
|
||||||
private boolean keepSupertype = false;
|
private boolean keepSupertype = false;
|
||||||
@@ -101,7 +98,6 @@ public class StaticEffect {
|
|||||||
copy.xValueMap = this.xValueMap;
|
copy.xValueMap = this.xValueMap;
|
||||||
copy.chosenType = this.chosenType;
|
copy.chosenType = this.chosenType;
|
||||||
copy.mapParams = this.mapParams;
|
copy.mapParams = this.mapParams;
|
||||||
map.fillKeyedMap(copy.originalPT, this.originalPT);
|
|
||||||
copy.overwriteTypes = this.overwriteTypes;
|
copy.overwriteTypes = this.overwriteTypes;
|
||||||
copy.keepSupertype = this.keepSupertype;
|
copy.keepSupertype = this.keepSupertype;
|
||||||
copy.removeSubTypes = this.removeSubTypes;
|
copy.removeSubTypes = this.removeSubTypes;
|
||||||
@@ -345,68 +341,6 @@ public class StaticEffect {
|
|||||||
this.originalKeywords.clear();
|
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?
|
// should we overwrite types?
|
||||||
/**
|
/**
|
||||||
@@ -995,7 +929,7 @@ public class StaticEffect {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// remove set P/T
|
// remove set P/T
|
||||||
if (!params.containsKey("CharacteristicDefining") && setPT) {
|
if (setPT) {
|
||||||
affectedCard.removeNewPT(getTimestamp());
|
affectedCard.removeNewPT(getTimestamp());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -582,14 +582,7 @@ public final class StaticAbilityContinuous {
|
|||||||
|
|
||||||
// set P/T
|
// set P/T
|
||||||
if (layer == StaticAbilityLayer.SETPT) {
|
if (layer == StaticAbilityLayer.SETPT) {
|
||||||
if (params.containsKey("CharacteristicDefining")) {
|
if ((setPower != Integer.MAX_VALUE) || (setToughness != Integer.MAX_VALUE)) {
|
||||||
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)) {
|
|
||||||
// non CharacteristicDefining
|
// non CharacteristicDefining
|
||||||
if (setP.startsWith("AffectedX")) {
|
if (setP.startsWith("AffectedX")) {
|
||||||
setPower = CardFactoryUtil.xCount(affectedCard, AbilityUtils.getSVar(stAb, setP));
|
setPower = CardFactoryUtil.xCount(affectedCard, AbilityUtils.getSVar(stAb, setP));
|
||||||
|
|||||||
Reference in New Issue
Block a user