public IGameBuilderSetStartingPlayer SecondPlayerSet(IPlayerType playerType) { var player = playerType.Player; _players = _players.Add(player); _startingPlayerMapper = _startingPlayerMapper.Add(StartingPlayer.As().SecondPlayer(), player); return(this); }
public void TellThePlayerItCantPickUpANonExistentItem() { var breweryHallZone = Substitute.For <IZoneConfiguration>(); breweryHallZone.GetItem("Blue Key").ReturnsNull(); var player = new StartingPlayer(breweryHallZone, Substitute.For <ZoneSwitcher>()); var message = player.Take("Blue Key"); Assert.Equal("I can't do that here!", message.ToString()); }
public void TakeItemFromTheFloor() { var breweryHallZone = Substitute.For <IZoneConfiguration>(); breweryHallZone.GetItem("White Key").Returns(new Item("White Key")); var player = new StartingPlayer(breweryHallZone, Substitute.For <ZoneSwitcher>()); var message = player.Take("White Key"); Assert.Equal("White Key: Taken", message.ToString()); }
public void TellPlayerTheresNothingWhenLookingSouth() { var zoneConfig = Substitute.For <IZoneConfiguration>(); zoneConfig.LookAtDirection(Direction.S).Returns(new Message("Nothing interesting to look at there!")); var player = new StartingPlayer(zoneConfig, Substitute.For <IZoneSwitcher>()); var message = player.Look("S"); Assert.Equal("Nothing interesting to look at there!", message.ToString()); }
public void TellPlayerTheresADoorNorth() { var zoneConfig = Substitute.For <IZoneConfiguration>(); zoneConfig.LookAtDirection(Direction.N).Returns(new Message("I CAN SEE A BRICK BUILDING WITH A SIGN SAYING \"TRUMAN BREWERY\" AND A WOODEN WHITE DOOR")); var player = new StartingPlayer(zoneConfig, Substitute.For <IZoneSwitcher>()); var message = player.Look("N"); Assert.Equal("I CAN SEE A BRICK BUILDING WITH A SIGN SAYING \"TRUMAN BREWERY\" AND A WOODEN WHITE DOOR", message.ToString()); }
public void ShowThePlayersInventory() { var breweryHallZone = Substitute.For <IZoneConfiguration>(); breweryHallZone.GetItem("White Key").Returns(new Item("White Key")); var player = new StartingPlayer(breweryHallZone, Substitute.For <ZoneSwitcher>()); player.Take("White Key"); var bag = player.Bag(); Assert.Equal("The bag contains: A White Key", bag.ToString()); }
public void GoToTheNextZone() { var breweryHallZone = Substitute.For <IZoneConfiguration>(); var zoneSwitcher = Substitute.For <IZoneSwitcher>(); var breweryHall2Zone = Substitute.For <IZoneConfiguration>(); breweryHall2Zone.LookAtDirection().Returns(new Message("Truman Brewery Hall 2", "You are in a small room, you can see a white door in front of you.")); zoneSwitcher.GetNextZone(breweryHallZone, Direction.E).Returns(breweryHall2Zone); var player = new StartingPlayer(breweryHallZone, zoneSwitcher); var message = player.Go(Direction.E); Assert.Equal("Truman Brewery Hall 2\r\nYou are in a small room, you can see a white door in front of you.", message.ToString()); }
public void Build_SecondPlayerType_VerifySecondPlayerAdded() { var player = new MockPlayer(); var startingPlayerMapper = new MockStartingPlayerMapper().AddReturnsItself(); var players = new MockPlayers().AddReturnsItself(); var secondPlayerType = new MockPlayerType().PlayerReturns(player); var builder = BuildGameBuilder(startingPlayerMapper, players, secondPlayerType: secondPlayerType); builder.Build(); secondPlayerType.VerifyPlayerCalled(); players.VerifyAddCalled(player); startingPlayerMapper.VerifyAddCalled(StartingPlayer.As().SecondPlayer(), player); }
public void PlayerLooksSouthThenLooksNorthOpensDoorPicksUpKeysOpensBagGoesNorthFailsLooksEastGoesEastUseKeyOpenDoor() { var player = new StartingPlayer(ZoneBuilder.Build("StartingZone"), new ZoneSwitcher()); _katacombs = new Katacombs(player); _katacombs.Start(); _katacombs.Action("Look S"); _katacombs.Action("Look N"); _katacombs.Action("Open White Door"); _katacombs.Action("Take Key"); _katacombs.Action("Bag"); _katacombs.Action("Go E"); _katacombs.Action("Use Key"); var message = _katacombs.Action("Open White Door"); Assert.Equal("Inside Truman Brewery's warehouse.\r\nYou're inside a warehouse filled with rows of beer kegs. You smell the putrid odor of death.", message.ToString()); }
public void GoToNextZoneWhenOpeningADoor() { var zoneConfig = Substitute.For <IZoneConfiguration>(); zoneConfig.DoesDoorExist("White Door").Returns(true); zoneConfig.IsDoorUnlocked("White Door").Returns(true); zoneConfig.GetDoorDirection("White Door").Returns(Direction.N); var secondZoneConfig = Substitute.For <IZoneConfiguration>(); secondZoneConfig.LookAtDirection().Returns(new Message("Inside the Truman Brewery", "You are in a large room, in front of you is a big counter and to the left some beer kegs. \r\n There's a key dropped on the floor.")); var zoneSwitcher = Substitute.For <IZoneSwitcher>(); zoneSwitcher.GetNextZone(zoneConfig, Direction.N).Returns(secondZoneConfig); var player = new StartingPlayer(zoneConfig, zoneSwitcher); var message = player.Open("White Door"); Assert.Equal("Inside the Truman Brewery\r\nYou are in a large room, in front of you is a big counter and to the left some beer kegs. \r\n There's a key dropped on the floor.", message.ToString()); }
public void Run() { var game = GameBuilder .Initialize(_startingPlayerMapper, _players, _boardService) .WithBoardSize(3) .FirstPlayerSet(PlayerType.As().Human("Player", "X")) .SecondPlayerSet(PlayerType.As().Computer("Computer", "O")) .Set(StartingPlayer.As().FirstPlayer()) .Build(); do { game.Accept(new DisplayBoardVisitor()); game.Start(); game.Play(); game.CheckForWin(); game.SwitchPlayer(); game.Over(); game.PlayAgain(); game.End(); } while (game.StillGoing); }
private static StartingPlayer BuildStartingPlayerAsSecondPlayer() => StartingPlayer.As().SecondPlayer();
private static StartingPlayer BuildStartingPlayerAsFirstPlayer() => StartingPlayer.As().FirstPlayer();