MCPcopy Create free account
hub / github.com/Card-Forge/forge / GameEntityView

Class GameEntityView

forge-game/src/main/java/forge/game/GameEntityView.java:13–72  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11import forge.trackable.Tracker;
12
13public abstract class GameEntityView extends TrackableObject {
14 private static final long serialVersionUID = -5129089945124455670L;
15
16 public static GameEntityView get(GameEntity e) {
17 return e == null ? null : e.getView();
18 }
19
20 public static TrackableCollection<GameEntityView> getEntityCollection(Iterable<? extends GameEntity> entities) {
21 if (entities == null) {
22 return null;
23 }
24 TrackableCollection<GameEntityView> collection = new TrackableCollection<>();
25 for (GameEntity e : entities) {
26 collection.add(e.getView());
27 }
28 return collection;
29 }
30
31 public static <T extends GameEntity, V extends GameEntityView> GameEntityViewMap<T, V> getMap(Iterable<T> spabs) {
32 GameEntityViewMap<T, V> gameViewCache = new GameEntityViewMap<T, V>();
33 gameViewCache.putAll(spabs);
34 return gameViewCache;
35 }
36
37 protected GameEntityView(final int id0, final Tracker tracker) {
38 super(id0, tracker);
39 }
40
41 @Override
42 public String toString() {
43 return getName();
44 }
45
46 public String getName() {
47 return get(TrackableProperty.Name);
48 }
49 protected void updateName(GameEntity e) {
50 set(TrackableProperty.Name, e.getName());
51 }
52
53 public int getPreventNextDamage() {
54 return get(TrackableProperty.PreventNextDamage);
55 }
56 public void updatePreventNextDamage(GameEntity e) {
57 set(TrackableProperty.PreventNextDamage, e.getPreventNextDamageTotalShields());
58 }
59
60 public List<CardView> getAttachedCards() {
61 return getAllAttachedCards().stream().filter(c -> !c.isPhasedOut()).collect(Collectors.toList());
62 }
63 public boolean hasCardAttachments() {
64 return !getAttachedCards().isEmpty();
65 }
66 public List<CardView> getAllAttachedCards() {
67 return Objects.requireNonNullElse(get(TrackableProperty.AttachedCards), List.of());
68 }
69 public boolean hasAnyCardAttachments() {
70 return getAllAttachedCards().isEmpty();

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected