Coverage Summary for Class: Move (it.polimi.ingsw.Server.Controller)
Class |
Class, %
|
Method, %
|
Line, %
|
Move |
100%
(1/1)
|
100%
(5/5)
|
71,4%
(20/28)
|
| package it.polimi.ingsw.Server.Controller; |
| |
| import com.google.gson.annotations.Expose; |
| import it.polimi.ingsw.Server.Model.Board; |
| import it.polimi.ingsw.Server.Model.ObjectCard; |
| import it.polimi.ingsw.Server.Model.Shelf; |
| |
| import java.util.List; |
| |
| |
| |
| |
| public class Move { |
| @Expose |
| private int column; |
| @Expose |
| private List<ObjectCard> orderedCards = null; |
| @Expose |
| private List<Integer> x; |
| @Expose |
| private List<Integer> y; |
| @Expose(serialize = false, deserialize = false) |
| private Board board; |
| @Expose(serialize = false, deserialize = false) |
| private Shelf shelf; |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| public Move(int column, List<Integer> x, List<Integer> y, Board board, Shelf shelf) { |
| this.column = column; |
| this.x = x; |
| this.y = y; |
| this.board = board; |
| this.shelf = shelf; |
| this.orderedCards = null; |
| } |
| |
| |
| |
| |
| |
| |
| |
| public void setBoardAndShelf(Board board, Shelf shelf) { |
| this.board = board; |
| this.shelf = shelf; |
| } |
| |
| |
| |
| |
| |
| |
| public boolean take() { |
| try { |
| if (orderedCards != null) { |
| if (board.valid(orderedCards)) |
| board.takeFromBoard(orderedCards); |
| else return false; |
| } else { |
| if (board.validFromCoordinate(x, y)) |
| orderedCards = board.takeFromBoardFromCoordinate(x, y); |
| else return false; |
| } |
| return true; |
| } catch (Exception ignored) { |
| return false; |
| } |
| } |
| |
| |
| |
| |
| |
| |
| public void restoreTaken() throws Exception { |
| board.restoreLastTaken(); |
| } |
| |
| |
| |
| |
| |
| |
| public boolean place() { |
| try { |
| if (shelf.emptySpacesInColumn(column) >= orderedCards.size()) { |
| for (ObjectCard oc : orderedCards) |
| shelf.placeCard(oc, column); |
| return true; |
| } else return false; |
| } catch (Exception ignored) { |
| return false; |
| } |
| } |
| } |