Advertisement
Guest User

Untitled

a guest
Nov 25th, 2015
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.41 KB | None | 0 0
  1. import java.util.ArrayList;
  2.  
  3. /**
  4. * Created by kristianhjensen on 02/11/2015.
  5. */
  6. public class Player {
  7. //player name
  8. private String playerName;
  9.  
  10. //player number
  11. public final int NUMBER;
  12.  
  13. //Buildings
  14. //private Road[] road;
  15.  
  16. //resources
  17. static int [] resources = new int[5];
  18.  
  19. int resourceAmount;
  20.  
  21. //Number of knights
  22. private int knights;
  23.  
  24. //Number of points
  25. private int points;
  26.  
  27. //How many development cards the players has
  28. private int[] devCard;
  29.  
  30. //Checks whether the player has to discard resource cards or not
  31. static boolean hasToDiscard;
  32.  
  33. //Has won
  34. private boolean hasWon;
  35.  
  36.  
  37.  
  38.  
  39.  
  40. /**
  41. * Constructor for the player classes, this constructor contains all information needed to generate
  42. * a new player object for the game.
  43. * @param playerName This is the name a player will have displayed in-game.
  44. * @param playerNumber This is the number that represents the player in-game.
  45. */
  46.  
  47. public Player (String playerName, int playerNumber){
  48. this.playerName = playerName;
  49. this.NUMBER = playerNumber;
  50. points = 0;
  51. int[] resources = new int[5];
  52. //road = 0;
  53. knights = 0;
  54. hasToDiscard = false;
  55.  
  56. }
  57.  
  58. public void setPlayerName(String name) {
  59. this.playerName = name;
  60. }
  61.  
  62. /**
  63. * Collect the resources for a given player.
  64. * @param dieRoll The number that was rolled by the die
  65. */
  66. public void collectResources(int dieRoll) {
  67. for (int i = 0; i < GameData.buildings.size(); i++) {
  68. Hexagon[] nearbyHexagons = GameData.buildings.get(i).POSITION.getNearbyHexagons();
  69. for (int j = 0; j < nearbyHexagons.length; j++) {
  70. if (nearbyHexagons[j].NUMBER == dieRoll) {
  71. if ( GameData.buildings.get(i).isUpgraded()) {
  72. resources[nearbyHexagons[j].TYPE.toInt()]+=2;
  73. resourceAmount += 2;
  74. }
  75. resources[nearbyHexagons[j].TYPE.toInt()]++;
  76. resourceAmount++;
  77. }
  78. }
  79. }
  80. }
  81.  
  82.  
  83.  
  84.  
  85. /**
  86. * Method for checking whether the player needs to discard resourcecards
  87. */
  88. public static void setHasToDiscard(){
  89. if(GameData.rolledNumber == 7){
  90. for(int i = 0; i < GameData.players.size(); i++){
  91. if(GameData.players.get(i).resourceAmount > 7){
  92. hasToDiscard = true;
  93. } else {
  94. hasToDiscard = false;
  95. }
  96. if( hasToDiscard == true){
  97. //Main.showCards()
  98. }
  99. }
  100.  
  101. }
  102.  
  103. }
  104.  
  105. public void discard(int[] indexOfResource) {
  106. for (int i = 0; i < indexOfResource.length; i++) {
  107. resources[indexOfResource[i]]--;
  108. resourceAmount--;
  109. }
  110. }
  111.  
  112.  
  113. public void addDevelopmentCard(CardType type) {
  114. devCard[type.toInt()]++;
  115. }
  116.  
  117. public void PlayDevCard(CardType type){
  118. switch(type) {
  119. case KNIGHT:
  120. //Move Robber
  121. //Take 1 resourceCard
  122. break;
  123. case VICTORYPOINT:
  124. ++points;
  125. break;
  126. case YEAROFPLENTY:
  127. //show resource bank
  128. break;
  129. case ROADBUILD:
  130. //Build a road
  131. break;
  132. case MONOPOLY:
  133. //Select a resource which the other players must hand over.
  134.  
  135.  
  136.  
  137. break;
  138. }
  139. }
  140.  
  141. public void addResource(int[] indexOfResource) {
  142. for (int i = 0; i < indexOfResource.length; i++) {
  143. resources[indexOfResource[i]]++;
  144. resourceAmount++;
  145. }
  146. }
  147.  
  148. public void stealResource(int[] stolenResource, Player playerBeingRobbed) {
  149.  
  150. playerBeingRobbed.discard(stolenResource);
  151.  
  152. addResource(stolenResource);
  153.  
  154. }
  155.  
  156. public static void main(String[] args) {
  157. Player player1 = new Player("Lord",2);
  158.  
  159.  
  160.  
  161. }
  162.  
  163.  
  164. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement