Fix #9649 and clean up counter effect text generation

This commit is contained in:
Alex W. Jackson 2022-10-14 00:41:02 -04:00
parent 5ec2cd0378
commit 332db3aecb
17 changed files with 117 additions and 374 deletions

View file

@ -1,6 +1,7 @@
package mage.counters;
import mage.util.CardUtil;
import java.io.Serializable;
import org.apache.log4j.Logger;
@ -56,20 +57,6 @@ public class Counter implements Serializable {
count += amount;
}
/**
* Decreases the {@code count} by one. Will not allow the count to be less
* than 0. If an attempt is made to make the count be less than zero, the
* call will be logged.
*/
public void decrease() {
if (count > 0) {
count--;
} else {
logger.warn("An attempt was made to set the counter '" + name
+ "' to less than 0. Setting to 0.");
}
}
/**
* Decreases the {@code count} by the passed in {@code amount}. Will not
* allow the count to be less than 0. If an attempt is made to make the
@ -105,6 +92,15 @@ public class Counter implements Serializable {
return count;
}
/**
* Returns a full description of this {@link Counter}, e.g. "a +1/+1 counter" or "two -1/-1 counters"
*
* @return a full description of this {@link Counter}
*/
public String getDescription() {
return CardUtil.numberToText(Math.max(count, 1), CounterType.findArticle(name)) + ' ' + name + (count > 1 ? " counters" : " counter");
}
/**
* Returns a deep copy of this object.
*