Housing: Home - ellenvoegtli/simcity GitHub Wiki
###Data
OccupantAgent occupant;
OwnerAgent owner;
String cookingMeal;
Map<String, Integer> FoodSupply;
enum houseState {checkingSupplies, reStocked, cooking, done};
List <Appliance> Appliances;
List <Appliance> AApliances;
List<String> needFood;
class Appliance{String appliance, boolean working, int posX, int posY};
###Actions
public void CheckAppliances()
{
for (Appliance appl : Appliances)
{
if(appl.isWorking() == false)
{
synchronized(occupant.needsWork)
{occupant.needsWork.add(appl.appliance);}
}
}
}
public void applianceBroke()
{
System.out.println("house set appliance to broken");
String appln = "sink";
switch((int) (Math.random() * 4)) {
case 0:
appln = "TV";
break;
case 1:
appln = "sink";
break;
case 2:
appln = "fridge";
break;
case 3:
appln = "stove";
break;
}
for(Appliance a : Appliances )
{
if(a.appliance.equals(appln))
a.setWorking(false);
}
}
checkSupplies(String meal)
{
if(needFood.getSize() == 0)
{
needFd.add(meal);
occupant.msgNeedFd(needFd);
}
else{
occupant.msgCookFood(meal);
if(FoodSupply.containsKey(meal))
{
int amt = FoodSupply.get(meal);
FoodSupply.put(meal, amt-1);
}
}
public void GroceryListDone()
{
if(needFood.size() != 0)
{
for(String f : needFood)
{
FoodSupply.put(f, 1);
needFood.remove(f);
}
}
}