use of mage.game.permanent.PermanentImpl 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.game.permanent.PermanentImpl in project mage by magefree.
the class AbilityPickerTest method getAbilitiesFromCard.
private Abilities<Ability> getAbilitiesFromCard(String cardName) {
CardInfo info = CardRepository.instance.findCard(cardName);
PermanentImpl permanent = new PermanentCard(info.getCard(), playerA.getId(), currentGame);
return permanent.getAbilities(currentGame);
}
use of mage.game.permanent.PermanentImpl 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));
}
Aggregations