Merge remote-tracking branch 'origin/main'
# Conflicts: # .idea/misc.xml
This commit is contained in:
		
						commit
						e48371a121
					
				| 
						 | 
					@ -1,10 +0,0 @@
 | 
				
			||||||
<?xml version="1.0" encoding="UTF-8"?>
 | 
					 | 
				
			||||||
<project version="4">
 | 
					 | 
				
			||||||
  <component name="RunConfigurationProducerService">
 | 
					 | 
				
			||||||
    <option name="ignoredProducers">
 | 
					 | 
				
			||||||
      <set>
 | 
					 | 
				
			||||||
        <option value="com.android.tools.idea.compose.preview.runconfiguration.ComposePreviewRunConfigurationProducer" />
 | 
					 | 
				
			||||||
      </set>
 | 
					 | 
				
			||||||
    </option>
 | 
					 | 
				
			||||||
  </component>
 | 
					 | 
				
			||||||
</project>
 | 
					 | 
				
			||||||
| 
						 | 
					@ -1,5 +1,6 @@
 | 
				
			||||||
package ch.zhaw.catan;
 | 
					package ch.zhaw.catan;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.util.List;
 | 
				
			||||||
import java.util.Map;
 | 
					import java.util.Map;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public class Bank {
 | 
					public class Bank {
 | 
				
			||||||
| 
						 | 
					@ -10,6 +11,12 @@ public class Bank {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public void storeResourceToBank(List<Config.Resource> resourceToGive) {
 | 
				
			||||||
 | 
					        for (Config.Resource resource : resourceToGive) {
 | 
				
			||||||
 | 
					            resources.put(resource,resources.get(resource)+1);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public boolean getResourceFromBank(Config.Resource resource,int numberOfResources) {
 | 
					    public boolean getResourceFromBank(Config.Resource resource,int numberOfResources) {
 | 
				
			||||||
        if(resources.get(resource) >= numberOfResources) {
 | 
					        if(resources.get(resource) >= numberOfResources) {
 | 
				
			||||||
            Integer newResourceNumber = resources.get(resource) - numberOfResources;
 | 
					            Integer newResourceNumber = resources.get(resource) - numberOfResources;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -18,7 +18,6 @@ public class Dummy {
 | 
				
			||||||
  private void run() {
 | 
					  private void run() {
 | 
				
			||||||
    TextIO textIO = TextIoFactory.getTextIO();
 | 
					    TextIO textIO = TextIoFactory.getTextIO();
 | 
				
			||||||
    TextTerminal<?> textTerminal = textIO.getTextTerminal();
 | 
					    TextTerminal<?> textTerminal = textIO.getTextTerminal();
 | 
				
			||||||
 | 
					 | 
				
			||||||
    SiedlerBoard board = new SiedlerBoard();
 | 
					    SiedlerBoard board = new SiedlerBoard();
 | 
				
			||||||
    board.addField(new Point(2, 2), Land.FOREST);
 | 
					    board.addField(new Point(2, 2), Land.FOREST);
 | 
				
			||||||
    board.setCorner(new Point(3, 3), new Settlement(Config.Faction.RED));
 | 
					    board.setCorner(new Point(3, 3), new Settlement(Config.Faction.RED));
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -192,23 +192,25 @@ public class SiedlerGame {
 | 
				
			||||||
     * @return true, if the placement was successful
 | 
					     * @return true, if the placement was successful
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public boolean buildSettlement(Point position) {
 | 
					    public boolean buildSettlement(Point position) {
 | 
				
			||||||
        //1. Check if Edge
 | 
					        //1. Check if Corner
 | 
				
			||||||
        if (!board.hasCorner(position)) {
 | 
					        if (!board.hasCorner(position)) {
 | 
				
			||||||
            // TODO: Error message
 | 
					            // TODO: Error message
 | 
				
			||||||
            return false;
 | 
					            return false;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        //2. Check if Edge is empty
 | 
					        //2. Check if Corner is empty
 | 
				
			||||||
        if (board.getCorner(position) != null) {
 | 
					        if (board.getCorner(position) != null) {
 | 
				
			||||||
            // TODO: Error message
 | 
					            // TODO: Error message
 | 
				
			||||||
            return false;
 | 
					            return false;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        //3. Can Player build road
 | 
					        //3. Can Player build Settlement
 | 
				
			||||||
        if (!allPlayers.get(activePlayer).buildSettlement()) {
 | 
					        if (!allPlayers.get(activePlayer).buildSettlement()) {
 | 
				
			||||||
            // TODO: Error message
 | 
					            // TODO: Error message
 | 
				
			||||||
            return false;
 | 
					            return false;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        //4. Insert Road to map
 | 
					        //4. Insert Road to map
 | 
				
			||||||
        board.setCorner(position, new Settlement(allPlayers.get(activePlayer).getFaction()));
 | 
					        board.setCorner(position, new Settlement(allPlayers.get(activePlayer).getFaction()));
 | 
				
			||||||
 | 
					        //5. Give Resoure to bank
 | 
				
			||||||
 | 
					        bank.storeResourceToBank(Config.Structure.SETTLEMENT.getCosts());
 | 
				
			||||||
        return true;
 | 
					        return true;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -262,6 +264,8 @@ public class SiedlerGame {
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        //4. Insert Road to map
 | 
					        //4. Insert Road to map
 | 
				
			||||||
        board.setEdge(roadStart, roadEnd, new Road(allPlayers.get(activePlayer).getFaction()));
 | 
					        board.setEdge(roadStart, roadEnd, new Road(allPlayers.get(activePlayer).getFaction()));
 | 
				
			||||||
 | 
					        //5. Give Resource to bank
 | 
				
			||||||
 | 
					        bank.storeResourceToBank(Config.Structure.ROAD.getCosts());
 | 
				
			||||||
        return true;
 | 
					        return true;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue