Merge origin/master into pull1

This commit is contained in:
Matt Oslan 2016-09-04 10:36:11 -04:00
commit 9b1dd2ceeb
304 changed files with 2419 additions and 628 deletions

View file

@ -10,6 +10,8 @@ public interface CardImageSource {
String generateURL(CardDownloadData card) throws Exception; String generateURL(CardDownloadData card) throws Exception;
String generateTokenUrl(CardDownloadData card) throws Exception; String generateTokenUrl(CardDownloadData card) throws Exception;
String getNextHttpImageUrl();
String getFileForHttpImage(String httpImageUrl);
String getSourceName(); String getSourceName();
Float getAverageSize(); Float getAverageSize();
} }

View file

@ -146,6 +146,16 @@ public class MagicCardsImageSource implements CardImageSource {
return instance; return instance;
} }
@Override
public String getNextHttpImageUrl() {
return null;
}
@Override
public String getFileForHttpImage(String httpImageUrl) {
return null;
}
@Override @Override
public String generateURL(CardDownloadData card) throws Exception { public String generateURL(CardDownloadData card) throws Exception {
String collectorId = card.getCollectorId(); String collectorId = card.getCollectorId();

View file

@ -55,6 +55,16 @@ public class MtgImageSource implements CardImageSource {
return "mtgimage.com"; return "mtgimage.com";
} }
@Override
public String getNextHttpImageUrl() {
return null;
}
@Override
public String getFileForHttpImage(String httpImageUrl) {
return null;
}
@Override @Override
public String generateURL(CardDownloadData card) throws Exception { public String generateURL(CardDownloadData card) throws Exception {
String collectorId = card.getCollectorId(); String collectorId = card.getCollectorId();

View file

@ -0,0 +1,358 @@
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package org.mage.plugins.card.dl.sources;
import java.io.IOException;
import java.net.URL;
import java.util.HashMap;
import org.apache.log4j.Logger;
import org.mage.plugins.card.images.CardDownloadData;
import org.mage.plugins.card.images.DownloadPictures;
/**
*
* @author spjspj
*/
public class MtgOnlTokensImageSource implements CardImageSource {
private static final Logger logger = Logger.getLogger(MtgOnlTokensImageSource.class);
private static CardImageSource instance = new MtgOnlTokensImageSource();
public static CardImageSource getInstance() {
if (instance == null) {
instance = new MtgOnlTokensImageSource();
}
return instance;
}
@Override
public String getSourceName() {
return "http://mtg.onl/token-list/tokens/";
}
@Override
public Float getAverageSize() {
return 26.7f;
}
@Override
public String getNextHttpImageUrl() {
if (copyUrlToImage == null) {
setupLinks();
}
for (String key : copyUrlToImageDone.keySet()) {
if (copyUrlToImageDone.get(key) == false) {
copyUrlToImageDone.put(key, true);
return key;
}
}
return null;
}
@Override
public String getFileForHttpImage(String httpImageUrl) {
if (httpImageUrl != null) {
return copyUrlToImage.get(httpImageUrl);
}
return null;
}
@Override
public String generateURL(CardDownloadData card) throws Exception {
return null;
}
HashMap<String, String> copyUrlToImage = null;
HashMap<String, String> copyImageToUrl = null;
HashMap<String, Boolean> copyUrlToImageDone = null;
private void setupLinks() {
if (copyUrlToImage != null) {
return;
}
copyUrlToImage = new HashMap<String, String>();
copyImageToUrl = new HashMap<String, String>();
copyUrlToImageDone = new HashMap<String, Boolean>();
copyUrlToImage.put("Angel_B_3_3.jpg", "ANGEL.B.ANGEL.CREATURE.3.3.full.jpg");
copyUrlToImage.put("Angel_W_3_3.jpg", "ANGEL.W.ANGEL.CREATURE.3.3.full.jpg");
copyUrlToImage.put("Angel_W_4_4.jpg", "ANGEL.W.ANGEL.CREATURE.4.4.full.jpg");
copyUrlToImage.put("Ape_G_2_2.jpg", "APE.G.APE.CREATURE.2.2.full.jpg");
copyUrlToImage.put("Ape_G_3_3.jpg", "APE.G.APE.CREATURE.3.3.full.jpg");
copyUrlToImage.put("Ashaya_the_Awoken_World_G_4_4.jpg", "ASHAYATHEAWOKENWORLD.G.ELEMENTAL.CREATURE.4.4.full.jpg");
copyUrlToImage.put("Assassin_B_1_1.jpg", "ASSASSIN.B.ASSASSIN.CREATURE.1.1.full.jpg");
copyUrlToImage.put("Assembly-Worker_2_2.jpg", "ASSEMBLYWORKER..ASSEMBLYWORKER.ARTIFACTCREATURE.2.2.full.jpg");
copyUrlToImage.put("Avatar_W_y_y.jpg", "AVATAR.W.AVATAR.CREATURE.S.S.full.jpg");
copyUrlToImage.put("Bat_B_1_1.jpg", "BAT.B.BAT.CREATURE.1.1.full.jpg");
copyUrlToImage.put("Bat_B_1_2.jpg", "BAT.B.BAT.CREATURE.1.2.full.jpg");
copyUrlToImage.put("Bear_G_2_2.jpg", "BEAR.G.BEAR.CREATURE.2.2.full.jpg");
copyUrlToImage.put("Bear_G_4_4.jpg", "BEAR.G.BEAR.CREATURE.4.4.full.jpg");
copyUrlToImage.put("Beast_B_3_3.jpg", "BEAST.B.BEAST.CREATURE.3.3.full.jpg");
copyUrlToImage.put("Beast_G_3_3.jpg", "BEAST.G.BEAST.CREATURE.3.3.full.jpg");
copyUrlToImage.put("Beast_G_2_2.jpg", "BEAST.G.BEAST.CREATURE.2.2.full.jpg");
copyUrlToImage.put("Beast_G_4_4.jpg", "BEAST.G.BEAST.CREATURE.4.4.full.jpg");
copyUrlToImage.put("Beast_G_5_5.jpg", "BEAST.G.BEAST.CREATURE.5.5.full.jpg");
copyUrlToImage.put("Beast_RGW_8_8.jpg", "BEAST.WRG.BEAST.CREATURE.8.8.full.jpg");
copyUrlToImage.put("Bird_Soldier_W_1_1.jpg", "BIRDSOLDIER.W.BIRD.CREATURE.1.1.full.jpg");
copyUrlToImage.put("Bird_U_1_1.jpg", "BIRD.U.BIRD.CREATURE.1.1.full.jpg");
copyUrlToImage.put("Bird_U_2_2.jpg", "BIRD.U.BIRD.CREATURE.2.2.full.jpg");
copyUrlToImage.put("Bird_U_2_2_Enchantment.jpg", "BIRD.U.BIRD.ENCHANTMENTCREATURE.2.2.full.jpg");
copyUrlToImage.put("Bird_WU_1_1.jpg", "BIRD.WU.BIRD.CREATURE.1.1.full.jpg");
copyUrlToImage.put("Bird_W_1_1.jpg", "BIRD.W.BIRD.CREATURE.1.1.full.jpg");
copyUrlToImage.put("Bird_W_3_3.jpg", "BIRD.W.BIRD.CREATURE.3.3.full.jpg");
copyUrlToImage.put("Bird_W_3_4.jpg", "BIRD.W.BIRD.CREATURE.3.4.full.jpg");
copyUrlToImage.put("Boar_G_2_2.jpg", "BOAR.G.BOAR.CREATURE.2.2.full.jpg");
copyUrlToImage.put("Boar_G_3_3.jpg", "BOAR.G.BOAR.CREATURE.3.3.full.jpg");
copyUrlToImage.put("Butterfly_G_1_1.jpg", "BUTTERFLY.G.INSECT.CREATURE.1.1.full.jpg");
copyUrlToImage.put("Camarid_U_1_1.jpg", "CAMARID.U.CAMARID.CREATURE.1.1.full.jpg");
copyUrlToImage.put("Caribou_W_0_1.jpg", "CARIBOU.W.CARIBOU.CREATURE.0.1.full.jpg");
copyUrlToImage.put("Carnivore_R_3_1.jpg", "CARNIVORE.R.BEAST.CREATURE.3.1.full.jpg");
copyUrlToImage.put("Cat_B_2_1.jpg", "CAT.B.CAT.CREATURE.2.1.full.jpg");
copyUrlToImage.put("Cat_G_1_1.jpg", "CAT.G.CAT.CREATURE.1.1.full.jpg");
copyUrlToImage.put("Cat_R_1_1.jpg", "CAT.R.CAT.CREATURE.1.1.full.jpg");
copyUrlToImage.put("Cat_Soldier_W_1_1.jpg", "CATSOLDIER.W.CATSOLDIER.CREATURE.1.1.full.jpg");
copyUrlToImage.put("Cat_W_2_2.jpg", "CAT.W.CAT.CREATURE.2.2.full.jpg");
copyUrlToImage.put("Cat_Warrior_G_2_2.jpg", "CATWARRIOR.G.CATWARRIOR.CREATURE.2.2.full.jpg");
copyUrlToImage.put("Centaur_G_3_3.jpg", "CENTAUR.G.CENTAUR.CREATURE.3.3.full.jpg");
copyUrlToImage.put("Centaur_G_3_3_Enchantment.jpg", "CENTAUR.G.CENTAUR.ENCHANTMENTCREATURE.3.3.full.jpg");
copyUrlToImage.put("Centaur_G_3_3_protection.jpg", "CENTAUR.G.CENTAUR.CREATURE.3.3a.full.jpg");
copyUrlToImage.put("Citizen_W_1_1.jpg", "CITIZEN.W.CITIZEN.CREATURE.1.1.full.jpg");
copyUrlToImage.put("Cleric_WB_1_1.jpg", "CLERIC.WB.CLERIC.CREATURE.1.1.full.jpg");
copyUrlToImage.put("Cleric_W_2_1.jpg", "CLERIC.W.CLERIC.CREATUREENCHANTMENT.2.1.full.jpg");
copyUrlToImage.put("Cloud_Sprite_U_1_1.jpg", "CLOUDSPRITE.U.FAERIE.CREATURE.1.1.full.jpg");
copyUrlToImage.put("Clue.jpg", "CLUE..CLUE.ARTIFACT.0.0.full.jpg");
copyUrlToImage.put("Construct_1_1.jpg", "CONSTRUCT..CONSTRUCT.ARTIFACTCREATURE.1.1.full.jpg");
copyUrlToImage.put("Construct_6_12.jpg", "CONSTRUCT..CONSTRUCT.CREATUREARTIFACT.6.12.full.jpg");
copyUrlToImage.put("Demon_B_5_5.jpg", "DEMON.B.DEMON.CREATURE.5.5.full.jpg");
copyUrlToImage.put("Demon_B_y_y.jpg", "DEMON.B.DEMON.CREATURE.S.S.full.jpg");
copyUrlToImage.put("Devil_R_1_1.jpg", "DEVIL.R.DEVIL.CREATURE.1.1.full.jpg");
copyUrlToImage.put("Djinn_5_5.jpg", "DJINN..DJINN.ARTIFACTCREATURE.5.5.full.jpg");
copyUrlToImage.put("Djinn_Monk_U_2_2.jpg", "DJINNMONK.U.DJINNMONK.CREATURE.2.2.full.jpg");
copyUrlToImage.put("Dragon_RG_1_1.jpg", "DRAGON.RG.DRAGON.CREATURE.1.1.full.jpg");
copyUrlToImage.put("Dragon_R_2_2.jpg", "DRAGON.R.DRAGON.CREATURE.2.2.full.jpg");
copyUrlToImage.put("Dragon_R_4_4.jpg", "DRAGON.R.DRAGON.CREATURE.4.4.full.jpg");
copyUrlToImage.put("Dragon_R_5_5.jpg", "DRAGON.R.DRAGON.CREATURE.5.5.full.jpg");
copyUrlToImage.put("Dragon_R_6_6.jpg", "DRAGON.R.DRAGON.CREATURE.6.6.full.jpg");
copyUrlToImage.put("Dragon_Spirit_U_5_5.jpg", "DRAGONSPIRIT.U.DRAGONSPIRIT.CREATURE.5.5.full.jpg");
copyUrlToImage.put("Drake_UG_2_2.jpg", "DRAKE.UG.DRAKE.CREATURE.2.2.full.jpg");
copyUrlToImage.put("Drake_U_2_2.jpg", "DRAKE.U.DRAKE.CREATURE.2.2.full.jpg");
copyUrlToImage.put("Eldrazi_10_10.jpg", "ELDRAZI..ELDRAZI.CREATURE.10.10.full.jpg");
copyUrlToImage.put("Eldrazi_Scion_1_1.jpg", "ELDRAZISCION..ELDRAZISCION.CREATURE.1.1.full.jpg");
copyUrlToImage.put("Eldrazi_Spawn_0_1.jpg", "ELDRAZISPAWN..ELDRAZISPAWN.CREATURE.0.1.full.jpg");
copyUrlToImage.put("Elemental_BR_5_5.jpg", "ELEMENTAL.BR.ELEMENTAL.CREATURE.1.1.full.jpg");
copyUrlToImage.put("Elemental_GW_y_y.jpg", "ELEMENTAL.WG.ELEMENTAL.CREATURE.S.S.full.jpg");
copyUrlToImage.put("Elemental_G_2_2.jpg", "ELEMENTAL.G.ELEMENTAL.CREATURE.2.2.full.jpg");
copyUrlToImage.put("Elemental_G_4_4.jpg", "ELEMENTAL.G.ELEMENTAL.CREATURE.4.4.full.jpg");
copyUrlToImage.put("Elemental_G_5_3.jpg", "ELEMENTAL.G.ELEMENTAL.CREATURE.5.3.full.jpg");
copyUrlToImage.put("Elemental_G_7_7.jpg", "ELEMENTAL.G.ELEMENTAL.CREATURE.7.7.full.jpg");
copyUrlToImage.put("Elemental_R_7_1.jpg", "ELEMENTAL.R.ELEMENTAL.CREATURE.7.1.full.jpg");
copyUrlToImage.put("Elemental_Shaman_R_3_1.jpg", "ELEMENTALSHAMAN.R.ELEMENTALSHAMAN.CREATURE.3.1.full.jpg");
copyUrlToImage.put("Elephant_G_3_3.jpg", "ELEPHANT.G.ELEPHANT.CREATURE.3.3.full.jpg");
copyUrlToImage.put("Elf_Druid_G_1_1.jpg", "ELFDRUID.G.ELFDRUID.CREATURE.1.1.full.jpg");
copyUrlToImage.put("Elf_G_1_1.jpg", "ELFWARRIOR.G.ELFWARRIOR.CREATURE.1.1.full.jpg");
copyUrlToImage.put("Elf_Warrior_GW_1_1.jpg", "ELFWARRIOR.WG.ELFWARRIOR.CREATURE.1.1.full.jpg");
copyUrlToImage.put("Elf_Warrior_G_1_1.jpg", "ELFWARRIOR.G.ELFWARRIOR.CREATURE.1.1.full.jpg");
copyUrlToImage.put("Faerie_Rogue_B_1_1.jpg", "FAERIEROGUE.B.FAERIEROGUE.CREATURE.1.1.full.jpg");
copyUrlToImage.put("Faerie_Rogue_UB_1_1.jpg", "FAERIEROGUE.UB.FAERIEROGUE.CREATURE.1.1.full.jpg");
copyUrlToImage.put("Faerie_U_1_1.jpg", "FAERIE.U.FAERIE.CREATURE.1.1.full.jpg");
copyUrlToImage.put("Festering_Goblin_B_1_1.jpg", "FESTERINGGOBLIN.B.ZOMBIEGOBLIN.CREATURE.1.1.full.jpg");
copyUrlToImage.put("Fish_U_3_3.jpg", "FISH.U.FISH.CREATURE.3.3.full.jpg");
copyUrlToImage.put("Frog_Lizard_G_3_3.jpg", "FROGLIZARD.G.FROGLIZARD.CREATURE.3.3.full.jpg");
copyUrlToImage.put("Gargoyle_3_4.jpg", "GARGOYLE..GARGOYLE.CREATUREARTIFACT.3.4.full.jpg");
copyUrlToImage.put("Germ_B_0_0.jpg", "GERM.B.GERM.CREATURE.0.0.full.jpg");
copyUrlToImage.put("Giant_R_4_4.jpg", "GIANT.R.GIANT.CREATURE.4.4.full.jpg");
copyUrlToImage.put("Giant_Warrior_RG_4_4.jpg", "GIANTWARRIOR.RG.GIANTWARRIOR.CREATURE.4.4.full.jpg");
copyUrlToImage.put("Giant_Warrior_W_5_5.jpg", "GIANTWARRIOR.W.GIANTWARRIOR.CREATURE.5.5.full.jpg");
copyUrlToImage.put("Gnome_1_1.jpg", "GNOME..GNOME.ARTIFACTCREATURE.1.1.full.jpg");
copyUrlToImage.put("Goat_W_0_1.jpg", "GOAT.W.GOAT.CREATURE.0.1.full.jpg");
copyUrlToImage.put("Goblin_R_1_1.jpg", "GOBLIN.R.GOBLIN.CREATURE.1.1.full.jpg");
copyUrlToImage.put("Goblin_R_2_1.jpg", "GOBLIN.R.GOBLIN.CREATURE.2.1.full.jpg");
copyUrlToImage.put("Goblin_Rogue_B_1_1.jpg", "GOBLINROGUE.B.GOBLINROGUE.CREATURE.1.1.full.jpg");
copyUrlToImage.put("Goblin_Scout_R_1_1.jpg", "GOBLINSCOUT.R.GOBLINSCOUT.CREATURE.1.1.full.jpg");
copyUrlToImage.put("Goblin_Soldier_RW_1_1.jpg", "GOBLINSOLDIER.WR.GOBLINSOLDIER.CREATURE.1.1.full.jpg");
copyUrlToImage.put("Goblin_Warrior_RG_1_1.jpg", "GOBLINWARRIOR.RG.GOBLINWARRIOR.CREATURE.1.1.full.jpg");
copyUrlToImage.put("Gold_.jpg", "GOLD...ARTIFACT.0.0.full.jpg");
copyUrlToImage.put("Goldmeadow_Harrier_W_1_1.jpg", "GOLDMEADOWHARRIER.W.KITHKINSOLDIER.CREATURE.1.1.full.jpg");
copyUrlToImage.put("Golem_3_3.jpg", "GOLEM..GOLEM.ARTIFACTCREATURE.3.3.full.jpg");
copyUrlToImage.put("Golem_3_3_Enchantment.jpg", "GOLEM..GOLEM.ENCHANTMENTARTIFACTCREATURE.3.3.full.jpg");
copyUrlToImage.put("Golem_9_9.jpg", "GOLEM..GOLEM.ARTIFACTCREATURE.9.9.full.jpg");
copyUrlToImage.put("Graveborn_BR_3_1.jpg", "GRAVEBORN.BR.GRAVEBORN.CREATURE.3.1.full.jpg");
copyUrlToImage.put("Griffin_W_2_2.jpg", "GRIFFIN.W.GRIFFIN.CREATURE.2.2.full.jpg");
copyUrlToImage.put("Harpy_B_1_1.jpg", "HARPY.B.HARPY.CREATURE.1.1.full.jpg");
copyUrlToImage.put("Hellion_R_4_4.jpg", "HELLION.R.HELLION.CREATURE.4.4.full.jpg");
copyUrlToImage.put("Hippo_G_1_1.jpg", "HIPPO.G.HIPPO.CREATURE.1.1.full.jpg");
copyUrlToImage.put("Homunculus_U_0_1.jpg", "HOMUNCULUS.U.HOMUNCULUS.CREATUREARTIFACT.0.1.full.jpg");
copyUrlToImage.put("Homunculus_U_2_2.jpg", "HOMUNCULUS.U.HOMUNCULUS.CREATURE.2.2.full.jpg");
copyUrlToImage.put("Hornet_1_1.jpg", "HORNET..INSECT.ARTIFACTCREATURE.1.1.full.jpg");
copyUrlToImage.put("Horror_B_4_4.jpg", "HORROR.B.HORROR.CREATURE.4.4.full.jpg");
copyUrlToImage.put("Horror_B_X_X.jpg", "HORROR.B.HORROR.CREATURE.X.X.full.jpg");
copyUrlToImage.put("Horror_UB_1_1.jpg", "HORROR.UB.HORROR.CREATURE.1.1.full.jpg");
copyUrlToImage.put("Horror_X_X.jpg", "HORROR..HORROR.ARTIFACTCREATURE.X.X.full.jpg");
copyUrlToImage.put("Hound_G_1_1.jpg", "HOUND.G.HOUND.CREATURE.1.1.full.jpg");
copyUrlToImage.put("Human_Cleric_WB_1_1.jpg", "HUMANCLERIC.WB.HUMANCLERIC.CREATURE.1.1.full.jpg");
copyUrlToImage.put("Human_R_1_1.jpg", "HUMAN.R.HUMAN.CREATURE.1.1.full.jpg");
copyUrlToImage.put("Human_Soldier_W_1_1.jpg", "HUMANSOLDIER.W.HUMANSOLDIER.CREATURE.1.1.full.jpg");
copyUrlToImage.put("Human_W_1_1.jpg", "HUMAN.W.HUMAN.CREATURE.1.1.full.jpg");
copyUrlToImage.put("Hydra_G_X_X.jpg", "HYDRA.G.HYDRA.CREATURE.X.X.full.jpg");
copyUrlToImage.put("Illusion_U_1_1.jpg", "ILLUSION.U.ILLUSION.CREATURE.1.1.full.jpg");
copyUrlToImage.put("Illusion_U_2_2.jpg", "ILLUSION.U.ILLUSION.CREATURE.2.2.full.jpg");
copyUrlToImage.put("Insect_G_1_1.jpg", "INSECT.G.INSECT.CREATURE.1.1.full.jpg");
copyUrlToImage.put("Insect_G_6_1.jpg", "INSECT.G.INSECT.CREATURE.6.1.full.jpg");
copyUrlToImage.put("Kaldra_4_4.jpg", "KALDRA..AVATAR.CREATURE.4.4.full.jpg");
copyUrlToImage.put("Kavu_B_3_3.jpg", "KAVU.B.KAVU.CREATURE.3.3.full.jpg");
copyUrlToImage.put("Kelp_U_0_1.jpg", "KELP.U.PLANTWALL.CREATURE.0.1.full.jpg");
copyUrlToImage.put("Kithkin_Soldier_W_1_1.jpg", "KITHKINSOLDIER.W.KITHKINSOLDIER.CREATURE.1.1.full.jpg");
copyUrlToImage.put("Knight_Ally_W_2_2.jpg", "KNIGHTALLY.W.KNIGHTALLY.CREATURE.2.2.full.jpg");
copyUrlToImage.put("Knight_B_2_2.jpg", "KNIGHT.B.KNIGHT.CREATURE.2.2.full.jpg");
copyUrlToImage.put("Knight_W_1_1.jpg", "KNIGHT.W.KNIGHT.CREATURE.1.1.full.jpg");
copyUrlToImage.put("Knight_W_2_2.jpg", "KNIGHT.W.KNIGHT.CREATURE.2.2.full.jpg");
copyUrlToImage.put("Kobolds_of_Kher_Keep_R_0_1.jpg", "KOBOLDSOFKHERKEEP.R.KOBOLD.CREATURE.0.1.full.jpg");
copyUrlToImage.put("Kor_Ally_W_1_1.jpg", "KORALLY.W.KORALLY.CREATURE.1.1.full.jpg");
copyUrlToImage.put("Kor_Soldier_W_1_1.jpg", "KORSOLDIER.W.KORSOLDIER.CREATURE.1.1.full.jpg");
copyUrlToImage.put("Kraken_U_9_9.jpg", "KRAKEN.U.KRAKEN.CREATURE.9.9.full.jpg");
copyUrlToImage.put("Landmine_.jpg", "LANDMINE...ARTIFACT.0.0.full.jpg");
copyUrlToImage.put("Lightning_Ranger_R_5_1.jpg", "LIGHTNINGRAGER.R.ELEMENTAL.CREATURE.5.1.full.jpg");
copyUrlToImage.put("Lizard_G_2_2.jpg", "LIZARD.G.LIZARD.CREATURE.2.2.full.jpg");
copyUrlToImage.put("Llanowar_Elves_G_1_1.jpg", "LLANOWARELVES.G.ELFDRUID.CREATURE.1.1.full.jpg");
copyUrlToImage.put("Marit_Lage_B_20_20.jpg", "MARITLAGE.B.AVATAR.CREATURE.20.20.full.jpg");
copyUrlToImage.put("Merfolk_U_1_1.jpg", "MERFOLK.U.MERFOLK.CREATURE.1.1.full.jpg");
copyUrlToImage.put("Merfolk_Wizard_U_1_1.jpg", "MERFOLKWIZARD.U.MERFOLKWIZARD.CREATURE.1.1.full.jpg");
copyUrlToImage.put("Metallic_Sliver_1_1.jpg", "METALLICSLIVER..SLIVER.CREATUREARTIFACT.1.1.full.jpg");
copyUrlToImage.put("Minion_B_1_1.jpg", "MINION.B.MINION.CREATURE.1.1.full.jpg");
copyUrlToImage.put("Minion_B_X_X.jpg", "MINION.B.MINION.CREATURE.X.X.full.jpg");
copyUrlToImage.put("Minor_Demon_BR_1_1.jpg", "MINORDEMON.BR.DEMON.CREATURE.1.1.full.jpg");
copyUrlToImage.put("Minotaur_R_2_3.jpg", "MINOTAUR.R.MINOTAUR.CREATURE.2.3.full.jpg");
copyUrlToImage.put("Monk_W_1_1.jpg", "MONK.W.MONK.CREATURE.1.1.full.jpg");
copyUrlToImage.put("Myr_1_1.jpg", "MYR..MYR.CREATUREARTIFACT.1.1.full.jpg");
copyUrlToImage.put("Octopus_U_8_8.jpg", "OCTOPUS.U.OCTOPUS.CREATURE.8.8.full.jpg");
copyUrlToImage.put("Ogre_R_3_3.jpg", "OGRE.R.OGRE.CREATURE.3.3.full.jpg");
copyUrlToImage.put("Ogre_R_4_4.jpg", "OGRE.R.OGRE.CREATURE.4.4.full.jpg");
copyUrlToImage.put("Ooze_G_1_1.jpg", "OOZE.G.OOZE.CREATURE.1.1.full.jpg");
copyUrlToImage.put("Ooze_G_2_2.jpg", "OOZE.G.OOZE.CREATURE.2.2.full.jpg");
copyUrlToImage.put("Ooze_G_3_3.jpg", "OOZE.G.OOZE.CREATURE.3.3.full.jpg");
copyUrlToImage.put("Orb_U_X_X.jpg", "ORB.U.ORB.CREATURE.X.X.jpg.full.jpg");
copyUrlToImage.put("Pegasus_W_1_1.jpg", "PEGASUS.W.PEGASUS.CREATURE.1.1.full.jpg");
copyUrlToImage.put("Pentavite_1_1.jpg", "PENTAVITE..PENTAVITE.ARTIFACTCREATURE.1.1.full.jpg");
copyUrlToImage.put("Pest_0_1.jpg", "PEST..PEST.ARTIFACTCREATURE.0.1.full.jpg");
copyUrlToImage.put("Pincher_2_2.jpg", "PINCHER..PINCHER.CREATURE.2.2.full.jpg");
copyUrlToImage.put("Plant_G_0_1.jpg", "PLANT.G.PLANT.CREATURE.0.1.full.jpg");
copyUrlToImage.put("Plant_G_1_1.jpg", "PLANT.G.PLANT.CREATURE.1.1.full.jpg");
copyUrlToImage.put("Rat_B_1_1.jpg", "RAT.B.RAT.CREATURE.1.1.full.jpg");
copyUrlToImage.put("Reflection_W_2_2.jpg", "REFLECTION.W.REFLECTION.CREATURE.2.2.full.jpg");
copyUrlToImage.put("Rhino_G_4_4.jpg", "RHINO.G.RHINO.CREATURE.4.4.full.jpg");
copyUrlToImage.put("Rukh_R_4_4.jpg", "BIRD.R.BIRD.CREATURE.4.4.full.jpg");
copyUrlToImage.put("Sand_1_1.jpg", "SAND..SAND.CREATURE.1.1.full.jpg");
copyUrlToImage.put("Sand_Warrior_RGW_1_1.jpg", "SANDWARRIOR.WRG.SANDWARRIOR.CREATURE.1.1.full.jpg");
copyUrlToImage.put("Saporling_G_1_1.jpg", "SAPROLING.G.SAPROLING.CREATURE.1.1.full.jpg");
copyUrlToImage.put("Satyr_RG_2_2.jpg", "SATYR.RG.SATYR.CREATURE.2.2.full.jpg");
copyUrlToImage.put("Serf_B_0_1.jpg", "SERF.B.SERF.CREATURE.0.1.full.jpg");
copyUrlToImage.put("Shapeshifter_1_1.jpg", "SHAPESHIFTER..SHAPESHIFTER.CREATURE.1.1.full.jpg");
copyUrlToImage.put("Skeleton_B_1_1.jpg", "SKELETON.B.SKELETON.CREATURE.1.1.full.jpg");
copyUrlToImage.put("Sliver_1_1.jpg", "SLIVER..SLIVER.CREATURE.1.1.full.jpg");
copyUrlToImage.put("Snake_1_1.jpg", "SNAKE..SNAKE.ARTIFACTCREATURE.1.1.full.jpg");
copyUrlToImage.put("Snake_B_1_1.jpg", "SNAKE.B.SNAKE.CREATURE.1.1.full.jpg");
copyUrlToImage.put("Snake_GB_1_1.jpg", "SNAKE.BG.SNAKE.ENCHANTMENTCREATURE.1.1.full.jpg");
copyUrlToImage.put("Snake_GU_1_1.jpg", "SNAKE.UG.SNAKE.CREATURE.1.1.full.jpg");
copyUrlToImage.put("Snake_G_1_1.jpg", "SNAKE.G.SNAKE.CREATURE.1.1.full.jpg");
copyUrlToImage.put("Soldier_Ally_W_1_1.jpg", "SOLDIERALLY.W.SOLDIERALLY.CREATURE.1.1.full.jpg");
copyUrlToImage.put("Soldier_RW_1_1.jpg", "SOLDIER.WR.SOLDIER.CREATURE.1.1.full.jpg");
copyUrlToImage.put("Soldier_R_1_1.jpg", "SOLDIER.R.SOLDIER.CREATURE.1.1.full.jpg");
copyUrlToImage.put("Soldier_W_1_1.jpg", "SOLDIER.W.SOLDIER.CREATURE.1.1.full.jpg");
copyUrlToImage.put("Soldier_W_1_1_Enchantment.jpg", "SOLDIER.W.SOLDIER.ENCHANTMENTCREATURE.1.1.full.jpg");
copyUrlToImage.put("Spark_Elemental_R_3_1.jpg", "SPARKELEMENTAL.R.ELEMENTAL.CREATURE.3.1.full.jpg");
copyUrlToImage.put("Spawn_2_2.jpg", "SPAWN..SPAWN.ARTIFACTCREATURE.2.2.full.jpg");
copyUrlToImage.put("Sphinx_U_4_4.jpg", "SPHINX.U.SPHINX.CREATURE.4.4.full.jpg");
copyUrlToImage.put("Spider_B_2_4.jpg", "SPIDER.B.SPIDER.CREATURE.2.4.full.jpg");
copyUrlToImage.put("Spider_G_1_2.jpg", "SPIDER.G.SPIDER.CREATURE.1.2.full.jpg");
copyUrlToImage.put("Spider_G_1_3.jpg", "SPIDER.G.SPIDER.ENCHANTMENTCREATURE.1.3.full.jpg");
copyUrlToImage.put("Spike_G_1_1.jpg", "SPIKE.G.SPIKE.CREATURE.1.1.full.jpg");
copyUrlToImage.put("Spirit_1_1.jpg", "SPIRIT..SPIRIT.CREATURE.1.1.full.jpg");
copyUrlToImage.put("Spirit_U_1_1.jpg", "SPIRIT.U.SPIRIT.CREATURE.1.1.full.jpg");
copyUrlToImage.put("Spirit_WB_1_1.jpg", "SPIRIT.WB.SPIRIT.CREATURE.1.1.full.jpg");
copyUrlToImage.put("Spirit_WB_y_y.jpg", "SPIRIT.WB.SPIRIT.ENCHANTMENTCREATURE.S.S.full.jpg");
copyUrlToImage.put("Spirit_W_1_1.jpg", "SPIRIT.W.SPIRIT.CREATURE.1.1.full.jpg");
copyUrlToImage.put("Spirit_W_3_3.jpg", "SPIRIT.W.SPIRIT.CREATURE.3.3.full.jpg");
copyUrlToImage.put("Spirit_Warror_BG_y_y.jpg", "SPIRITWARRIOR.BG.SPIRITWARRIOR.CREATURE.S.S.full.jpg");
copyUrlToImage.put("Squid_U_1_1.jpg", "SQUID.U.SQUID.CREATURE.1.1.full.jpg");
copyUrlToImage.put("Squirrel_G_1_1.jpg", "SQUIRREL.G.SQUIRREL.CREATURE.1.1.full.jpg");
copyUrlToImage.put("Stoneforged_Blade_.jpg", "STONEFORGEDBLADE..EQUIPMENT.ARTIFACT.0.0.full.jpg");
copyUrlToImage.put("Tetravite_1_1.jpg", "TETRAVITE..TETRAVITE.CREATUREARTIFACT.1.1.full.jpg");
copyUrlToImage.put("Thopter_1_1.jpg", "THOPTER..THOPTER.ARTIFACTCREATURE.1.1.full.jpg");
copyUrlToImage.put("Thopter_U_1_1.jpg", "THOPTER.U.THOPTER.CREATUREARTIFACT.1.1.full.jpg");
copyUrlToImage.put("Thrull_B_0_1.jpg", "THRULL.B.THRULL.CREATURE.0.1.full.jpg");
copyUrlToImage.put("Thrull_B_1_1.jpg", "THRULL.B.THRULL.CREATURE.1.1.full.jpg");
copyUrlToImage.put("Treefolk_G_X_X.jpg", "TREEFOLK.G.TREEFOLK.CREATURE.X.X.full.jpg");
copyUrlToImage.put("Treefolk_Shaman_G_2_5.jpg", "TREEFOLKSHAMAN.G.TREEFOLKSHAMAN.CREATURE.2.5.full.jpg");
copyUrlToImage.put("Treefolk_Warrior_G_y_y.jpg", "TREEFOLKWARRIOR.G.TREEFOLKWARRIOR.CREATURE.S.S.full.jpg");
copyUrlToImage.put("Triskelavite_1_1.jpg", "TRISKELAVITE..TRISKELAVITE.ARTIFACTCREATURE.1.1.full.jpg");
copyUrlToImage.put("Tuktuk_the_Returned_5_5.jpg", "TUKTUKTHERETURNED..GOBLIN.ARTIFACTCREATURE.5.5.full.jpg");
copyUrlToImage.put("Urami_B_5_5.jpg", "URAMI.B.DEMONSPIRIT.CREATURE.5.5.full.jpg");
copyUrlToImage.put("Vampire_B_1_1.jpg", "VAMPIRE.B.VAMPIRE.CREATURE.1.1.full.jpg");
copyUrlToImage.put("Vampire_B_2_2.jpg", "VAMPIRE.B.VAMPIRE.CREATURE.2.2.full.jpg");
copyUrlToImage.put("Vampire_B_X_X.jpg", "VAMPIRE.B.VAMPIRE.CREATURE.X.X.full.jpg");
copyUrlToImage.put("Vampire_Knight_B_1_1.jpg", "VAMPIREKNIGHT.B.VAMPIREKNIGHT.CREATURE.1.1.full.jpg");
copyUrlToImage.put("Voja_GW_2_2.jpg", "VOJA.WG.WOLF.CREATURE.2.2.full.jpg");
copyUrlToImage.put("Wall_U_5_5.jpg", "WALL.U.WALL.CREATURE.5.5.full.jpg");
copyUrlToImage.put("Warrior_B_2_1.jpg", "WARRIOR.B.WARRIOR.CREATURE.2.1.full.jpg");
copyUrlToImage.put("Warrior_R_1_1.jpg", "WARRIOR.R.WARRIOR.CREATURE.1.1.full.jpg");
copyUrlToImage.put("Warrior_W_1_1.jpg", "WARRIOR.W.WARRIOR.CREATURE.1.1.full.jpg");
copyUrlToImage.put("Wasp_1_1.jpg", "WASP..INSECT.ARTIFACTCREATURE.1.1.full.jpg");
copyUrlToImage.put("Weird_U_3_3.jpg", "WEIRD.U.WEIRD.CREATURE.3.3.full.jpg");
copyUrlToImage.put("Whale_U_6_6.jpg", "WHALE.U.WHALE.CREATURE.6.6.full.jpg");
copyUrlToImage.put("Wirefly_2_2.jpg", "WIREFLY..INSECT.ARTIFACTCREATURE.2.2.full.jpg");
copyUrlToImage.put("Wolf_G_2_2.jpg", "WOLF.G.WOLF.CREATURE.2.2.full.jpg");
copyUrlToImage.put("Wood_G_0_1.jpg", "WOOD.G.WALL.CREATURE.0.1.full.jpg");
copyUrlToImage.put("Worm_BG_1_1.jpg", "WORM.BG.WORM.CREATURE.1.1.full.jpg");
copyUrlToImage.put("Wurm_3_3.jpg", "WURM..WURM.ARTIFACTCREATURE.3.3.full.jpg");
copyUrlToImage.put("Wurm_B_6_6.jpg", "WURM.B.WURM.CREATURE.6.6.full.jpg");
copyUrlToImage.put("Wurm_G_6_6.jpg", "WURM.G.WURM.CREATURE.6.6.full.jpg");
copyUrlToImage.put("Zombie_B_2_2.jpg", "ZOMBIE.B.ZOMBIE.CREATURE.2.2.full.jpg");
copyUrlToImage.put("Zombie_B_2_2_Enchantment.jpg", "ZOMBIE.B.ZOMBIE.ENCHANTMENTCREATURE.2.2.full.jpg");
copyUrlToImage.put("Zombie_B_5_5.jpg", "ZOMBIEGIANT.B.ZOMBIEGIANT.CREATURE.5.5.full.jpg");
copyUrlToImage.put("Zombie_B_X_X.jpg", "ZOMBIE.B.ZOMBIE.CREATURE.X.X.full.jpg");
copyUrlToImage.put("Zombie_Horror_B_X_X.jpg", "ZOMBIEHORROR.B.ZOMBIEHORROR.CREATURE.X.X.full.jpg");
copyUrlToImage.put("Zombie_U_X_X.jpg", "ZOMBIE.U.ZOMBIE.CREATURE.X.X.full.jpg");
copyUrlToImage.put("Zombie_Wizard_UB_1_1.jpg", "ZOMBIEWIZARD.BG.ZOMBIEWIZARD.CREATURE.1.1.full.jpg");
copyUrlToImage.put("Zombie_Wizard_UB_1_1.jpg", "ZOMBIEWIZARD.UB.ZOMBIEWIZARD.CREATURE.1.1.full.jpg");
for (String key : copyUrlToImage.keySet()) {
copyUrlToImageDone.put(key, false);
copyImageToUrl.put(copyUrlToImage.get(key), key);
}
}
@Override
public String generateTokenUrl(CardDownloadData card) throws IOException {
if (copyUrlToImage == null) {
setupLinks();
}
return null;
}
}

View file

@ -234,4 +234,14 @@ public class MythicspoilerComSource implements CardImageSource {
public Float getAverageSize() { public Float getAverageSize() {
return 50.0f; return 50.0f;
} }
@Override
public String getNextHttpImageUrl() {
return null;
}
@Override
public String getFileForHttpImage(String httpImageUrl) {
return null;
}
} }

View file

@ -67,6 +67,16 @@ public class TokensMtgImageSource implements CardImageSource {
return 26.7f; return 26.7f;
} }
@Override
public String getNextHttpImageUrl() {
return null;
}
@Override
public String getFileForHttpImage(String httpImageUrl) {
return null;
}
@Override @Override
public String generateURL(CardDownloadData card) throws Exception { public String generateURL(CardDownloadData card) throws Exception {
return null; return null;

View file

@ -260,6 +260,16 @@ public class WizardCardsImageSource implements CardImageSource {
languageAliases.put("de", "German"); languageAliases.put("de", "German");
} }
@Override
public String getNextHttpImageUrl() {
return null;
}
@Override
public String getFileForHttpImage(String httpImageUrl) {
return null;
}
private Map<String, String> getSetLinks(String cardSet) { private Map<String, String> getSetLinks(String cardSet) {
ConcurrentHashMap<String, String> setLinks = new ConcurrentHashMap<>(); ConcurrentHashMap<String, String> setLinks = new ConcurrentHashMap<>();
ExecutorService executor = Executors.newFixedThreadPool(10); ExecutorService executor = Executors.newFixedThreadPool(10);

View file

@ -58,6 +58,7 @@ import net.java.truevfs.kernel.spec.FsSyncException;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.mage.plugins.card.dl.sources.CardImageSource; import org.mage.plugins.card.dl.sources.CardImageSource;
import org.mage.plugins.card.dl.sources.MagicCardsImageSource; import org.mage.plugins.card.dl.sources.MagicCardsImageSource;
import org.mage.plugins.card.dl.sources.MtgOnlTokensImageSource;
import org.mage.plugins.card.dl.sources.MythicspoilerComSource; import org.mage.plugins.card.dl.sources.MythicspoilerComSource;
import org.mage.plugins.card.dl.sources.TokensMtgImageSource; import org.mage.plugins.card.dl.sources.TokensMtgImageSource;
import org.mage.plugins.card.dl.sources.WizardCardsImageSource; import org.mage.plugins.card.dl.sources.WizardCardsImageSource;
@ -145,6 +146,7 @@ public class DownloadPictures extends DefaultBoundedRangeModel implements Runnab
"wizards.com", "wizards.com",
"mythicspoiler.com", "mythicspoiler.com",
"tokens.mtg.onl", //"mtgimage.com (HQ)", "tokens.mtg.onl", //"mtgimage.com (HQ)",
"mtg.onl"
//"mtgathering.ru HQ", //"mtgathering.ru HQ",
//"mtgathering.ru MQ", //"mtgathering.ru MQ",
//"mtgathering.ru LQ", //"mtgathering.ru LQ",
@ -172,6 +174,9 @@ public class DownloadPictures extends DefaultBoundedRangeModel implements Runnab
case 3: case 3:
cardImageSource = TokensMtgImageSource.getInstance(); cardImageSource = TokensMtgImageSource.getInstance();
break; break;
case 4:
cardImageSource = MtgOnlTokensImageSource.getInstance();
break;
} }
int count = DownloadPictures.this.cards.size(); int count = DownloadPictures.this.cards.size();
float mb = (count * cardImageSource.getAverageSize()) / 1024; float mb = (count * cardImageSource.getAverageSize()) / 1024;
@ -492,15 +497,30 @@ public class DownloadPictures extends DefaultBoundedRangeModel implements Runnab
url = cardImageSource.generateURL(card); url = cardImageSource.generateURL(card);
} }
if (url != null) { if (url == null) {
Runnable task = new DownloadTask(card, new URL(url), cardsToDownload.size()); String imageRef = cardImageSource.getNextHttpImageUrl();
String fileName = cardImageSource.getFileForHttpImage(imageRef);
if (imageRef != null && fileName != null) {
imageRef = cardImageSource.getSourceName() + imageRef;
try {
URL imageUrl = new URL(imageRef);
Runnable task = new DownloadTask(imageUrl, fileName, 1);
executor.execute(task); executor.execute(task);
} catch (Exception ex) {
}
} else { } else {
if (card != null) {
logger.info("Card not available on " + cardImageSource.getSourceName() + ": " + card.getName() + " (" + card.getSet() + ")"); logger.info("Card not available on " + cardImageSource.getSourceName() + ": " + card.getName() + " (" + card.getSet() + ")");
synchronized (sync) { synchronized (sync) {
update(cardIndex + 1, cardsToDownload.size()); update(cardIndex + 1, cardsToDownload.size());
} }
} }
}
} else if (url != null) {
Runnable task = new DownloadTask(card, new URL(url), cardsToDownload.size());
executor.execute(task);
}
} catch (Exception ex) { } catch (Exception ex) {
logger.error(ex, ex); logger.error(ex, ex);
@ -535,11 +555,23 @@ public class DownloadPictures extends DefaultBoundedRangeModel implements Runnab
private final CardDownloadData card; private final CardDownloadData card;
private final URL url; private final URL url;
private final int count; private final int count;
private final String actualFilename;
private boolean useSpecifiedPaths;
public DownloadTask(CardDownloadData card, URL url, int count) { public DownloadTask(CardDownloadData card, URL url, int count) {
this.card = card; this.card = card;
this.url = url; this.url = url;
this.count = count; this.count = count;
this.actualFilename = "";
useSpecifiedPaths = false;
}
public DownloadTask(URL url, String actualFilename, int count) {
this.card = null;
this.url = url;
this.count = count;
this.actualFilename = actualFilename;
useSpecifiedPaths = true;
} }
@Override @Override
@ -549,9 +581,20 @@ public class DownloadPictures extends DefaultBoundedRangeModel implements Runnab
TFile outputFile = null; TFile outputFile = null;
try { try {
filePath.append(Constants.IO.imageBaseDir); filePath.append(Constants.IO.imageBaseDir);
if (!useSpecifiedPaths && card != null) {
filePath.append(card.hashCode()).append(".").append(card.getName().replace(":", "").replace("//", "-")).append(".jpg"); filePath.append(card.hashCode()).append(".").append(card.getName().replace(":", "").replace("//", "-")).append(".jpg");
temporaryFile = new File(filePath.toString()); temporaryFile = new File(filePath.toString());
String imagePath = CardImageUtils.generateImagePath(card); }
String imagePath;
if (useSpecifiedPaths) {
imagePath = CardImageUtils.getTokenBasePath(); // temporaryFile = plugins/images\NUM.jace, telepath unbound.jpg
imagePath += actualFilename; // imagePath = d:\xmage_images\ORI.zip\ORI\Jace,telepathunbound.jpg
String tmpFile = filePath + actualFilename + ".2";
temporaryFile = new File(tmpFile.toString());
} else {
imagePath = CardImageUtils.generateImagePath(card);
}
outputFile = new TFile(imagePath); outputFile = new TFile(imagePath);
if (!outputFile.exists()) { if (!outputFile.exists()) {
outputFile.getParentFile().mkdirs(); outputFile.getParentFile().mkdirs();
@ -599,7 +642,7 @@ public class DownloadPictures extends DefaultBoundedRangeModel implements Runnab
out.flush(); out.flush();
out.close(); out.close();
if (card.isTwoFacedCard()) { if (card != null && card.isTwoFacedCard()) {
BufferedImage image = ImageIO.read(temporaryFile); BufferedImage image = ImageIO.read(temporaryFile);
if (image.getHeight() == 470) { if (image.getHeight() == 470) {
BufferedImage renderedImage = new BufferedImage(265, 370, BufferedImage.TYPE_INT_RGB); BufferedImage renderedImage = new BufferedImage(265, 370, BufferedImage.TYPE_INT_RGB);
@ -620,9 +663,11 @@ public class DownloadPictures extends DefaultBoundedRangeModel implements Runnab
new TFile(temporaryFile).cp_rp(outputFile); new TFile(temporaryFile).cp_rp(outputFile);
} }
} else { } else {
if (card != null) {
logger.warn("Image download for " + card.getName() logger.warn("Image download for " + card.getName()
+ (!card.getDownloadName().equals(card.getName()) ? " downloadname: " + card.getDownloadName() : "") + (!card.getDownloadName().equals(card.getName()) ? " downloadname: " + card.getDownloadName() : "")
+ "(" + card.getSet() + ") failed - responseCode: " + responseCode + " url: " + url.toString()); + "(" + card.getSet() + ") failed - responseCode: " + responseCode + " url: " + url.toString());
}
if (logger.isDebugEnabled()) { // Shows the returned html from the request to the web server if (logger.isDebugEnabled()) { // Shows the returned html from the request to the web server
logger.debug("Returned HTML ERROR:\n" + convertStreamToString(((HttpURLConnection) httpConn).getErrorStream())); logger.debug("Returned HTML ERROR:\n" + convertStreamToString(((HttpURLConnection) httpConn).getErrorStream()));
} }

View file

@ -118,6 +118,17 @@ public class CardImageUtils {
} }
} }
public static String getTokenBasePath() {
String useDefault = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_CARD_IMAGES_USE_DEFAULT, "true");
String imagesPath = useDefault.equals("true") ? null : PreferencesDialog.getCachedValue(PreferencesDialog.KEY_CARD_IMAGES_PATH, null);
if (PreferencesDialog.isSaveImagesToZip()) {
return imagesPath + TFile.separator + "TOK" + ".zip" + TFile.separator;
} else {
return imagesPath + TFile.separator + "TOK" + TFile.separator;
}
}
private static String getTokenDescriptorImagePath(CardDownloadData card) { private static String getTokenDescriptorImagePath(CardDownloadData card) {
String useDefault = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_CARD_IMAGES_USE_DEFAULT, "true"); String useDefault = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_CARD_IMAGES_USE_DEFAULT, "true");
String imagesPath = useDefault.equals("true") ? null : PreferencesDialog.getCachedValue(PreferencesDialog.KEY_CARD_IMAGES_PATH, null); String imagesPath = useDefault.equals("true") ? null : PreferencesDialog.getCachedValue(PreferencesDialog.KEY_CARD_IMAGES_PATH, null);

View file

@ -246,14 +246,14 @@ public class CardView extends SimpleCardView {
if (card instanceof Permanent) { if (card instanceof Permanent) {
this.mageObjectType = MageObjectType.PERMANENT; this.mageObjectType = MageObjectType.PERMANENT;
Permanent permanent = (Permanent) card; Permanent permanent = (Permanent) card;
this.loyalty = Integer.toString(permanent.getCounters().getCount(CounterType.LOYALTY)); this.loyalty = Integer.toString(permanent.getCounters(game).getCount(CounterType.LOYALTY));
this.pairedCard = permanent.getPairedCard() != null ? permanent.getPairedCard().getSourceId() : null; this.pairedCard = permanent.getPairedCard() != null ? permanent.getPairedCard().getSourceId() : null;
if (!permanent.getControllerId().equals(permanent.getOwnerId())) { if (!permanent.getControllerId().equals(permanent.getOwnerId())) {
controlledByOwner = false; controlledByOwner = false;
} }
if (game != null && permanent.getCounters() != null && !permanent.getCounters().isEmpty()) { if (game != null && permanent.getCounters(game) != null && !permanent.getCounters(game).isEmpty()) {
counters = new ArrayList<>(); counters = new ArrayList<>();
for (Counter counter : permanent.getCounters().values()) { for (Counter counter : permanent.getCounters(game).values()) {
counters.add(new CounterView(counter)); counters.add(new CounterView(counter));
} }
} }
@ -348,7 +348,7 @@ public class CardView extends SimpleCardView {
this.mageObjectType = MageObjectType.PERMANENT; this.mageObjectType = MageObjectType.PERMANENT;
this.power = Integer.toString(object.getPower().getValue()); this.power = Integer.toString(object.getPower().getValue());
this.toughness = Integer.toString(object.getToughness().getValue()); this.toughness = Integer.toString(object.getToughness().getValue());
this.loyalty = Integer.toString(((Permanent) object).getCounters().getCount(CounterType.LOYALTY)); this.loyalty = Integer.toString(((Permanent) object).getCounters((Game)null).getCount(CounterType.LOYALTY));
} else { } else {
this.power = object.getPower().toString(); this.power = object.getPower().toString();
this.toughness = object.getToughness().toString(); this.toughness = object.getToughness().toString();

View file

@ -64,8 +64,8 @@ public class ArtificialScoringSystem {
public static int getVariablePermanentScore(final Game game, final Permanent permanent) { public static int getVariablePermanentScore(final Game game, final Permanent permanent) {
int score = permanent.getCounters().getCount(CounterType.CHARGE) * 30; int score = permanent.getCounters(game).getCount(CounterType.CHARGE) * 30;
score += permanent.getCounters().getCount(CounterType.LEVEL) * 30; score += permanent.getCounters(game).getCount(CounterType.LEVEL) * 30;
score -= permanent.getDamage() * 2; score -= permanent.getDamage() * 2;
if (!canTap(permanent)) { if (!canTap(permanent)) {
score += getTappedScore(permanent); score += getTappedScore(permanent);

View file

@ -30,7 +30,7 @@ public class LevelUpOptimizer extends BaseTreeOptimizer {
if (permanent != null && permanent instanceof PermanentCard) { if (permanent != null && permanent instanceof PermanentCard) {
PermanentCard leveler = (PermanentCard) permanent; PermanentCard leveler = (PermanentCard) permanent;
// check already existing Level counters and compare to maximum that make sense // check already existing Level counters and compare to maximum that make sense
if (permanent.getCounters().getCount(CounterType.LEVEL) >= leveler.getMaxLevelCounters()) { if (permanent.getCounters(game).getCount(CounterType.LEVEL) >= leveler.getMaxLevelCounters()) {
removeAbility(ability); removeAbility(ability);
} }
} }

View file

@ -68,7 +68,7 @@ public class CombatSimulator implements Serializable {
} }
else { else {
Permanent permanent = game.getPermanent(defenderId); Permanent permanent = game.getPermanent(defenderId);
simCombat.planeswalkerLoyalty.put(defenderId, permanent.getCounters().getCount(CounterType.LOYALTY)); simCombat.planeswalkerLoyalty.put(defenderId, permanent.getCounters(game).getCount(CounterType.LOYALTY));
} }
} }
return simCombat; return simCombat;

View file

@ -111,7 +111,7 @@ public class GameStateEvaluator {
if (!(ability instanceof ManaAbility) && ability.canActivate(ability.getControllerId(), game)) if (!(ability instanceof ManaAbility) && ability.canActivate(ability.getControllerId(), game))
value += ability.getEffects().size(); value += ability.getEffects().size();
} }
for (Counter counter: permanent.getCounters().values()) { for (Counter counter: permanent.getCounters(game).values()) {
if (!(counter instanceof BoostCounter)) { if (!(counter instanceof BoostCounter)) {
value += counter.getCount(); value += counter.getCount();
} }

View file

@ -116,7 +116,7 @@ class AvenEffect extends ContinuousEffectImpl {
@Override @Override
public boolean isInactive(Ability source, Game game) { public boolean isInactive(Ability source, Game game) {
Permanent creature = game.getPermanent(this.targetPointer.getFirst(game, source)); Permanent creature = game.getPermanent(this.targetPointer.getFirst(game, source));
if (creature != null && creature.getCounters().getCount(CounterType.FEATHER) < 1) { if (creature != null && creature.getCounters(game).getCount(CounterType.FEATHER) < 1) {
return true; return true;
} }
return false; return false;
@ -160,7 +160,7 @@ class AvenEffect2 extends ContinuousEffectImpl {
@Override @Override
public boolean isInactive(Ability source, Game game) { public boolean isInactive(Ability source, Game game) {
Permanent creature = game.getPermanent(this.targetPointer.getFirst(game, source)); Permanent creature = game.getPermanent(this.targetPointer.getFirst(game, source));
if (creature != null && creature.getCounters().getCount(CounterType.FEATHER) < 1) { if (creature != null && creature.getCounters(game).getCount(CounterType.FEATHER) < 1) {
return true; return true;
} }
return false; return false;

View file

@ -97,7 +97,7 @@ class MayaelsAriaEffect extends OneShotEffect {
FilterCreaturePermanent filter = new FilterCreaturePermanent(); FilterCreaturePermanent filter = new FilterCreaturePermanent();
filter.add(new PowerPredicate(Filter.ComparisonType.GreaterThan, 4)); filter.add(new PowerPredicate(Filter.ComparisonType.GreaterThan, 4));
if (game.getState().getBattlefield().countAll(filter, controller.getId(), game) > 0) { if (game.getState().getBattlefield().countAll(filter, controller.getId(), game) > 0) {
for (Permanent creature : game.getBattlefield().getAllActivePermanents(source.getControllerId())) { for (Permanent creature : game.getBattlefield().getAllActivePermanents(new FilterCreaturePermanent(), source.getControllerId(), game)) {
creature.addCounters(CounterType.P1P1.createInstance(), game); creature.addCounters(CounterType.P1P1.createInstance(), game);
} }
} }

View file

@ -104,7 +104,7 @@ class MindFuneralEffect extends OneShotEffect {
cards.add(card); cards.add(card);
} }
opponent.revealCards("Mind Funeral", cards, game); opponent.revealCards("Mind Funeral", cards, game);
opponent.moveCards(cards, Zone.LIBRARY, Zone.GRAVEYARD, source, game); opponent.moveCards(cards, Zone.GRAVEYARD, source, game);
return true; return true;
} }

View file

@ -141,7 +141,7 @@ class MakeshiftMannequinGainAbilityEffect extends ContinuousEffectImpl {
@Override @Override
public boolean isInactive(Ability source, Game game) { public boolean isInactive(Ability source, Game game) {
Permanent permanent = game.getPermanent(this.getTargetPointer().getFirst(game, source)); Permanent permanent = game.getPermanent(this.getTargetPointer().getFirst(game, source));
return permanent == null || permanent.getCounters().getCount(CounterType.MANNEQUIN) < 1; return permanent == null || permanent.getCounters(game).getCount(CounterType.MANNEQUIN) < 1;
} }
@Override @Override

View file

@ -117,7 +117,7 @@ class DescentIntoMadnessEffect extends OneShotEffect {
sourcePermanent = (Permanent) game.getLastKnownInformation(source.getSourceId(), Zone.BATTLEFIELD); sourcePermanent = (Permanent) game.getLastKnownInformation(source.getSourceId(), Zone.BATTLEFIELD);
} }
if (sourcePermanent != null && controller != null) { if (sourcePermanent != null && controller != null) {
int count = sourcePermanent.getCounters().getCount(CounterType.DESPAIR); int count = sourcePermanent.getCounters(game).getCount(CounterType.DESPAIR);
if (count > 0) { if (count > 0) {
// select the permanents and hand cards in turn order // select the permanents and hand cards in turn order
LinkedList<UUID> selectedObjects = new LinkedList<>(); LinkedList<UUID> selectedObjects = new LinkedList<>();

View file

@ -94,7 +94,7 @@ class HeraldOfWarCostReductionEffect extends CostModificationEffectImpl {
SpellAbility spellAbility = (SpellAbility) abilityToModify; SpellAbility spellAbility = (SpellAbility) abilityToModify;
Permanent sourcePermanent = game.getPermanent(source.getSourceId()); Permanent sourcePermanent = game.getPermanent(source.getSourceId());
if (sourcePermanent != null) { if (sourcePermanent != null) {
int amount = sourcePermanent.getCounters().getCount(CounterType.P1P1); int amount = sourcePermanent.getCounters(game).getCount(CounterType.P1P1);
if (amount > 0) { if (amount > 0) {
CardUtil.adjustCost(spellAbility, amount); CardUtil.adjustCost(spellAbility, amount);
return true; return true;

View file

@ -91,7 +91,7 @@ class OtherworldAtlasDrawEffect extends OneShotEffect {
Player sourcePlayer = game.getPlayer(source.getControllerId()); Player sourcePlayer = game.getPlayer(source.getControllerId());
Permanent permanent = game.getPermanent(source.getSourceId()); Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null) { if (permanent != null) {
int amount = permanent.getCounters().getCount(CounterType.CHARGE); int amount = permanent.getCounters(game).getCount(CounterType.CHARGE);
if (amount > 0) { if (amount > 0) {
for (UUID playerId : game.getState().getPlayersInRange(sourcePlayer.getId(), game)) { for (UUID playerId : game.getState().getPlayersInRange(sourcePlayer.getId(), game)) {
Player player = game.getPlayer(playerId); Player player = game.getPlayer(playerId);

View file

@ -93,7 +93,7 @@ class BaneOfBalaGedEffect extends OneShotEffect {
if (defendingPlayer != null) { if (defendingPlayer != null) {
Target target = new TargetControlledPermanent(2); Target target = new TargetControlledPermanent(2);
defendingPlayer.chooseTarget(outcome, target, source, game); defendingPlayer.chooseTarget(outcome, target, source, game);
defendingPlayer.moveCards(new CardsImpl(target.getTargets()), null, Zone.EXILED, source, game); defendingPlayer.moveCards(new CardsImpl(target.getTargets()), Zone.EXILED, source, game);
return true; return true;
} }
return false; return false;

View file

@ -107,7 +107,7 @@ class BlightHerderEffect extends OneShotEffect {
if (target.canChoose(source.getSourceId(), source.getControllerId(), game)) { if (target.canChoose(source.getSourceId(), source.getControllerId(), game)) {
if (controller.chooseTarget(outcome, target, source, game)) { if (controller.chooseTarget(outcome, target, source, game)) {
Cards cardsToGraveyard = new CardsImpl(target.getTargets()); Cards cardsToGraveyard = new CardsImpl(target.getTargets());
controller.moveCards(cardsToGraveyard, null, Zone.GRAVEYARD, source, game); controller.moveCards(cardsToGraveyard, Zone.GRAVEYARD, source, game);
return new CreateTokenEffect(new EldraziScionToken(), 3).apply(game, source); return new CreateTokenEffect(new EldraziScionToken(), 3).apply(game, source);
} }
} }

View file

@ -192,7 +192,7 @@ class KioraRevealEffect extends OneShotEffect {
} }
} }
} }
controller.moveCards(cards, null, Zone.GRAVEYARD, source, game); controller.moveCards(cards, Zone.GRAVEYARD, source, game);
return true; return true;
} }
return false; return false;

View file

@ -108,7 +108,7 @@ class UlamogsDespoilerEffect extends OneShotEffect {
if (target.canChoose(source.getSourceId(), source.getControllerId(), game)) { if (target.canChoose(source.getSourceId(), source.getControllerId(), game)) {
if (controller.chooseTarget(outcome, target, source, game)) { if (controller.chooseTarget(outcome, target, source, game)) {
Cards cardsToGraveyard = new CardsImpl(target.getTargets()); Cards cardsToGraveyard = new CardsImpl(target.getTargets());
controller.moveCards(cardsToGraveyard, null, Zone.GRAVEYARD, source, game); controller.moveCards(cardsToGraveyard, Zone.GRAVEYARD, source, game);
return new AddCountersSourceEffect(CounterType.P1P1.createInstance(4)).apply(game, source); return new AddCountersSourceEffect(CounterType.P1P1.createInstance(4)).apply(game, source);
} }
} }

View file

@ -123,7 +123,7 @@ class UlamogsNullifierEffect extends OneShotEffect {
if (target.canChoose(source.getSourceId(), source.getControllerId(), game)) { if (target.canChoose(source.getSourceId(), source.getControllerId(), game)) {
if (controller.chooseTarget(outcome, target, source, game)) { if (controller.chooseTarget(outcome, target, source, game)) {
Cards cardsToGraveyard = new CardsImpl(target.getTargets()); Cards cardsToGraveyard = new CardsImpl(target.getTargets());
controller.moveCards(cardsToGraveyard, null, Zone.GRAVEYARD, source, game); controller.moveCards(cardsToGraveyard, Zone.GRAVEYARD, source, game);
game.getStack().counter(source.getFirstTarget(), source.getSourceId(), game); game.getStack().counter(source.getFirstTarget(), source.getSourceId(), game);
return true; return true;
} }

View file

@ -119,7 +119,7 @@ class UndergrowthChampionPreventionEffect extends PreventionEffectImpl {
} }
} }
if(removeCounter && permanent.getCounters().containsKey(CounterType.P1P1)) { if(removeCounter && permanent.getCounters(game).containsKey(CounterType.P1P1)) {
preventDamageAction(event, source, game); preventDamageAction(event, source, game);
StringBuilder sb = new StringBuilder(permanent.getName()).append(": "); StringBuilder sb = new StringBuilder(permanent.getName()).append(": ");
permanent.removeCounters(CounterType.P1P1.createInstance(), game); permanent.removeCounters(CounterType.P1P1.createInstance(), game);

View file

@ -91,8 +91,8 @@ class SwayOfTheStarsEffect extends OneShotEffect {
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
Player player = game.getPlayer(playerId); Player player = game.getPlayer(playerId);
if (player != null) { if (player != null) {
player.moveCards(player.getHand(), Zone.HAND, Zone.LIBRARY, source, game); player.moveCards(player.getHand(), Zone.LIBRARY, source, game);
player.moveCards(player.getGraveyard(), Zone.GRAVEYARD, Zone.LIBRARY, source, game); player.moveCards(player.getGraveyard(), Zone.LIBRARY, source, game);
FilterPermanent filter = new FilterPermanent(); FilterPermanent filter = new FilterPermanent();
filter.add(new OwnerIdPredicate(playerId)); filter.add(new OwnerIdPredicate(playerId));
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, controller.getId(), source.getSourceId(), game)) { for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, controller.getId(), source.getSourceId(), game)) {

View file

@ -93,7 +93,7 @@ class AstralCornucopiaManaAbility extends ManaAbility {
netMana.clear(); netMana.clear();
Permanent sourcePermanent = game.getPermanent(getSourceId()); Permanent sourcePermanent = game.getPermanent(getSourceId());
if (sourcePermanent != null) { if (sourcePermanent != null) {
int counters = sourcePermanent.getCounters().getCount(CounterType.CHARGE.getName()); int counters = sourcePermanent.getCounters(game).getCount(CounterType.CHARGE.getName());
if (counters > 0) { if (counters > 0) {
netMana.add(new Mana(0, 0, 0, 0, 0, 0, counters, 0)); netMana.add(new Mana(0, 0, 0, 0, 0, 0, counters, 0));
} }
@ -132,7 +132,7 @@ class AstralCornucopiaManaEffect extends ManaEffect {
Permanent sourcePermanent = game.getPermanent(source.getSourceId()); Permanent sourcePermanent = game.getPermanent(source.getSourceId());
if (choice.getChoice() != null) { if (choice.getChoice() != null) {
String color = choice.getChoice(); String color = choice.getChoice();
int counters = sourcePermanent.getCounters().getCount(CounterType.CHARGE.getName()); int counters = sourcePermanent.getCounters(game).getCount(CounterType.CHARGE.getName());
switch (color) { switch (color) {
case "Red": case "Red":
computedMana.setRed(counters); computedMana.setRed(counters);

View file

@ -113,7 +113,7 @@ class SatyrWayfinderEffect extends OneShotEffect {
} }
} }
controller.moveCards(cards, Zone.LIBRARY, Zone.GRAVEYARD, source, game); controller.moveCards(cards, Zone.GRAVEYARD, source, game);
} }
return true; return true;
} }

View file

@ -119,8 +119,8 @@ class GiftsUngivenEffect extends OneShotEffect {
} }
} }
player.moveCards(cards, Zone.LIBRARY, Zone.GRAVEYARD, source, game); player.moveCards(cards, Zone.GRAVEYARD, source, game);
player.moveCards(cardsToKeep, Zone.LIBRARY, Zone.HAND, source, game); player.moveCards(cardsToKeep, Zone.HAND, source, game);
} }
player.shuffleLibrary(source, game); player.shuffleLibrary(source, game);
return true; return true;

View file

@ -188,7 +188,7 @@ class HankyuCountersSourceCost extends CostImpl {
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) { public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) {
Permanent equipment = game.getPermanent(this.effectGivingEquipmentId); Permanent equipment = game.getPermanent(this.effectGivingEquipmentId);
if (equipment != null ) { if (equipment != null ) {
this.removedCounters = equipment.getCounters().getCount(CounterType.AIM); this.removedCounters = equipment.getCounters(game).getCount(CounterType.AIM);
if (this.removedCounters > 0) { if (this.removedCounters > 0) {
equipment.removeCounters("aim", this.removedCounters, game); equipment.removeCounters("aim", this.removedCounters, game);
} }

View file

@ -98,7 +98,7 @@ class InameDeathAspectEffect extends SearchEffect {
Player player = game.getPlayer(source.getControllerId()); Player player = game.getPlayer(source.getControllerId());
if (player != null && player.searchLibrary(target, game)) { if (player != null && player.searchLibrary(target, game)) {
if (target.getTargets().size() > 0) { if (target.getTargets().size() > 0) {
player.moveCards(new CardsImpl(target.getTargets()), Zone.LIBRARY, Zone.GRAVEYARD, source, game); player.moveCards(new CardsImpl(target.getTargets()), Zone.GRAVEYARD, source, game);
} }
player.shuffleLibrary(source, game); player.shuffleLibrary(source, game);
return true; return true;

View file

@ -112,7 +112,7 @@ class PiousKitsuneEffect extends OneShotEffect {
if (game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game) > 0) { if (game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game) > 0) {
Permanent permanent = game.getPermanent(source.getSourceId()); Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null) { if (permanent != null) {
int life = permanent.getCounters().getCount(CounterType.DEVOTION); int life = permanent.getCounters(game).getCount(CounterType.DEVOTION);
if (life > 0) { if (life > 0) {
Player controller = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
if (controller != null) { if (controller != null) {

View file

@ -0,0 +1,98 @@
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.sets.chronicles;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.common.SacrificeSourceCost;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.effects.OneShotEffect;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.counters.BoostCounter;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.target.common.TargetCreaturePermanent;
/**
*
* @author Derpthemeus
*/
public class LivingArmor extends CardImpl {
public LivingArmor(UUID ownerId) {
super(ownerId, 83, "Living Armor", Rarity.COMMON, new CardType[]{CardType.ARTIFACT}, "{4}");
this.expansionSetCode = "CHR";
// {tap}, Sacrifice Living Armor: Put X +0/+1 counters on target creature, where X is that creature's converted mana cost.
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new LivingArmorEffect(), new TapSourceCost());
ability.addCost(new SacrificeSourceCost());
ability.addTarget(new TargetCreaturePermanent());
this.addAbility(ability);
}
public LivingArmor(final LivingArmor card) {
super(card);
}
@Override
public LivingArmor copy() {
return new LivingArmor(this);
}
class LivingArmorEffect extends OneShotEffect {
public LivingArmorEffect() {
super(Outcome.BoostCreature);
this.staticText = "Put X +0/+1 counters on target creature, where X is that creature's converted mana cost";
}
public LivingArmorEffect(final LivingArmorEffect effect) {
super(effect);
}
@Override
public LivingArmorEffect copy() {
return new LivingArmorEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Permanent creature = game.getPermanent(source.getTargets().getFirstTarget());
if (creature != null) {
int amount = creature.getConvertedManaCost();
creature.addCounters(new BoostCounter(0, 1, amount), game);
}
return false;
}
}
}

View file

@ -131,7 +131,7 @@ class DarkDepthsAbility extends StateTriggeredAbility {
@Override @Override
public boolean checkTrigger(GameEvent event, Game game) { public boolean checkTrigger(GameEvent event, Game game) {
Permanent permanent = game.getPermanent(getSourceId()); Permanent permanent = game.getPermanent(getSourceId());
return permanent != null && permanent.getCounters().getCount(CounterType.ICE) == 0; return permanent != null && permanent.getCounters(game).getCount(CounterType.ICE) == 0;
} }
@Override @Override

View file

@ -128,7 +128,7 @@ class HibernationsEndEffect extends OneShotEffect {
Player player = game.getPlayer(source.getControllerId()); Player player = game.getPlayer(source.getControllerId());
Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId()); Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId());
if (sourcePermanent != null && player != null) { if (sourcePermanent != null && player != null) {
int newConvertedCost = sourcePermanent.getCounters().getCount("age"); int newConvertedCost = sourcePermanent.getCounters(game).getCount("age");
FilterCard filter = new FilterCard("creature card with converted mana cost " + newConvertedCost); FilterCard filter = new FilterCard("creature card with converted mana cost " + newConvertedCost);
filter.add(new ConvertedManaCostPredicate(Filter.ComparisonType.Equal, newConvertedCost)); filter.add(new ConvertedManaCostPredicate(Filter.ComparisonType.Equal, newConvertedCost));
filter.add(new CardTypePredicate(CardType.CREATURE)); filter.add(new CardTypePredicate(CardType.CREATURE));

View file

@ -117,7 +117,7 @@ class AnimarCostReductionEffect extends CostModificationEffectImpl {
Ability spellAbility = (SpellAbility) abilityToModify; Ability spellAbility = (SpellAbility) abilityToModify;
Permanent sourcePermanent = game.getPermanent(source.getSourceId()); Permanent sourcePermanent = game.getPermanent(source.getSourceId());
if (sourcePermanent != null && spellAbility != null) { if (sourcePermanent != null && spellAbility != null) {
int amount = sourcePermanent.getCounters().getCount(CounterType.P1P1); int amount = sourcePermanent.getCounters(game).getCount(CounterType.P1P1);
if (amount > 0) { if (amount > 0) {
CardUtil.reduceCost(spellAbility, amount); CardUtil.reduceCost(spellAbility, amount);
return true; return true;

View file

@ -89,7 +89,7 @@ class BuriedAliveEffect extends SearchEffect {
Player controller = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
if (controller != null) { if (controller != null) {
if (controller.searchLibrary(target, game)) { if (controller.searchLibrary(target, game)) {
controller.moveCards(new CardsImpl(target.getTargets()), Zone.LIBRARY, Zone.GRAVEYARD, source, game); controller.moveCards(new CardsImpl(target.getTargets()), Zone.GRAVEYARD, source, game);
} }
controller.shuffleLibrary(source, game); controller.shuffleLibrary(source, game);
return true; return true;

View file

@ -124,7 +124,7 @@ class DesecratorHagEffect extends OneShotEffect {
} }
} }
} else { } else {
return you.moveCards(cards, null, Zone.HAND, source, game); return you.moveCards(cards, Zone.HAND, source, game);
} }
} }
return false; return false;

View file

@ -123,7 +123,7 @@ class VishKalBloodArbiterCost extends CostImpl {
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) { public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) {
Permanent permanent = game.getPermanent(sourceId); Permanent permanent = game.getPermanent(sourceId);
if (permanent != null) { if (permanent != null) {
this.amount = permanent.getCounters().getCount(name); this.amount = permanent.getCounters(game).getCount(name);
permanent.removeCounters(name, amount, game); permanent.removeCounters(name, amount, game);
this.paid = true; this.paid = true;
} }

View file

@ -126,7 +126,7 @@ class FosterEffect extends OneShotEffect {
controller.moveCards(cardFound, Zone.HAND, source, game); controller.moveCards(cardFound, Zone.HAND, source, game);
cards.remove(cardFound); cards.remove(cardFound);
} }
controller.moveCards(cards, Zone.LIBRARY, Zone.GRAVEYARD, source, game); controller.moveCards(cards, Zone.GRAVEYARD, source, game);
} }
return true; return true;
} }

View file

@ -112,7 +112,7 @@ public class MarathWillOfTheWild extends CardImpl {
if (ability instanceof SimpleActivatedAbility && ability.getModes().size() == 3) { if (ability instanceof SimpleActivatedAbility && ability.getModes().size() == 3) {
Permanent sourcePermanent = game.getPermanent(ability.getSourceId()); Permanent sourcePermanent = game.getPermanent(ability.getSourceId());
if (sourcePermanent != null) { if (sourcePermanent != null) {
int amount = sourcePermanent.getCounters().getCount(CounterType.P1P1); int amount = sourcePermanent.getCounters(game).getCount(CounterType.P1P1);
if (amount > 0) { if (amount > 0) {
for (VariableCost cost: ability.getManaCostsToPay().getVariableCosts()) { for (VariableCost cost: ability.getManaCostsToPay().getVariableCosts()) {
if (cost instanceof VariableManaCost) { if (cost instanceof VariableManaCost) {
@ -192,7 +192,7 @@ class MarathWillOfTheWildRemoveCountersCost extends CostImpl {
@Override @Override
public boolean canPay(Ability ability, UUID sourceId, UUID controllerId, Game game) { public boolean canPay(Ability ability, UUID sourceId, UUID controllerId, Game game) {
Permanent permanent = game.getPermanent(sourceId); Permanent permanent = game.getPermanent(sourceId);
if (permanent != null && permanent.getCounters().getCount(CounterType.P1P1) > 0) { if (permanent != null && permanent.getCounters(game).getCount(CounterType.P1P1) > 0) {
return true; return true;
} }
return false; return false;
@ -202,7 +202,7 @@ class MarathWillOfTheWildRemoveCountersCost extends CostImpl {
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) { public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) {
int amount = new ManacostVariableValue().calculate(game, ability, null); int amount = new ManacostVariableValue().calculate(game, ability, null);
Permanent permanent = game.getPermanent(sourceId); Permanent permanent = game.getPermanent(sourceId);
if (permanent != null && permanent.getCounters().getCount(CounterType.P1P1) >= amount) { if (permanent != null && permanent.getCounters(game).getCount(CounterType.P1P1) >= amount) {
permanent.removeCounters(CounterType.P1P1.getName(), amount, game); permanent.removeCounters(CounterType.P1P1.getName(), amount, game);
this.paid = true; this.paid = true;
} }

View file

@ -129,7 +129,7 @@ class PhantomNantukoPreventionEffect extends PreventionEffectImpl {
} }
} }
if(removeCounter && permanent.getCounters().containsKey(CounterType.P1P1)) { if(removeCounter && permanent.getCounters(game).containsKey(CounterType.P1P1)) {
StringBuilder sb = new StringBuilder(permanent.getName()).append(": "); StringBuilder sb = new StringBuilder(permanent.getName()).append(": ");
permanent.removeCounters(CounterType.P1P1.createInstance(), game); permanent.removeCounters(CounterType.P1P1.createInstance(), game);
sb.append("Removed a +1/+1 counter "); sb.append("Removed a +1/+1 counter ");

View file

@ -101,7 +101,7 @@ class PlagueBoilerEffect extends OneShotEffect {
Player controller = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
Permanent sourcePermanent = game.getPermanent(source.getSourceId()); Permanent sourcePermanent = game.getPermanent(source.getSourceId());
if (controller != null && sourcePermanent != null) { if (controller != null && sourcePermanent != null) {
if (!sourcePermanent.getCounters().containsKey(CounterType.PLAGUE) || controller.chooseUse(outcome, "Put a plague counter on? (No removes one)", source, game)) { if (!sourcePermanent.getCounters(game).containsKey(CounterType.PLAGUE) || controller.chooseUse(outcome, "Put a plague counter on? (No removes one)", source, game)) {
return new AddCountersSourceEffect(CounterType.PLAGUE.createInstance(), true).apply(game, source); return new AddCountersSourceEffect(CounterType.PLAGUE.createInstance(), true).apply(game, source);
} else { } else {
return new RemoveCounterSourceEffect(CounterType.PLAGUE.createInstance()).apply(game, source); return new RemoveCounterSourceEffect(CounterType.PLAGUE.createInstance()).apply(game, source);
@ -135,7 +135,7 @@ class PlagueBoilerTriggeredAbility extends TriggeredAbilityImpl {
public boolean checkTrigger(GameEvent event, Game game) { public boolean checkTrigger(GameEvent event, Game game) {
if (event.getTargetId().equals(this.getSourceId()) && event.getData().equals(CounterType.PLAGUE.getName())) { if (event.getTargetId().equals(this.getSourceId()) && event.getData().equals(CounterType.PLAGUE.getName())) {
Permanent sourcePermanent = game.getPermanent(this.getSourceId()); Permanent sourcePermanent = game.getPermanent(this.getSourceId());
if (sourcePermanent != null && sourcePermanent.getCounters().getCount(CounterType.PLAGUE) >= 3) { if (sourcePermanent != null && sourcePermanent.getCounters(game).getCount(CounterType.PLAGUE) >= 3) {
return true; return true;
} }
} }

View file

@ -101,7 +101,7 @@ class StrategicPlanningEffect extends OneShotEffect {
cards.remove(card); cards.remove(card);
} }
} }
controller.moveCards(cards, Zone.LIBRARY, Zone.GRAVEYARD, source, game); controller.moveCards(cards, Zone.GRAVEYARD, source, game);
} }
return true; return true;
} }

View file

@ -90,8 +90,8 @@ class AEtherSnapEffect extends OneShotEffect {
for (Permanent permanent : game.getBattlefield().getActivePermanents(new FilterPermanent(), controller.getId(), source.getSourceId(), game)) { for (Permanent permanent : game.getBattlefield().getActivePermanents(new FilterPermanent(), controller.getId(), source.getSourceId(), game)) {
if (permanent instanceof PermanentToken) { if (permanent instanceof PermanentToken) {
controller.moveCardToExileWithInfo(permanent, null, "", source.getSourceId(), game, Zone.BATTLEFIELD, true); controller.moveCardToExileWithInfo(permanent, null, "", source.getSourceId(), game, Zone.BATTLEFIELD, true);
} else if (!permanent.getCounters().isEmpty()) { } else if (!permanent.getCounters(game).isEmpty()) {
Counters counters = permanent.getCounters().copy(); Counters counters = permanent.getCounters(game).copy();
for (Counter counter : counters.values()) { for (Counter counter : counters.values()) {
permanent.removeCounters(counter, game); permanent.removeCounters(counter, game);
} }

View file

@ -111,7 +111,7 @@ class GraveSifterEffect extends OneShotEffect {
filter.add(new SubtypePredicate(typeChoice.getChoice())); filter.add(new SubtypePredicate(typeChoice.getChoice()));
Target target = new TargetCardInYourGraveyard(0, Integer.MAX_VALUE, filter); Target target = new TargetCardInYourGraveyard(0, Integer.MAX_VALUE, filter);
player.chooseTarget(outcome, target, source, game); player.chooseTarget(outcome, target, source, game);
player.moveCards(new CardsImpl(target.getTargets()), null, Zone.HAND, source, game); player.moveCards(new CardsImpl(target.getTargets()), Zone.HAND, source, game);
} }
} }

View file

@ -108,7 +108,7 @@ class StitcherGeralfEffect extends OneShotEffect {
cards.addAll(player.getLibrary().getTopCards(game, 3)); cards.addAll(player.getLibrary().getTopCards(game, 3));
} }
} }
controller.moveCards(cards, Zone.LIBRARY, Zone.GRAVEYARD, source, game); controller.moveCards(cards, Zone.GRAVEYARD, source, game);
TargetCard target = new TargetCard(0,2,Zone.GRAVEYARD, new FilterCreatureCard("creature cards to exile")); TargetCard target = new TargetCard(0,2,Zone.GRAVEYARD, new FilterCreatureCard("creature cards to exile"));
controller.chooseTarget(outcome, cards, target, source, game); controller.chooseTarget(outcome, cards, target, source, game);
int power = 0; int power = 0;

View file

@ -106,7 +106,7 @@ class BloodsporeThrinaxEntersBattlefieldEffect extends ReplacementEffectImpl {
Permanent sourceCreature = game.getPermanent(source.getSourceId()); Permanent sourceCreature = game.getPermanent(source.getSourceId());
Permanent creature = ((EntersTheBattlefieldEvent) event).getTarget(); Permanent creature = ((EntersTheBattlefieldEvent) event).getTarget();
if (sourceCreature != null && creature != null) { if (sourceCreature != null && creature != null) {
int amount = sourceCreature.getCounters().getCount(CounterType.P1P1); int amount = sourceCreature.getCounters(game).getCount(CounterType.P1P1);
if (amount > 0) { if (amount > 0) {
creature.addCounters(CounterType.P1P1.createInstance(amount), game); creature.addCounters(CounterType.P1P1.createInstance(amount), game);
} }

View file

@ -101,7 +101,7 @@ class ThiefOfBloodEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
int countersRemoved = 0; int countersRemoved = 0;
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), game)) { for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), game)) {
Counters counters = permanent.getCounters().copy(); Counters counters = permanent.getCounters(game).copy();
for (Counter counter : counters.values()) { for (Counter counter : counters.values()) {
permanent.removeCounters(counter.getName(), counter.getCount(), game); permanent.removeCounters(counter.getName(), counter.getCount(), game);
countersRemoved += counter.getCount(); countersRemoved += counter.getCount();

View file

@ -140,7 +140,7 @@ class GwafaHazidProfiteerEffect2 extends RestrictionEffect {
@Override @Override
public boolean applies(Permanent permanent, Ability source, Game game) { public boolean applies(Permanent permanent, Ability source, Game game) {
return permanent.getCounters().containsKey(CounterType.BRIBERY); return permanent.getCounters(game).containsKey(CounterType.BRIBERY);
} }
@Override @Override

View file

@ -104,7 +104,7 @@ class TeleminPerformanceEffect extends OneShotEffect {
} }
if (!cards.isEmpty()) { if (!cards.isEmpty()) {
opponent.revealCards("Telemin Performance", cards, game); opponent.revealCards("Telemin Performance", cards, game);
opponent.moveCards(cards, Zone.LIBRARY, Zone.GRAVEYARD, source, game); opponent.moveCards(cards, Zone.GRAVEYARD, source, game);
} }
if (creature != null) { if (creature != null) {
return creature.putOntoBattlefield(game, Zone.LIBRARY, source.getSourceId(), source.getControllerId()); return creature.putOntoBattlefield(game, Zone.LIBRARY, source.getSourceId(), source.getControllerId());

View file

@ -148,7 +148,7 @@ class JarOfEyeballsCost extends CostImpl {
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) { public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) {
Permanent permanent = game.getPermanent(ability.getSourceId()); Permanent permanent = game.getPermanent(ability.getSourceId());
if (permanent != null) { if (permanent != null) {
this.removedCounters = permanent.getCounters().getCount(CounterType.EYEBALL); this.removedCounters = permanent.getCounters(game).getCount(CounterType.EYEBALL);
if (this.removedCounters > 0) { if (this.removedCounters > 0) {
permanent.removeCounters(CounterType.EYEBALL.createInstance(this.removedCounters), game); permanent.removeCounters(CounterType.EYEBALL.createInstance(this.removedCounters), game);
} }

View file

@ -118,7 +118,7 @@ class TrackersInstinctsEffect extends OneShotEffect {
} }
} }
controller.moveCards(cards, Zone.LIBRARY, Zone.GRAVEYARD, source, game); controller.moveCards(cards, Zone.GRAVEYARD, source, game);
} }
return true; return true;
} }

View file

@ -101,7 +101,7 @@ class AEtherVialEffect extends OneShotEffect {
return false; return false;
} }
} }
int count = permanent.getCounters().getCount(CounterType.CHARGE); int count = permanent.getCounters(game).getCount(CounterType.CHARGE);
FilterCreatureCard filter = new FilterCreatureCard("creature card with converted mana cost equal to " + count); FilterCreatureCard filter = new FilterCreatureCard("creature card with converted mana cost equal to " + count);
filter.add(new ConvertedManaCostPredicate(Filter.ComparisonType.Equal, count)); filter.add(new ConvertedManaCostPredicate(Filter.ComparisonType.Equal, count));

View file

@ -109,8 +109,8 @@ class ChromescaleDrakeEffect extends OneShotEffect {
cards.remove(card); cards.remove(card);
} }
} }
controller.moveCards(cardsToHand, Zone.LIBRARY, Zone.HAND, source, game); controller.moveCards(cardsToHand, Zone.HAND, source, game);
controller.moveCards(cards, Zone.LIBRARY, Zone.GRAVEYARD, source, game); controller.moveCards(cards, Zone.GRAVEYARD, source, game);
} }
return true; return true;
} }

View file

@ -90,7 +90,7 @@ class DarksteelReactorStateTriggeredAbility extends StateTriggeredAbility {
@Override @Override
public boolean checkTrigger(GameEvent event, Game game) { public boolean checkTrigger(GameEvent event, Game game) {
Permanent permanent = game.getPermanent(this.getSourceId()); Permanent permanent = game.getPermanent(this.getSourceId());
if(permanent != null && permanent.getCounters().getCount(CounterType.CHARGE) >= 20){ if(permanent != null && permanent.getCounters(game).getCount(CounterType.CHARGE) >= 20){
return true; return true;
} }
return false; return false;

View file

@ -125,7 +125,7 @@ class BoundEffect extends OneShotEffect {
TargetCardInYourGraveyard targetCard = new TargetCardInYourGraveyard(0, colors, TargetCardInYourGraveyard targetCard = new TargetCardInYourGraveyard(0, colors,
new FilterCard("up to " + colors + " card" + (colors > 1 ? "s" : "") + " from your graveyard")); new FilterCard("up to " + colors + " card" + (colors > 1 ? "s" : "") + " from your graveyard"));
controller.chooseTarget(outcome, targetCard, source, game); controller.chooseTarget(outcome, targetCard, source, game);
controller.moveCards(new CardsImpl(targetCard.getTargets()), null, Zone.HAND, source, game); controller.moveCards(new CardsImpl(targetCard.getTargets()), Zone.HAND, source, game);
} }
} }
} }

View file

@ -114,7 +114,7 @@ class CytoplastRootKinEffect extends OneShotEffect {
if (sourcePermanent != null if (sourcePermanent != null
&& targetPermanent != null && targetPermanent != null
&& !sourcePermanent.getId().equals(targetPermanent.getId()) && !sourcePermanent.getId().equals(targetPermanent.getId())
&& targetPermanent.getCounters().getCount(CounterType.P1P1) > 0) { && targetPermanent.getCounters(game).getCount(CounterType.P1P1) > 0) {
targetPermanent.removeCounters(CounterType.P1P1.createInstance(), game); targetPermanent.removeCounters(CounterType.P1P1.createInstance(), game);
sourcePermanent.addCounters(CounterType.P1P1.createInstance(), game); sourcePermanent.addCounters(CounterType.P1P1.createInstance(), game);
return true; return true;

View file

@ -136,7 +136,7 @@ class MomirVigSimicVisionaryEffect extends OneShotEffect {
cards.remove(card); cards.remove(card);
} }
} }
controller.moveCards(cardsToHand, null, Zone.HAND, source, game); controller.moveCards(cardsToHand, Zone.HAND, source, game);
return true; return true;
} }
} }

View file

@ -108,7 +108,7 @@ class RiseEffect extends OneShotEffect {
if (permanent != null) { if (permanent != null) {
cardsToHand.add(permanent); cardsToHand.add(permanent);
} }
controller.moveCards(cardsToHand, null, Zone.HAND, source, game); controller.moveCards(cardsToHand, Zone.HAND, source, game);
return true; return true;
} }
return false; return false;

View file

@ -89,7 +89,7 @@ class BredForTheHuntTriggeredAbility extends TriggeredAbilityImpl {
public boolean checkTrigger(GameEvent event, Game game) { public boolean checkTrigger(GameEvent event, Game game) {
if (((DamagedEvent) event).isCombatDamage()) { if (((DamagedEvent) event).isCombatDamage()) {
Permanent creature = game.getPermanent(event.getSourceId()); Permanent creature = game.getPermanent(event.getSourceId());
if (creature != null && creature.getControllerId().equals(getControllerId()) && creature.getCounters().getCount(CounterType.P1P1) > 0) { if (creature != null && creature.getControllerId().equals(getControllerId()) && creature.getCounters(game).getCount(CounterType.P1P1) > 0) {
return true; return true;
} }
} }

View file

@ -93,7 +93,7 @@ class TakeEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Permanent creature = game.getPermanent(targetPointer.getFirst(game, source)); Permanent creature = game.getPermanent(targetPointer.getFirst(game, source));
if (creature != null) { if (creature != null) {
int numberCounters = creature.getCounters().getCount(CounterType.P1P1); int numberCounters = creature.getCounters(game).getCount(CounterType.P1P1);
if (numberCounters > 0) { if (numberCounters > 0) {
creature.removeCounters(CounterType.P1P1.getName(), numberCounters, game); creature.removeCounters(CounterType.P1P1.getName(), numberCounters, game);
Player controller = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());

View file

@ -119,7 +119,7 @@ class MirkoVoskMindDrinkerEffect extends OneShotEffect {
} }
} }
player.revealCards("by " + sourceObject.getName() + " from " + player.getName(), cards, game); player.revealCards("by " + sourceObject.getName() + " from " + player.getName(), cards, game);
player.moveCards(cards, Zone.LIBRARY, Zone.GRAVEYARD, source, game); player.moveCards(cards, Zone.GRAVEYARD, source, game);
return true; return true;
} }
} }

View file

@ -107,7 +107,7 @@ class VorelOfTheHullCladeEffect extends OneShotEffect {
if (target == null) { if (target == null) {
return false; return false;
} }
for (Counter counter : target.getCounters().values()) { for (Counter counter : target.getCounters(game).values()) {
Counter newCounter = new Counter(counter.getName(), counter.getCount()); Counter newCounter = new Counter(counter.getName(), counter.getCount());
target.addCounters(newCounter, game); target.addCounters(newCounter, game);
} }

View file

@ -111,7 +111,7 @@ class CountersOnControlledCount implements DynamicValue {
Permanent enchantment = game.getPermanent(sourceAbility.getSourceId()); Permanent enchantment = game.getPermanent(sourceAbility.getSourceId());
for (Permanent permanent : game.getState().getBattlefield().getAllActivePermanents(filter, sourceAbility.getControllerId(), game)) { for (Permanent permanent : game.getState().getBattlefield().getAllActivePermanents(filter, sourceAbility.getControllerId(), game)) {
if (!permanent.getId().equals(enchantment.getAttachedTo())) { if (!permanent.getId().equals(enchantment.getAttachedTo())) {
count += permanent.getCounters().getCount(CounterType.P1P1); count += permanent.getCounters(game).getCount(CounterType.P1P1);
} }
} }
return count; return count;

View file

@ -111,7 +111,7 @@ class GurmagDrownerEffect extends OneShotEffect {
cards.remove(card); cards.remove(card);
} }
} }
controller.moveCards(cards, Zone.LIBRARY, Zone.GRAVEYARD, source, game); controller.moveCards(cards, Zone.GRAVEYARD, source, game);
} }
return true; return true;
} }

View file

@ -131,7 +131,7 @@ class MythRealizedSetPTEffect extends ContinuousEffectImpl {
if (controller != null) { if (controller != null) {
Permanent permanent = game.getPermanent(source.getSourceId()); Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null && new MageObjectReference(source.getSourceObject(game), game).refersTo(permanent, game)) { if (permanent != null && new MageObjectReference(source.getSourceObject(game), game).refersTo(permanent, game)) {
int amount = permanent.getCounters().getCount(CounterType.LORE); int amount = permanent.getCounters(game).getCount(CounterType.LORE);
permanent.getPower().setValue(amount); permanent.getPower().setValue(amount);
permanent.getToughness().setValue(amount); permanent.getToughness().setValue(amount);
return true; return true;

View file

@ -105,7 +105,7 @@ class ProfanerOfTheDeadReturnEffect extends OneShotEffect {
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) { for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) {
cardsToHand.add(permanent); cardsToHand.add(permanent);
} }
controller.moveCards(cardsToHand, null, Zone.HAND, source, game); controller.moveCards(cardsToHand, Zone.HAND, source, game);
return true; return true;
} }
return false; return false;

View file

@ -104,7 +104,7 @@ class ServantOfTheScaleEffect extends OneShotEffect {
if (sourcePermanent != null && controller != null && if (sourcePermanent != null && controller != null &&
(sourcePermanent.getZoneChangeCounter(game) == source.getSourceObjectZoneChangeCounter() // Token (sourcePermanent.getZoneChangeCounter(game) == source.getSourceObjectZoneChangeCounter() // Token
|| sourcePermanent.getZoneChangeCounter(game) + 1 == source.getSourceObjectZoneChangeCounter())) { // PermanentCard || sourcePermanent.getZoneChangeCounter(game) + 1 == source.getSourceObjectZoneChangeCounter())) { // PermanentCard
int amount = sourcePermanent.getCounters().getCount(CounterType.P1P1); int amount = sourcePermanent.getCounters(game).getCount(CounterType.P1P1);
if (amount > 0) { if (amount > 0) {
Effect effect = new AddCountersTargetEffect(CounterType.P1P1.createInstance(amount)); Effect effect = new AddCountersTargetEffect(CounterType.P1P1.createInstance(amount));
effect.setTargetPointer(targetPointer); effect.setTargetPointer(targetPointer);

View file

@ -139,7 +139,7 @@ class IdentityThiefEffect extends OneShotEffect {
Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId()); Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId());
if (controller != null && permanent != null && sourcePermanent != null) { if (controller != null && permanent != null && sourcePermanent != null) {
Permanent permanentReset = permanent.copy(); Permanent permanentReset = permanent.copy();
permanentReset.getCounters().clear(); permanentReset.getCounters(game).clear();
permanentReset.getPower().resetToBaseValue(); permanentReset.getPower().resetToBaseValue();
permanentReset.getToughness().resetToBaseValue(); permanentReset.getToughness().resetToBaseValue();
CopyEffect copyEffect = new CopyEffect(Duration.EndOfTurn, permanentReset, source.getSourceId()); CopyEffect copyEffect = new CopyEffect(Duration.EndOfTurn, permanentReset, source.getSourceId());

View file

@ -96,7 +96,7 @@ class NoosegrafMobEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(source.getSourceId()); Permanent permanent = game.getPermanent(source.getSourceId());
Player controller = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
if (controller != null && permanent != null && permanent.getCounters().getCount(CounterType.P1P1) > 0) { if (controller != null && permanent != null && permanent.getCounters(game).getCount(CounterType.P1P1) > 0) {
permanent.removeCounters(CounterType.P1P1.createInstance(), game); permanent.removeCounters(CounterType.P1P1.createInstance(), game);
Effect effect = new CreateTokenEffect(new ZombieToken()); Effect effect = new CreateTokenEffect(new ZombieToken());
return effect.apply(game, source); return effect.apply(game, source);

View file

@ -103,7 +103,7 @@ class ReturnToHandAllNamedPermanentsEffect extends OneShotEffect {
for (Permanent perm : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), game)) { for (Permanent perm : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), game)) {
cardsToHand.add(perm); cardsToHand.add(perm);
} }
controller.moveCards(cardsToHand, null, Zone.HAND, source, game); controller.moveCards(cardsToHand, Zone.HAND, source, game);
return true; return true;
} }
return true; return true;

View file

@ -98,7 +98,7 @@ class GilderBairnEffect extends OneShotEffect {
if (target == null) { if (target == null) {
return false; return false;
} }
for (Counter counter : target.getCounters().values()) { for (Counter counter : target.getCounters(game).values()) {
Counter newCounter = new Counter(counter.getName(), counter.getCount()); Counter newCounter = new Counter(counter.getName(), counter.getCount());
target.addCounters(newCounter, game); target.addCounters(newCounter, game);
} }

View file

@ -103,7 +103,7 @@ class NecroskitterTriggeredAbility extends TriggeredAbilityImpl {
if (zEvent.getFromZone() == Zone.BATTLEFIELD && zEvent.getToZone() == Zone.GRAVEYARD) { if (zEvent.getFromZone() == Zone.BATTLEFIELD && zEvent.getToZone() == Zone.GRAVEYARD) {
Permanent permanent = zEvent.getTarget(); Permanent permanent = zEvent.getTarget();
if (permanent != null if (permanent != null
&& permanent.getCounters().containsKey(CounterType.M1M1) && permanent.getCounters(game).containsKey(CounterType.M1M1)
&& game.getOpponents(controllerId).contains(permanent.getControllerId())) { && game.getOpponents(controllerId).contains(permanent.getControllerId())) {
for (Effect effect : this.getEffects()) { for (Effect effect : this.getEffects()) {
effect.setTargetPointer(new FixedTarget(event.getTargetId(), game.getState().getZoneChangeCounter(event.getTargetId()))); effect.setTargetPointer(new FixedTarget(event.getTargetId(), game.getState().getZoneChangeCounter(event.getTargetId())));

View file

@ -104,7 +104,7 @@ class SpikeCannibalEffect extends OneShotEffect {
if (sourcePermanent != null) { if (sourcePermanent != null) {
for (Permanent creature : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), game)) { for (Permanent creature : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), game)) {
if (creature != sourcePermanent) { if (creature != sourcePermanent) {
int numberCounters = creature.getCounters().getCount(CounterType.P1P1); int numberCounters = creature.getCounters(game).getCount(CounterType.P1P1);
if (numberCounters > 0) { if (numberCounters > 0) {
creature.removeCounters(CounterType.P1P1.getName(), numberCounters, game); creature.removeCounters(CounterType.P1P1.getName(), numberCounters, game);
countersRemoved += numberCounters; countersRemoved += numberCounters;

View file

@ -111,7 +111,7 @@ class MoveCounterFromTargetToTargetEffect extends OneShotEffect {
MageObject sourceObject = game.getObject(source.getSourceId()); MageObject sourceObject = game.getObject(source.getSourceId());
if (sourceObject != null && controller != null) { if (sourceObject != null && controller != null) {
Permanent fromPermanent = game.getPermanent(getTargetPointer().getFirst(game, source)); Permanent fromPermanent = game.getPermanent(getTargetPointer().getFirst(game, source));
if (fromPermanent != null && fromPermanent.getCounters().getCount(CounterType.P1P1) > 0) { if (fromPermanent != null && fromPermanent.getCounters(game).getCount(CounterType.P1P1) > 0) {
Permanent toPermanent = game.getPermanent(source.getTargets().get(1).getFirstTarget()); Permanent toPermanent = game.getPermanent(source.getTargets().get(1).getFirstTarget());
if (toPermanent != null) { if (toPermanent != null) {
fromPermanent.removeCounters(CounterType.P1P1.createInstance(), game); fromPermanent.removeCounters(CounterType.P1P1.createInstance(), game);

View file

@ -150,7 +150,7 @@ class RenownedWeaponsmithEffect extends OneShotEffect {
Cards revealed = new CardsImpl(); Cards revealed = new CardsImpl();
revealed.add(card); revealed.add(card);
controller.revealCards(sourceObject.getIdName(), revealed, game); controller.revealCards(sourceObject.getIdName(), revealed, game);
controller.moveCards(revealed, null, Zone.HAND, source, game); controller.moveCards(revealed, Zone.HAND, source, game);
} }
} }
controller.shuffleLibrary(source, game); controller.shuffleLibrary(source, game);

View file

@ -110,7 +110,7 @@ class SuddenReclamationEffect extends OneShotEffect {
cardsToHand.add(card); cardsToHand.add(card);
} }
} }
controller.moveCards(cardsToHand, null, Zone.HAND, source, game); controller.moveCards(cardsToHand, Zone.HAND, source, game);
return true; return true;
} }
return false; return false;

View file

@ -99,7 +99,7 @@ class EngineeredExplosivesEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
MageObject engineeredExplosives = game.getLastKnownInformation(source.getSourceId(), Zone.BATTLEFIELD); MageObject engineeredExplosives = game.getLastKnownInformation(source.getSourceId(), Zone.BATTLEFIELD);
if(engineeredExplosives != null && engineeredExplosives instanceof Permanent){ if(engineeredExplosives != null && engineeredExplosives instanceof Permanent){
int count = ((Permanent)engineeredExplosives).getCounters().getCount(CounterType.CHARGE); int count = ((Permanent)engineeredExplosives).getCounters(game).getCount(CounterType.CHARGE);
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) { for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) {
if(permanent.getConvertedManaCost() == count){ if(permanent.getConvertedManaCost() == count){
permanent.destroy(source.getSourceId(), game, false); permanent.destroy(source.getSourceId(), game, false);

View file

@ -96,7 +96,7 @@ class RecallEffect extends OneShotEffect {
TargetCardInYourGraveyard target = new TargetCardInYourGraveyard(cardsDiscarded.size(), new FilterCard()); TargetCardInYourGraveyard target = new TargetCardInYourGraveyard(cardsDiscarded.size(), new FilterCard());
target.setNotTarget(true); target.setNotTarget(true);
target.choose(Outcome.ReturnToHand, controller.getId(), source.getSourceId(), game); target.choose(Outcome.ReturnToHand, controller.getId(), source.getSourceId(), game);
controller.moveCards(new CardsImpl(target.getTargets()), null, Zone.HAND, source, game); controller.moveCards(new CardsImpl(target.getTargets()), Zone.HAND, source, game);
} }
return true; return true;

View file

@ -89,7 +89,7 @@ class WindsOfChangeEffect extends OneShotEffect {
Player player = game.getPlayer(playerId); Player player = game.getPlayer(playerId);
if (player != null) { if (player != null) {
permanentsCount.put(playerId, player.getHand().size()); permanentsCount.put(playerId, player.getHand().size());
player.moveCards(player.getHand(), Zone.HAND, Zone.LIBRARY, source, game); player.moveCards(player.getHand(), Zone.LIBRARY, source, game);
player.shuffleLibrary(source, game); player.shuffleLibrary(source, game);
} }
} }

View file

@ -100,7 +100,7 @@ class AvianAddCountersSourceEffect extends AddCountersSourceEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
//record how many counters //record how many counters
Counters permCounters = game.getPermanent(source.getSourceId()).getCounters(); Counters permCounters = game.getPermanent(source.getSourceId()).getCounters(game);
int countersWas = permCounters.getCount(CounterType.P1P0); int countersWas = permCounters.getCount(CounterType.P1P0);
if (countersWas < 4){ if (countersWas < 4){
super.apply(game, source); super.apply(game, source);

View file

@ -0,0 +1,52 @@
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.sets.fourthedition;
import java.util.UUID;
/**
*
* @author Derpthemeus
*/
public class CyclopeanMummy extends mage.sets.legends.CyclopeanMummy {
public CyclopeanMummy(UUID ownerId) {
super(ownerId);
this.cardNumber = "12";
this.expansionSetCode = "4ED";
}
public CyclopeanMummy(final CyclopeanMummy card) {
super(card);
}
@Override
public CyclopeanMummy copy() {
return new CyclopeanMummy(this);
}
}

View file

@ -97,7 +97,7 @@ class CoalitionRelicEffect extends OneShotEffect {
Permanent sourcePermanent = game.getPermanent(source.getSourceId()); Permanent sourcePermanent = game.getPermanent(source.getSourceId());
Player player = game.getPlayer(source.getControllerId()); Player player = game.getPlayer(source.getControllerId());
if (sourcePermanent != null && player != null) { if (sourcePermanent != null && player != null) {
int chargeCounters = sourcePermanent.getCounters().getCount(CounterType.CHARGE); int chargeCounters = sourcePermanent.getCounters(game).getCount(CounterType.CHARGE);
sourcePermanent.removeCounters(CounterType.CHARGE.createInstance(chargeCounters), game); sourcePermanent.removeCounters(CounterType.CHARGE.createInstance(chargeCounters), game);
Mana mana = new Mana(); Mana mana = new Mana();
ChoiceColor choice = new ChoiceColor(); ChoiceColor choice = new ChoiceColor();

View file

@ -138,7 +138,7 @@ public class DustOfMoments extends CardImpl {
if (permFilter.match(card, game)) { if (permFilter.match(card, game)) {
final String counterName = counter.getName(); final String counterName = counter.getName();
if (shouldRemoveCounters()) { if (shouldRemoveCounters()) {
final Counter existingCounterOfSameType = card.getCounters().get(counterName); final Counter existingCounterOfSameType = card.getCounters(game).get(counterName);
final int countersToRemove = Math.min(existingCounterOfSameType.getCount(), counter.getCount()); final int countersToRemove = Math.min(existingCounterOfSameType.getCount(), counter.getCount());
final Counter modifiedCounter = new Counter(counterName, countersToRemove); final Counter modifiedCounter = new Counter(counterName, countersToRemove);
card.removeCounters(modifiedCounter, game); card.removeCounters(modifiedCounter, game);

View file

@ -104,7 +104,7 @@ class LostAuramancersAbility extends PutIntoGraveFromBattlefieldSourceTriggeredA
public boolean checkTrigger(GameEvent event, Game game) { public boolean checkTrigger(GameEvent event, Game game) {
if (super.checkTrigger(event, game)) { if (super.checkTrigger(event, game)) {
Permanent permanent = (Permanent) game.getLastKnownInformation(event.getTargetId(), Zone.BATTLEFIELD); Permanent permanent = (Permanent) game.getLastKnownInformation(event.getTargetId(), Zone.BATTLEFIELD);
if (!permanent.getCounters().containsKey(CounterType.TIME) || permanent.getCounters().getCount(CounterType.TIME) == 0) { if (!permanent.getCounters(game).containsKey(CounterType.TIME) || permanent.getCounters(game).getCount(CounterType.TIME) == 0) {
return true; return true;
} }
} }

View file

@ -0,0 +1,92 @@
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.sets.futuresight;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.filter.common.FilterCreaturePermanent;
import mage.game.Game;
import mage.players.Player;
/**
*
* @author Derpthemeus
*/
public class MinionsMurmurs extends CardImpl {
public MinionsMurmurs(UUID ownerId) {
super(ownerId, 71, "Minions' Murmurs", Rarity.UNCOMMON, new CardType[]{CardType.SORCERY}, "{2}{B}{B}");
this.expansionSetCode = "FUT";
// You draw X cards and you lose X life, where X is the number of creatures you control.
this.getSpellAbility().addEffect(new MinionsMurmursEffect());
}
public MinionsMurmurs(final MinionsMurmurs card) {
super(card);
}
@Override
public MinionsMurmurs copy() {
return new MinionsMurmurs(this);
}
class MinionsMurmursEffect extends OneShotEffect {
public MinionsMurmursEffect() {
super(Outcome.DrawCard);
this.staticText = "You draw X cards and you lose X life, where X is the number of creatures you control";
}
public MinionsMurmursEffect(final MinionsMurmursEffect effect) {
super(effect);
}
@Override
public MinionsMurmursEffect copy() {
return new MinionsMurmursEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
int creaturesControlled = game.getBattlefield().countAll(new FilterCreaturePermanent(), controller.getId(), game);
controller.drawCards(creaturesControlled, game);
controller.loseLife(creaturesControlled, game);
return true;
}
return false;
}
}
}

View file

@ -115,7 +115,7 @@ class BalustradeSpyEffect extends OneShotEffect {
} }
if (!cards.isEmpty()) { if (!cards.isEmpty()) {
controller.revealCards(sourceObject.getName(), cards, game); controller.revealCards(sourceObject.getName(), cards, game);
controller.moveCards(cards, Zone.LIBRARY, Zone.GRAVEYARD, source, game); controller.moveCards(cards, Zone.GRAVEYARD, source, game);
return true; return true;
} }
return true; return true;

View file

@ -45,7 +45,6 @@ import mage.game.Game;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
import mage.game.stack.StackObject; import mage.game.stack.StackObject;
import mage.players.Player; import mage.players.Player;
import mage.target.Target;
import mage.target.common.TargetCreaturePermanent; import mage.target.common.TargetCreaturePermanent;
/** /**
@ -114,7 +113,7 @@ class MoveCounterFromTargetToTargetEffect extends OneShotEffect {
if (fromPermanent == null || toPermanent == null || !fromPermanent.getControllerId().equals(toPermanent.getControllerId())) { if (fromPermanent == null || toPermanent == null || !fromPermanent.getControllerId().equals(toPermanent.getControllerId())) {
return false; return false;
} }
int amountCounters = fromPermanent.getCounters().getCount(CounterType.P1P1); int amountCounters = fromPermanent.getCounters(game).getCount(CounterType.P1P1);
if (amountCounters > 0) { if (amountCounters > 0) {
int amountToMove = controller.getAmount(0, amountCounters, "How many counters do you want to move?", game); int amountToMove = controller.getAmount(0, amountCounters, "How many counters do you want to move?", game);
if (amountToMove > 0) { if (amountToMove > 0) {

View file

@ -121,8 +121,8 @@ class BorborygmosEnragedEffect extends OneShotEffect {
cards.remove(card); cards.remove(card);
} }
} }
controller.moveCards(landCards, Zone.LIBRARY, Zone.HAND, source, game); controller.moveCards(landCards, Zone.HAND, source, game);
controller.moveCards(cards, Zone.LIBRARY, Zone.GRAVEYARD, source, game); controller.moveCards(cards, Zone.GRAVEYARD, source, game);
} }
return true; return true;
} }

View file

@ -97,7 +97,7 @@ class CoercedConfessionMillEffect extends OneShotEffect {
++foundCreatures; ++foundCreatures;
} }
} }
player.moveCards(cards, Zone.LIBRARY, Zone.GRAVEYARD, source, game); player.moveCards(cards, Zone.GRAVEYARD, source, game);
if (foundCreatures > 0) { if (foundCreatures > 0) {
Player controller = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
if (controller != null) { if (controller != null) {

View file

@ -116,7 +116,7 @@ class ConsumingAberrationEffect extends OneShotEffect {
} }
} }
player.revealCards("Consuming Aberrtion", cards, game); player.revealCards("Consuming Aberrtion", cards, game);
player.moveCards(cards, Zone.LIBRARY, Zone.GRAVEYARD, source, game); player.moveCards(cards, Zone.GRAVEYARD, source, game);
} }
return true; return true;
} }

View file

@ -129,7 +129,7 @@ class DimirCharmEffect extends OneShotEffect {
card.moveToZone(Zone.LIBRARY, source.getSourceId(), game, true); card.moveToZone(Zone.LIBRARY, source.getSourceId(), game, true);
cards.remove(card); cards.remove(card);
} }
controller.moveCards(cards, Zone.LIBRARY, Zone.GRAVEYARD, source, game); controller.moveCards(cards, Zone.GRAVEYARD, source, game);
} }
} }
} }

View file

@ -117,7 +117,7 @@ class MindGrindEffect extends OneShotEffect {
} }
} }
player.revealCards("by " + sourceCard.getName() + " from " + player.getName(), cards, game); player.revealCards("by " + sourceCard.getName() + " from " + player.getName(), cards, game);
player.moveCards(cards, Zone.LIBRARY, Zone.GRAVEYARD, source, game); player.moveCards(cards, Zone.GRAVEYARD, source, game);
} }
return true; return true;
} }

View file

@ -101,7 +101,7 @@ class MoveCounterFromSourceToTargetEffect extends OneShotEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Permanent sourcePermanent = game.getPermanent(source.getSourceId()); Permanent sourcePermanent = game.getPermanent(source.getSourceId());
if (sourcePermanent != null && sourcePermanent.getCounters().getCount(CounterType.P1P1) > 0) { if (sourcePermanent != null && sourcePermanent.getCounters(game).getCount(CounterType.P1P1) > 0) {
Permanent targetPermanent = game.getPermanent(targetPointer.getFirst(game, source)); Permanent targetPermanent = game.getPermanent(targetPointer.getFirst(game, source));
if (targetPermanent != null) { if (targetPermanent != null) {
sourcePermanent.removeCounters(CounterType.P1P1.createInstance(), game); sourcePermanent.removeCounters(CounterType.P1P1.createInstance(), game);

View file

@ -117,7 +117,7 @@ class UndercityInformerEffect extends OneShotEffect {
} }
} }
player.revealCards("Undercity Informer", cards, game); player.revealCards("Undercity Informer", cards, game);
player.moveCards(cards, Zone.LIBRARY, Zone.GRAVEYARD, source, game); player.moveCards(cards, Zone.GRAVEYARD, source, game);
return true; return true;
} }
} }

View file

@ -121,7 +121,7 @@ class DemonicConsultationEffect extends OneShotEffect {
controller.moveCards(cardToHand, Zone.HAND, source, game); controller.moveCards(cardToHand, Zone.HAND, source, game);
controller.revealCards(sourceObject.getIdName(), cardsToReaveal, game); controller.revealCards(sourceObject.getIdName(), cardsToReaveal, game);
cardsToReaveal.remove(cardToHand); cardsToReaveal.remove(cardToHand);
controller.moveCards(cardsToReaveal, null, Zone.EXILED, source, game); controller.moveCards(cardsToReaveal, Zone.EXILED, source, game);
return true; return true;
} }
return false; return false;

View file

@ -100,7 +100,7 @@ class EssenceOfTheWildEffect extends ReplacementEffectImpl {
Permanent sourceObject = game.getPermanentOrLKIBattlefield(source.getSourceId()); Permanent sourceObject = game.getPermanentOrLKIBattlefield(source.getSourceId());
if (sourceObject != null) { if (sourceObject != null) {
Permanent permanentReset = sourceObject.copy(); Permanent permanentReset = sourceObject.copy();
permanentReset.getCounters().clear(); permanentReset.getCounters(game).clear();
permanentReset.getPower().resetToBaseValue(); permanentReset.getPower().resetToBaseValue();
permanentReset.getToughness().resetToBaseValue(); permanentReset.getToughness().resetToBaseValue();
game.addEffect(new CopyEffect(Duration.Custom, permanentReset, event.getTargetId()), source); game.addEffect(new CopyEffect(Duration.Custom, permanentReset, event.getTargetId()), source);

Some files were not shown because too many files have changed in this diff Show more