(CardView view)
| 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); |
no test coverage detected