package pdp.scrabble.game.impl;
import pdp.scrabble.game.GameEngine;
import pdp.scrabble.game.GameEnvironment;
import pdp.scrabble.ihm.GameStatisticsModel;
import pdp.scrabble.ihm.GameStatisticsModelImpl;
public abstract class AbstractEngine implements GameEngine {
protected GameEnvironment gameEnv;
protected int globalTurn;
protected Thread gameThread;
protected boolean running;
protected GameStatisticsModel stats;
public AbstractEngine(GameEnvironment env) {
gameEnv = env;
globalTurn = 0;
gameThread = new GameThread(this);
stats = new GameStatisticsModelImpl();
}
@Override
public void setEnvironment(GameEnvironment env) {
this.gameEnv = env;
}
@Override
public GameStatisticsModel getStatsModel() {
return stats;
}
@Override
public abstract void increaseTurn();
@Override
public abstract int getPlayerTurn();
@Override
public int getGlobalTurn() {
return this.globalTurn;
}
@Override
public void terminate() {
this.running=false;
}
@Override
public void start() {
this.running=true;
gameThread.start();
}
@Override
public void reset() {
this.running=false;
this.gameEnv.reset();
this.stats.clear();
}
@Override
public abstract void play() ;
}