From b25cee830238c64c08a2e3733bbed0730d20a734 Mon Sep 17 00:00:00 2001 From: Timothée Floure Date: Tue, 1 Mar 2016 16:26:40 +0100 Subject: Add the blocksAt() and blockAt() methods to the Board class --- src/ch/epfl/xblast/server/Board.java | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'src') diff --git a/src/ch/epfl/xblast/server/Board.java b/src/ch/epfl/xblast/server/Board.java index 5e899f6..2cbf380 100644 --- a/src/ch/epfl/xblast/server/Board.java +++ b/src/ch/epfl/xblast/server/Board.java @@ -2,6 +2,7 @@ package ch.epfl.xblast.server; import ch.epfl.cs108.Sq; import ch.epfl.xblast.Lists; +import ch.epfl.xblast.Cell; import java.util.ArrayList; import java.util.List; @@ -123,4 +124,23 @@ public final class Board { return ofInnerBlocksWalled(rowsList); } + /** + * Return the sequence of blocks related to the given cell. + * + * @param c cell + * @return the sequence of blocks related to the given cell. + */ + public Sq blocksAt(Cell c) { + return blocks.get(c.rowMajorIndex()); + } + + /** + * Returns the block related to the given cell. + * + * @param c cell + * @return the first block of the sequence related to the given cell + */ + public Block blockAt(Cell c) { + return blocksAt(c).head(); + } } -- cgit v1.2.3