package belight;

import com.amazon.speech.speechlet.Session;

/**
 * Created 4/16/16. Description...
 *
 * @author Neo Li. <neo.siqi.li@hotmail.com>
 */
public class ResponseGenerator {
    public static String getInitialPrompt(Session session) {
        return "I don't know. What did you have so far?";
    }

    public static String getResponse(Session session, FoodItem foodItem) {
        final int residualInCalories = SessionHelper.getResidualInCalories(session, foodItem);

        if (residualInCalories <= 0) {
            return String.format("You ate %s.  %d calories over your goal. Stop it. American " +
                                         "say yes.", foodItem.getName(), foodItem
                    .getCalories());
        } else if(foodItem.isBadFood()) {
            return String.format("%s is bad. It is %d calories. Be careful. Be light");

        } else {
            return String.format("%s is %d calories. You are doing great." +
                                         "Be light", foodItem.getName(),
                                 foodItem.getCalories());
        }
    }

    public static String getWhatElseCanIEat(Session session) {
        String eatenAlready = SessionHelper.getCurrentIntakeFoodNames(session);
        int residualInCalories = SessionHelper.caloriesMax - SessionHelper.getCurrentIntakeCalories
                (session);

        String response = "You had eaten " + eatenAlready + ". Total intake calories are " +
                residualInCalories;

        // increase already eat too much, or can't find a suitable items.
        String recommendation = "Sorry, I don't know. I'll find out.";

        for(FoodItem item : FoodDAO.foodItems.values()) {
            if(!eatenAlready.contains(item.getName()) && residualInCalories + item.getCalories() <
                    SessionHelper.caloriesMax) {
                recommendation = "I recommend  " + item.getName() + ", which is " + item
                        .getCalories() + " calories. And you can buy it from " + item.getBuyAt()
                        + ". Do you want me to order?";
            }
        }

        return response + recommendation;
    }
}

@@ -613,37 +613,16 @@
 can %22 +%0A
-                     
         
@@ -728,16 +728,17 @@
  else if
+ 
 (foodIte
@@ -839,16 +839,60 @@
 e light%22
+, foodItem.getName(), foodItem.getCalories()
 );%0A%0A    
@@ -1009,29 +1009,16 @@
         
-             
 %22Be ligh
@@ -1041,29 +1041,16 @@
 Name(),%0A
-             
         
@@ -1661,16 +1661,17 @@
      for
+ 
 (FoodIte
@@ -1723,16 +1723,17 @@
       if
+ 
 (!eatenA

fix string formatter