use of mage.remote.traffic.ZippedObjectImpl in project mage by magefree.
the class SerializationTest method test_Game.
@Test
public void test_Game() {
addCard(Zone.BATTLEFIELD, playerA, "Grizzly Bears", 1);
setStopAt(1, PhaseStep.END_TURN);
execute();
GameView gameView = getGameView(playerA);
Object compressed = CompressUtil.compress(gameView);
Assert.assertTrue("Must be zip", compressed instanceof ZippedObjectImpl);
GameView uncompressed = (GameView) CompressUtil.decompress(compressed);
Assert.assertEquals("Must be same", 1, uncompressed.getPlayers().get(0).getBattlefield().size());
}
use of mage.remote.traffic.ZippedObjectImpl in project mage by magefree.
the class SerializationTest method test_PermanentImpl_Simple.
@Test
public void test_PermanentImpl_Simple() {
CardInfo cardInfo = CardRepository.instance.findCard("Balduvian Bears");
Card newCard = cardInfo.getCard();
Card permCard = CardUtil.getDefaultCardSideForBattlefield(currentGame, newCard);
PermanentImpl permanent = new PermanentCard(permCard, playerA.getId(), currentGame);
currentGame.addPermanent(permanent, 0);
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());
}
use of mage.remote.traffic.ZippedObjectImpl in project mage by magefree.
the class SerializationTest method test_PermanentImpl_MarkedDamageInfo.
@Test
public void test_PermanentImpl_MarkedDamageInfo() {
CardInfo cardInfo = CardRepository.instance.findCard("Balduvian Bears");
Card newCard = cardInfo.getCard();
Card permCard = CardUtil.getDefaultCardSideForBattlefield(currentGame, newCard);
PermanentImpl permanent = new PermanentCard(permCard, playerA.getId(), currentGame);
currentGame.addPermanent(permanent, 0);
// mark damage from infected ability
permanent.addAbility(InfectAbility.getInstance(), null, currentGame);
permanent.markDamage(1, permanent.getId(), null, 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));
}
use of mage.remote.traffic.ZippedObjectImpl in project mage by magefree.
the class SerializationTest method processSingleCard.
private void processSingleCard(CardInfo cardInfo) {
// compress each card's part
Card newCard = cardInfo.getCard();
CardUtil.getObjectPartsAsObjects(newCard).stream().map(Card.class::cast).forEach(card -> {
Card testCard = CardUtil.getDefaultCardSideForBattlefield(currentGame, newCard);
Card testPermanent = null;
if (!testCard.isInstantOrSorcery()) {
testPermanent = new PermanentCard(testCard, playerA.getId(), currentGame);
}
// card
{
Object compressed = CompressUtil.compress(testCard);
Assert.assertTrue("Must be zip", compressed instanceof ZippedObjectImpl);
Card uncompressed = (Card) CompressUtil.decompress(compressed);
Assert.assertEquals("Must be same", testCard.getName(), uncompressed.getName());
}
// permanent
if (testPermanent != null) {
Object compressed = CompressUtil.compress(testPermanent);
Assert.assertTrue("Must be zip", compressed instanceof ZippedObjectImpl);
Card uncompressed = (Card) CompressUtil.decompress(compressed);
Assert.assertEquals("Must be same", testPermanent.getName(), uncompressed.getName());
}
});
}
use of mage.remote.traffic.ZippedObjectImpl in project mage by magefree.
the class SerializationTest method test_LondonMulligan.
@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());
}
Aggregations