Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package telnet.player;
- import java.util.ArrayDeque;
- import java.util.Deque;
- import java.util.Map.Entry;
- import java.util.logging.Logger;
- public class ActionGenerator {
- private final static Logger log = Logger.getLogger(PLayerController.class.getName());
- public ActionGenerator() {
- }
- public Deque<Action> generateActions() {
- log.fine("trying actions...");
- Deque<Action> actions = new ArrayDeque<>();
- for (Entry<Flag, Boolean> entry : Player.INSTANCE.getFlags().entrySet()) {
- if (entry.getValue()) {
- //if this flag is true, then get the actions
- //from Flag.getActionsForState sending the entry key
- //and add to actions Deque.
- //example:
- actions.add(Action.DRAW); // **get** the specific action **from** Flag enum
- actions.add(Action.PROCESS);
- //add those actions when the entry key is Flag.CORPSE and
- //the entry val is true
- //the actions, themselves, actually come *from* the Flag
- //enum through the getActionsForState the
- //constant-specific method implementations
- //from item 30 in effective java, 2nd edition
- //strategy enum pattern, I believe.
- }
- }
- return actions;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment