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

Method findByView

forge-game/src/main/java/forge/game/Game.java:706–731  ·  view source on GitHub ↗
(CardView view)

Source from the content-addressed store, hash-verified

704 }
705
706 public Card findByView(CardView view) {
707 if (view == null) {
708 return null;
709 }
710 CardIdVisitor visit = new CardIdVisitor(view.getId());
711 if (ZoneType.Stack.equals(view.getZone())) {
712 visit.visitAll(getStackZone());
713 } else if (view.getController() != null && view.getZone() != null) {
714 Player p = getPlayer(view.getController());
715 if (p != null) {
716 visit.visitAll(p.getZone(view.getZone()));
717 }
718 }
719 // Zone-specific search may miss if the view has stale zone info
720 // (e.g. IdRef resolved from a tracker that wasn't updated after a
721 // zone change). Fall back to global search.
722 if (visit.getFound() == null) {
723 forEachCardInGame(visit);
724 }
725 Card found = visit.getFound();
726 if (found == null) {
727 netLog.error("findByView: id={} (zone={}, controller={}) not found in any zone — returning null",
728 view.getId(), view.getZone(), view.getController());
729 }
730 return found;
731 }
732
733 public Card findById(int id) {
734 CardIdVisitor visit = new CardIdVisitor(id);

Callers 2

getCardMethod · 0.80
revealMethod · 0.80

Calls 11

getStackZoneMethod · 0.95
getPlayerMethod · 0.95
getZoneMethod · 0.95
getFoundMethod · 0.95
forEachCardInGameMethod · 0.95
visitAllMethod · 0.80
getIdMethod · 0.65
equalsMethod · 0.45
getZoneMethod · 0.45
getControllerMethod · 0.45
errorMethod · 0.45

Tested by

no test coverage detected