Fixed missing serialization settings (#6420);

This commit is contained in:
Oleg Agafonov 2020-04-16 09:17:41 +04:00
parent 972a32446a
commit 10348faaec
2 changed files with 27 additions and 1 deletions

View file

@ -3,7 +3,11 @@ package org.mage.test.serverside.performance;
import mage.abilities.keyword.InfectAbility;
import mage.cards.repository.CardInfo;
import mage.cards.repository.CardRepository;
import mage.constants.PhaseStep;
import mage.constants.Zone;
import mage.counters.CounterType;
import mage.game.Game;
import mage.game.mulligan.LondonMulligan;
import mage.game.permanent.PermanentCard;
import mage.game.permanent.PermanentImpl;
import mage.remote.traffic.ZippedObjectImpl;
@ -50,4 +54,25 @@ public class SerializationTest extends CardTestPlayerBase {
Assert.assertEquals("Must get infected counter", 1, permanent.getCounters(currentGame).getCount(CounterType.M1M1));
}
@Test
public void test_LondonMulligan() {
LondonMulligan mulligan = new LondonMulligan(15);
Object compressed = CompressUtil.compress(mulligan);
Assert.assertTrue("Must be zip", compressed instanceof ZippedObjectImpl);
LondonMulligan uncompressed = (LondonMulligan) CompressUtil.decompress(compressed);
Assert.assertEquals("Must be same", mulligan.getFreeMulligans(), uncompressed.getFreeMulligans());
}
@Test
public void test_Game() {
addCard(Zone.BATTLEFIELD, playerA, "Grizzly Bears", 1);
setStopAt(1, PhaseStep.END_TURN);
execute();
Object compressed = CompressUtil.compress(currentGame);
Assert.assertTrue("Must be zip", compressed instanceof ZippedObjectImpl);
Game uncompressed = (Game) CompressUtil.decompress(compressed);
Assert.assertEquals("Must be same", 1, uncompressed.getBattlefield().getAllActivePermanents().size());
}
}

View file

@ -4,9 +4,10 @@ import mage.game.Game;
import mage.game.events.GameEvent;
import mage.players.Player;
import java.io.Serializable;
import java.util.*;
public abstract class Mulligan {
public abstract class Mulligan implements Serializable {
protected final int freeMulligans;
protected final Map<UUID, Integer> usedFreeMulligans = new HashMap<>();