package com.bernard.greposimu.model.game;

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

import com.bernard.greposimu.model.FightStats;

public class Unit {
	  
	public String id;
	public String name;
	public String name_plural;
	public int speed;
	public int attack;
	public String description;
	public Resources resources;
	public int favor;
	public int population;
	public int build_time;
	public String god_id;
	public List<String> research_dependencies;
	public Map<String, Integer> building_dependencies;
	public boolean is_naval;
	public int max_per_attack;
	public int max_per_support;
	public String unit_function;
	public String category;
	public List<Object> special_abilities;
	public String passive;
	public boolean is_npc_unit_only;
	public int def_hack;
	public int def_pierce;
	public int def_distance;
	public int booty;
	public Object infantry;
	public boolean flying;
	public String attack_type;
	
	// Naval
	public int defense;
	public boolean transport;
	public int capacity;
	
	public FightStats getDefStats() {
		return new FightStats(def_hack, def_pierce, def_distance, defense);
	}
	public FightStats getAttStats() {
		switch(attack_type) {
			case "hack":
				return new FightStats(attack, 0.0, 0.0, 0.0);
			case "pierce":
				return new FightStats(0.0, attack, 0.0, 0.0);
			case "distance":
				return new FightStats(0.0, 0.0, attack, 0.0);
		}
		if(is_naval)
			return new FightStats(0.0, 0.0, 0.0, attack);
		throw new IllegalStateException("This unit has no known attack type, and is not a ship");
	}
	
	public boolean isMythological() {
		return category.equals("mythological_ground") || category.equals("mythological_naval");
	}
	public boolean isGround() {
		return category.equals("regular_ground") || category.equals("mythological_ground");
	}
	public boolean isNaval() {
		return category.equals("regular_naval") || category.equals("mythological_naval");
	}
}
