Update MapPanel.java

- sysouts
This commit is contained in:
Dennis Weinberger 2019-03-26 20:37:56 +00:00
parent 2a54eab4fc
commit 1319536671

View file

@ -170,30 +170,23 @@ public class MapPanel extends JScrollPane {
if(scared.getOwner() == game.getCurrentPlayer()) { if(scared.getOwner() == game.getCurrentPlayer()) {
return; return;
} }
System.out.println("Ausgewählt: " + scared.getName());
List<Edge<Castle>> castleEdges = map.getEdges(); List<Edge<Castle>> castleEdges = map.getEdges();
List<Castle> adjacentCastles = new ArrayList<>(); List<Castle> adjacentCastles = new ArrayList<>();
for(Edge<Castle> edge : castleEdges) { for(Edge<Castle> edge : castleEdges) {
if(edge.getNodeA().getValue().equals(scared)) { if(edge.getNodeA().getValue().equals(scared)) {
if(edge.getNodeB().getValue().getOwner() != game.getCurrentPlayer() && !edge.getNodeB().getValue().equals(scared)) { if(edge.getNodeB().getValue().getOwner() != game.getCurrentPlayer() && !edge.getNodeB().getValue().equals(scared)) {
adjacentCastles.add(edge.getNodeB().getValue()); adjacentCastles.add(edge.getNodeB().getValue());
System.out.print("added: " + edge.getNodeB().getValue().getName());
} }
} else if(edge.getNodeB().getValue().equals(scared)) { } else if(edge.getNodeB().getValue().equals(scared)) {
if(edge.getNodeA().getValue().getOwner() != game.getCurrentPlayer() && !edge.getNodeA().getValue().equals(scared)) { if(edge.getNodeA().getValue().getOwner() != game.getCurrentPlayer() && !edge.getNodeA().getValue().equals(scared)) {
adjacentCastles.add(edge.getNodeA().getValue()); adjacentCastles.add(edge.getNodeA().getValue());
System.out.print("added: " + edge.getNodeA().getValue().getName());
} }
} }
} }
int troopsToDistribute = scared.getTroopCount() - 1; int troopsToDistribute = scared.getTroopCount() - 1;
System.out.println(troopsToDistribute);
scared.removeTroops(troopsToDistribute); scared.removeTroops(troopsToDistribute);
System.out.println(adjacentCastles.size());
for(Castle c : adjacentCastles) {
System.out.print(c.getName() + " ");
}
if(adjacentCastles.isEmpty()) { if(adjacentCastles.isEmpty()) {
gameView.revalidate(); gameView.revalidate();
@ -206,7 +199,6 @@ public class MapPanel extends JScrollPane {
Random random = new Random(); Random random = new Random();
for(int i = 0; i < troopsToDistribute; i++) { for(int i = 0; i < troopsToDistribute; i++) {
int castleNumber = random.nextInt(adjacentCastles.size()); int castleNumber = random.nextInt(adjacentCastles.size());
System.out.print(castleNumber + " ");
adjacentCastles.get(castleNumber).addTroops(1); adjacentCastles.get(castleNumber).addTroops(1);
} }