diff --git a/HTW/src/htw/HtwMessageReceiver.java b/HTW/src/htw/HtwMessageReceiver.java index b99a475..c386c64 100644 --- a/HTW/src/htw/HtwMessageReceiver.java +++ b/HTW/src/htw/HtwMessageReceiver.java @@ -1,11 +1,13 @@ package htw; +import htw.HuntTheWumpus.Direction; + public interface HtwMessageReceiver { void noPassage(); void hearBats(); void hearPit(); void smellWumpus(); - void passage(HuntTheWumpus.Direction direction); + void passage(Direction direction); void noArrows(); void arrowShot(); void playerShootsSelfInBack(); @@ -16,4 +18,7 @@ public interface HtwMessageReceiver { void playerMovesToWumpus(); void wumpusMovesToPlayer(); void batsTransport(); + void addPitCoverToAdjacentCavern(Direction direction); + void cavernNotAdjacentForPitCover(); + void noPitCover(); } diff --git a/HTW/src/htw/HuntTheWumpus.java b/HTW/src/htw/HuntTheWumpus.java index 95529f4..dccd2bb 100644 --- a/HTW/src/htw/HuntTheWumpus.java +++ b/HTW/src/htw/HuntTheWumpus.java @@ -42,6 +42,7 @@ public Direction opposite() { HuntTheWumpusGame.Command makeRestCommand(); HuntTheWumpusGame.Command makeShootCommand(Direction direction); HuntTheWumpusGame.Command makeMoveCommand(Direction direction); + HuntTheWumpusGame.Command makeAddPitCoverCommand(Direction direction); public interface Command { void execute(); diff --git a/HTW/src/htw/console/Main.java b/HTW/src/htw/console/Main.java index 411597d..5554220 100644 --- a/HTW/src/htw/console/Main.java +++ b/HTW/src/htw/console/Main.java @@ -99,6 +99,14 @@ else if (command.equalsIgnoreCase("sn")) c = game.makeShootCommand(NORTH); else if (command.equalsIgnoreCase("ss")) c = game.makeShootCommand(SOUTH); + else if (command.equalsIgnoreCase("pce")) + c = game.makeAddPitCoverCommand(EAST); + else if (command.equalsIgnoreCase("pcw")) + c = game.makeAddPitCoverCommand(WEST); + else if (command.equalsIgnoreCase("pcn")) + c = game.makeAddPitCoverCommand(NORTH); + else if (command.equalsIgnoreCase("pcs")) + c = game.makeAddPitCoverCommand(SOUTH); else if (command.equalsIgnoreCase("q")) return; @@ -236,6 +244,21 @@ public void batsTransport() { System.out.println("Some bats carried you away."); } + @Override + public void addPitCoverToAdjacentCavern(Direction direction) { + System.out.println("Pit cover added to cavern to the " + direction); + } + + @Override + public void cavernNotAdjacentForPitCover() { + System.out.println("You cannot add a pit cover in that direction"); + } + + @Override + public void noPitCover() { + System.out.println("You have no more pit covers"); + } + private void hit(int points) { hitPoints -= points; if (hitPoints <= 0) { diff --git a/HTW/src/htw/game/HuntTheWumpusGame.java b/HTW/src/htw/game/HuntTheWumpusGame.java index f0311bd..5fe9a65 100644 --- a/HTW/src/htw/game/HuntTheWumpusGame.java +++ b/HTW/src/htw/game/HuntTheWumpusGame.java @@ -5,6 +5,7 @@ import java.util.*; import java.util.function.Predicate; +import java.util.stream.Collectors; public class HuntTheWumpusGame implements HuntTheWumpus { private List connections = new ArrayList<>(); @@ -17,11 +18,16 @@ public class HuntTheWumpusGame implements HuntTheWumpus { private String wumpusCavern = "NONE"; private int quiver = 0; private Map arrowsIn = new HashMap<>(); + private String cavernWithPitCover = "NONE"; public HuntTheWumpusGame(HtwMessageReceiver receiver) { this.messageReceiver = receiver; } + public void initializeArrowsIn() { + arrowsIn = new HashMap<>(); + } + public void setPlayerCavern(String playerCavern) { this.playerCavern = playerCavern; } @@ -41,17 +47,21 @@ private void reportStatus() { } private boolean reportNearby(Predicate nearTest) { - for (Connection c : connections) - if (playerCavern.equals(c.from) && nearTest.test(c)) - return true; - return false; + return connections.stream() + .filter(c -> playerCavern.equals(c.from) && nearTest.test(c)) + .findAny() + .isPresent(); } private void reportAvailableDirections() { - for (Connection c : connections) { - if (playerCavern.equals(c.from)) - messageReceiver.passage(c.direction); - } + connections.stream() + .filter(isFromPlayerCavern()) + .map(c -> c.direction) + .forEach(messageReceiver::passage); + } + + private Predicate isFromPlayerCavern() { + return c -> playerCavern.equals(c.from); } public void addBatCavern(String cavern) { @@ -71,24 +81,40 @@ public String getWumpusCavern() { } protected void moveWumpus() { - List wumpusChoices = new ArrayList<>(); - for (Connection c : connections) - if (wumpusCavern.equals(c.from)) - wumpusChoices.add(c.to); + List wumpusChoices = connections.stream() + .filter(isFromWumpusCavern()) + .map(c -> c.to) + .collect(Collectors.toList()); wumpusChoices.add(wumpusCavern); - int nChoices = wumpusChoices.size(); - int choice = (int) (Math.random() * nChoices); - wumpusCavern = wumpusChoices.get(choice); + wumpusCavern = wumpusChoices.stream() + .skip(randomCavernIndex(wumpusChoices.size())) + .findFirst() + .get(); + } + + private Predicate isFromWumpusCavern() { + return c -> wumpusCavern.equals(c.from); + } + + private int randomCavernIndex() { + return randomCavernIndex(caverns.size() - 1); + } + + private int randomCavernIndex(int size) { + return new Random().nextInt(size); } private void randomlyTransportPlayer() { - Set transportChoices = new HashSet<>(caverns); - transportChoices.remove(playerCavern); - int nChoices = transportChoices.size(); - int choice = (int) (Math.random() * nChoices); - String[] choices = new String[nChoices]; - playerCavern = transportChoices.toArray(choices)[choice]; + playerCavern = caverns.stream() + .filter(excludePlayerCavern()) + .skip(randomCavernIndex()) + .findFirst() + .get(); + } + + private Predicate excludePlayerCavern() { + return c -> !playerCavern.equals(c); } public void setQuiver(int arrows) { @@ -110,6 +136,26 @@ private int zeroIfNull(Integer integer) { return integer.intValue(); } + public String farthestCavern(String startingCavern, Direction direction) { + String cavern = startingCavern; + String furthestCavern = null; + for (int count = 0; count < 100 && (cavern = nextCavern(cavern, direction)) != null; count++) + furthestCavern = cavern; + return furthestCavern; + } + + private String nextCavern(String cavern, Direction direction) { + Connection connection = connections.stream() + .filter(isFromDirection(cavern, direction)) + .findFirst() + .orElse(null); + return connection != null ? connection.to : null; + } + + private Predicate isFromDirection(String cavern, Direction direction) { + return c -> cavern.equals(c.from) && direction.equals(c.direction); + } + private class Connection { String from; String to; @@ -129,10 +175,15 @@ public void connectCavern(String from, String to, Direction direction) { } public String findDestination(String cavern, Direction direction) { - for (Connection c : connections) - if (c.from.equals(cavern) && c.direction == direction) - return c.to; - return null; + Connection destination = connections.stream() + .filter(isDestination(cavern, direction)) + .findFirst() + .orElse(null); + return destination != null ? destination.to : null; + } + + private Predicate isDestination(String cavern, Direction direction) { + return c -> c.from.equals(cavern) && c.direction == direction; } public Command makeRestCommand() { @@ -147,6 +198,10 @@ public Command makeMoveCommand(Direction direction) { return new MoveCommand(direction); } + public Command makeAddPitCoverCommand(Direction direction) { + return new AddPitCoverCommand(direction); + } + public abstract class GameCommand implements Command { public void execute() { processCommand(); @@ -242,10 +297,15 @@ private boolean shotSelfInBack() { } private String nextCavern(String cavern, Direction direction) { - for (Connection c : connections) - if (cavern.equals(c.from) && direction.equals(c.direction)) - return c.to; - return null; + Connection connection = connections.stream() + .filter(isFromDirection(cavern, direction)) + .findFirst() + .orElse(null); + return connection != null ? connection.to : null; + } + + private Predicate isFromDirection(String cavern, Direction direction) { + return c -> cavern.equals(c.from) && direction.equals(c.direction); } } } @@ -289,7 +349,7 @@ public boolean movePlayer(Direction direction) { } private void checkForPit() { - if (pitCaverns.contains(playerCavern)) + if (pitCaverns.contains(playerCavern) && !cavernWithPitCover.equals(playerCavern)) messageReceiver.fellInPit(); } @@ -301,4 +361,27 @@ private void checkForArrows() { arrowsIn.put(playerCavern, 0); } } + + private class AddPitCoverCommand implements Command { + private Direction direction; + + public AddPitCoverCommand(Direction direction) { + this.direction = direction; + } + + public void execute() { + if (cavernWithPitCover.equals("NONE")) { + String destination = findDestination(playerCavern, direction); + if (destination != null) { + cavernWithPitCover = destination; + messageReceiver.addPitCoverToAdjacentCavern(direction); + } else { + messageReceiver.cavernNotAdjacentForPitCover(); + } + } + else { + messageReceiver.noPitCover(); + } + } + } } diff --git a/HTW/src/htw/gui/Main.java b/HTW/src/htw/gui/Main.java new file mode 100644 index 0000000..8ad1a04 --- /dev/null +++ b/HTW/src/htw/gui/Main.java @@ -0,0 +1,647 @@ +package htw.gui; + +import htw.HtwMessageReceiver; +import htw.HuntTheWumpus; +import htw.HuntTheWumpus.Direction; +import htw.factory.HtwFactory; + +import javax.swing.*; +import javax.swing.border.Border; +import java.awt.*; +import java.util.ArrayList; +import java.util.List; + +import static htw.HuntTheWumpus.Direction.EAST; +import static htw.HuntTheWumpus.Direction.NORTH; +import static htw.HuntTheWumpus.Direction.SOUTH; +import static htw.HuntTheWumpus.Direction.WEST; + +public class Main extends JPanel implements HtwMessageReceiver { + + private static HuntTheWumpus game; + private static List caverns = new ArrayList<>(); + + private JPanel warningPanel; + private JPanel cavernControlPanel; + private JPanel historyPanel; + private JPanel buttonPanel; + + private JTextArea historyTextArea; + private JTextArea warningTextArea; + + private JRadioButton moveRadioButton = new JRadioButton("Move"); + private JRadioButton shootRadioButton = new JRadioButton("Shoot"); + private JRadioButton addPitCoverRadioButton = new JRadioButton("Add Pit Cover"); + + private JSeparator quiverSeparator = getVerticalSeparator(); + private JSeparator healthSeparator = getVerticalSeparator(); + + private JLabel currentCavernLabel = new JLabel(); + private JLabel quiverCount = new JLabel(); + private JLabel healthLabel = new JLabel(); + + private JButton northButton = new JButton(); + private JButton southButton = new JButton(); + private JButton westButton = new JButton(); + private JButton eastButton = new JButton(); + private JButton startButton = new JButton("Start"); + private JButton quitButton = new JButton("Quit"); + + private static List warnings = new ArrayList<>(); + private static List passageDirections = new ArrayList<>(); + private static boolean playerMovesToWumpus = false; + private static boolean wumpusMovesToPlayer = false; + private static boolean playerKillsWumpus = false; + private static int health = 10; + private static Direction pitCoverDirection; + + private static final String[] environments = new String[]{ + "bright", + "humid", + "dry", + "creepy", + "ugly", + "foggy", + "hot", + "cold", + "drafty", + "dreadful" + }; + + private static final String[] shapes = new String[]{ + "round", + "square", + "oval", + "irregular", + "long", + "craggy", + "rough", + "tall", + "narrow" + }; + + private static final String[] cavernTypes = new String[]{ + "cavern", + "room", + "chamber", + "catacomb", + "crevasse", + "cell", + "tunnel", + "passageway", + "hall", + "expanse" + }; + + private static final String[] adornments = new String[]{ + "smelling of sulphur", + "with engravings on the walls", + "with a bumpy floor", + "", + "littered with garbage", + "spattered with guano", + "with piles of Wumpus droppings", + "with bones scattered around", + "with a corpse on the floor", + "that seems to vibrate", + "that feels stuffy", + "that fills you with dread" + }; + + public Main() { + super(new BorderLayout()); + add(createWarningsPanel(), BorderLayout.NORTH); + add(getCavernPanel(), BorderLayout.CENTER); + add(createButtonPanel(), BorderLayout.SOUTH); + initializeNavigationButtons(); + disableAllComponents(); + } + + public static void main(String[] args) { + javax.swing.SwingUtilities.invokeLater(() -> createAndShowGUI()); + } + + private static void createAndShowGUI() { + JFrame frame = new JFrame("Hunt The Wumpus"); + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + JComponent newContentPane = new Main(); + newContentPane.setOpaque(true); + frame.setContentPane(newContentPane); + frame.pack(); + frame.setVisible(true); + } + + private JPanel getCavernPanel() { + JPanel gamePanel = new JPanel(); + gamePanel.setLayout(new GridLayout(2, 1)); + gamePanel.add(createCavernControlPanel(), BorderLayout.CENTER); + gamePanel.add(createHistoryPanel()); + return gamePanel; + } + + private JPanel createWarningsPanel() { + initializeWarningPanel(); + initializeWarningPanelTextArea(); + warningPanel.add(warningTextArea, BorderLayout.WEST); + return warningPanel; + } + + private void initializeWarningPanel() { + warningPanel = new JPanel(); + warningPanel.setLayout(new BorderLayout()); + warningPanel.setBorder(BorderFactory.createTitledBorder("Warnings")); + warningPanel.setPreferredSize(new Dimension(500, 100)); + } + + private void initializeWarningPanelTextArea() { + warningTextArea = new JTextArea(5, 30); + warningTextArea.setEditable(false); + warningTextArea.setForeground(Color.RED); + warningTextArea.setBorder(javax.swing.BorderFactory.createEmptyBorder()); + warningTextArea.setOpaque(false); + warningTextArea.setAlignmentX(JTextArea.LEFT_ALIGNMENT); + } + + private void initializeNavigationButtons() { + initializeNavigationButtonIcons(); + initializeNavigationButtonListeners(); + setNavigationButtonLabels(); + setNavigationButtonToolTips(); + } + + private void initializeNavigationButtonIcons() { + northButton.setIcon(new ImageIcon(getClass().getResource("images/up24.gif"))); + southButton.setIcon(new ImageIcon(getClass().getResource("images/down24.gif"))); + eastButton.setIcon(new ImageIcon(getClass().getResource("images/right24.gif"))); + westButton.setIcon(new ImageIcon(getClass().getResource("images/left24.gif"))); + } + + private void initializeNavigationButtonListeners() { + northButton.addActionListener(e -> navigationButtonHandler(Direction.NORTH)); + southButton.addActionListener(e -> navigationButtonHandler(Direction.SOUTH)); + eastButton.addActionListener(e -> navigationButtonHandler(Direction.EAST)); + westButton.addActionListener(e -> navigationButtonHandler(Direction.WEST)); + } + + private void navigationButtonHandler(Direction direction) { + if (moveRadioButton.isSelected()) + moveButtonHandler(direction); + else if (shootRadioButton.isSelected()) + shootButtonHandler(direction); + else if (addPitCoverRadioButton.isSelected()) + addPitCoverButtonHandler(direction); + } + + private void setNavigationButtonLabels() { + northButton.setText(getNavigationButtonLabel(Direction.NORTH)); + southButton.setText(getNavigationButtonLabel(Direction.SOUTH)); + eastButton.setText(getNavigationButtonLabel(Direction.EAST)); + westButton.setText(getNavigationButtonLabel(Direction.WEST)); + } + + private String getNavigationButtonLabel(Direction direction) { + String command; + if (shootRadioButton.isSelected()) + command = "Shoot"; + else if (addPitCoverRadioButton.isSelected()) + command = "Add Pit Cover"; + else + command = "Move"; + return command + " " + direction.name(); + } + + private void setNavigationButtonToolTips() { + northButton.setToolTipText(getNavigationButtonToolTip(Direction.NORTH)); + southButton.setToolTipText(getNavigationButtonToolTip(Direction.SOUTH)); + eastButton.setToolTipText(getNavigationButtonToolTip(Direction.EAST)); + westButton.setToolTipText(getNavigationButtonToolTip(Direction.WEST)); + } + + private String getNavigationButtonToolTip(Direction direction) { + String toolTip; + if (shootRadioButton.isSelected()) + toolTip = "Shoot an arrow in the " + direction.name() + " direction"; + else if (addPitCoverRadioButton.isSelected()) + toolTip = "Add a pit cover in the " + direction.name() + " direction"; + else + toolTip = "Move the player in the " + direction.name() + " direction"; + return toolTip; + } + + private void moveButtonHandler(Direction direction) { + warnings.clear(); + passageDirections.clear(); + game.makeMoveCommand(direction).execute(); + updateHistory("Moved " + direction.name() + " to cavern \"" + game.getPlayerCavern() + "\""); + updatePresentation(); + } + + private void updateHistory(String message) { + historyTextArea.append(message + "\n"); + historyTextArea.validate(); + } + + private void shootButtonHandler(Direction direction) { + warnings.clear(); + updateHistory("Shot in direction " + direction.name()); + game.makeShootCommand(direction).execute(); + updatePresentation(); + } + + private void addPitCoverButtonHandler(Direction direction) { + game.makeAddPitCoverCommand(direction).execute(); + addPitCoverRadioButton.setEnabled(false); + moveRadioButton.doClick(); + if (pitCoverDirection != null) { + updateHistory("Pit cover added to cavern to the " + direction); + pitCoverDirection = null; + } + } + + private void updatePresentation() { + if (playerKillsWumpus) + gameOverWon("You killed the Wumpus."); + else if (health <= 0) + gameOverLose("You have died from your wounds"); + else if (playerMovesToWumpus) + gameOverLose("You walked into the waiting arms of the Wumpus."); + else if (wumpusMovesToPlayer) + gameOverLose("The Wumpus has found you."); + else + updatePanels(); + } + + private void updatePanels() { + updateCurrentCavern(); + enableButtonsForExistingPassages(); + updateQuiver(); + updateWarnings(); + updateHealth(); + showSeparators(); + } + + private void gameOverWon(String message) { + updateHistory(message); + disableAllComponents(); + warningTextArea.setText("You won! " + message); + } + + private void gameOverLose(String message) { + updateHistory(message); + disableAllComponents(); + warningTextArea.setText("You lost. " + message); + } + + private void updateCurrentCavern() { + currentCavernLabel.setText(game.getPlayerCavern()); + setBoldItalicFont(currentCavernLabel); + } + + private void setBoldItalicFont(JLabel label) { + Font font = new Font(label.getFont().getName(), Font.ITALIC + Font.BOLD, label.getFont().getSize()); + label.setFont(font); + } + + private void enableButtonsForExistingPassages() { + northButton.setEnabled(passageDirections.contains(Direction.NORTH)); + southButton.setEnabled(passageDirections.contains(Direction.SOUTH)); + eastButton.setEnabled(passageDirections.contains(Direction.EAST)); + westButton.setEnabled(passageDirections.contains(Direction.WEST)); + } + + private void updateQuiver() { + quiverCount.setText(String.format("Quiver Count: %d ", game != null ? game.getQuiver() : 0)); + if (game.getQuiver() <= 0) { + shootRadioButton.setEnabled(false); + moveRadioButton.doClick(); + } + else { + shootRadioButton.setEnabled(true); + } + } + + private void updateWarnings() { + warningTextArea.setText(""); + if (warnings.size() > 0) { + for (String warning : warnings) { + warningTextArea.append(warning + "\n"); + } + } else { + warningTextArea.append("No warnings at this time."); + } + } + + private void updateHealth() { + healthLabel.setText(String.format("Health: %d", health)); + } + + private void showSeparators() { + quiverSeparator.setVisible(true); + healthSeparator.setVisible(true); + } + + private JPanel createCavernControlPanel() { + cavernControlPanel = new JPanel(); + cavernControlPanel.setBorder(BorderFactory.createTitledBorder("Cavern")); + cavernControlPanel.setLayout(new BorderLayout()); + cavernControlPanel.add(createCavernPanel(), BorderLayout.CENTER); + cavernControlPanel.add(createOptionPanel(), BorderLayout.SOUTH); + + moveRadioButton.setSelected(true); + + return cavernControlPanel; + } + + private JPanel createCavernPanel() { + JPanel cavernPanel = new JPanel(); + cavernPanel.setLayout(new GridBagLayout()); + GridBagConstraints gbc = new GridBagConstraints(); + + Border paddingBorder = BorderFactory.createEmptyBorder(20, 20, 20, 20); + currentCavernLabel.setBorder(paddingBorder); + + gbc.gridy = 0; + gbc.gridx = 1; + cavernPanel.add(northButton, gbc); + + gbc.gridy = 2; + cavernPanel.add(southButton, gbc); + + gbc.gridy = 1; + gbc.gridx = 0; + cavernPanel.add(westButton, gbc); + + gbc.gridx++; + cavernPanel.add(currentCavernLabel, gbc); + + gbc.gridx++; + cavernPanel.add(eastButton, gbc); + + return cavernPanel; + } + + private JPanel createOptionPanel() { + JPanel optionPanel = new JPanel(); + optionPanel.setLayout(new FlowLayout(FlowLayout.CENTER)); + addComponentsToOptionPanel(optionPanel); + createRadioButtonGroup(); + initializeRadioButtonListeners(); + return optionPanel; + } + + public void addComponentsToOptionPanel(JPanel optionPanel) { + optionPanel.add(moveRadioButton); + optionPanel.add(shootRadioButton); + optionPanel.add(addPitCoverRadioButton); + optionPanel.add(quiverSeparator); + optionPanel.add(quiverCount); + optionPanel.add(healthSeparator); + optionPanel.add(healthLabel); + } + + private void createRadioButtonGroup() { + ButtonGroup bg = new ButtonGroup(); + bg.add(moveRadioButton); + bg.add(shootRadioButton); + bg.add(addPitCoverRadioButton); + } + + private void initializeRadioButtonListeners() { + moveRadioButton.addActionListener(e -> {setNavigationButtonLabels(); setNavigationButtonToolTips();}); + shootRadioButton.addActionListener(e -> {setNavigationButtonLabels(); setNavigationButtonToolTips();}); + addPitCoverRadioButton.addActionListener(e -> {setNavigationButtonLabels(); setNavigationButtonToolTips();}); + } + + private JSeparator getVerticalSeparator() { + JSeparator separator = new JSeparator(SwingConstants.VERTICAL); + separator.setPreferredSize(new Dimension(10, 15)); + separator.setVisible(false); + return separator; + } + + private JPanel createHistoryPanel() { + initializeHistoryPanel(); + initializeHistoryTextArea(); + historyPanel.add(getHistoryScrollPane(), BorderLayout.WEST); + return historyPanel; + } + + private void initializeHistoryPanel() { + historyPanel = new JPanel(); + historyPanel.setLayout(new BorderLayout()); + historyPanel.setBorder(BorderFactory.createTitledBorder("History")); + } + + private void initializeHistoryTextArea() { + historyTextArea = new JTextArea(15, 80); + historyTextArea.setEditable(false); + historyTextArea.setBorder(javax.swing.BorderFactory.createEmptyBorder()); + historyTextArea.setOpaque(false); + historyTextArea.setAlignmentX(JTextArea.LEFT_ALIGNMENT); + } + + private JScrollPane getHistoryScrollPane() { + JScrollPane scrollPane = new JScrollPane(historyTextArea); + scrollPane.setOpaque(false); + scrollPane.setBorder(BorderFactory.createEmptyBorder()); + scrollPane.setAlignmentX(JScrollPane.LEFT_ALIGNMENT); + return scrollPane; + } + + private JPanel createButtonPanel() { + buttonPanel = new JPanel(); + buttonPanel.setLayout(new FlowLayout(FlowLayout.CENTER)); + + initializeStartButton(); + initializeQuitButton(); + + buttonPanel.add(startButton); + buttonPanel.add(quitButton); + + return buttonPanel; + } + + private void initializeStartButton() { + startButton.setPreferredSize(new Dimension(80, 40)); + startButton.addActionListener(e -> startGame()); + } + + private void initializeQuitButton() { + quitButton.setPreferredSize(new Dimension(80, 40)); + quitButton.addActionListener(e -> System.exit(0)); + } + + private void disableAllComponents() { + disableNavigationButtons(); + disableOptionRadioButtons(); + } + + private void disableNavigationButtons() { + northButton.setEnabled(false); + southButton.setEnabled(false); + eastButton.setEnabled(false); + westButton.setEnabled(false); + } + + private void disableOptionRadioButtons() { + moveRadioButton.setEnabled(false); + shootRadioButton.setEnabled(false); + addPitCoverRadioButton.setEnabled(false); + } + + private void startGame() { + startButton.setEnabled(false); + initializeGame(); + } + + private void initializeGame() { + game = HtwFactory.makeGame("htw.game.HuntTheWumpusGame", new Main()); + createMap(); + game.makeRestCommand().execute(); + updateHistory("Started in cavern \"" + game.getPlayerCavern() + "\""); + enableOptionRadioButtons(); + updatePresentation(); + } + + private static void createMap() { + int ncaverns = (int) (Math.random() * 30.0 + 10.0); + while (ncaverns-- > 0) + caverns.add(makeName()); + + for (String cavern : caverns) { + maybeConnectCavern(cavern, NORTH); + maybeConnectCavern(cavern, SOUTH); + maybeConnectCavern(cavern, EAST); + maybeConnectCavern(cavern, WEST); + } + + String playerCavern = anyCavern(); + game.setPlayerCavern(playerCavern); + game.setWumpusCavern(anyOther(playerCavern)); + game.addBatCavern(anyOther(playerCavern)); + game.addBatCavern(anyOther(playerCavern)); + game.addBatCavern(anyOther(playerCavern)); + + game.addPitCavern(anyOther(playerCavern)); + game.addPitCavern(anyOther(playerCavern)); + game.addPitCavern(anyOther(playerCavern)); + + game.setQuiver(5); + } + + private static String makeName() { + + return "A " + chooseName(environments) + " " + + chooseName(shapes) + " " + + chooseName(cavernTypes) + " " + + chooseName(adornments); + } + + private static String chooseName(String[] names) { + int n = names.length; + int choice = (int) (Math.random() * (double) n); + return names[choice]; + } + + private static void maybeConnectCavern(String cavern, Direction direction) { + if (Math.random() > .2) { + String other = anyOther(cavern); + connectIfAvailable(cavern, direction, other); + connectIfAvailable(other, direction.opposite(), cavern); + } + } + + private static String anyCavern() { + return caverns.get((int) (Math.random() * caverns.size())); + } + + private static String anyOther(String cavern) { + String otherCavern = cavern; + while (cavern.equals(otherCavern)) { + otherCavern = anyCavern(); + } + return otherCavern; + } + + private static void connectIfAvailable(String from, Direction direction, String to) { + if (game.findDestination(from, direction) == null) { + game.connectCavern(from, to, direction); + } + } + + private void enableOptionRadioButtons() { + addPitCoverRadioButton.setEnabled(true); + moveRadioButton.setEnabled(true); + shootRadioButton.setEnabled(true); + } + + public void noPassage() { + throw new RuntimeException("noPassage"); + } + + public void hearBats() { + warnings.add("You hear chirping."); + } + + public void hearPit() { + warnings.add("You hear wind."); + } + + public void smellWumpus() { + warnings.add("There is a terrible smell."); + } + + public void passage(Direction direction) { + passageDirections.add(direction); + } + + public void noArrows() { + } + + public void arrowShot() { + } + + public void playerShootsSelfInBack() { + warnings.add("Ow! You shot yourself in the back."); + health -= 3; + } + + public void playerKillsWumpus() { + playerKillsWumpus = true; + } + + public void playerShootsWall() { + warnings.add("You shot the wall and the ricochet hurt you."); + health -= 3; + } + + public void arrowsFound(Integer value) { + warnings.add("You found " + value + " arrow(s)"); + } + + public void fellInPit() { + warnings.add("You fell into a pit and hurt yourself"); + health -= 4; + } + + public void playerMovesToWumpus() { + playerMovesToWumpus = true; + } + + public void wumpusMovesToPlayer() { + wumpusMovesToPlayer = true; + } + + public void batsTransport() { + } + + public void addPitCoverToAdjacentCavern(Direction direction) { + pitCoverDirection = direction; + } + + public void noPitCover() { + } + + public void cavernNotAdjacentForPitCover() { + } +} diff --git a/HTW/src/htw/gui/images/down24.gif b/HTW/src/htw/gui/images/down24.gif new file mode 100755 index 0000000..cabf772 Binary files /dev/null and b/HTW/src/htw/gui/images/down24.gif differ diff --git a/HTW/src/htw/gui/images/left24.gif b/HTW/src/htw/gui/images/left24.gif new file mode 100755 index 0000000..787518c Binary files /dev/null and b/HTW/src/htw/gui/images/left24.gif differ diff --git a/HTW/src/htw/gui/images/right24.gif b/HTW/src/htw/gui/images/right24.gif new file mode 100755 index 0000000..1936fd4 Binary files /dev/null and b/HTW/src/htw/gui/images/right24.gif differ diff --git a/HTW/src/htw/gui/images/up24.gif b/HTW/src/htw/gui/images/up24.gif new file mode 100755 index 0000000..3db8873 Binary files /dev/null and b/HTW/src/htw/gui/images/up24.gif differ diff --git a/HTW/test/htw/fixtures/CanPlayerShootWithoutArrows.java b/HTW/test/htw/fixtures/CanPlayerShootWithoutArrows.java new file mode 100644 index 0000000..f2126d8 --- /dev/null +++ b/HTW/test/htw/fixtures/CanPlayerShootWithoutArrows.java @@ -0,0 +1,33 @@ +package htw.fixtures; + +import htw.HuntTheWumpus.Direction; + +import static htw.fixtures.TestContext.game; + +public class CanPlayerShootWithoutArrows { + + private String playerCavern; + private Direction shootingDirection; + + public void setPlayerCavern(String playerCavern) { + this.playerCavern = playerCavern; + } + + public void setShootingDirection(Direction shootingDirection) { + this.shootingDirection = shootingDirection; + } + + public void reset() { + TestContext.messages.clear(); + } + + public void execute() { + game.setPlayerCavern(playerCavern); + game.setQuiver(0); + game.makeShootCommand(shootingDirection).execute(); + } + + public String noArrowsMessageGiven() { + return TestContext.messages.contains("NO_ARROWS") ? "Yes" : "No"; + } +} diff --git a/HTW/test/htw/fixtures/DoArrowsAccumulateInFarthestCavern.java b/HTW/test/htw/fixtures/DoArrowsAccumulateInFarthestCavern.java new file mode 100644 index 0000000..114ce5c --- /dev/null +++ b/HTW/test/htw/fixtures/DoArrowsAccumulateInFarthestCavern.java @@ -0,0 +1,59 @@ +package htw.fixtures; + +import htw.HuntTheWumpus.Direction; + +import static htw.fixtures.TestContext.game; + +public class DoArrowsAccumulateInFarthestCavern { + + private String playerCavern; + private int arrowCount; + private Direction shootingDirection; + private int NUM_SHOTS = 3; + private int[] shotCount = new int[NUM_SHOTS]; + + public void setPlayerCavern(String playerCavern) { + this.playerCavern = playerCavern; + } + + public void setArrowCount(int arrowCount) { + this.arrowCount = arrowCount; + } + + public void setShootingDirection(Direction shootingDirection) { + this.shootingDirection = shootingDirection; + } + + public String farthestCavern() { + return game.farthestCavern(playerCavern, shootingDirection); + } + + public void reset() { + TestContext.messages.clear(); + TestContext.game.initializeArrowsIn(); + } + + public void execute() { + game.setPlayerCavern(playerCavern); + game.setQuiver(arrowCount); + for (int i = 0; i < NUM_SHOTS; i++) + recordShotCountAfterShooting(i, farthestCavern()); + } + + private void recordShotCountAfterShooting(int i, String farthestCavern) { + game.makeShootCommand(shootingDirection).execute(); + shotCount[i] = game.getArrowsInCavern(farthestCavern); + } + + public int countAfterFirstShot() { + return shotCount[0]; + } + + public int countAfterSecondShot() { + return shotCount[1]; + } + + public int countAfterThirdShot() { + return shotCount[2]; + } +} diff --git a/HTW/test/htw/fixtures/DoesArrowKillWumpus.java b/HTW/test/htw/fixtures/DoesArrowKillWumpus.java new file mode 100644 index 0000000..717424d --- /dev/null +++ b/HTW/test/htw/fixtures/DoesArrowKillWumpus.java @@ -0,0 +1,54 @@ +package htw.fixtures; + +import htw.HuntTheWumpus; + +import static htw.fixtures.TestContext.game; + +public class DoesArrowKillWumpus { + + private String playerCavern; + private String wumpusCavern; + private int arrowsForPlayer; + private HuntTheWumpus.Direction shootingDirection; + + public void setPlayerCavern(String playerCavern) { + this.playerCavern = playerCavern; + } + + public void setWumpusCavern(String wumpusCavern) { + this.wumpusCavern = wumpusCavern; + } + + public void setArrowsForPlayer(int arrowsForPlayer) { + this.arrowsForPlayer = arrowsForPlayer; + } + + public void setShootingDirection(HuntTheWumpus.Direction shootingDirection) { + this.shootingDirection = shootingDirection; + } + + public void reset() { + TestContext.messages.clear(); + TestContext.game.initializeArrowsIn(); + } + + public void execute() { + game.setPlayerCavern(playerCavern); + game.setWumpusCavern(wumpusCavern); + game.setQuiver(arrowsForPlayer); + game.makeShootCommand(shootingDirection).execute(); + } + + public String farthestCavern() { + return game.farthestCavern(playerCavern, shootingDirection); + } + + public int arrowsInFarthestCavern() { + return game.getArrowsInCavern(farthestCavern()); + } + + public String wumpusKilledMessage() { + return TestContext.messages.contains("WUMPUS_KILLED") ? "Yes" : "No"; + } + +} diff --git a/HTW/test/htw/fixtures/HtwFixture.java b/HTW/test/htw/fixtures/HtwFixture.java index 236fb36..763f5c4 100644 --- a/HTW/test/htw/fixtures/HtwFixture.java +++ b/HTW/test/htw/fixtures/HtwFixture.java @@ -125,4 +125,9 @@ public int arrowsInQuiver() { public int arrowsInCavern(String cavern) { return game.getArrowsInCavern(cavern); } + + public boolean addPitCover(String dir) { + game.makeAddPitCoverCommand(toDirection(dir)).execute(); + return true; + } } diff --git a/HTW/test/htw/fixtures/TestContext.java b/HTW/test/htw/fixtures/TestContext.java index d297644..61ee527 100644 --- a/HTW/test/htw/fixtures/TestContext.java +++ b/HTW/test/htw/fixtures/TestContext.java @@ -1,7 +1,7 @@ package htw.fixtures; import htw.HtwMessageReceiver; -import htw.HuntTheWumpus; +import htw.HuntTheWumpus.Direction; import htw.factory.HtwFactory; import java.util.HashMap; @@ -60,7 +60,7 @@ public void arrowsFound(Integer arrowsFound) { messages.add(String.format("%d_ARROW_FOUND", arrowsFound)); } - public void passage(HuntTheWumpus.Direction direction) { + public void passage(Direction direction) { messages.add(direction.name() + "_PASSAGE"); } @@ -83,4 +83,19 @@ public void playerKillsWumpus() { public void playerShootsWall() { messages.add("PLAYER_SHOOTS_WALL"); } + + @Override + public void addPitCoverToAdjacentCavern(Direction cavern) { + messages.add("PIT_COVER_ADDED_TO_CAVERN_" + cavern.name()); + } + + @Override + public void cavernNotAdjacentForPitCover() { + messages.add("CAVERN_NOT_ADJACENT_FOR_PIT_COVER"); + } + + @Override + public void noPitCover() { + messages.add("NO_PIT_COVER"); + } } diff --git a/fitnesse/FitNesseRoot/HuntTheWumpus/ReleaseOne/HuntingWithArrows/ArrowKillsWumpus/20151216232211.zip b/fitnesse/FitNesseRoot/HuntTheWumpus/ReleaseOne/HuntingWithArrows/ArrowKillsWumpus/20151216232211.zip new file mode 100644 index 0000000..2f13848 Binary files /dev/null and b/fitnesse/FitNesseRoot/HuntTheWumpus/ReleaseOne/HuntingWithArrows/ArrowKillsWumpus/20151216232211.zip differ diff --git a/fitnesse/FitNesseRoot/HuntTheWumpus/ReleaseOne/HuntingWithArrows/ArrowKillsWumpus/content.txt b/fitnesse/FitNesseRoot/HuntTheWumpus/ReleaseOne/HuntingWithArrows/ArrowKillsWumpus/content.txt index 9e55692..fa5b85e 100644 --- a/fitnesse/FitNesseRoot/HuntTheWumpus/ReleaseOne/HuntingWithArrows/ArrowKillsWumpus/content.txt +++ b/fitnesse/FitNesseRoot/HuntTheWumpus/ReleaseOne/HuntingWithArrows/ArrowKillsWumpus/content.txt @@ -1,8 +1,72 @@ -!|script| |Given Cross Map| -|Given the player is in cavern FarLeft| -|Given the wumpus is in cavern Middle| -|Given the player has 1 arrow| -|When the player shoots East| -|Then there are 0 arrows in cavern FarRight| -|Then a|WUMPUS_KILLED|message is given| + +{{{ +Cross Map +''Links are bidirectional'' + + + [ Top ] + + [Above ] + +[FarLeft] [Left] [Middle] [Right] [FarRight] + + [Below ] + + [Bottom] + +}}} + +!|Does arrow kill wumpus| +|player cavern|wumpus cavern|arrows for player|shooting direction|farthest cavern?|arrows in farthest cavern?|wumpus killed message?| +|FarLeft|Left|1|East|FarRight|0|Yes| +|FarLeft|Middle|1|East|FarRight|0|Yes| +|FarLeft|Right|1|East|FarRight|0|Yes| +|FarLeft|FarRight|1|East|FarRight|0|Yes| +|FarLeft|Top|1|East|FarRight|1|No| +|FarRight|Right|1|West|FarLeft|0|Yes| +|FarRight|Middle|1|West|FarLeft|0|Yes| +|FarRight|Left|1|West|FarLeft|0|Yes| +|FarRight|FarLeft|1|West|FarLeft|0|Yes| +|FarRight|Bottom|1|West|FarLeft|1|No| +|Top|Above|1|South|Bottom|0|Yes| +|Top|Middle|1|South|Bottom|0|Yes| +|Top|Below|1|South|Bottom|0|Yes| +|Top|Bottom|1|South|Bottom|0|Yes| +|Top|FarLeft|1|South|Bottom|1|No| +|Bottom|Below|1|North|Top|0|Yes| +|Bottom|Middle|1|North|Top|0|Yes| +|Bottom|Above|1|North|Top|0|Yes| +|Bottom|Top|1|North|Top|0|Yes| +|Bottom|FarRight|1|North|Top|1|No| + +-!|script| +|Given Donut Map| + +{{{ +Donut Map + +[3]<-[2]<-[1] + | A + V | +[4] [8] + | A + V | +[5]->[6]->[7] +}}} + +!|Does arrow kill wumpus| +|player cavern|wumpus cavern|arrows for player|shooting direction|farthest cavern?|arrows in farthest cavern?|wumpus killed message?| +|1|2|1|West|3|0|Yes| +|1|3|1|West|3|0|Yes| +|1|5|1|West|3|1|No| +|3|4|1|South|5|0|Yes| +|3|5|1|South|5|0|Yes| +|3|7|1|South|5|1|No| +|5|6|1|East|7|0|Yes| +|5|7|1|East|7|0|Yes| +|5|8|1|East|7|1|No| +|7|8|1|North|1|0|Yes| +|7|1|1|North|1|0|Yes| +|7|3|1|North|1|1|No| diff --git a/fitnesse/FitNesseRoot/HuntTheWumpus/ReleaseOne/HuntingWithArrows/ArrowsAccumulateInFarthestCavern/20151217213807.zip b/fitnesse/FitNesseRoot/HuntTheWumpus/ReleaseOne/HuntingWithArrows/ArrowsAccumulateInFarthestCavern/20151217213807.zip new file mode 100644 index 0000000..ac0c2e2 Binary files /dev/null and b/fitnesse/FitNesseRoot/HuntTheWumpus/ReleaseOne/HuntingWithArrows/ArrowsAccumulateInFarthestCavern/20151217213807.zip differ diff --git a/fitnesse/FitNesseRoot/HuntTheWumpus/ReleaseOne/HuntingWithArrows/ArrowsAccumulateInFarthestCavern/content.txt b/fitnesse/FitNesseRoot/HuntTheWumpus/ReleaseOne/HuntingWithArrows/ArrowsAccumulateInFarthestCavern/content.txt index 35f6cd4..1553ebf 100644 --- a/fitnesse/FitNesseRoot/HuntTheWumpus/ReleaseOne/HuntingWithArrows/ArrowsAccumulateInFarthestCavern/content.txt +++ b/fitnesse/FitNesseRoot/HuntTheWumpus/ReleaseOne/HuntingWithArrows/ArrowsAccumulateInFarthestCavern/content.txt @@ -1,11 +1,38 @@ -!|script| |Given Cross Map| -|Given the player is in cavern FarLeft| -|Given the player has 3 arrows| -|When the player shoots East| -|Then there is 1 arrow in cavern FarRight| -|When the player shoots East| -|Then there are 2 arrows in cavern FarRight| -|When the player shoots East| -|Then there are 3 arrows in cavern FarRight| -|Then the player has no arrows| + +{{{ +Cross Map +''Links are bidirectional'' + + + [ Top ] + + [Above ] + +[FarLeft] [Left] [Middle] [Right] [FarRight] + + [Below ] + + [Bottom] + +}}} + +!|Do arrows accumulate in farthest cavern| +|player cavern|arrow count|shooting direction|farthest cavern?|count after first shot?|count after second shot?|count after third shot?| +|FarLeft|3|East|FarRight|1|2|3| +|Left|3|East|FarRight|1|2|3| +|Middle|3|East|FarRight|1|2|3| +|Right|3|East|FarRight|1|2|3| +|FarRight|3|West|FarLeft|1|2|3| +|Right|3|West|FarLeft|1|2|3| +|Middle|3|West|FarLeft|1|2|3| +|Left|3|West|FarLeft|1|2|3| +|Bottom|3|North|Top|1|2|3| +|Below|3|North|Top|1|2|3| +|Middle|3|North|Top|1|2|3| +|Above|3|North|Top|1|2|3| +|Top|3|South|Bottom|1|2|3| +|Above|3|South|Bottom|1|2|3| +|Middle|3|South|Bottom|1|2|3| +|Below|3|South|Bottom|1|2|3| diff --git a/fitnesse/FitNesseRoot/HuntTheWumpus/ReleaseOne/HuntingWithArrows/PlayerCanNotShootWithoutArrows/20151217222400.zip b/fitnesse/FitNesseRoot/HuntTheWumpus/ReleaseOne/HuntingWithArrows/PlayerCanNotShootWithoutArrows/20151217222400.zip new file mode 100644 index 0000000..70c52fe Binary files /dev/null and b/fitnesse/FitNesseRoot/HuntTheWumpus/ReleaseOne/HuntingWithArrows/PlayerCanNotShootWithoutArrows/20151217222400.zip differ diff --git a/fitnesse/FitNesseRoot/HuntTheWumpus/ReleaseOne/HuntingWithArrows/PlayerCanNotShootWithoutArrows/content.txt b/fitnesse/FitNesseRoot/HuntTheWumpus/ReleaseOne/HuntingWithArrows/PlayerCanNotShootWithoutArrows/content.txt index af3485c..485f5da 100644 --- a/fitnesse/FitNesseRoot/HuntTheWumpus/ReleaseOne/HuntingWithArrows/PlayerCanNotShootWithoutArrows/content.txt +++ b/fitnesse/FitNesseRoot/HuntTheWumpus/ReleaseOne/HuntingWithArrows/PlayerCanNotShootWithoutArrows/content.txt @@ -1,8 +1,38 @@ -|script| |Given Cross map| -|Given the player is in cavern Middle| -|Given the player has no arrows| -|When the player shoots East| -|Then a message|NO_ARROWS|is given| -' +{{{ +Cross Map +''Links are bidirectional'' + + + [ Top ] + + [Above ] + +[FarLeft] [Left] [Middle] [Right] [FarRight] + + [Below ] + + [Bottom] + +}}} + +!|Can player shoot without arrows| +|player cavern|shooting direction|no arrows message given?| +|FarLeft|East|Yes| +|Left|East|Yes| +|Middle|East|Yes| +|Right|East|Yes| +|FarRight|West|Yes| +|Right|West|Yes| +|Middle|West|Yes| +|Left|West|Yes| +|Top|South|Yes| +|Above|South|Yes| +|Middle|South|Yes| +|Below|South|Yes| +|Bottom|North|Yes| +|Below|North|Yes| +|Middle|North|Yes| +|Above|North|Yes| diff --git a/fitnesse/FitNesseRoot/HuntTheWumpus/ReleaseOne/PitCaverns/PlayerCanAddPitCoverToAdjacentCavern/20151218013821.zip b/fitnesse/FitNesseRoot/HuntTheWumpus/ReleaseOne/PitCaverns/PlayerCanAddPitCoverToAdjacentCavern/20151218013821.zip new file mode 100644 index 0000000..f140627 Binary files /dev/null and b/fitnesse/FitNesseRoot/HuntTheWumpus/ReleaseOne/PitCaverns/PlayerCanAddPitCoverToAdjacentCavern/20151218013821.zip differ diff --git a/fitnesse/FitNesseRoot/HuntTheWumpus/ReleaseOne/PitCaverns/PlayerCanAddPitCoverToAdjacentCavern/20151218014036.zip b/fitnesse/FitNesseRoot/HuntTheWumpus/ReleaseOne/PitCaverns/PlayerCanAddPitCoverToAdjacentCavern/20151218014036.zip new file mode 100644 index 0000000..d182bbd Binary files /dev/null and b/fitnesse/FitNesseRoot/HuntTheWumpus/ReleaseOne/PitCaverns/PlayerCanAddPitCoverToAdjacentCavern/20151218014036.zip differ diff --git a/fitnesse/FitNesseRoot/HuntTheWumpus/ReleaseOne/PitCaverns/PlayerCanAddPitCoverToAdjacentCavern/20151218020603.zip b/fitnesse/FitNesseRoot/HuntTheWumpus/ReleaseOne/PitCaverns/PlayerCanAddPitCoverToAdjacentCavern/20151218020603.zip new file mode 100644 index 0000000..af3d0f4 Binary files /dev/null and b/fitnesse/FitNesseRoot/HuntTheWumpus/ReleaseOne/PitCaverns/PlayerCanAddPitCoverToAdjacentCavern/20151218020603.zip differ diff --git a/fitnesse/FitNesseRoot/HuntTheWumpus/ReleaseOne/PitCaverns/PlayerCanAddPitCoverToAdjacentCavern/20151218020651.zip b/fitnesse/FitNesseRoot/HuntTheWumpus/ReleaseOne/PitCaverns/PlayerCanAddPitCoverToAdjacentCavern/20151218020651.zip new file mode 100644 index 0000000..66362a7 Binary files /dev/null and b/fitnesse/FitNesseRoot/HuntTheWumpus/ReleaseOne/PitCaverns/PlayerCanAddPitCoverToAdjacentCavern/20151218020651.zip differ diff --git a/fitnesse/FitNesseRoot/HuntTheWumpus/ReleaseOne/PitCaverns/PlayerCanAddPitCoverToAdjacentCavern/20151219083843.zip b/fitnesse/FitNesseRoot/HuntTheWumpus/ReleaseOne/PitCaverns/PlayerCanAddPitCoverToAdjacentCavern/20151219083843.zip new file mode 100644 index 0000000..bd1d4f9 Binary files /dev/null and b/fitnesse/FitNesseRoot/HuntTheWumpus/ReleaseOne/PitCaverns/PlayerCanAddPitCoverToAdjacentCavern/20151219083843.zip differ diff --git a/fitnesse/FitNesseRoot/HuntTheWumpus/ReleaseOne/PitCaverns/PlayerCanAddPitCoverToAdjacentCavern/content.txt b/fitnesse/FitNesseRoot/HuntTheWumpus/ReleaseOne/PitCaverns/PlayerCanAddPitCoverToAdjacentCavern/content.txt new file mode 100644 index 0000000..0696aca --- /dev/null +++ b/fitnesse/FitNesseRoot/HuntTheWumpus/ReleaseOne/PitCaverns/PlayerCanAddPitCoverToAdjacentCavern/content.txt @@ -0,0 +1,5 @@ +-!|script| +|Given Cross Map| +|Given the player is in cavern Left| +|When the player adds a pit cover to the East| +|Then a PIT_COVER_ADDED_TO_CAVERN_EAST message is given| diff --git a/fitnesse/FitNesseRoot/HuntTheWumpus/ReleaseOne/PitCaverns/PlayerCanAddPitCoverToAdjacentCavern/properties.xml b/fitnesse/FitNesseRoot/HuntTheWumpus/ReleaseOne/PitCaverns/PlayerCanAddPitCoverToAdjacentCavern/properties.xml new file mode 100644 index 0000000..55bd9cd --- /dev/null +++ b/fitnesse/FitNesseRoot/HuntTheWumpus/ReleaseOne/PitCaverns/PlayerCanAddPitCoverToAdjacentCavern/properties.xml @@ -0,0 +1,12 @@ + + +true +true +true +true +true +true +true +true +true + diff --git a/fitnesse/FitNesseRoot/HuntTheWumpus/ReleaseOne/PitCaverns/PlayerCanNotAddPitCoverOnceAdded/20151216232211.zip b/fitnesse/FitNesseRoot/HuntTheWumpus/ReleaseOne/PitCaverns/PlayerCanNotAddPitCoverOnceAdded/20151216232211.zip new file mode 100644 index 0000000..1b37b1a Binary files /dev/null and b/fitnesse/FitNesseRoot/HuntTheWumpus/ReleaseOne/PitCaverns/PlayerCanNotAddPitCoverOnceAdded/20151216232211.zip differ diff --git a/fitnesse/FitNesseRoot/HuntTheWumpus/ReleaseOne/PitCaverns/PlayerCanNotAddPitCoverOnceAdded/20151218020928.zip b/fitnesse/FitNesseRoot/HuntTheWumpus/ReleaseOne/PitCaverns/PlayerCanNotAddPitCoverOnceAdded/20151218020928.zip new file mode 100644 index 0000000..77b1208 Binary files /dev/null and b/fitnesse/FitNesseRoot/HuntTheWumpus/ReleaseOne/PitCaverns/PlayerCanNotAddPitCoverOnceAdded/20151218020928.zip differ diff --git a/fitnesse/FitNesseRoot/HuntTheWumpus/ReleaseOne/PitCaverns/PlayerCanNotAddPitCoverOnceAdded/20151218021119.zip b/fitnesse/FitNesseRoot/HuntTheWumpus/ReleaseOne/PitCaverns/PlayerCanNotAddPitCoverOnceAdded/20151218021119.zip new file mode 100644 index 0000000..c997434 Binary files /dev/null and b/fitnesse/FitNesseRoot/HuntTheWumpus/ReleaseOne/PitCaverns/PlayerCanNotAddPitCoverOnceAdded/20151218021119.zip differ diff --git a/fitnesse/FitNesseRoot/HuntTheWumpus/ReleaseOne/PitCaverns/PlayerCanNotAddPitCoverOnceAdded/content.txt b/fitnesse/FitNesseRoot/HuntTheWumpus/ReleaseOne/PitCaverns/PlayerCanNotAddPitCoverOnceAdded/content.txt new file mode 100644 index 0000000..267d64f --- /dev/null +++ b/fitnesse/FitNesseRoot/HuntTheWumpus/ReleaseOne/PitCaverns/PlayerCanNotAddPitCoverOnceAdded/content.txt @@ -0,0 +1,7 @@ +-!|script| +|Given Cross Map| +|Given the player is in cavern Middle| +|When the player adds a pit cover to the East| +|Then a PIT_COVER_ADDED_TO_CAVERN_EAST message is given| +|When the player adds a pit cover to the West| +|Then a NO_PIT_COVER message is given| diff --git a/fitnesse/FitNesseRoot/HuntTheWumpus/ReleaseOne/PitCaverns/PlayerCanNotAddPitCoverOnceAdded/properties.xml b/fitnesse/FitNesseRoot/HuntTheWumpus/ReleaseOne/PitCaverns/PlayerCanNotAddPitCoverOnceAdded/properties.xml new file mode 100644 index 0000000..55bd9cd --- /dev/null +++ b/fitnesse/FitNesseRoot/HuntTheWumpus/ReleaseOne/PitCaverns/PlayerCanNotAddPitCoverOnceAdded/properties.xml @@ -0,0 +1,12 @@ + + +true +true +true +true +true +true +true +true +true + diff --git a/fitnesse/FitNesseRoot/HuntTheWumpus/ReleaseOne/PitCaverns/PlayerCanNotAddPitCoverToNonAdjacentCavern/20151216232211.zip b/fitnesse/FitNesseRoot/HuntTheWumpus/ReleaseOne/PitCaverns/PlayerCanNotAddPitCoverToNonAdjacentCavern/20151216232211.zip new file mode 100644 index 0000000..e5495c8 Binary files /dev/null and b/fitnesse/FitNesseRoot/HuntTheWumpus/ReleaseOne/PitCaverns/PlayerCanNotAddPitCoverToNonAdjacentCavern/20151216232211.zip differ diff --git a/fitnesse/FitNesseRoot/HuntTheWumpus/ReleaseOne/PitCaverns/PlayerCanNotAddPitCoverToNonAdjacentCavern/20151218020538.zip b/fitnesse/FitNesseRoot/HuntTheWumpus/ReleaseOne/PitCaverns/PlayerCanNotAddPitCoverToNonAdjacentCavern/20151218020538.zip new file mode 100644 index 0000000..b5ede74 Binary files /dev/null and b/fitnesse/FitNesseRoot/HuntTheWumpus/ReleaseOne/PitCaverns/PlayerCanNotAddPitCoverToNonAdjacentCavern/20151218020538.zip differ diff --git a/fitnesse/FitNesseRoot/HuntTheWumpus/ReleaseOne/PitCaverns/PlayerCanNotAddPitCoverToNonAdjacentCavern/content.txt b/fitnesse/FitNesseRoot/HuntTheWumpus/ReleaseOne/PitCaverns/PlayerCanNotAddPitCoverToNonAdjacentCavern/content.txt new file mode 100644 index 0000000..d97c889 --- /dev/null +++ b/fitnesse/FitNesseRoot/HuntTheWumpus/ReleaseOne/PitCaverns/PlayerCanNotAddPitCoverToNonAdjacentCavern/content.txt @@ -0,0 +1,5 @@ +-!|script| +|Given Cross Map| +|Given the player is in cavern FarLeft| +|When the player adds a pit cover to the West| +|Then a CAVERN_NOT_ADJACENT_FOR_PIT_COVER message is given| diff --git a/fitnesse/FitNesseRoot/HuntTheWumpus/ReleaseOne/PitCaverns/PlayerCanNotAddPitCoverToNonAdjacentCavern/properties.xml b/fitnesse/FitNesseRoot/HuntTheWumpus/ReleaseOne/PitCaverns/PlayerCanNotAddPitCoverToNonAdjacentCavern/properties.xml new file mode 100644 index 0000000..55bd9cd --- /dev/null +++ b/fitnesse/FitNesseRoot/HuntTheWumpus/ReleaseOne/PitCaverns/PlayerCanNotAddPitCoverToNonAdjacentCavern/properties.xml @@ -0,0 +1,12 @@ + + +true +true +true +true +true +true +true +true +true + diff --git a/fitnesse/FitNesseRoot/HuntTheWumpus/ReleaseOne/PitCaverns/PlayerVisitsAdjacentCavernWithPitAndPitCoverAndLives/20151216232211.zip b/fitnesse/FitNesseRoot/HuntTheWumpus/ReleaseOne/PitCaverns/PlayerVisitsAdjacentCavernWithPitAndPitCoverAndLives/20151216232211.zip new file mode 100644 index 0000000..48c368a Binary files /dev/null and b/fitnesse/FitNesseRoot/HuntTheWumpus/ReleaseOne/PitCaverns/PlayerVisitsAdjacentCavernWithPitAndPitCoverAndLives/20151216232211.zip differ diff --git a/fitnesse/FitNesseRoot/HuntTheWumpus/ReleaseOne/PitCaverns/PlayerVisitsAdjacentCavernWithPitAndPitCoverAndLives/20151218021401.zip b/fitnesse/FitNesseRoot/HuntTheWumpus/ReleaseOne/PitCaverns/PlayerVisitsAdjacentCavernWithPitAndPitCoverAndLives/20151218021401.zip new file mode 100644 index 0000000..73ae5fa Binary files /dev/null and b/fitnesse/FitNesseRoot/HuntTheWumpus/ReleaseOne/PitCaverns/PlayerVisitsAdjacentCavernWithPitAndPitCoverAndLives/20151218021401.zip differ diff --git a/fitnesse/FitNesseRoot/HuntTheWumpus/ReleaseOne/PitCaverns/PlayerVisitsAdjacentCavernWithPitAndPitCoverAndLives/20151218021459.zip b/fitnesse/FitNesseRoot/HuntTheWumpus/ReleaseOne/PitCaverns/PlayerVisitsAdjacentCavernWithPitAndPitCoverAndLives/20151218021459.zip new file mode 100644 index 0000000..c1ba3fe Binary files /dev/null and b/fitnesse/FitNesseRoot/HuntTheWumpus/ReleaseOne/PitCaverns/PlayerVisitsAdjacentCavernWithPitAndPitCoverAndLives/20151218021459.zip differ diff --git a/fitnesse/FitNesseRoot/HuntTheWumpus/ReleaseOne/PitCaverns/PlayerVisitsAdjacentCavernWithPitAndPitCoverAndLives/content.txt b/fitnesse/FitNesseRoot/HuntTheWumpus/ReleaseOne/PitCaverns/PlayerVisitsAdjacentCavernWithPitAndPitCoverAndLives/content.txt new file mode 100644 index 0000000..b4f53ea --- /dev/null +++ b/fitnesse/FitNesseRoot/HuntTheWumpus/ReleaseOne/PitCaverns/PlayerVisitsAdjacentCavernWithPitAndPitCoverAndLives/content.txt @@ -0,0 +1,7 @@ +-!|script| +|Given Cross Map| +|Given the Middle cavern has a pit| +|Given the player is in cavern Left| +|When the player adds a pit cover to the East| +|When the player goes East| +|Then a FELL_IN_PIT message is not given| diff --git a/fitnesse/FitNesseRoot/HuntTheWumpus/ReleaseOne/PitCaverns/PlayerVisitsAdjacentCavernWithPitAndPitCoverAndLives/properties.xml b/fitnesse/FitNesseRoot/HuntTheWumpus/ReleaseOne/PitCaverns/PlayerVisitsAdjacentCavernWithPitAndPitCoverAndLives/properties.xml new file mode 100644 index 0000000..55bd9cd --- /dev/null +++ b/fitnesse/FitNesseRoot/HuntTheWumpus/ReleaseOne/PitCaverns/PlayerVisitsAdjacentCavernWithPitAndPitCoverAndLives/properties.xml @@ -0,0 +1,12 @@ + + +true +true +true +true +true +true +true +true +true + diff --git a/fitnesse/FitNesseRoot/HuntTheWumpus/ScenarioLibrary/content.txt b/fitnesse/FitNesseRoot/HuntTheWumpus/ScenarioLibrary/content.txt index eb14300..2cad4ed 100644 --- a/fitnesse/FitNesseRoot/HuntTheWumpus/ScenarioLibrary/content.txt +++ b/fitnesse/FitNesseRoot/HuntTheWumpus/ScenarioLibrary/content.txt @@ -15,6 +15,9 @@ |scenario|Given the _ cavern has a pit|cavern| |set cavern|@cavern|as pit| +|scenario|When the player adds a pit cover to the|dir| +|add pit cover|@dir| + !3 Player Scenarios |scenario|Given the player is in cavern|c| diff --git a/fitnesse/FitNesseRoot/RecentChanges/20151216232211.zip b/fitnesse/FitNesseRoot/RecentChanges/20151216232211.zip new file mode 100644 index 0000000..1cafebd Binary files /dev/null and b/fitnesse/FitNesseRoot/RecentChanges/20151216232211.zip differ diff --git a/fitnesse/FitNesseRoot/RecentChanges/20151217213807.zip b/fitnesse/FitNesseRoot/RecentChanges/20151217213807.zip new file mode 100644 index 0000000..b685021 Binary files /dev/null and b/fitnesse/FitNesseRoot/RecentChanges/20151217213807.zip differ diff --git a/fitnesse/FitNesseRoot/RecentChanges/20151217222400.zip b/fitnesse/FitNesseRoot/RecentChanges/20151217222400.zip new file mode 100644 index 0000000..7e1ebf7 Binary files /dev/null and b/fitnesse/FitNesseRoot/RecentChanges/20151217222400.zip differ diff --git a/fitnesse/FitNesseRoot/RecentChanges/20151219084224.zip b/fitnesse/FitNesseRoot/RecentChanges/20151219084224.zip new file mode 100644 index 0000000..51880aa Binary files /dev/null and b/fitnesse/FitNesseRoot/RecentChanges/20151219084224.zip differ diff --git a/fitnesse/FitNesseRoot/RecentChanges/content.txt b/fitnesse/FitNesseRoot/RecentChanges/content.txt index 9bb9367..e09742d 100644 --- a/fitnesse/FitNesseRoot/RecentChanges/content.txt +++ b/fitnesse/FitNesseRoot/RecentChanges/content.txt @@ -1,4 +1,11 @@ -|HuntTheWumpus.ScenarioLibrary||13:46:54 Wed, Nov 11, 2015| +|HuntTheWumpus.ReleaseOne.PitCaverns.PlayerCanNotAddPitCoverOnceAdded||08:43:44 Sat, Dec 19, 2015| +|HuntTheWumpus.ReleaseOne.PitCaverns.PlayerCanAddPitCoverToAdjacentCavern||08:42:24 Sat, Dec 19, 2015| +|HuntTheWumpus.ReleaseOne.PitCaverns.PlayerVisitsAdjacentCavernWithPitAndPitCoverAndLives||02:16:26 Fri, Dec 18, 2015| +|HuntTheWumpus.ReleaseOne.PitCaverns.PlayerCanNotAddPitCoverToNonAdjacentCavern||02:08:05 Fri, Dec 18, 2015| +|HuntTheWumpus.ScenarioLibrary||02:06:27 Fri, Dec 18, 2015| +|HuntTheWumpus.ReleaseOne.HuntingWithArrows.PlayerCanNotShootWithoutArrows||22:27:02 Thu, Dec 17, 2015| +|HuntTheWumpus.ReleaseOne.HuntingWithArrows.ArrowsAccumulateInFarthestCavern||21:38:52 Thu, Dec 17, 2015| +|HuntTheWumpus.ReleaseOne.HuntingWithArrows.ArrowKillsWumpus||24:06:08 Thu, Dec 17, 2015| |HuntTheWumpus.ReleaseOne.PlayerRecievesStatusAfterEachTurn.AvailablePassagesAreReported||11:59:47 Tue, Oct 13, 2015| |HuntTheWumpus.ReleaseOne.PitCaverns.PlayerIsInformedAboutFallingIntoPit||06:57:44 Tue, Oct 13, 2015| |HuntTheWumpus.ReleaseOne.PitCaverns||06:55:37 Tue, Oct 13, 2015| @@ -15,13 +22,10 @@ |HuntTheWumpus.SetUp||09:21:04 Fri, Oct 09, 2015| |HuntTheWumpus.ReleaseOne.WumpusKillsPlayer.WumpusMovesToPlayer||09:16:17 Fri, Oct 09, 2015| |HuntTheWumpus.ReleaseOne.HuntingWithArrows.AfterShootingPlayersArrowLeavesQuiverAndLandsInFarthestCavern||09:08:42 Fri, Oct 09, 2015| -|HuntTheWumpus.ReleaseOne.HuntingWithArrows.ArrowKillsWumpus||09:08:05 Fri, Oct 09, 2015| -|HuntTheWumpus.ReleaseOne.HuntingWithArrows.ArrowsAccumulateInFarthestCavern||09:07:49 Fri, Oct 09, 2015| |HuntTheWumpus.ReleaseOne.WumpusKillsPlayer.PlayerMovesIntoWumpus||09:04:35 Fri, Oct 09, 2015| |HuntTheWumpus.ReleaseOne.WumpusKillsPlayer||08:59:43 Fri, Oct 09, 2015| |HuntTheWumpus.WumpusKillsPlayer||08:58:56 Fri, Oct 09, 2015| |HuntTheWumpus.ReleaseOne.HuntingWithArrows.PlayerKilledByShootingInCircle||08:40:30 Fri, Oct 09, 2015| -|HuntTheWumpus.ReleaseOne.HuntingWithArrows.PlayerCanNotShootWithoutArrows||11:42:17 Thu, Oct 08, 2015| |HuntTheWumpus.ReleaseOne.HuntingWithArrows||11:36:42 Thu, Oct 08, 2015| |HuntTheWumpus.ReleaseOne.WumpusMovesRandomlyEachTurn||10:52:50 Thu, Oct 08, 2015| |HuntTheWumpus.ReleaseOne.PlayerRecievesStatusAfterEachTurn||12:38:11 Tue, Oct 06, 2015|