package com.philihp.weblabora.model.building;

import static com.philihp.weblabora.model.TerrainTypeEnum.COAST;
import static com.philihp.weblabora.model.TerrainTypeEnum.MOUNTAIN;
import static com.philihp.weblabora.model.TerrainTypeEnum.HILLSIDE;
import static com.philihp.weblabora.model.TerrainTypeEnum.PLAINS;

import java.util.EnumSet;
import java.util.Set;

import com.philihp.weblabora.model.Board;
import com.philihp.weblabora.model.BuildCost;
import com.philihp.weblabora.model.Coordinate;
import com.philihp.weblabora.model.Landscape;
import com.philihp.weblabora.model.Player;
import com.philihp.weblabora.model.TerrainTypeEnum;
import com.philihp.weblabora.model.UsageParam;
import com.philihp.weblabora.model.WeblaboraException;
import com.philihp.weblabora.model.Wheel;

public class Estate extends Building {

	public Estate() {
		super("G39", "D", 4, "Estate", BuildCost.is().wood(2).stone(2), 6, 5,
				EnumSet.of(PLAINS, HILLSIDE, COAST), false);
	}

	@Override
	public void use(Board board, UsageParam input) throws WeblaboraException {
		Player player = board.getPlayer(board.getActivePlayer());
		
		player.subtractAll(input);
		int energy = (int)input.getEnergy();
		int food = (int)input.getFood();
		
		int iterations = 0;
		while(iterations++ < 2) {
			if(energy >= 6) energy -= 6;
			else if(food >= 0) food -= 10;
			else break;
			player.addBooks(1);
			player.addOrnament(1);
		}
	}
}

@@ -1139,20 +1139,18 @@
 er());%0D%0A
-%09%09
 %0D%0A
+
 %09%09player
@@ -1173,19 +1173,22 @@
 ut);%0D%0A%09%09
-int
+double
  energy 
@@ -1189,21 +1189,16 @@
 nergy = 
-(int)
 input.ge
@@ -1227,16 +1227,17 @@
  = (int)
+ 
 input.ge
@@ -1250,14 +1250,17 @@
 );%0D%0A
-%09%09
 %0D%0A%09%09
+for (
 int 
@@ -1278,18 +1278,9 @@
 = 0;
-%0D%0A%09%09while(
+ 
 iter
@@ -1289,14 +1289,26 @@
 ions
-++
  %3C 2
+; iterations++
 ) %7B%0D
@@ -1313,16 +1313,17 @@
 %7B%0D%0A%09%09%09if
+ 
 (energy 
@@ -1327,17 +1327,22 @@
 gy %3E= 6)
- 
+%0D%0A%09%09%09%09
 energy -
@@ -1357,16 +1357,17 @@
 %09else if
+ 
 (food %3E=
@@ -1369,17 +1369,22 @@
 od %3E= 0)
- 
+%0D%0A%09%09%09%09
 food -= 
@@ -1395,17 +1395,22 @@
 %0A%09%09%09else
- 
+%0D%0A%09%09%09%09
 break;%0D%0A

fix #034, it was rounding energy when it shouldn't have been.