01: package net.innig.macker.example.modularity.game.impl;
02:
03: import net.innig.macker.example.modularity.game.*;
04: import net.innig.macker.example.modularity.player.*;
05: import java.util.*;
06:
07: public abstract class AbstractGame implements Game {
08: public AbstractGame() {
09: player = new Player[2];
10: score = new int[2];
11: prevMove = new Move[2];
12: }
13:
14: public void setPlayer(int playerNum, Player player) {
15: this .player[playerNum] = player;
16: }
17:
18: public Player getPlayer(int playerNum) {
19: return player[playerNum];
20: }
21:
22: public int getScore(int playerNum) {
23: return score[playerNum];
24: }
25:
26: public Move getPreviousMove(int playerNum) {
27: return prevMove[playerNum];
28: }
29:
30: public void move() {
31: Move move0 = player[0].nextMove(getLegalMoves(), prevMove[1]);
32: Move move1 = player[1].nextMove(getLegalMoves(), prevMove[0]);
33: prevMove[0] = move0;
34: prevMove[1] = move1;
35: score[0] += move0.getScoreFor(move1);
36: score[1] += move1.getScoreFor(move0);
37: }
38:
39: private Player[] player;
40: private int[] score;
41: private Move[] prevMove;
42: }
|