package engine;

import engine.nutritionists.CakeChaserNutritionist;
import engine.nutritionists.GluttonChaserNutritionist;
import sun.util.resources.cldr.ebu.CalendarData_ebu_KE;

import java.awt.*;
import java.util.HashMap;
import java.util.Map;

public final class EntityAssociation {

    private static Map<String, Entity>     entityMap = new HashMap<>();
    private static Map<String, EntityView> viewMap   = new HashMap<>();

    public final static void register(String name, Entity e, EntityView ev) {
        if (entityMap.containsKey(name)) {
            throw new IllegalArgumentException(name + " already exists.");
        }

        entityMap.put(name, e);
        viewMap.put(name, ev);
    }

    public final static Entity getEntity(String name) {
        if (!entityMap.containsKey(name)) {
            throw new IllegalArgumentException(name + " doesn't exists.");
        }

        try {
            return (Entity) entityMap.get(name).clone();
        } catch (CloneNotSupportedException e) {
            e.printStackTrace();
            return null;
        }
    }

    public final static EntityView getEntityView(String name) {
        if (!viewMap.containsKey(name)) {
            throw new IllegalArgumentException(name + " doesn't exists.");
        }

        try {
            return (EntityView) viewMap.get(name).clone();
        } catch (CloneNotSupportedException e) {
            e.printStackTrace();
            return null;
        }
    }

    public final static void defaults() {
        /* TODO */

        /* Default Glutton */
        Glutton glutton = new Glutton(null, new Dimension(30, 30), 3f, 0f, 10);
        EntityView gluttonView = new EntityView(new Skin(30, 30));
        register("default_glutton", glutton, gluttonView);


        /* CakeChaser */
        CakeChaserNutritionist cakeChaser = new CakeChaserNutritionist(null, new Dimension(30, 30), 2f, 0f, 3);
        EntityView cakeChaserView = new EntityView(new Skin(30, 30));
        register("default_cakechaser", cakeChaser, cakeChaserView);


        /* GluttonChaser */
        GluttonChaserNutritionist gluttonChaser =
                new GluttonChaserNutritionist(null, new Dimension(30, 30), 2f, 0f, 6);
        EntityView gluttonChaserView = new EntityView(new Skin(30, 30));
        register("default_gluttonchaser", gluttonChaser, gluttonChaserView);


        /* DefaultCake */
        Cake cake = new Cake(null, new Dimension(15, 15), null);
        EntityView cakeView = new EntityView(new Skin(30, 30));
        register("default_cake", cake, cakeView);

    }

}

@@ -120,64 +120,8 @@
 ist;
-%0Aimport sun.util.resources.cldr.ebu.CalendarData_ebu_KE;
 %0A%0Aim
@@ -226,16 +226,380 @@
 tion %7B%0A%0A
+    /* Gluttons */%0A    public final static String DEFAULT_GLUTTON       = %22default_glutton%22;%0A%0A    /* Nutritionists */%0A    public final static String DEFAULT_CAKECHASER    = %22default_cakechaser%22;%0A    public final static String DEFAULT_GLUTTONCHASER = %22default_gluttonchaser%22;%0A%0A    /* Cakes */%0A    public final static String DEFAULT_CAKE          = %22default_cake%22;%0A%0A
     priv
@@ -628,20 +628,16 @@
  Entity%3E
-    
  entityM
@@ -639,16 +639,18 @@
 tityMap 
+  
 = new Ha
@@ -707,26 +707,24 @@
 ew%3E viewMap 
-  
 = new HashMa
@@ -2034,33 +2034,31 @@
 egister(
-%22default_glutton%22
+DEFAULT_GLUTTON
 , glutto
@@ -2300,36 +2300,34 @@
 egister(
-%22default_cakechaser%22
+DEFAULT_CAKECHASER
 , cakeCh
@@ -2606,39 +2606,37 @@
 egister(
-%22default_gluttonchaser%22
+DEFAULT_GLUTTONCHASER
 , glutto
@@ -2838,30 +2838,28 @@
 egister(
-%22default_cake%22
+DEFAULT_CAKE
 , cake, 

add static name.