Merge remote-tracking branch 'origin/main'

# Conflicts:
#	.idea/misc.xml
This commit is contained in:
Leonardo Brandenberger 2021-12-02 15:16:00 +01:00
commit e48371a121
4 changed files with 14 additions and 14 deletions

View File

@ -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>

View File

@ -1,5 +1,6 @@
package ch.zhaw.catan;
import java.util.List;
import java.util.Map;
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) {
if(resources.get(resource) >= numberOfResources) {
Integer newResourceNumber = resources.get(resource) - numberOfResources;

View File

@ -18,7 +18,6 @@ public class Dummy {
private void run() {
TextIO textIO = TextIoFactory.getTextIO();
TextTerminal<?> textTerminal = textIO.getTextTerminal();
SiedlerBoard board = new SiedlerBoard();
board.addField(new Point(2, 2), Land.FOREST);
board.setCorner(new Point(3, 3), new Settlement(Config.Faction.RED));

View File

@ -192,23 +192,25 @@ public class SiedlerGame {
* @return true, if the placement was successful
*/
public boolean buildSettlement(Point position) {
//1. Check if Edge
//1. Check if Corner
if (!board.hasCorner(position)) {
// TODO: Error message
return false;
}
//2. Check if Edge is empty
//2. Check if Corner is empty
if (board.getCorner(position) != null) {
// TODO: Error message
return false;
}
//3. Can Player build road
//3. Can Player build Settlement
if (!allPlayers.get(activePlayer).buildSettlement()) {
// TODO: Error message
return false;
}
//4. Insert Road to map
board.setCorner(position, new Settlement(allPlayers.get(activePlayer).getFaction()));
//5. Give Resoure to bank
bank.storeResourceToBank(Config.Structure.SETTLEMENT.getCosts());
return true;
}
@ -262,6 +264,8 @@ public class SiedlerGame {
}
//4. Insert Road to map
board.setEdge(roadStart, roadEnd, new Road(allPlayers.get(activePlayer).getFaction()));
//5. Give Resource to bank
bank.storeResourceToBank(Config.Structure.ROAD.getCosts());
return true;
}