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

Method surveil

forge-game/src/main/java/forge/game/player/Player.java:1059–1105  ·  view source on GitHub ↗
(int num, SpellAbility cause, Map<AbilityKey, Object> params)

Source from the content-addressed store, hash-verified

1057 }
1058
1059 public void surveil(int num, SpellAbility cause, Map<AbilityKey, Object> params) {
1060 num += StaticAbilitySurveilNum.surveilNumMod(this);
1061
1062 final CardCollection topN = getTopXCardsFromLibrary(num);
1063
1064 if (!topN.isEmpty()) {
1065 final Pair<CardCollection, CardCollection> lists = getController().arrangeForSurveil(topN);
1066 final CardCollection toTop = lists.getLeft();
1067 final CardCollection toGrave = lists.getRight();
1068
1069 int numToGrave = 0;
1070 int numToTop = 0;
1071
1072 if (toGrave != null) {
1073 for (Card c : toGrave) {
1074 Card moved = getGame().getAction().moveToGraveyard(c, cause, params);
1075 moved.setSurveilled(true);
1076 numToGrave++;
1077 }
1078 if (cause.hasParam("RememberMoved")) {
1079 cause.getHostCard().addRemembered(toGrave);
1080 }
1081 }
1082
1083 if (toTop != null) {
1084 Collections.reverse(toTop); // the last card in list will become topmost in library, have to revert thus.
1085 for (Card c : toTop) {
1086 getGame().getAction().moveToLibrary(c, cause, params);
1087 numToTop++;
1088 }
1089 if (cause.hasParam("RememberKept")) {
1090 cause.getHostCard().addRemembered(toTop);
1091 }
1092 }
1093
1094 getGame().fireEvent(new GameEventSurveil(PlayerView.get(this), numToTop, numToGrave));
1095 }
1096
1097 final Map<AbilityKey, Object> runParams = AbilityKey.mapFromPlayer(this);
1098 runParams.put(AbilityKey.FirstTime, surveilThisTurn == 0);
1099 if (params != null) {
1100 runParams.putAll(params);
1101 }
1102 getGame().getTriggerHandler().runTrigger(TriggerType.Surveil, runParams, false);
1103
1104 surveilThisTurn++;
1105 }
1106
1107 public int getSurveilThisTurn() {
1108 return surveilThisTurn;

Callers 1

resolveMethod · 0.80

Calls 15

surveilNumModMethod · 0.95
getControllerMethod · 0.95
getGameMethod · 0.95
setSurveilledMethod · 0.95
getMethod · 0.95
mapFromPlayerMethod · 0.95
getLeftMethod · 0.80
getRightMethod · 0.80
moveToGraveyardMethod · 0.80
reverseMethod · 0.80
moveToLibraryMethod · 0.80

Tested by

no test coverage detected