use of com.bladecoder.engine.model.VerbRunner in project bladecoder-adventure-engine by bladecoder.
the class ChooseAction method run.
@Override
public boolean run(VerbRunner cb) {
VerbRunner v = (VerbRunner) cb;
int startIp = v.getIP();
int ip0 = startIp + 1;
final List<Action> actions = v.getActions();
int ip = skipControlIdBlock(actions, startIp);
int numActions = ip - startIp - 1;
if (numActions <= 0)
return false;
switch(chooseCriteria) {
case ITERATE:
chooseCount++;
break;
case RANDOM:
chooseCount = MathUtils.random(0, numActions - 1);
break;
case CYCLE:
chooseCount = (chooseCount + 1) % numActions;
break;
}
v.setIP(ip);
if (chooseCount < numActions) {
return actions.get(ip0 + chooseCount).run(v);
}
return false;
}
use of com.bladecoder.engine.model.VerbRunner in project bladecoder-adventure-engine by bladecoder.
the class IfSceneAttrAction method run.
@Override
public boolean run(VerbRunner cb) {
Scene s = (scene != null && !scene.isEmpty()) ? World.getInstance().getScene(scene) : World.getInstance().getCurrentScene();
if (attr == SceneAttr.STATE) {
if (!ActionUtils.compareNullStr(value, s.getState())) {
gotoElse((VerbRunner) cb);
}
} else if (attr == SceneAttr.CURRENT_SCENE) {
String scn = World.getInstance().getCurrentScene().getId();
if (!ActionUtils.compareNullStr(value, scn)) {
gotoElse((VerbRunner) cb);
}
} else if (attr == SceneAttr.PLAYER) {
CharacterActor player = s.getPlayer();
String id = player != null ? player.getId() : null;
if (!ActionUtils.compareNullStr(value, id)) {
gotoElse((VerbRunner) cb);
}
}
return false;
}
use of com.bladecoder.engine.model.VerbRunner in project bladecoder-adventure-engine by bladecoder.
the class InkManager method cancel.
@Override
public void cancel() {
ArrayList<Action> actions = getActions();
for (Action c : actions) {
if (c instanceof VerbRunner)
((VerbRunner) c).cancel();
}
ip = actions.size();
}
Aggregations