Skip to content
Permalink
4795507841
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
87 lines (73 sloc) 3 KB
package model;
import java.util.ArrayList;
import java.util.Arrays;
import model.TileCircularLinkedList.Node;
public class GameBoard
{
private Professions _profs;
private TileCircularLinkedList _tiles;
private static Tile t1 = new DealTile("Deal Tile", 0);
private static Tile t2 = new MarketTile("Market Tile", 1);
private static Tile t3 = new DealTile("Deal Tile", 2);
private static Tile t4 = new PaydayTile("Payday Tile", 3);
private static Tile t5 = new DealTile("Deal Tile", 4);
private static Tile t6 = new DownsizeTile("Downsize", 5);
private static Tile t7 = new DealTile("Deal Tile", 6);
private static Tile t8 = new DoodadTile("Doodad Tile", 7);
private static Tile t9 = new DealTile("Deal Tile", 8);
private static Tile t10 = new MarketTile("Market Tile", 9);
private static Tile t11 = new DealTile("Deal Tile", 10);
private static Tile t12 = new PaydayTile("Payday Tile", 11);
private static Tile t13 = new DealTile("Deal Tile", 12);
private static Tile t14 = new CharityTile("Charity Tile", 13);
private static Tile t15 = new DealTile("Deal Tile", 14);
private static Tile t16 = new DoodadTile("Doodad Tile", 15);
private static Tile t17 = new DealTile("Deal Tile", 16);
private static Tile t18 = new MarketTile("Market Tile", 17);
private static Tile t19 = new DealTile("Deal Tile", 18);
private static Tile t20 = new PaydayTile("Payday Tile", 19);
private static Tile t21 = new DealTile("Deal Tile", 20);
private static Tile t22 = new ChildTile("Child Tile", 21);
private static Tile t23 = new DealTile("Deal Tile", 22);
private static Tile t24 = new DoodadTile("Doodad Tile", 23);
public GameBoard(Player... players)
{
_profs = new Professions();
_tiles = new TileCircularLinkedList();
_tiles.addTiles(t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16,t17,t18,t19,t20,t21,t22,t23,t24);
t1.addPlayers(players);
}
public Tile getTile(int index) {
return _tiles.get(index).getData();
}
// TODO This method will move the player and returns the number of pay days they passed along the way.
// It also removes the player from the _players ArrayList of their initial tile and adds them to the
// array list of the tile they land on.
public int movePlayer(Player p, int distance)
{
int currentLocation = p.getLocation();
Node currentNode = _tiles.get(currentLocation);
Tile currentTile = _tiles.elementAt(currentLocation);
currentTile.removePlayer(p);
int passedPaydays = 0;
for(int i=0; i<distance; i++)
{
Node nextNode = currentNode.getNext();
if(nextNode.getData().getName().equals("Payday Tile"))
{
passedPaydays++;
}
// TODO update player location on board each iteration and maybe add delay
System.out.println("Player is at tile number: " + currentNode.getData().getBoardIndex());
currentNode = nextNode;
}
currentNode.getData().addPlayers(p);
p.setLocation(currentNode.getData().getBoardIndex());
currentNode.getData().getLandedOn(p);
return passedPaydays;
}
public Professions getProfessions()
{
return _profs;
}
}