This repository has been archived on 2022-12-21. You can view files and clone it, but cannot push or open issues or pull requests.
sdm03/src/main/java/com/github/dtschust/zork/types/HasPrintsAndActions.java

23 lines
623 B
Java

package com.github.dtschust.zork.types;
import com.github.dtschust.zork.ZorkGame;
import com.github.dtschust.zork.repl.ActionDispatcher;
import java.util.List;
public interface HasPrintsAndActions {
List<String> getPrints();
List<String> getActions();
default void printAndExecuteActions(final ZorkGame game) {
for (final String print : getPrints()) {
game.stream.println(print);
}
final ActionDispatcher effectsDispatcher = new ActionDispatcher(game);
for (final String action : getActions()) {
effectsDispatcher.dispatch(action);
}
}
}