public void Validate_PlayerIsCurrent_ReturnsFalse() { GoFishGame game = GameProvider.Game; Player player = game.Players[0]; GiveCardsGameAction ga = new GiveCardsGameAction(new HashSet <Card>(player.Cards.Take(1)), player); Game.Lib.Result result = ga.Validate(game); Assert.IsFalse(result.Success); }
public void Validate_PlayerDoesNotHaveCard_ReturnsFalse() { GoFishGame game = GameProvider.Game; Player player = game.Players[1]; HashSet <Card> cards = new HashSet <Card>(player.Cards.Skip(1).Append(game.Deck.First())); GiveCardsGameAction ga = new GiveCardsGameAction(cards, player); Game.Lib.Result result = ga.Validate(game); Assert.IsFalse(result.Success); }
public void Validate_NotallOfSameCollection_ReturnsFalse() { GoFishGame game = GameProvider.Game; game.RuleSet.GiveCardBehaviour = GiveCardBehaviour.AllOfCollection; Player player = game.Players[1]; GiveCardsGameAction ga = new GiveCardsGameAction(player.Cards, player); Game.Lib.Result result = ga.Validate(game); Assert.IsFalse(result.Success); }
public void Validate_ValidSingle_ReturnsTrue() { GoFishGame game = GameProvider.Game; game.RuleSet.GiveCardBehaviour = GiveCardBehaviour.Single; Player player = game.Players[1]; HashSet <Card> cards = new HashSet <Card>(player.Cards.Where(c => c.Collection == "C4").Take(1)); GiveCardsGameAction ga = new GiveCardsGameAction(cards, player); Game.Lib.Result result = ga.Validate(game); Assert.IsTrue(result.Success); }
public void Validate_AllOfCollectionNotAllGiven_ReturnsFalse() { GoFishGame game = GameProvider.Game; game.RuleSet.GiveCardBehaviour = GiveCardBehaviour.AllOfCollection; Player player = game.Players[1]; HashSet <Card> cards = new HashSet <Card>(player.Cards.Where(c => c.Collection.Equals("C4")).Take(1)); GiveCardsGameAction ga = new GiveCardsGameAction(cards, player); Game.Lib.Result result = ga.Validate(game); Assert.IsFalse(result.Success); }
public Result Give(IEnumerable <CardViewModel> cards) { GoFishGame game = _gameAccessor.Game; Guid sourceGuid = _userContextProvider.UserId; Player sourcePlayer = game.Players.FirstOrDefault(p => p.Id.Equals(sourceGuid)); HashSet <Card> cardset = new HashSet <Card>(cards.Select(c1 => sourcePlayer.Cards.FirstOrDefault(c => c.Collection.Equals(c1.Collection) && c.Index.Equals(c1.Index)))); GiveCardsGameAction gameAction = new GiveCardsGameAction(cardset, sourcePlayer); Result result = _gameManager.PerformAction(gameAction, ref game); return(result); }
public void Apply_Valid_GivesCardToCurrentPlayer() { GoFishGame game = GameProvider.Game; game.RuleSet.GiveCardBehaviour = GiveCardBehaviour.Single; Player player = game.Players[1]; HashSet <Card> cards = new HashSet <Card>(player.Cards.Where(c => c.Collection == "C4").Take(1)); GiveCardsGameAction ga = new GiveCardsGameAction(cards, player); ga.Perform(ref game); CollectionAssert.Contains(game.CurrentPlayer.Cards, cards.First()); CollectionAssert.DoesNotContain(game.Players[1].Cards, cards.First()); }