package org.vostan.banvor.game;

import java.io.InputStream;

import static org.vostan.banvor.App.theApp;

import org.vostan.banvor.R;
import org.vostan.banvor.model.Puzzle;

public class PuzzleContainer implements IPuzzleSource
{
	protected int count;
	
	/*
	 * Load puzzle from the puzzle.bin.
	 */
	public Puzzle getPuzzle(int i )
	{
		InputStream is = theApp().getResources().openRawResource(R.raw.puzzles);
		return PuzzleBinLoader.loadNthPuzzle(is, i);
	}
	//
	//	Retrieve amount of puzzles.
	//
	public int getCount()
	{
		if ( count == 0 )
		{
			InputStream is = theApp().getResources().openRawResource(R.raw.puzzles);
			count = PuzzleBinLoader.getCount(is);
		}
		return count;
	}
}
