package city.home;

import java.util.ArrayList;
import java.util.List;

import city.Directory;
import city.PersonAgent;
import city.Place;
import agent.Role;

public class LandlordRole extends Role {
	
	// ------------------------------------ DATA -------------------------------------
	public enum MyApartmentState { VACANT, REQUESTED, ASKED_TENANT, READY_TO_LEASE, OCCUPIED }
	class MyApartment {
		Apartment apartment;
		ApartmentBuilding apartmentBuilding;
		
		ApartmentRenterRole tenant = null;
		double weeklyRate = 40; // hard-coded for now
		double owedAmount = 0;
		MyApartmentState state = MyApartmentState.VACANT;
		boolean justPaid = false;
	}
	List<MyApartment> _myApartments = new ArrayList<MyApartment>();
	
	public enum MyHouseState { VACANT, REQUESTED, ASKED_OWNER, CHECK_OWED_AMOUNT, OWNED }
	class MyHouse
	{
		House house;
		HouseOwnerRole owner = null;
		double price = 400;
		double owedAmount = 0;
		MyHouseState state = MyHouseState.VACANT;
	}
	List<MyHouse> _myHouses;
	
	// ------------------------------ CONSTRUCTOR & PROPERTIES ---------------------------
	public LandlordRole(PersonAgent person)
	{
		super(person);
		
		// Populate the _myApartments list
		List<ApartmentBuilding> apartmentBuildings = Directory.apartmentBuildings();
		for(ApartmentBuilding b : apartmentBuildings)
		{
			List<Apartment> apartments = b.apartments();
			for(Apartment a : apartments)
			{
				MyApartment m = new MyApartment();
				m.apartment = a;
				m.apartmentBuilding = b;
				_myApartments.add(m);
			}
		}
		
		// Populate the _myHouses list
		List<House> houses = Directory.houses();
		for(House h : houses)
		{
			MyHouse m = new MyHouse();
			m.house = h;
			_myHouses.add(m);
		}
	}
	@Override
	public Place place() { return null; }
	
	
	
	// ------------------------------------ COMMANDS ------------------------------------
	@Override
	public void cmdFinishAndLeave() { } // do nothing
	
	// ------------------------------------- MESSAGES ---------------------------------
	public void msgIWouldLikeToStartRenting(ApartmentRenterRole sender, ApartmentBuilding a)
	{
		for(MyApartment m : _myApartments)
		MyApartment m = myApartments.findByBuilding(a);
		if(m.state is VACANT)
		{
			m.state = REQUESTED;
			m.tenant = sender;
		}
		stateChanged();
	}
	public void msgIAcceptRate(ApartmentRenter sender)
	{
		m.state = READY_TO_LEASE;
		stateChanged();
	}
	


	// ------------------------------------ SCHEDULER --------------------------------
	@Override
	public boolean pickAndExecuteAnAction() {
		// TODO Auto-generated method stub
		return false;
	}

}

@@ -2123,16 +2123,33 @@
 tments)%0A
+%09%09%7B%0A%09%09%09%0A%09%09%7D%0A%09%09%0A//
 %09%09MyApar
@@ -2190,16 +2190,18 @@
 ing(a);%0A
+//
 %09%09if(m.s
@@ -2216,20 +2216,24 @@
 VACANT)%0A
+//
 %09%09%7B%0A
+//
 %09%09%09m.sta
@@ -2248,16 +2248,18 @@
 UESTED;%0A
+//
 %09%09%09m.ten
@@ -2272,20 +2272,24 @@
 sender;%0A
+//
 %09%09%7D%0A
+//
 %09%09stateC
@@ -2344,16 +2344,20 @@
 ntRenter
+Role
  sender)
@@ -2360,16 +2360,18 @@
 der)%0A%09%7B%0A
+//
 %09%09m.stat
@@ -2390,16 +2390,18 @@
 _LEASE;%0A
+//
 %09%09stateC

remove pseudocode compile error section