Search in sources :

Example 1 with PermanentImpl

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());
}
Also used : CardInfo(mage.cards.repository.CardInfo) PermanentImpl(mage.game.permanent.PermanentImpl) ZippedObjectImpl(mage.remote.traffic.ZippedObjectImpl) PermanentCard(mage.game.permanent.PermanentCard) Card(mage.cards.Card) PermanentCard(mage.game.permanent.PermanentCard) Test(org.junit.Test)

Example 2 with PermanentImpl

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);
}
Also used : CardInfo(mage.cards.repository.CardInfo) PermanentImpl(mage.game.permanent.PermanentImpl) PermanentCard(mage.game.permanent.PermanentCard)

Example 3 with PermanentImpl

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));
}
Also used : CardInfo(mage.cards.repository.CardInfo) PermanentImpl(mage.game.permanent.PermanentImpl) ZippedObjectImpl(mage.remote.traffic.ZippedObjectImpl) PermanentCard(mage.game.permanent.PermanentCard) Card(mage.cards.Card) PermanentCard(mage.game.permanent.PermanentCard) Test(org.junit.Test)

Aggregations

CardInfo (mage.cards.repository.CardInfo)3 PermanentCard (mage.game.permanent.PermanentCard)3 PermanentImpl (mage.game.permanent.PermanentImpl)3 Card (mage.cards.Card)2 ZippedObjectImpl (mage.remote.traffic.ZippedObjectImpl)2 Test (org.junit.Test)2