Skip to content

Stat gui #4

Merged
merged 3 commits into from
Apr 22, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 30 additions & 1 deletion src/TowerFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,20 +58,49 @@ public void createNexus(){
}

public void createBasicTower(int x, int y, TowerTypes type){
System.out.println("x is: "+ x + " , y is: "+ y);
//Checks if there's already a tower here
//TODO make this better
if (!_map.getStatGui().spendMoney(cost)) {
if (!_map.getStatGui().canAfford(type.getBuycost())) { //check to see if player can afford
return;
}
if (quantity < _max) {
int i = 0;
//prevents tower from being placed on existing towers or on path
while (i < quantity) {
if ((towerarray[i].getTowerXlocation() == x) && (towerarray[i].getTowerYlocation() == y)) {
System.out.println("CONSEQUENCES WILL NEVER BE THE SAME"); //informal logging
return;
}
i++;
}

//first segment
if (((x >= 1) &&(x <= 16)) &&(y == 3)) {
System.out.println("NO TOWER ON PATH");
return;
}
//second segment
if (((y >= 3) &&(y <= 9)) &&(x == 16)) {
System.out.println("NO TOWER ON PATH");
return;
}
//third segment
if (((x >= 4) &&(x <= 16)) &&(y == 9)) {
System.out.println("NO TOWER ON PATH");
return;
}
//fourth segment
if (((y >= 9) &&(y <= 15)) &&(x == 4)) {
System.out.println("NO TOWER ON PATH");
return;
}
//fifth segment
if (((x >= 4) &&(x <= 18)) &&(y == 15)) {
System.out.println("NO TOWER ON PATH");
return;
}
_map.getStatGui().spendMoney(type.getBuycost()); //actually spend money, prevent double spending
towerarray[quantity] = new TowerMock(quantity, x, y, true, type, _map);
quantity++;
}
Expand Down