package logic;
import java.util.ArrayList;
import exceptions.InvalidDiceSetException;
import fileIO.DiceSetReader;
import fileIO.DictReader;
import generator.BoggleField;
import generator.BoggleFieldGenerator;
import gui.Gui;
public class Game
{
DictReader myDict;
ArrayList myDiceSet;
BoggleFieldGenerator myGen;
Gui myGui;
BoggleField currentfield;
public Game()
{
try
{
myDict = new DictReader("dict.txt");
myGen = new BoggleFieldGenerator(DiceSetReader.readDiceSet("nl.txt"));
myGui = new Gui(this);
currentfield = myGen.generateField();
myGui.setField(currentfield);
}
catch (InvalidDiceSetException e)
{
System.out.println("Invalid Dice set");
}
}
public void validate(String txt)
{
System.out.println(txt + "veld" + currentfield.canContainWord(txt));
System.out.println(txt + "dict" + myDict.findWord(txt));
if(!currentfield.canContainWord(txt))
{
myGui.setStatus(txt + " cannot be formed !");
return;
}
if(!myDict.findWord(txt))
{
myGui.setStatus(txt + " can't be found in the dictionary.");
return;
}
else
{
myGui.setStatus(txt + " is correct !");
}
}
}