mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 19:28:01 +00:00
Attached: combine Enchant+Equip+Fortify
This commit is contained in:
@@ -404,56 +404,24 @@ public class TargetingOverlay {
|
||||
return; //don't add arcs for cards if card already visualized
|
||||
}
|
||||
|
||||
final CardView enchanting = c.getEnchantingCard();
|
||||
final CardView equipping = c.getEquipping();
|
||||
final CardView fortifying = c.getFortifying();
|
||||
final Iterable<CardView> enchantedBy = c.getEnchantedBy();
|
||||
final Iterable<CardView> equippedBy = c.getEquippedBy();
|
||||
final Iterable<CardView> fortifiedBy = c.getFortifiedBy();
|
||||
final CardView attaching = c.getAttachingCard();
|
||||
final Iterable<CardView> attachedBy = c.getAttachedBy();
|
||||
final CardView paired = c.getPairedWith();
|
||||
|
||||
if (null != enchanting) {
|
||||
if (enchanting.getController() != null && !enchanting.getController().equals(c.getController())) {
|
||||
addArc(endpoints.get(enchanting.getId()), endpoints.get(c.getId()), ArcConnection.Friends);
|
||||
cardsVisualized.add(enchanting);
|
||||
if (null != attaching) {
|
||||
if (attaching.getController() != null && !attaching.getController().equals(c.getController())) {
|
||||
addArc(endpoints.get(attaching.getId()), endpoints.get(c.getId()), ArcConnection.Friends);
|
||||
cardsVisualized.add(attaching);
|
||||
}
|
||||
}
|
||||
if (null != equipping) {
|
||||
if (equipping.getController() != null && !equipping.getController().equals(c.getController())) {
|
||||
addArc(endpoints.get(equipping.getId()), endpoints.get(c.getId()), ArcConnection.Friends);
|
||||
cardsVisualized.add(equipping);
|
||||
}
|
||||
}
|
||||
if (null != fortifying) {
|
||||
if (fortifying.getController() != null && !fortifying.getController().equals(c.getController())) {
|
||||
addArc(endpoints.get(fortifying.getId()), endpoints.get(c.getId()), ArcConnection.Friends);
|
||||
cardsVisualized.add(fortifying);
|
||||
}
|
||||
}
|
||||
if (null != enchantedBy) {
|
||||
for (final CardView enc : enchantedBy) {
|
||||
if (null != attachedBy) {
|
||||
for (final CardView enc : attachedBy) {
|
||||
if (enc.getController() != null && !enc.getController().equals(c.getController())) {
|
||||
addArc(endpoints.get(c.getId()), endpoints.get(enc.getId()), ArcConnection.Friends);
|
||||
cardsVisualized.add(enc);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (null != equippedBy) {
|
||||
for (final CardView eq : equippedBy) {
|
||||
if (eq.getController() != null && !eq.getController().equals(c.getController())) {
|
||||
addArc(endpoints.get(c.getId()), endpoints.get(eq.getId()), ArcConnection.Friends);
|
||||
cardsVisualized.add(eq);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (null != fortifiedBy) {
|
||||
for (final CardView eq : fortifiedBy) {
|
||||
if (eq.getController() != null && !eq.getController().equals(c.getController())) {
|
||||
addArc(endpoints.get(c.getId()), endpoints.get(eq.getId()), ArcConnection.Friends);
|
||||
cardsVisualized.add(eq);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (null != paired) {
|
||||
addArc(endpoints.get(paired.getId()), endpoints.get(c.getId()), ArcConnection.Friends);
|
||||
cardsVisualized.add(paired);
|
||||
|
||||
@@ -106,7 +106,7 @@ public class PlayArea extends CardPanelContainer implements CardPanelMouseListen
|
||||
final CardStack stack = allLands.get(i);
|
||||
final CardPanel firstPanel = stack.get(0);
|
||||
if (firstPanel.getCard().getCurrentState().getName().equals(state.getName())) {
|
||||
if (!firstPanel.getAttachedPanels().isEmpty() || firstPanel.getCard().isEnchanted()) {
|
||||
if (!firstPanel.getAttachedPanels().isEmpty() || firstPanel.getCard().isAttached()) {
|
||||
// Put this land to the left of lands with the same name
|
||||
// and attachments.
|
||||
insertIndex = i;
|
||||
@@ -114,7 +114,7 @@ public class PlayArea extends CardPanelContainer implements CardPanelMouseListen
|
||||
}
|
||||
if (!panel.getAttachedPanels().isEmpty()
|
||||
|| !panel.getCard().hasSameCounters(firstPanel.getCard())
|
||||
|| firstPanel.getCard().isEnchanted() || (stack.size() == this.landStackMax)) {
|
||||
|| firstPanel.getCard().isAttached() || (stack.size() == this.landStackMax)) {
|
||||
// If this land has attachments or the stack is full,
|
||||
// put it to the right.
|
||||
insertIndex = i + 1;
|
||||
@@ -683,8 +683,8 @@ public class PlayArea extends CardPanelContainer implements CardPanelMouseListen
|
||||
}
|
||||
toPanel.getAttachedPanels().clear();
|
||||
|
||||
if (card.isEnchanted()) {
|
||||
final Iterable<CardView> enchants = card.getEnchantedBy();
|
||||
if (card.isAttached()) {
|
||||
final Iterable<CardView> enchants = card.getAttachedBy();
|
||||
for (final CardView e : enchants) {
|
||||
final CardPanel cardE = getCardPanel(e.getId());
|
||||
if (cardE != null) {
|
||||
@@ -697,43 +697,9 @@ public class PlayArea extends CardPanelContainer implements CardPanelMouseListen
|
||||
}
|
||||
}
|
||||
|
||||
if (card.isEquipped()) {
|
||||
final Iterable<CardView> equips = card.getEquippedBy();
|
||||
for (final CardView e : equips) {
|
||||
final CardPanel cardE = getCardPanel(e.getId());
|
||||
if (cardE != null) {
|
||||
if (cardE.getAttachedToPanel() != toPanel) {
|
||||
cardE.setAttachedToPanel(toPanel);
|
||||
needLayoutRefresh = true; //ensure layout refreshed if any attachments change
|
||||
}
|
||||
toPanel.getAttachedPanels().add(cardE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (card.isFortified()) {
|
||||
final Iterable<CardView> fortifications = card.getFortifiedBy();
|
||||
for (final CardView f : fortifications) {
|
||||
final CardPanel cardE = getCardPanel(f.getId());
|
||||
if (cardE != null) {
|
||||
if (cardE.getAttachedToPanel() != toPanel) {
|
||||
cardE.setAttachedToPanel(toPanel);
|
||||
needLayoutRefresh = true; //ensure layout refreshed if any attachments change
|
||||
}
|
||||
toPanel.getAttachedPanels().add(cardE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CardPanel attachedToPanel;
|
||||
if (card.getEnchantingCard() != null) {
|
||||
attachedToPanel = getCardPanel(card.getEnchantingCard().getId());
|
||||
}
|
||||
else if (card.getEquipping() != null) {
|
||||
attachedToPanel = getCardPanel(card.getEquipping().getId());
|
||||
}
|
||||
else if (card.getFortifying() != null) {
|
||||
attachedToPanel = getCardPanel(card.getFortifying().getId());
|
||||
if (card.getAttachingCard() != null) {
|
||||
attachedToPanel = getCardPanel(card.getAttachingCard().getId());
|
||||
}
|
||||
else {
|
||||
attachedToPanel = null;
|
||||
|
||||
@@ -115,7 +115,7 @@ public class GameSimulatorTest extends SimulationTestCase {
|
||||
Card bear = addCard(bearCardName, p);
|
||||
bear.setSickness(false);
|
||||
Card cloak = addCard("Whispersilk Cloak", p);
|
||||
cloak.equipCard(bear);
|
||||
cloak.attachEntity(bear);
|
||||
game.getPhaseHandler().devModeSet(PhaseType.MAIN1, p);
|
||||
game.getAction().checkStateEffects(true);
|
||||
assertEquals(1, bear.getAmountOfKeyword("Unblockable"));
|
||||
@@ -133,7 +133,7 @@ public class GameSimulatorTest extends SimulationTestCase {
|
||||
Card bear = addCard(bearCardName, p);
|
||||
bear.setSickness(false);
|
||||
Card lifelink = addCard("Lifelink", p);
|
||||
lifelink.enchantEntity(bear);
|
||||
lifelink.attachEntity(bear);
|
||||
game.getPhaseHandler().devModeSet(PhaseType.MAIN1, p);
|
||||
game.getAction().checkStateEffects(true);
|
||||
assertEquals(1, bear.getAmountOfKeyword("Lifelink"));
|
||||
@@ -661,7 +661,7 @@ public class GameSimulatorTest extends SimulationTestCase {
|
||||
Card pridemate = addCard(pridemateName, p1);
|
||||
Card indestructibility = addCard(indestructibilityName, p1);
|
||||
|
||||
indestructibility.enchantEntity(pridemate);
|
||||
indestructibility.attachEntity(pridemate);
|
||||
|
||||
Card ignition = addCardToZone(ignitionName, p1, ZoneType.Hand);
|
||||
SpellAbility ignitionSA = ignition.getFirstSpellAbility();
|
||||
@@ -681,6 +681,7 @@ public class GameSimulatorTest extends SimulationTestCase {
|
||||
|
||||
// because it was destroyed
|
||||
assertNull(simBrood);
|
||||
assertNotNull(simPridemate);
|
||||
|
||||
assertEquals(0, simKalitas.getDamage());
|
||||
assertEquals(3, simPridemate.getDamage());
|
||||
@@ -774,7 +775,7 @@ public class GameSimulatorTest extends SimulationTestCase {
|
||||
Card pridemate = addCard(pridemateName, p1);
|
||||
Card indestructibility = addCard(indestructibilityName, p1);
|
||||
|
||||
indestructibility.enchantEntity(pridemate);
|
||||
indestructibility.attachEntity(pridemate);
|
||||
|
||||
Card ignition = addCardToZone(ignitionName, p1, ZoneType.Hand);
|
||||
SpellAbility ignitionSA = ignition.getFirstSpellAbility();
|
||||
@@ -800,6 +801,7 @@ public class GameSimulatorTest extends SimulationTestCase {
|
||||
|
||||
//destoryed because of to much redirected damage
|
||||
assertNull(simPalisade);
|
||||
assertNotNull(simPridemate);
|
||||
|
||||
assertEquals(0, simKalitas.getDamage());
|
||||
assertEquals(3, simPridemate.getDamage());
|
||||
|
||||
@@ -102,22 +102,16 @@ public class GameWrapper {
|
||||
actualController.getZone( zoneType ).add( actualCard );
|
||||
|
||||
if( card.getTarget() != null ) {
|
||||
Card target = CardSpecificationHandler.INSTANCE.find( game, card.getTarget() );
|
||||
if( actualCard.isEnchantment() ) {
|
||||
if( target.canBeEnchantedBy( actualCard ) ) {
|
||||
actualCard.enchantEntity( target );
|
||||
} else {
|
||||
throw new IllegalStateException( actualCard + " can't enchant " + target );
|
||||
}
|
||||
} else if( actualCard.isEquipment() ) {
|
||||
if( target.canBeEquippedBy( actualCard ) ) {
|
||||
actualCard.equipCard( target );
|
||||
} else {
|
||||
throw new IllegalStateException( actualCard + " can't equip " + target );
|
||||
}
|
||||
} else {
|
||||
throw new IllegalStateException( "Don't know how to make " + actualCard + " target anything" );
|
||||
}
|
||||
Card target = CardSpecificationHandler.INSTANCE.find( game, card.getTarget() );
|
||||
if (actualCard.isAttachment()) {
|
||||
if (target.canBeAttachedBy(actualCard)) {
|
||||
actualCard.attachEntity(target);
|
||||
} else {
|
||||
throw new IllegalStateException( actualCard + " can't attach " + target );
|
||||
}
|
||||
} else {
|
||||
throw new IllegalStateException( "Don't know how to make " + actualCard + " target anything" );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user