mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 12:48:00 +00:00
Use interface to simplify getting list items with associated card views to display card image
This commit is contained in:
@@ -7,6 +7,8 @@ import forge.game.card.CardCollection;
|
||||
import forge.game.card.CardFactoryUtil;
|
||||
import forge.game.card.CardLists;
|
||||
import forge.game.card.CardUtil;
|
||||
import forge.game.card.CardView;
|
||||
import forge.game.card.IHasCardView;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.zone.ZoneType;
|
||||
import forge.util.Expressions;
|
||||
@@ -20,7 +22,7 @@ import com.google.common.collect.Maps;
|
||||
* Base class for Triggers,ReplacementEffects and StaticAbilities.
|
||||
*
|
||||
*/
|
||||
public abstract class CardTraitBase extends GameObject {
|
||||
public abstract class CardTraitBase extends GameObject implements IHasCardView {
|
||||
|
||||
/** The host card. */
|
||||
protected Card hostCard;
|
||||
@@ -385,4 +387,9 @@ public abstract class CardTraitBase extends GameObject {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public CardView getCardView() {
|
||||
return CardView.get(hostCard);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
package forge.game.card;
|
||||
|
||||
public interface IHasCardView {
|
||||
CardView getCardView();
|
||||
}
|
||||
@@ -18,6 +18,7 @@
|
||||
package forge.game.spellability;
|
||||
|
||||
import com.google.common.collect.Iterables;
|
||||
|
||||
import forge.card.mana.ManaCost;
|
||||
import forge.game.CardTraitBase;
|
||||
import forge.game.Game;
|
||||
|
||||
@@ -20,6 +20,8 @@ package forge.game.spellability;
|
||||
import forge.game.IIdentifiable;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.card.CardCollection;
|
||||
import forge.game.card.CardView;
|
||||
import forge.game.card.IHasCardView;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.trigger.TriggerType;
|
||||
import forge.game.zone.ZoneType;
|
||||
@@ -39,7 +41,7 @@ import java.util.Set;
|
||||
* @author Forge
|
||||
* @version $Id$
|
||||
*/
|
||||
public class SpellAbilityStackInstance implements IIdentifiable {
|
||||
public class SpellAbilityStackInstance implements IIdentifiable, IHasCardView {
|
||||
private static int maxId = 0;
|
||||
private static int nextId() { return ++maxId; }
|
||||
|
||||
@@ -311,4 +313,9 @@ public class SpellAbilityStackInstance implements IIdentifiable {
|
||||
public StackItemView getView() {
|
||||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CardView getCardView() {
|
||||
return CardView.get(getSourceCard());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
package forge.game.spellability;
|
||||
|
||||
import forge.game.card.CardView;
|
||||
import forge.game.card.IHasCardView;
|
||||
import forge.trackable.TrackableCollection;
|
||||
import forge.trackable.TrackableObject;
|
||||
import forge.trackable.TrackableProperty;
|
||||
|
||||
public class SpellAbilityView extends TrackableObject {
|
||||
public class SpellAbilityView extends TrackableObject implements IHasCardView {
|
||||
private static final long serialVersionUID = 2514234930798754769L;
|
||||
|
||||
public static SpellAbilityView get(SpellAbility spab) {
|
||||
@@ -62,4 +63,9 @@ public class SpellAbilityView extends TrackableObject {
|
||||
void updatePromptIfOnlyPossibleAbility(SpellAbility sa) {
|
||||
set(TrackableProperty.PromptIfOnlyPossibleAbility, sa.promptIfOnlyPossibleAbility());
|
||||
}
|
||||
|
||||
@Override
|
||||
public CardView getCardView() {
|
||||
return getHostCard();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
package forge.game.spellability;
|
||||
|
||||
import forge.game.card.CardView;
|
||||
import forge.game.card.IHasCardView;
|
||||
import forge.game.player.PlayerView;
|
||||
import forge.trackable.TrackableCollection;
|
||||
import forge.trackable.TrackableObject;
|
||||
import forge.trackable.TrackableProperty;
|
||||
import forge.util.FCollectionView;
|
||||
|
||||
public class StackItemView extends TrackableObject {
|
||||
public class StackItemView extends TrackableObject implements IHasCardView {
|
||||
private static final long serialVersionUID = 6733415646691356052L;
|
||||
|
||||
public static StackItemView get(SpellAbilityStackInstance si) {
|
||||
@@ -113,4 +114,9 @@ public class StackItemView extends TrackableObject {
|
||||
public String toString() {
|
||||
return getText();
|
||||
}
|
||||
|
||||
@Override
|
||||
public CardView getCardView() {
|
||||
return getSourceCard();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user