mirror of
https://github.com/correl/mage.git
synced 2024-11-28 19:19:55 +00:00
* Infected counters - fixed rollback error on usage;
This commit is contained in:
parent
1b3a5d625b
commit
9ec6aa83c4
2 changed files with 55 additions and 1 deletions
|
@ -0,0 +1,53 @@
|
|||
package org.mage.test.serverside.performance;
|
||||
|
||||
import mage.abilities.keyword.InfectAbility;
|
||||
import mage.cards.repository.CardInfo;
|
||||
import mage.cards.repository.CardRepository;
|
||||
import mage.counters.CounterType;
|
||||
import mage.game.permanent.PermanentCard;
|
||||
import mage.game.permanent.PermanentImpl;
|
||||
import mage.remote.traffic.ZippedObjectImpl;
|
||||
import mage.utils.CompressUtil;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.mage.test.serverside.base.CardTestPlayerBase;
|
||||
|
||||
/**
|
||||
* @author JayDi85
|
||||
*/
|
||||
public class SerializationTest extends CardTestPlayerBase {
|
||||
|
||||
@Test
|
||||
public void test_PermanentImpl_Simple() {
|
||||
CardInfo cardInfo = CardRepository.instance.findCard("Balduvian Bears");
|
||||
PermanentImpl permanent = new PermanentCard(cardInfo.getCard(), playerA.getId(), currentGame);
|
||||
currentGame.addPermanent(permanent);
|
||||
|
||||
Object compressed = CompressUtil.compress(permanent);
|
||||
Assert.assertTrue("Must be zip", compressed instanceof ZippedObjectImpl);
|
||||
PermanentImpl uncompressed = (PermanentImpl) CompressUtil.decompress(compressed);
|
||||
Assert.assertEquals("Must be same", permanent.getName(), uncompressed.getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_PermanentImpl_MarkedDamageInfo() {
|
||||
CardInfo cardInfo = CardRepository.instance.findCard("Balduvian Bears");
|
||||
PermanentImpl permanent = new PermanentCard(cardInfo.getCard(), playerA.getId(), currentGame);
|
||||
currentGame.addPermanent(permanent);
|
||||
|
||||
// mark damage from infected ability
|
||||
permanent.addAbility(InfectAbility.getInstance(), currentGame);
|
||||
permanent.markDamage(1, permanent.getId(), currentGame, false, false);
|
||||
|
||||
// test compress (it uses default java serialization)
|
||||
Object compressed = CompressUtil.compress(permanent);
|
||||
Assert.assertTrue("Must be zip", compressed instanceof ZippedObjectImpl);
|
||||
PermanentImpl uncompressed = (PermanentImpl) CompressUtil.decompress(compressed);
|
||||
Assert.assertEquals("Must be same", permanent.getName(), uncompressed.getName());
|
||||
|
||||
// ensure that it was marked damage
|
||||
permanent.applyDamage(currentGame);
|
||||
Assert.assertEquals("Must get infected counter", 1, permanent.getCounters(currentGame).getCount(CounterType.M1M1));
|
||||
}
|
||||
|
||||
}
|
|
@ -37,6 +37,7 @@ import mage.util.GameLog;
|
|||
import mage.util.ThreadLocalStringBuilder;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
|
@ -46,7 +47,7 @@ public abstract class PermanentImpl extends CardImpl implements Permanent {
|
|||
|
||||
private static final Logger logger = Logger.getLogger(PermanentImpl.class);
|
||||
|
||||
static class MarkedDamageInfo {
|
||||
static class MarkedDamageInfo implements Serializable {
|
||||
|
||||
public MarkedDamageInfo(Counter counter, MageObject sourceObject) {
|
||||
this.counter = counter;
|
||||
|
|
Loading…
Reference in a new issue