mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 12:18:00 +00:00
CanBlockAdditional: moved to CardView for better display
This commit is contained in:
@@ -203,7 +203,12 @@ public class PumpEffect extends SpellAbilityEffect {
|
|||||||
final int atk = AbilityUtils.calculateAmount(sa.getHostCard(), sa.getParam("NumAtt"), sa, true);
|
final int atk = AbilityUtils.calculateAmount(sa.getHostCard(), sa.getParam("NumAtt"), sa, true);
|
||||||
final int def = AbilityUtils.calculateAmount(sa.getHostCard(), sa.getParam("NumDef"), sa, true);
|
final int def = AbilityUtils.calculateAmount(sa.getHostCard(), sa.getParam("NumDef"), sa, true);
|
||||||
|
|
||||||
sb.append("gains ");
|
boolean gains = sa.hasParam("NumAtt") || sa.hasParam("NumDef") || !keywords.isEmpty();
|
||||||
|
|
||||||
|
if (gains) {
|
||||||
|
sb.append("gains ");
|
||||||
|
}
|
||||||
|
|
||||||
if (sa.hasParam("NumAtt") || sa.hasParam("NumDef")) {
|
if (sa.hasParam("NumAtt") || sa.hasParam("NumDef")) {
|
||||||
if (atk >= 0) {
|
if (atk >= 0) {
|
||||||
sb.append("+");
|
sb.append("+");
|
||||||
@@ -221,8 +226,25 @@ public class PumpEffect extends SpellAbilityEffect {
|
|||||||
sb.append(keywords.get(i)).append(" ");
|
sb.append(keywords.get(i)).append(" ");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (sa.hasParam("CanBlockAny")) {
|
||||||
|
if (gains) {
|
||||||
|
sb.append(" and ");
|
||||||
|
}
|
||||||
|
sb.append("can block any number of creatures ");
|
||||||
|
} else if (sa.hasParam("CanBlockAmount")) {
|
||||||
|
if (gains) {
|
||||||
|
sb.append(" and ");
|
||||||
|
}
|
||||||
|
String n = sa.getParam("CanBlockAmount");
|
||||||
|
sb.append("can block an additional ");
|
||||||
|
sb.append("1".equals(n) ? "creature" : Lang.nounWithNumeral(n, "creature"));
|
||||||
|
sb.append(" each combat ");
|
||||||
|
}
|
||||||
|
|
||||||
if (!sa.hasParam("Permanent")) {
|
if (!sa.hasParam("Permanent")) {
|
||||||
sb.append("until end of turn.");
|
sb.append("until end of turn.");
|
||||||
|
} else {
|
||||||
|
sb.append(".");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2048,16 +2048,6 @@ public class Card extends GameEntity implements Comparable<Card> {
|
|||||||
sb.append("\r\n");
|
sb.append("\r\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
// maybe move to CardView for better output
|
|
||||||
if (canBlockAny()) {
|
|
||||||
sb.append("CARDNAME can block any number of creatures.");
|
|
||||||
sb.append("\r\n");
|
|
||||||
} else if (!canBlockAdditional.isEmpty()){
|
|
||||||
sb.append("CARDNAME can block an additional ");
|
|
||||||
sb.append(Lang.nounWithNumeral(canBlockAdditional(), "creature"));
|
|
||||||
sb.append(" creatures each combat.");
|
|
||||||
sb.append("\r\n");
|
|
||||||
}
|
|
||||||
// replace triple line feeds with double line feeds
|
// replace triple line feeds with double line feeds
|
||||||
int start;
|
int start;
|
||||||
final String s = "\r\n\r\n\r\n";
|
final String s = "\r\n\r\n\r\n";
|
||||||
@@ -6243,12 +6233,17 @@ public class Card extends GameEntity implements Comparable<Card> {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
canBlockAdditional.put(timestamp, n);
|
canBlockAdditional.put(timestamp, n);
|
||||||
|
getView().updateBlockAdditional(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean removeCanBlockAdditional(long timestamp) {
|
public boolean removeCanBlockAdditional(long timestamp) {
|
||||||
return canBlockAdditional.remove(timestamp) != null;
|
boolean result = canBlockAdditional.remove(timestamp) != null;
|
||||||
|
if (result) {
|
||||||
|
getView().updateBlockAdditional(this);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int canBlockAdditional() {
|
public int canBlockAdditional() {
|
||||||
int result = 0;
|
int result = 0;
|
||||||
for (Integer v : canBlockAdditional.values()) {
|
for (Integer v : canBlockAdditional.values()) {
|
||||||
@@ -6259,10 +6254,15 @@ public class Card extends GameEntity implements Comparable<Card> {
|
|||||||
|
|
||||||
public void addCanBlockAny(long timestamp) {
|
public void addCanBlockAny(long timestamp) {
|
||||||
canBlockAny.add(timestamp);
|
canBlockAny.add(timestamp);
|
||||||
|
getView().updateBlockAdditional(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean removeCanBlockAny(long timestamp) {
|
public boolean removeCanBlockAny(long timestamp) {
|
||||||
return canBlockAny.remove(timestamp);
|
boolean result = canBlockAny.remove(timestamp);
|
||||||
|
if (result) {
|
||||||
|
getView().updateBlockAdditional(this);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canBlockAny() {
|
public boolean canBlockAny() {
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ import forge.trackable.TrackableCollection;
|
|||||||
import forge.trackable.TrackableObject;
|
import forge.trackable.TrackableObject;
|
||||||
import forge.trackable.TrackableProperty;
|
import forge.trackable.TrackableProperty;
|
||||||
import forge.trackable.Tracker;
|
import forge.trackable.Tracker;
|
||||||
|
import forge.util.Lang;
|
||||||
import forge.util.collect.FCollectionView;
|
import forge.util.collect.FCollectionView;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
@@ -608,6 +609,22 @@ public class CardView extends GameEntityView {
|
|||||||
sb.append("\r\n");
|
sb.append("\r\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (getCanBlockAny()) {
|
||||||
|
sb.append("\r\n\r\n");
|
||||||
|
sb.append("CARDNAME can block any number of creatures.".replaceAll("CARDNAME", getName()));
|
||||||
|
sb.append("\r\n");
|
||||||
|
} else {
|
||||||
|
int i = getBlockAdditional();
|
||||||
|
if (i > 0) {
|
||||||
|
sb.append("\r\n\r\n");
|
||||||
|
sb.append("CARDNAME can block an additional ".replaceAll("CARDNAME", getName()));
|
||||||
|
sb.append(i == 1 ? "creature" : Lang.nounWithNumeral(i, "creature"));
|
||||||
|
sb.append(" each combat.");
|
||||||
|
sb.append("\r\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
String cloner = get(TrackableProperty.Cloner);
|
String cloner = get(TrackableProperty.Cloner);
|
||||||
if (!cloner.isEmpty()) {
|
if (!cloner.isEmpty()) {
|
||||||
sb.append("\r\nCloned by: ").append(cloner);
|
sb.append("\r\nCloned by: ").append(cloner);
|
||||||
@@ -712,6 +729,19 @@ public class CardView extends GameEntityView {
|
|||||||
set(TrackableProperty.HiddenId, hiddenId);
|
set(TrackableProperty.HiddenId, hiddenId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int getBlockAdditional() {
|
||||||
|
return get(TrackableProperty.BlockAdditional);
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean getCanBlockAny() {
|
||||||
|
return get(TrackableProperty.BlockAny);
|
||||||
|
}
|
||||||
|
|
||||||
|
void updateBlockAdditional(Card c) {
|
||||||
|
set(TrackableProperty.BlockAdditional, c.canBlockAdditional());
|
||||||
|
set(TrackableProperty.BlockAny, c.canBlockAny());
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
String name = getName();
|
String name = getName();
|
||||||
|
|||||||
@@ -88,6 +88,8 @@ public enum TrackableProperty {
|
|||||||
HasTrample(TrackableTypes.BooleanType),
|
HasTrample(TrackableTypes.BooleanType),
|
||||||
YouMayLook(TrackableTypes.BooleanType),
|
YouMayLook(TrackableTypes.BooleanType),
|
||||||
OpponentMayLook(TrackableTypes.BooleanType),
|
OpponentMayLook(TrackableTypes.BooleanType),
|
||||||
|
BlockAdditional(TrackableTypes.IntegerType),
|
||||||
|
BlockAny(TrackableTypes.BooleanType),
|
||||||
AbilityText(TrackableTypes.StringType),
|
AbilityText(TrackableTypes.StringType),
|
||||||
NonAbilityText(TrackableTypes.StringType),
|
NonAbilityText(TrackableTypes.StringType),
|
||||||
FoilIndex(TrackableTypes.IntegerType),
|
FoilIndex(TrackableTypes.IntegerType),
|
||||||
|
|||||||
Reference in New Issue
Block a user