package com.bernard.greposimu.model.simulator;

import java.util.List;
import java.util.Map;
import java.util.Set;

import com.bernard.greposimu.model.game.Building;
import com.bernard.greposimu.model.game.God;
import com.bernard.greposimu.model.game.Resources;
import com.bernard.greposimu.model.game.powers.Power;
import com.bernard.greposimu.model.game.queues.BuildingQueueItem;
import com.bernard.greposimu.model.game.queues.RecruitmentQueueItem;
import com.bernard.greposimu.model.game.queues.ResearchQueueItem;
import com.bernard.greposimu.model.game.researches.Research;
import com.bernard.greposimu.model.runtime.Timestamp;

public class Ville {
	
	int id;
	String nom;
	
	Map<Building,Integer> batiments;
	
	Troupes troupes;
	
	// origin town id -> troupes
	Map<Integer,Troupes> soutiens;
	
	// Destination town -> troupes
	Map<Integer,Troupes> soutenus;
	
	// sortilegeId -> effectEnd
	Map<Power,Timestamp> sortileges;
	
	// Agora
	Timestamp festivalEnd,olympiquesEnd,marchEnd,theaterEnd;
	
	// Academie
	Set<Research> researches;
	List<ResearchQueueItem> researchQueue;
	
	// Senat
	List<BuildingQueueItem> buildingQueue;
	
	// Farm
	// End time of militia
	Timestamp miliceUntil;
	
	// Entrepôt
	Resources storage;
	
	// Caserne
	List<RecruitmentQueueItem> terrestrialQueue;
	
	// Temple
	God god;
	
	// Port
	List<RecruitmentQueueItem> navalQueue;
	
	// Grotte
	int piecesStoquees;
	
	/* Ordres */
	Set<UnitOrder> ordresMilitaires;
	Set<TradeOrder> incomingTrade;
	Set<TradeOrder> outgoingTrade;
	
	
	public Ville(int id, String nom, Map<Building, Integer> batiments, Troupes troupes, Map<Integer, Troupes> soutiens,
			Map<Integer, Troupes> soutenus, Map<Power, Timestamp> sortileges, Timestamp festivalEnd,
			Timestamp olympiquesEnd, Timestamp marchEnd, Timestamp theaterEnd, Set<Research> researches,
			List<ResearchQueueItem> researchQueue, List<BuildingQueueItem> buildingQueue, Timestamp miliceUntil,
			Resources storage, List<RecruitmentQueueItem> terrestrialQueue, God god,
			List<RecruitmentQueueItem> navalQueue, int piecesStoquees, Set<UnitOrder> ordresMilitaires, Set<TradeOrder> incomingTrade,
			Set<TradeOrder> outgoingTrade) {
		super();
		this.id = id;
		this.nom = nom;
		this.batiments = batiments;
		this.troupes = troupes;
		this.soutiens = soutiens;
		this.soutenus = soutenus;
		this.sortileges = sortileges;
		this.festivalEnd = festivalEnd;
		this.olympiquesEnd = olympiquesEnd;
		this.marchEnd = marchEnd;
		this.theaterEnd = theaterEnd;
		this.researches = researches;
		this.researchQueue = researchQueue;
		this.buildingQueue = buildingQueue;
		this.miliceUntil = miliceUntil;
		this.storage = storage;
		this.terrestrialQueue = terrestrialQueue;
		this.god = god;
		this.navalQueue = navalQueue;
		this.piecesStoquees = piecesStoquees;
		this.ordresMilitaires = ordresMilitaires;
		this.incomingTrade = incomingTrade;
		this.outgoingTrade = outgoingTrade;
	}
	
	public static class TradeOrder {
		Resources resources;
		Integer other;
		public TradeOrder(Resources resources, Integer other) {
			this.resources = resources;
			this.other = other;
		}
	}
	public static class UnitOrder {
		Troupes attq;
		Timestamp arrivee;
		OrderType type;
		Set<String> sortileges;
	}
	public static enum OrderType {
		ATTACK,
		SUPPORT,
		ATTACK_CANCELED,
		ATTACK_RETURN;
	}
	
	public static class QueueItem {
		String buildingId;
		Timestamp startTime;
		Timestamp endTime;
		long duration;
	}

	public int getId() {
		return id;
	}

	public String getNom() {
		return nom;
	}

	public Map<Building, Integer> getBatiments() {
		return batiments;
	}

	public Troupes getTroupes() {
		return troupes;
	}

	public Map<Integer, Troupes> getSoutiens() {
		return soutiens;
	}

	public Map<Integer, Troupes> getSoutenus() {
		return soutenus;
	}

	public Map<Power, Timestamp> getSortileges() {
		return sortileges;
	}

	public Timestamp getFestivalEnd() {
		return festivalEnd;
	}

	public Timestamp getOlympiquesEnd() {
		return olympiquesEnd;
	}

	public Timestamp getMarchEnd() {
		return marchEnd;
	}

	public Timestamp getTheaterEnd() {
		return theaterEnd;
	}

	public Set<Research> getResearches() {
		return researches;
	}

	public List<ResearchQueueItem> getResearchQueue() {
		return researchQueue;
	}

	public List<BuildingQueueItem> getBuildingQueue() {
		return buildingQueue;
	}

	public Timestamp getMiliceUntil() {
		return miliceUntil;
	}
	
	public Resources getStorage() {
		return storage;
	}

	public List<RecruitmentQueueItem> getTerrestrialQueue() {
		return terrestrialQueue;
	}

	public God getGod() {
		return god;
	}

	public List<RecruitmentQueueItem> getNavalQueue() {
		return navalQueue;
	}

	public int getPiecesStoquees() {
		return piecesStoquees;
	}

	public Set<UnitOrder> getOrdresMilitaires() {
		return ordresMilitaires;
	}

	public Set<TradeOrder> getIncomingTrade() {
		return incomingTrade;
	}

	public Set<TradeOrder> getOutgoingTrade() {
		return outgoingTrade;
	}
	
}
