当前位置: 首页>>代码示例>>Java>>正文


Java Story.canContinue方法代码示例

本文整理汇总了Java中com.bladecoder.ink.runtime.Story.canContinue方法的典型用法代码示例。如果您正苦于以下问题:Java Story.canContinue方法的具体用法?Java Story.canContinue怎么用?Java Story.canContinue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.bladecoder.ink.runtime.Story的用法示例。


在下文中一共展示了Story.canContinue方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: nextAll

import com.bladecoder.ink.runtime.Story; //导入方法依赖的package包/类
public static final void nextAll(Story story, List<String> text) throws StoryException, Exception {
	while (story.canContinue()) {
		String line = story.Continue();
		System.out.print(line);
		
		if(!line.isEmpty())
			text.add(line.trim());
	}

	if (story.hasError()) {
		fail(TestUtils.joinText(story.getCurrentErrors()));
	}
}
 
开发者ID:bladecoder,项目名称:blade-ink,代码行数:14,代码来源:TestUtils.java

示例2: getResponseText

import com.bladecoder.ink.runtime.Story; //导入方法依赖的package包/类
private void getResponseText(Session session, CurrentResponse currentResponse, Story story, IntentMatch intentMatch, boolean skipfirst)
  throws StoryException, Exception
{
  // reset reprompt, hint and quick replies
  currentResponse.setReprompt(null);
  currentResponse.setHint(null);
  currentResponse.setResponseQuickReplies(null);

  StringBuffer response = new StringBuffer();
  boolean first = true;
  while (story.canContinue())
  {
    String line = story.Continue();

    // skip first line as ink replays choice first
    if (first && skipfirst)
    {
      first = false;
      continue;
    }

    log.debug("Line {}", line);

    String trimmedLine = line.trim();

    if (trimmedLine.startsWith("::"))
    {
      String functionName = trimmedLine.split(" ")[0].substring(2).trim();
      String param = trimmedLine.substring(functionName.length() + 2).trim();

      InkBotFunction function = inkBotFunctions.get(functionName.toLowerCase());
      if (function != null)
      {
        function.execute(currentResponse, session, intentMatch, story, param);
      }
      else
      {
        log.warn("Did not find function named {}", functionName);
      }
    }
    else
    {
      response.append(line);
    }
  }

  // chop off last \n
  if (response.length() > 0 && response.charAt(response.length() - 1) == '\n')
  {
    response.setLength(response.length() - 1);
  }

  currentResponse.setResponseText(response.toString());
}
 
开发者ID:rabidgremlin,项目名称:Mutters,代码行数:55,代码来源:InkBot.java

示例3: runStory

import com.bladecoder.ink.runtime.Story; //导入方法依赖的package包/类
public static final List<String> runStory(String filename, List<Integer> choiceList, List<String> errors) throws Exception {
		// 1) Load story
		String json = getJsonString(filename);

//		System.out.println(json);

		Story story = new Story(json);

		List<String> text = new ArrayList<String>();

//		System.out.println(story.BuildStringOfHierarchy());
		
		int choiceListIndex = 0;

		while (story.canContinue() || story.getCurrentChoices().size() > 0) {
			// 2) Game content, line by line
			while (story.canContinue()) {
				String line = story.Continue();
				System.out.print(line);
				text.add(line);
			}

			if (story.hasError()) {
				for (String errorMsg : story.getCurrentErrors()) {
					System.out.println(errorMsg);
					errors.add(errorMsg);
				}
			}

			// 3) Display story.currentChoices list, allow player to choose one
			if (story.getCurrentChoices().size() > 0) {

				for (Choice c : story.getCurrentChoices()) {
					System.out.println(c.getText());
					text.add(c.getText() + "\n");
				}

				if(choiceList == null || choiceListIndex >= choiceList.size())
					story.chooseChoiceIndex((int) (Math.random() * story.getCurrentChoices().size()));
				else {
					story.chooseChoiceIndex(choiceList.get(choiceListIndex));
					choiceListIndex++;
				}
			}
		}

		return text;
	}
 
开发者ID:bladecoder,项目名称:blade-ink,代码行数:49,代码来源:TestUtils.java

示例4: isEnded

import com.bladecoder.ink.runtime.Story; //导入方法依赖的package包/类
public static final boolean isEnded(Story story) {
	return !story.canContinue() && story.getCurrentChoices().size() == 0;
}
 
开发者ID:bladecoder,项目名称:blade-ink,代码行数:4,代码来源:TestUtils.java


注:本文中的com.bladecoder.ink.runtime.Story.canContinue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。