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 {
            return String.format("You eat %s. And it is %d calories. You have %d calories to go. " +
                                         "Keep it up.", foodItem.getName(),
                                 foodItem.getCalories(), residualInCalories);
        }
    }

    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;
    }
}

@@ -744,15 +744,38 @@
     
- %7D
  else
+ if(foodItem.isBadFood())
  %7B%0A 
@@ -811,25 +811,20 @@
 at(%22
-You eat %25s. And i
+%25s is bad. I
 t is
@@ -841,36 +841,123 @@
 es. 
-You have %25d calories to go. 
+Be careful. Be light%22);%0A%0A        %7D else %7B%0A            return String.format(%22%25s is %25d calories. You are doing great.
 %22 +%0A
@@ -1002,19 +1002,16 @@
    %22
-Keep it up.
+Be light
 %22, f
@@ -1088,28 +1088,8 @@
 es()
-, residualInCalories
 );%0A 

deal with bad food