Exemplo n.º 1
0
 private Story parseStory(Json.Object jsonStory) {
   final String text = jsonStory.getString("text");
   Story.Builder storyBuilder = Story.withText(text);
   Json.Array jsonTriggers = jsonStory.getArray("triggers");
   for (int i = 0, limit = jsonTriggers.length(); i < limit; i++) {
     Json.Object jsonTrigger = jsonTriggers.getObject(i);
     parseTrigger(jsonTrigger, storyBuilder);
   }
   return storyBuilder.build();
 }
Exemplo n.º 2
0
 private void parseTrigger(Json.Object jsonTrigger, Story.Builder storyBuilder) {
   String skillString = jsonTrigger.getString("skill");
   Json.Object conclusionObject = jsonTrigger.getObject("conclusion");
   Conclusion conclusion = parseConclusion(conclusionObject);
   if (skillString != null) {
     Skill skill = Skill.named(skillString);
     storyBuilder.trigger(SkillTrigger.skill(skill).conclusion(conclusion));
   } else {
     NoSkillTrigger noSkill = new NoSkillTrigger(conclusion);
     storyBuilder.trigger(noSkill);
   }
 }