Permalink
Cannot retrieve contributors at this time
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?
2102-Group-Project-Spring-2017/src/model/GameBoard.java
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
58 lines (48 sloc)
1.49 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package model; | |
import java.util.LinkedList; | |
import java.util.Queue; | |
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 DealTile("Doodad", 1); | |
private static Tile t3 = new DealTile("Deal", 2); | |
private static Tile t4 = new DealTile("Charity", 3); | |
public GameBoard(Player... players) | |
{ | |
_profs = new Professions(); | |
_tiles = new TileCircularLinkedList(); | |
_tiles.addTiles(t1, t2, t3, t4); | |
t1.addPlayers(players); | |
} | |
// 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 | |
// arraylist 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")) | |
{ | |
passedPaydays++; | |
} | |
currentNode = nextNode; | |
} | |
currentNode.getData().addPlayers(p); | |
p.setLocation(currentNode.getData().getBoardIndex()); | |
currentNode.getData().getLandedOn(p); | |
return passedPaydays; | |
} | |
public Professions getProfessions() | |
{ | |
return _profs; | |
} | |
} |