MonopolyFactory.java
package edu.chl.hajo.monopoly.core;
import edu.chl.hajo.monopoly.core.card.Card;
import edu.chl.hajo.monopoly.core.card.MoveCard;
import edu.chl.hajo.monopoly.core.card.PayCard;
import edu.chl.hajo.monopoly.core.space.Property;
import edu.chl.hajo.monopoly.core.space.Space;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
/**
* Factory to build a complete model
*
* This will build and initialize (put pieces on start space etc)
* Hard coded for now
*
* @author hajo
*
*/
public class MonopolyFactory {
public static IMonopoly getMonopoly() {
DicePair dicePair = new DicePair(new Dice(MonopolyOptions.getNFaces()),
new Dice(MonopolyOptions.getNFaces()));
List<Card> cards = Arrays.asList(new MoveCard("Move", "Move", 2),
new PayCard("Pay", "Pay", 200));
Deck deck = new Deck(cards);
List<Space> spaces = new ArrayList<>();
for (int i = 0; i < MonopolyOptions.getNSpaces(); i++) {
spaces.add(new Property(String.valueOf(i), 100));
}
List<Player> players = MonopolyOptions.getPlayers();
Board board = new Board(spaces);
for (Player p : players) {
p.setPosition(board.getStart());
}
Monopoly m = new Monopoly(players, board, dicePair, deck);
return m;
}
}