* Fixed a bug that adding counters with Skyship Plunder or Maulfist Revolution did not trigger counter added events.

This commit is contained in:
LevelX2 2017-01-13 22:40:37 +01:00
parent 350436dee2
commit 17fbee2400
6 changed files with 58 additions and 81 deletions

View file

@ -73,13 +73,6 @@ public class Counter implements Serializable {
this.count = counter.count;
}
/**
* Increases the {@code count} by 1
*/
public void increase() {
count++;
}
/**
* Adds the passed in {@code amount} to the {@code count}
*

View file

@ -24,8 +24,7 @@
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
*/
package mage.counters;
import java.io.Serializable;
@ -52,11 +51,6 @@ public class Counters extends HashMap<String, Counter> implements Serializable {
return new Counters(this);
}
public void addCounter(String name) {
putIfAbsent(name, new Counter(name));
this.get(name).increase();
}
public void addCounter(String name, int amount) {
putIfAbsent(name, new Counter(name));
this.get(name).add(amount);

View file

@ -1,10 +1,9 @@
package mage.counters;
import static org.junit.Assert.*;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* Custom unit tests for {@link Counter}
*/
@ -17,20 +16,6 @@ public class CounterTest {
counter = new Counter("test", 1);
}
@Test
public void shouldIncreaseCounter() {
// given
// when
counter.increase();
// then
assertEquals(2, counter.getCount());
assertEquals("test", counter.getName());
}
@Test
public void shouldAddMana() {
// given
@ -42,38 +27,10 @@ public class CounterTest {
assertEquals(6, counter.getCount());
}
@Test
public void shouldDecreaseCounter() {
// given
// when
counter.decrease();
// then
assertEquals(0, counter.getCount());
}
@Test
public void shouldNotDecreaseToLessThanZero() {
// given
// when
counter.decrease();
counter.decrease();
// then
assertEquals(0, counter.getCount());
}
@Test
public void shouldRemoveCounters() {
// given
// when
counter.remove(1);
@ -81,7 +38,6 @@ public class CounterTest {
assertEquals(0, counter.getCount());
}
@Test
public void shouldNotRemoveMoreCountersThanAvailable() {
// given
@ -93,7 +49,6 @@ public class CounterTest {
assertEquals(0, counter.getCount());
}
@Test
public void shouldReturnCopy() {
// given
@ -106,7 +61,6 @@ public class CounterTest {
assertFalse(copy == counter);
}
@Test
public void shouldCreateCounterFromCounter() {
// given
@ -119,12 +73,10 @@ public class CounterTest {
assertEquals("test", copy.getName());
}
@Test
public void shouldCreatDefaultCounter() {
// given
// when
Counter defaultCounter = new Counter("default");
@ -132,4 +84,4 @@ public class CounterTest {
assertEquals(1, defaultCounter.getCount());
assertEquals("default", defaultCounter.getName());
}
}
}