mirror of
https://github.com/correl/mage.git
synced 2024-12-26 19:16:54 +00:00
Merge origin/master
This commit is contained in:
commit
1f1f8544e3
4 changed files with 26 additions and 35 deletions
|
@ -34,6 +34,7 @@ import mage.abilities.Ability;
|
||||||
import mage.abilities.common.OnEventTriggeredAbility;
|
import mage.abilities.common.OnEventTriggeredAbility;
|
||||||
import mage.abilities.effects.OneShotEffect;
|
import mage.abilities.effects.OneShotEffect;
|
||||||
import mage.abilities.effects.common.AttachEffect;
|
import mage.abilities.effects.common.AttachEffect;
|
||||||
|
import mage.abilities.keyword.ChangelingAbility;
|
||||||
import mage.abilities.keyword.EnchantAbility;
|
import mage.abilities.keyword.EnchantAbility;
|
||||||
import mage.cards.Card;
|
import mage.cards.Card;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
|
@ -66,7 +67,6 @@ public class CallToTheKindred extends CardImpl {
|
||||||
this.expansionSetCode = "DKA";
|
this.expansionSetCode = "DKA";
|
||||||
this.subtype.add("Aura");
|
this.subtype.add("Aura");
|
||||||
|
|
||||||
|
|
||||||
// Enchant creature
|
// Enchant creature
|
||||||
TargetPermanent auraTarget = new TargetCreaturePermanent();
|
TargetPermanent auraTarget = new TargetCreaturePermanent();
|
||||||
this.getSpellAbility().addTarget(auraTarget);
|
this.getSpellAbility().addTarget(auraTarget);
|
||||||
|
@ -106,10 +106,10 @@ class CallToTheKindredEffect extends OneShotEffect {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
Player player = game.getPlayer(source.getControllerId());
|
Player controller = game.getPlayer(source.getControllerId());
|
||||||
Permanent enchantment = game.getPermanent(source.getSourceId());
|
Permanent enchantment = game.getPermanent(source.getSourceId());
|
||||||
|
|
||||||
if (player == null || enchantment.getAttachedTo() == null) {
|
if (enchantment == null || controller == null || enchantment.getAttachedTo() == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -119,18 +119,14 @@ class CallToTheKindredEffect extends OneShotEffect {
|
||||||
}
|
}
|
||||||
|
|
||||||
Cards cards = new CardsImpl();
|
Cards cards = new CardsImpl();
|
||||||
int count = Math.min(player.getLibrary().size(), 5);
|
cards.addAll(controller.getLibrary().getTopCards(game, 5));
|
||||||
for (int i = 0; i < count; i++) {
|
controller.lookAtCards(enchantment.getIdName(), cards, game);
|
||||||
Card card = player.getLibrary().removeFromTop(game);
|
|
||||||
if (card != null) {
|
|
||||||
cards.add(card);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
player.lookAtCards("Call to the Kindred", cards, game);
|
|
||||||
|
|
||||||
FilterCreatureCard filter = new FilterCreatureCard();
|
FilterCreatureCard filter = new FilterCreatureCard();
|
||||||
|
|
||||||
|
if (!creature.getAbilities().contains(ChangelingAbility.getInstance())) {
|
||||||
StringBuilder sb = new StringBuilder("creature card with at least one subtype from: ");
|
StringBuilder sb = new StringBuilder("creature card with at least one subtype from: ");
|
||||||
ArrayList<Predicate<MageObject>> subtypes = new ArrayList<Predicate<MageObject>>();
|
ArrayList<Predicate<MageObject>> subtypes = new ArrayList<>();
|
||||||
for (String subtype : creature.getSubtype()) {
|
for (String subtype : creature.getSubtype()) {
|
||||||
subtypes.add(new SubtypePredicate(subtype));
|
subtypes.add(new SubtypePredicate(subtype));
|
||||||
sb.append(subtype).append(", ");
|
sb.append(subtype).append(", ");
|
||||||
|
@ -138,19 +134,22 @@ class CallToTheKindredEffect extends OneShotEffect {
|
||||||
filter.add(Predicates.or(subtypes));
|
filter.add(Predicates.or(subtypes));
|
||||||
sb.delete(sb.length() - 2, sb.length());
|
sb.delete(sb.length() - 2, sb.length());
|
||||||
filter.setMessage(sb.toString());
|
filter.setMessage(sb.toString());
|
||||||
|
} else {
|
||||||
|
filter.setMessage("creature card that shares a creature type with enchanted creature");
|
||||||
|
}
|
||||||
|
|
||||||
if (cards.count(filter, game) > 0 && player.chooseUse(Outcome.DrawCard, "Do you wish to put a creature card onto the battlefield?", source, game)) {
|
if (cards.count(filter, game) > 0 && controller.chooseUse(Outcome.DrawCard, "Do you wish to put a creature card onto the battlefield?", source, game)) {
|
||||||
TargetCard target = new TargetCard(Zone.LIBRARY, filter);
|
TargetCard target = new TargetCard(Zone.LIBRARY, filter);
|
||||||
|
|
||||||
if (player.choose(Outcome.PutCreatureInPlay, cards, target, game)) {
|
if (controller.choose(Outcome.PutCreatureInPlay, cards, target, game)) {
|
||||||
Card card = cards.get(target.getFirstTarget(), game);
|
Card card = cards.get(target.getFirstTarget(), game);
|
||||||
if (card != null) {
|
if (card != null) {
|
||||||
cards.remove(card);
|
cards.remove(card);
|
||||||
card.putOntoBattlefield(game, Zone.LIBRARY, source.getSourceId(), source.getControllerId());
|
controller.moveCards(card, Zone.BATTLEFIELD, source, game);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
player.putCardsOnBottomOfLibrary(cards, game, source, true);
|
controller.putCardsOnBottomOfLibrary(cards, game, source, true);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -59,7 +59,7 @@ public class CursedScroll extends CardImpl {
|
||||||
super(ownerId, 271, "Cursed Scroll", Rarity.RARE, new CardType[]{CardType.ARTIFACT}, "{1}");
|
super(ownerId, 271, "Cursed Scroll", Rarity.RARE, new CardType[]{CardType.ARTIFACT}, "{1}");
|
||||||
this.expansionSetCode = "TMP";
|
this.expansionSetCode = "TMP";
|
||||||
|
|
||||||
// {3}, {tap}: Name a card. Reveal a card at random from your hand. If it's the named card, Cursed Scroll deals 2 damage to target creature or player.
|
// {3}, {T}: Name a card. Reveal a card at random from your hand. If it's the named card, Cursed Scroll deals 2 damage to target creature or player.
|
||||||
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new NameACardEffect(NameACardEffect.TypeOfName.ALL), new ManaCostsImpl("{3}"));
|
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new NameACardEffect(NameACardEffect.TypeOfName.ALL), new ManaCostsImpl("{3}"));
|
||||||
ability.addEffect(new CursedScrollEffect());
|
ability.addEffect(new CursedScrollEffect());
|
||||||
ability.addCost(new TapSourceCost());
|
ability.addCost(new TapSourceCost());
|
||||||
|
|
|
@ -81,15 +81,6 @@ public class Deck implements Serializable {
|
||||||
Collections.sort(sbCardNames);
|
Collections.sort(sbCardNames);
|
||||||
String deckString = deckCardNames.toString() + sbCardNames.toString();
|
String deckString = deckCardNames.toString() + sbCardNames.toString();
|
||||||
deck.setDeckHashCode(DeckUtil.fixedHash(deckString));
|
deck.setDeckHashCode(DeckUtil.fixedHash(deckString));
|
||||||
// try{
|
|
||||||
// MessageDigest messageDigest = MessageDigest.getInstance("SHA-256");
|
|
||||||
// messageDigest.update(deckString.getBytes());
|
|
||||||
// String encryptedString = new String(messageDigest.digest());
|
|
||||||
// deck.setDeckHashCode(encryptedString.hashCode());
|
|
||||||
// }
|
|
||||||
// catch (NoSuchAlgorithmException e) {
|
|
||||||
// // nothing
|
|
||||||
// }
|
|
||||||
return deck;
|
return deck;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -386,6 +386,7 @@ public enum CardRepository {
|
||||||
|
|
||||||
return cardDao.query(queryBuilder.prepare());
|
return cardDao.query(queryBuilder.prepare());
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
|
Logger.getLogger(CardRepository.class).error("Error during execution of card repository query statement", ex);
|
||||||
}
|
}
|
||||||
return new ArrayList<>();
|
return new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue