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
Raw Normal View History

2022-11-21 16:10:08 +00:00
package com.github.dtschust.zork.types;
import com.github.dtschust.zork.ZorkGame;
2022-11-21 16:10:08 +00:00
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()) {
2022-11-22 17:03:09 +00:00
game.stream.println(print);
2022-11-21 16:10:08 +00:00
}
2022-11-22 17:03:09 +00:00
final ActionDispatcher effectsDispatcher = new ActionDispatcher(game);
2022-11-21 16:10:08 +00:00
for (final String action : getActions()) {
effectsDispatcher.dispatch(action);
}
}
}