Player created
This commit is contained in:
		
							parent
							
								
									3adec5bd43
								
							
						
					
					
						commit
						aef0479cf5
					
				| 
						 | 
				
			
			@ -1,6 +1,6 @@
 | 
			
		|||
<?xml version="1.0" encoding="UTF-8"?>
 | 
			
		||||
<project version="4">
 | 
			
		||||
  <component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="openjdk-17" project-jdk-type="JavaSDK">
 | 
			
		||||
  <component name="ProjectRootManager" version="2" languageLevel="JDK_X" default="true" project-jdk-name="openjdk-17" project-jdk-type="JavaSDK">
 | 
			
		||||
    <output url="file://$PROJECT_DIR$/out" />
 | 
			
		||||
  </component>
 | 
			
		||||
</project>
 | 
			
		||||
| 
						 | 
				
			
			@ -1,6 +1,6 @@
 | 
			
		|||
package ch.zhaw.catan;
 | 
			
		||||
 | 
			
		||||
import java.util.ArrayList;
 | 
			
		||||
import java.util.HashMap;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * New Class PLayer
 | 
			
		||||
| 
						 | 
				
			
			@ -11,10 +11,51 @@ public class Player {
 | 
			
		|||
 | 
			
		||||
    private String name;
 | 
			
		||||
    private Config.Faction faction;
 | 
			
		||||
    private Config.Resource resource;
 | 
			
		||||
    private HashMap<Config.Resource,Integer> resources;
 | 
			
		||||
    private int roadsToUse;
 | 
			
		||||
    private int settlementsToUse;
 | 
			
		||||
 | 
			
		||||
    public Player (String name, Config.Faction faction){
 | 
			
		||||
        this.name = new name(" ");
 | 
			
		||||
        //Datenfelder
 | 
			
		||||
        this.name = name;
 | 
			
		||||
        this.faction = faction;
 | 
			
		||||
        roadsToUse = Config.Structure.ROAD.getStockPerPlayer();
 | 
			
		||||
        settlementsToUse = Config.Structure.SETTLEMENT.getStockPerPlayer();
 | 
			
		||||
        //Ressourcen initialisiern
 | 
			
		||||
        resources = new HashMap<>();
 | 
			
		||||
        for(Config.Resource resource : Config.Resource.values()) {
 | 
			
		||||
            resources.put(resource,0);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This method returns all the resources the player has at the moment
 | 
			
		||||
     * @return HashMap
 | 
			
		||||
     */
 | 
			
		||||
    public HashMap<Config.Resource,Integer> getResources() {
 | 
			
		||||
        return resources;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    public boolean buildRoad() {
 | 
			
		||||
        if (roadsToUse > 0) {
 | 
			
		||||
            roadsToUse--;
 | 
			
		||||
            return true;
 | 
			
		||||
        }
 | 
			
		||||
        return false;
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    public boolean buildSettlement() {
 | 
			
		||||
        if (settlementsToUse > 0) {
 | 
			
		||||
            settlementsToUse--;
 | 
			
		||||
            return true;
 | 
			
		||||
        }
 | 
			
		||||
        return false;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -16,5 +16,7 @@ public class Siedler {
 | 
			
		|||
        TextTerminal<?> textTerminal = textIO.getTextTerminal();
 | 
			
		||||
        textTerminal.println(game.getBoard().getTextView());
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -24,7 +24,9 @@ public class SiedlerGame {
 | 
			
		|||
  static final int FOUR_TO_ONE_TRADE_OFFER = 4;
 | 
			
		||||
  static final int FOUR_TO_ONE_TRADE_WANT = 1;
 | 
			
		||||
 | 
			
		||||
  SiedlerBoard board;
 | 
			
		||||
  private SiedlerBoard board;
 | 
			
		||||
  private Player[] allPlayers;
 | 
			
		||||
  private int winPoints;
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * Constructs a SiedlerGame game state object.
 | 
			
		||||
| 
						 | 
				
			
			@ -38,6 +40,8 @@ public class SiedlerGame {
 | 
			
		|||
  public SiedlerGame(int winPoints, int numberOfPlayers) {
 | 
			
		||||
    board = new SiedlerBoard();
 | 
			
		||||
    board.createFixGamefield();
 | 
			
		||||
    allPlayers = new Player[numberOfPlayers];
 | 
			
		||||
    this.winPoints = winPoints;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
| 
						 | 
				
			
			@ -69,6 +73,9 @@ public class SiedlerGame {
 | 
			
		|||
   */
 | 
			
		||||
  public List<Faction> getPlayerFactions() {
 | 
			
		||||
    // TODO: Implement
 | 
			
		||||
    Faction[] factions = new Faction[allPlayers.length];
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    return Collections.emptyList();
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue