@@ -114,6 +114,14 @@ public Map getMap() {
114114
115115 @ Override
116116 public List <Path > getPathsCrossingCell (Cell cell ) {
117+ if (cell == null ) return new ArrayList <>();
118+ return getPathsCrossingCell (cell .getRow (), cell .getCol ());
119+ }
120+
121+ @ Override
122+ public List <Path > getPathsCrossingCell (int row , int col ) {
123+ Cell cell = getCellByCoordination (row , col );
124+
117125 if (cell == null ) return new ArrayList <>();
118126 if (pathsCrossingCells .get (cell ) == null ) {
119127 List <Path > paths = new ArrayList <>();
@@ -125,51 +133,43 @@ public List<Path> getPathsCrossingCell(Cell cell) {
125133 return new ArrayList <>(pathsCrossingCells .get (cell ));
126134 }
127135
128- @ Override
129- public List <Path > getPathsCrossingCell (int row , int col ) {
130- Cell cell = getCellByCoordination (row , col );
131- if (cell == null ) return new ArrayList <>();
132- return getPathsCrossingCell (cell );
133- }
134-
135136 @ Override
136137 public List <Unit > getCellUnits (Cell cell ) {
137138 if (cell == null ) return new ArrayList <>();
138- return new ArrayList <> (cell .getUnits ());
139+ return getCellUnits (cell .getRow (), cell . getCol ());
139140 }
140141
141142 @ Override
142143 public List <Unit > getCellUnits (int row , int col ) {
143144 Cell cell = getCellByCoordination (row , col );
144145 if (cell == null ) return new ArrayList <>();
145- return getCellUnits (cell );
146+ return new ArrayList <> (cell . getUnits () );
146147 }
147148
148149 @ Override
149150 public Path getShortestPathToCell (int fromPlayerId , Cell cell ) {
150- Player player = getPlayerById (fromPlayerId );
151- if (player == null || cell == null ) return null ;
152- return player .getShortestPathsToCells ()[cell .getRow ()][cell .getCol ()];
151+ if (cell == null ) return null ;
152+ return getShortestPathToCell (fromPlayerId , cell .getRow (), cell .getCol ());
153153 }
154154
155155 @ Override
156156 public Path getShortestPathToCell (int fromPlayerId , int row , int col ) {
157157 Cell cell = getCellByCoordination (row , col );
158- if (cell == null ) return null ;
159- return getShortestPathToCell (fromPlayerId , cell );
158+ Player player = getPlayerById (fromPlayerId );
159+ if (cell == null || player == null ) return null ;
160+ return player .getShortestPathsToCells ()[cell .getRow ()][cell .getCol ()];
160161 }
161162
162163 @ Override
163164 public Path getShortestPathToCell (Player fromPlayer , Cell cell ) {
164165 if (fromPlayer == null || cell == null ) return null ;
165- return getShortestPathToCell (fromPlayer .getPlayerId (), cell );
166+ return getShortestPathToCell (fromPlayer .getPlayerId (), cell . getRow (), cell . getCol () );
166167 }
167168
168169 @ Override
169170 public Path getShortestPathToCell (Player fromPlayer , int row , int col ) {
170- Cell cell = getCellByCoordination (row , col );
171- if (fromPlayer == null || cell == null ) return null ;
172- return getShortestPathToCell (fromPlayer .getPlayerId (), cell );
171+ if (fromPlayer == null ) return null ;
172+ return getShortestPathToCell (fromPlayer .getPlayerId (), row , col );
173173 }
174174
175175 @ Override
@@ -295,6 +295,31 @@ public void castAreaSpell(Cell center, Spell spell) {
295295 @ Override
296296 public List <Unit > getAreaSpellTargets (Cell center , Spell spell ) {
297297 if (center == null || spell == null ) return new ArrayList <>();
298+ return getAreaSpellTargets (center .getRow (), center .getCol (), spell .getTypeId ());
299+ }
300+
301+ private boolean isInRange (Unit unit , int minRow , int maxRow , int minCol , int maxCol ) {
302+ return (minRow <= unit .getCell ().getRow () && unit .getCell ().getRow () <= maxRow ) &&
303+ (minCol <= unit .getCell ().getCol () && unit .getCell ().getCol () <= maxCol );
304+ }
305+
306+ @ Override
307+ public List <Unit > getAreaSpellTargets (Cell center , int spellId ) {
308+ if (center == null ) return new ArrayList <>();
309+ return new ArrayList <>(getAreaSpellTargets (center .getRow (), center .getCol (), spellId ));
310+ }
311+
312+ @ Override
313+ public List <Unit > getAreaSpellTargets (int row , int col , Spell spell ) {
314+ if (spell == null ) return new ArrayList <>();
315+ return new ArrayList <>(getAreaSpellTargets (row , col , spell .getTypeId ()));
316+ }
317+
318+ @ Override
319+ public List <Unit > getAreaSpellTargets (int row , int col , int spellId ) {
320+ Cell center = getCellByCoordination (row , col );
321+ if (center == null ) return new ArrayList <>();
322+ Spell spell = spellsByTypeId .get (spellId );
298323 List <Unit > units = new ArrayList <>();
299324 int minRow = Math .max (0 , center .getRow () - spell .getRange ());
300325 int maxRow = Math .min (initMessage .getMap ().getRowNum () - 1 , center .getRow () + spell .getRange ());
@@ -321,35 +346,6 @@ public List<Unit> getAreaSpellTargets(Cell center, Spell spell) {
321346 return units ;
322347 }
323348
324- private boolean isInRange (Unit unit , int minRow , int maxRow , int minCol , int maxCol ) {
325- return (minRow <= unit .getCell ().getRow () && unit .getCell ().getRow () <= maxRow ) &&
326- (minCol <= unit .getCell ().getCol () && unit .getCell ().getCol () <= maxCol );
327- }
328-
329- @ Override
330- public List <Unit > getAreaSpellTargets (Cell center , int spellId ) {
331- if (center == null ) return new ArrayList <>();
332- Spell spell = spellsByTypeId .get (spellId );
333- if (spell == null ) return new ArrayList <>();
334- return new ArrayList <>(getAreaSpellTargets (center , spell ));
335- }
336-
337- @ Override
338- public List <Unit > getAreaSpellTargets (int row , int col , Spell spell ) {
339- if (spell == null ) return new ArrayList <>();
340- Cell cell = getCellByCoordination (row , col );
341- if (cell == null ) return new ArrayList <>();
342- return new ArrayList <>(getAreaSpellTargets (cell , spell ));
343- }
344-
345- @ Override
346- public List <Unit > getAreaSpellTargets (int row , int col , int spellId ) {
347- Cell cell = getCellByCoordination (row , col );
348- if (cell == null ) return new ArrayList <>();
349- Spell spell = spellsByTypeId .get (spellId );
350- return new ArrayList <>(getAreaSpellTargets (cell , spell ));
351- }
352-
353349 @ Override
354350 public int getRemainingTurnsToUpgrade () {
355351 return clientInitMessage .getGameConstants ().getTurnsToUpgrade () -
0 commit comments