Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.ArrayList;
- /**
- * Created by kristianhjensen on 02/11/2015.
- */
- public class Player {
- //player name
- private String playerName;
- //player number
- public final int NUMBER;
- //Buildings
- //private Road[] road;
- //resources
- static int [] resources = new int[5];
- int resourceAmount;
- //Number of knights
- private int knights;
- //Number of points
- private int points;
- //How many development cards the players has
- private int[] devCard;
- //Checks whether the player has to discard resource cards or not
- static boolean hasToDiscard;
- //Has won
- private boolean hasWon;
- /**
- * Constructor for the player classes, this constructor contains all information needed to generate
- * a new player object for the game.
- * @param playerName This is the name a player will have displayed in-game.
- * @param playerNumber This is the number that represents the player in-game.
- */
- public Player (String playerName, int playerNumber){
- this.playerName = playerName;
- this.NUMBER = playerNumber;
- points = 0;
- int[] resources = new int[5];
- //road = 0;
- knights = 0;
- hasToDiscard = false;
- }
- public void setPlayerName(String name) {
- this.playerName = name;
- }
- /**
- * Collect the resources for a given player.
- * @param dieRoll The number that was rolled by the die
- */
- public void collectResources(int dieRoll) {
- for (int i = 0; i < GameData.buildings.size(); i++) {
- Hexagon[] nearbyHexagons = GameData.buildings.get(i).POSITION.getNearbyHexagons();
- for (int j = 0; j < nearbyHexagons.length; j++) {
- if (nearbyHexagons[j].NUMBER == dieRoll) {
- if ( GameData.buildings.get(i).isUpgraded()) {
- resources[nearbyHexagons[j].TYPE.toInt()]+=2;
- resourceAmount += 2;
- }
- resources[nearbyHexagons[j].TYPE.toInt()]++;
- resourceAmount++;
- }
- }
- }
- }
- /**
- * Method for checking whether the player needs to discard resourcecards
- */
- public static void setHasToDiscard(){
- if(GameData.rolledNumber == 7){
- for(int i = 0; i < GameData.players.size(); i++){
- if(GameData.players.get(i).resourceAmount > 7){
- hasToDiscard = true;
- } else {
- hasToDiscard = false;
- }
- if( hasToDiscard == true){
- //Main.showCards()
- }
- }
- }
- }
- public void discard(int[] indexOfResource) {
- for (int i = 0; i < indexOfResource.length; i++) {
- resources[indexOfResource[i]]--;
- resourceAmount--;
- }
- }
- public void addDevelopmentCard(CardType type) {
- devCard[type.toInt()]++;
- }
- public void PlayDevCard(CardType type){
- switch(type) {
- case KNIGHT:
- //Move Robber
- //Take 1 resourceCard
- break;
- case VICTORYPOINT:
- ++points;
- break;
- case YEAROFPLENTY:
- //show resource bank
- break;
- case ROADBUILD:
- //Build a road
- break;
- case MONOPOLY:
- //Select a resource which the other players must hand over.
- break;
- }
- }
- public void addResource(int[] indexOfResource) {
- for (int i = 0; i < indexOfResource.length; i++) {
- resources[indexOfResource[i]]++;
- resourceAmount++;
- }
- }
- public void stealResource(int[] stolenResource, Player playerBeingRobbed) {
- playerBeingRobbed.discard(stolenResource);
- addResource(stolenResource);
- }
- public static void main(String[] args) {
- Player player1 = new Player("Lord",2);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement