package de.siphalor.was.game;

import org.jetbrains.annotations.NotNull;

public class Storage {
	StorageSlot[][] slots;

	public Storage(int width, int height, int depth) {
		if (width <= 0 || height <= 0 || depth <= 0) {
			throw new IllegalArgumentException("Storage lengths must be bigger than zero");
		}
		slots = new StorageSlot[height][width];

		for (StorageSlot[] row : slots) {
			for (int i = 0; i < row.length; i++) {
				row[i] = new StorageSlot(depth);
			}
		}
	}

	@NotNull
	public StorageSlot get(int x, int y) {
		return slots[x][y];
	}

	public int getWidth() {
		return slots.length;
	}

	public int getHeight() {
		return slots[0].length;
	}

	public void clear() {
		for (StorageSlot[] row : slots) {
			for (StorageSlot slot : row) {
				slot.clear();
			}
		}
	}
}
