Merge pull request #185 from Card-Forge/attachSpellAbility

canEquip checks for SpellAbility
This commit is contained in:
Anthony Calosa
2022-05-02 06:01:14 +08:00
committed by GitHub
20 changed files with 187 additions and 198 deletions

View File

@@ -1077,7 +1077,7 @@ public class ComputerUtil {
playNow = false;
break;
}
if (!playNow && c.isCreature() && ComputerUtilCombat.canAttackNextTurn(c) && c.canBeAttached(card)) {
if (!playNow && c.isCreature() && ComputerUtilCombat.canAttackNextTurn(c) && c.canBeAttached(card, null)) {
playNow = true;
}
}

View File

@@ -1135,7 +1135,7 @@ public abstract class GameState {
Card attachedTo = idToCard.get(entry.getValue());
Card attacher = entry.getKey();
if (attacher.isAttachment()) {
attacher.attachToEntity(attachedTo);
attacher.attachToEntity(attachedTo, null, true);
}
}
@@ -1146,7 +1146,7 @@ public abstract class GameState {
Game game = attacher.getGame();
Player attachedTo = entry.getValue() == TARGET_AI ? game.getPlayers().get(1) : game.getPlayers().get(0);
attacher.attachToEntity(attachedTo);
attacher.attachToEntity(attachedTo, null);
}
}

View File

@@ -618,7 +618,7 @@ public class AttachAi extends SpellAbilityAi {
CardCollection preList = new CardCollection(lki);
preList.add(attachSourceLki);
c.getGame().getAction().checkStaticAbilities(false, Sets.newHashSet(preList), preList);
boolean result = lki.canBeAttached(attachSourceLki);
boolean result = lki.canBeAttached(attachSourceLki, null);
//reset static abilities
c.getGame().getAction().checkStaticAbilities(false);
@@ -1354,7 +1354,7 @@ public class AttachAi extends SpellAbilityAi {
if (tgt == null) {
list = AbilityUtils.getDefinedCards(attachSource, sa.getParam("Defined"), sa);
} else {
list = CardLists.filter(CardUtil.getValidCardsToTarget(tgt, sa), CardPredicates.canBeAttached(attachSource));
list = CardLists.filter(CardUtil.getValidCardsToTarget(tgt, sa), CardPredicates.canBeAttached(attachSource, sa));
}
if (list.isEmpty()) {
@@ -1627,7 +1627,6 @@ public class AttachAi extends SpellAbilityAi {
* @return true, if is useful keyword
*/
private static boolean isUsefulCurseKeyword(final String keyword, final Card card, final SpellAbility sa) {
final Player ai = sa.getActivatingPlayer();
if (!CardUtil.isStackingKeyword(keyword) && card.hasKeyword(keyword)) {
return false;
}

View File

@@ -39,7 +39,7 @@ public class ZoneExchangeAi extends SpellAbilityAi {
}
if (type.equals("Aura")) {
Card c = object1.getEnchantingCard();
if (!c.canBeAttached(object2)) {
if (!c.canBeAttached(object2, sa)) {
return false;
}
}