public void CanPlayTrumperOnlyIfDontHaveSameColorInHand(List <Card> playedCards) { PlayerService ps = new PlayerService(); Player player = ps.CreatePlayer("ASD", true, true); RoundService rs = new RoundService(true, new List <Player>() { player }); Card queenHearts = new Card("hearts", 13); Card eighteenTrumper = new Card("trumpers", 18); player.Hand = new List <object> { eighteenTrumper, queenHearts, new Card("spades", 1) }; List <Card> playableCards = rs.GetPlayableCardsForPlayer(player, playedCards).ToList(); Assert.That(playableCards.Count, Is.EqualTo(1)); Assert.That(playableCards.First(), Is.EqualTo(queenHearts)); player.Hand.Remove(queenHearts); playableCards = rs.GetPlayableCardsForPlayer(player, playedCards).ToList(); Assert.That(playableCards.Count, Is.EqualTo(1)); Assert.That(playableCards.First(), Is.EqualTo(eighteenTrumper)); }
public void ExcusePlayedFirstMakesColorMustFollowSecondCard(string secondCardColor, int secondCardRank) { PlayerService ps = new PlayerService(); Player player = ps.CreatePlayer("ASdASd", false, false); RoundService rs = new RoundService(true, new List <Player>() { player }); Card excuse = new Card("trumpers", 0); Card secondCardPlayed = new Card(secondCardColor, secondCardRank); Card expectedOnlyPlayableCard = new Card(secondCardColor, 14); player.Hand = new List <object>() { new Card("hearts", 2), new Card("spades", 4), expectedOnlyPlayableCard }; List <Card> playedCards = new List <Card>() { excuse, secondCardPlayed }; List <Card> playableCards = rs.GetPlayableCardsForPlayer(player, playedCards).ToList(); Assert.That(playableCards.Count, Is.EqualTo(1)); Assert.That(playableCards.First(), Is.EqualTo(expectedOnlyPlayableCard)); }
public ActionResult UpdateRound(Round round) { Round newRound = RoundService.UpdateRound(round); ViewBag.IdRound = newRound.idRound; return(View()); }
public void InitializeServices() { this.hubService = new Mock <ISignalRHubService>(); this.userService = new UserService(this.users); this.roomService = new RoomService(this.hubService.Object, this.rooms, this.users); this.roundService = new RoundService(this.hubService.Object, new TimerService(), this.rooms, this.rounds, this.users, this.decks); }
public void Go() { string name1 = "Player 1"; string name2 = "Player 2"; var messageService = new Mock <IMessageService>(); var turnService = new Mock <ITurnService>(); var resultsService = new ResultsService(); var roundService = new RoundService(resultsService); IPlayer[] players = new IPlayer[2] { new Human(turnService.Object) { Name = name1 }, new Human(turnService.Object) { Name = name2 } }; for (var i = 0; i < 4; i++) { messageService.Setup(e => e.ReadPlayerChoice()).Returns(i.ToString()); int result = roundService.Go(players); Assert.IsTrue(result == -1); } }
public void MustPlayHigherTrumperIfTrumperPlayed() { PlayerService ps = new PlayerService(); Player player = ps.CreatePlayer("ASD", true, true); RoundService rs = new RoundService(true, new List <Player>() { player }); Card eighteenTrumper = new Card("trumpers", 18); player.Hand = new List <object> { new Card("trumpers", 8), eighteenTrumper, new Card("spades", 14) }; List <Card> playedCards = new List <Card>() { new Card("hearts", 14), new Card("trumpers", 9), }; List <Card> playableCards = rs.GetPlayableCardsForPlayer(player, playedCards).ToList(); Assert.That(playableCards.Count, Is.EqualTo(1)); Assert.That(playableCards.First(), Is.EqualTo(eighteenTrumper)); }
public RoundServiceFixture() { _dataStore = new Mock <IDataStore>(); _dataStore.Setup(x => x.GetUserBySimpleIdAsync(It.IsAny <string>())).ReturnsAsync(new User()); _service = new RoundService(); }
public Round(DeckService deckService,Player human,Player computer) { CounterRound = 0; Human = human; Computer = computer; RoundService = new RoundService(deckService,this); Winner = "Nobody"; Loser = "Nobody"; }
public void DoGame() { Output.ShowSomeOutput(TextCuts.StartGame); Output.ShowSomeOutput(TextCuts.EnterName); GameService gameService = new GameService(); RoundService roundService = new RoundService(); string userName = Input.InputString(); Output.ShowSomeOutput(TextCuts.HowManyBots, Settings.MaxBots); int howManyBots = Input.InputInt(Settings.MinBots, Settings.MaxBots); Output.ShowSomeOutput(TextCuts.EnterValidRate, Settings.MinRateForGamer, Settings.MaxRateForGamer); int rate = Input.InputInt(Settings.MinRateForGamer, Settings.MaxRateForGamer); Output.ShowSomeOutput(TextCuts.ShowStartRaund); var GameInfo = new GameInfoModel { UserName = userName, UserRate = rate, HowManyBots = howManyBots }; GamerView gamer = gameService.PrepareGame(GameInfo); Output.ShowAllGamerCards(gamer); Output.ShowSomeOutput(TextCuts.NowYouHave + gamer.Points); bool isAnswer = true; string gamerAnswer; while (isAnswer) { Output.ShowSomeOutput(TextCuts.DoYouWantCard); gamerAnswer = Input.InputString(); if (gamerAnswer == Settings.YesAnswer && gamer.Status != GamerViewStatus.Enough) { gamer = roundService.GiveCardToTheRealPlayer(); Output.ShowAllGamerCards(gamer); Output.ShowSomeOutput(TextCuts.NowYouHave + gamer.Points); } if (gamerAnswer != Settings.YesAnswer || gamer.Status == GamerViewStatus.Many) { isAnswer = false; gameService.GamerSayEnaugh(); } } List <GamerView> finalResult = roundService.DoRoundForAllGamerWithResult(); Output.ShowFinishResult(finalResult); gameService.WriteHistoryInFile(); Console.ReadKey(); }
public void Setup() { var dbContextoptions = new DbContextOptionsBuilder <ModelContext>().UseInMemoryDatabase("TestDB"); db = new ModelContext(dbContextoptions.Options); db.Database.EnsureCreated(); context = MockHubContext.GetContext; round = new RoundService((IHubContext <RoomsHub>)context, db); }
protected override async Task OnInitializedAsync() { try { AllRounds = await RoundService.GetRounds(); } catch (Exception e) { Console.WriteLine(e.Message); } }
// // GET: /Home/ public ActionResult Index() { List <Round> listRound = RoundService.GetAllRound(); foreach (Round round in listRound) { List <Video> listVideo = VideoService.GetAllVideosByMost(round.idRound); round.Videos = listVideo; } return(View(listRound)); }
internal static void Main(string[] args) { RoundService roundService = new RoundService(); TaxRuleService taxRuleService = new TaxRuleService(roundService); EmployeeIncomeService employeeIncomeService = new EmployeeIncomeService(taxRuleService, roundService); var employeeList = GetEmployeeInfos(); OutputToFile(employeeList, employeeIncomeService); }
public void RoundRotatesRightAndLeftCheck() { PlayerService ps = new PlayerService(); List <Player> roundPlayers = PlayerGenerator(3).ToList(); ps.MakeDealer(roundPlayers[2]); RoundService roundLeft = new RoundService(true, roundPlayers); RoundService roundRight = new RoundService(false, roundPlayers); string nextNameWhenLeft = roundLeft.NextPlayer().Name; string nextNameWhenRight = roundRight.NextPlayer().Name; Assert.That(nextNameWhenLeft, Is.Not.EqualTo(nextNameWhenRight)); Assert.That(nextNameWhenLeft, Is.EqualTo("Prosper_0")); Assert.That(nextNameWhenRight, Is.EqualTo("Prosper_1")); }
public void PlayOneGame(int nbPlayers) { DealingRules dealingRules = new DealingRules(); BettingService bettingService = new BettingService(); PlayerService playerService = new PlayerService(); List <Player> players = playerService.CreatePlayers(Musketeers().Take(nbPlayers)).ToList(); DealingService dealingService = new DealingService(false, players); RoundService roundService = new RoundService(false, players); Player dealer = players.First(); dealer.Dealer = true; dealingService.DealsAllCardsFromDeck(); Assert.That(dealingService.NbPlayers(), Is.EqualTo(nbPlayers)); Assert.That(dealingService.CountAside(), Is.EqualTo(dealingRules.AsideMaxCards(nbPlayers))); Assert.NotNull(dealingService.GetDealer()); Assert.Zero(dealingService.GetRoundNumber()); Assert.That(dealingService.DealtAsideIsCorrect(), Is.True); foreach (Player player in players) { Assert.That(player.Hand.Count == players.First().Hand.Count); Assert.That(player.Contract.ToString(), Is.EqualTo("pass")); } bettingService.GatherBets(players); bettingService.AuctionIsWon(dealingService); Player attacker = bettingService.GetWinningBet().Key; playerService.MakeAside(attacker, dealingService.NbCardsInAside()); // Put this in dealing service ? // Game is ready to start when: Assert.That(attacker.Hand.Count, Is.EqualTo(players.First(x => x.Attacker is false).Hand.Count)); Assert.That(attacker.WonHands.Count, Is.EqualTo(dealingRules.AsideMaxCards(nbPlayers))); Assert.Zero(dealingService.GetRoundNumber()); while (dealer.Hand.Count > 0) { var round = roundService.PlayRound(); } Assert.Zero(players.Select(x => x.Hand.Count).Sum()); Assert.That(players.Select(x => x.WonHands.Count).Sum(), Is.EqualTo(DealingRules.MaxCardsInDeck)); Assert.That(players.Select(x => x.WonHands.Cast <Card>().Score()).Sum(), Is.EqualTo(CardCountingRules.MaxScore)); }
public void CanAlwaysPlayExcuse(List <Card> playedCards) { PlayerService ps = new PlayerService(); Player player = ps.CreatePlayer("ASD", true, true); Card excuse = new Card("trumpers", 0); player.Hand.Add(excuse); RoundService rs = new RoundService(true, new List <Player>() { player }); List <Card> playableCards = rs.GetPlayableCardsForPlayer(player, playedCards).ToList(); Assert.That(playableCards.Count, Is.EqualTo(1)); Assert.That(playableCards.First(), Is.EqualTo(excuse)); }
public void MustPlayBasicIfNoMoreTrumperAndNoFirstColorInHand(List <Card> playedCards) { PlayerService ps = new PlayerService(); Player player = ps.CreatePlayer("ASD", true, true); RoundService rs = new RoundService(true, new List <Player>() { player }); player.Hand = new List <object> { new Card("clubs", 8), new Card("spades", 1) }; List <Card> playableCards = rs.GetPlayableCardsForPlayer(player, playedCards).ToList(); Assert.That(playableCards.Count, Is.EqualTo(2)); Assert.That(playableCards, Is.EqualTo(player.Hand)); }
public void RoundFinishWithDealerAndRotateRight(Tuple <int, int> input) { int nbPlayers = input.Item1; int dealerPosition = input.Item2; PlayerService ps = new PlayerService(); List <Player> roundPlayers = PlayerGenerator(nbPlayers).ToList(); RoundService round = new RoundService(true, roundPlayers); ps.MakeDealer(roundPlayers[dealerPosition]); for (int i = dealerPosition + 1; i < nbPlayers; i++) { Assert.AreEqual(roundPlayers[i].Name, round.NextPlayer().Name); } for (int i = 0; i < dealerPosition + 1; i++) { Assert.AreEqual(roundPlayers[i].Name, round.NextPlayer().Name); } }
/// <summary> /// Конструктор класса. /// </summary> /// <param name="context">контекст бд.</param> /// <param name="roundService">сервис раундов.</param> public RoundController(RoundService roundService) { this.roundService = roundService; }
public RoundsController(RoundService roundService) { _roundService = roundService; }
/// <summary> /// Конструктор класса. /// </summary> /// <param name="context">контекст бд.</param> /// <param name="roundService">сервис раундов.</param> public RoundController(ModelContext context, RoundService roundService) { this.db = context; this.roundService = roundService; }
public void StartTest() { _mockGameRepository = new Mock <IGameRepository>(MockBehavior.Strict); _mockGamePlayerRepository = new Mock <IGamePlayerRepository>(MockBehavior.Strict); _mockPlayerCardRepository = new Mock <IPlayerCardRepository>(MockBehavior.Strict); _mockCardRepository = new Mock <ICardRepository>(MockBehavior.Strict); _mockHistoryMessageManager = new Mock <IHistoryMessageManager>(MockBehavior.Strict); var requestView = new RequestStartRoundView() { GameId = 9, IsNewRound = true }; var gamePlayers = new List <GamePlayer>() { new GamePlayer() { Player = new Player() { Type = PlayerType.Dealer }, CardScore = 10 }, new GamePlayer() { Player = new Player() { Type = PlayerType.Human }, CardScore = 10 } }; var game = new Game() { RoundResult = "" }; int cardAmount = 4; var cards = new List <Card>() { new Card() { Worth = 9 }, new Card() { Worth = 11 }, new Card() { Worth = 4 }, new Card() { Worth = 10 } }; var playerCards = new List <PlayerCard>(); int createMany = 0; _mockGamePlayerRepository.Setup(p => p.GetAllByGameId(requestView.GameId)).Returns(Task.FromResult(gamePlayers)); _mockGameRepository.Setup(p => p.Get(requestView.GameId)).Returns(Task.FromResult(game)); _mockPlayerCardRepository.Setup(p => p.CreateMany(playerCards)).Returns(Task.FromResult(createMany)); _mockCardRepository.Setup(p => p.GetSpecifiedAmount(cardAmount)).Returns(Task.FromResult(cards)); _roundService = new RoundService ( null, _mockGameRepository.Object, _mockGamePlayerRepository.Object, _mockPlayerCardRepository.Object, _mockCardRepository.Object, _mockHistoryMessageManager.Object ); ResponseStartRoundView result = _roundService.Start(requestView).Result; result.RoundResult = ""; Assert.That(result.RoundResult, Is.EqualTo("")); //_mockGameRepository.VerifyAll(); //_mockGamePlayerRepository.VerifyAll(); //_mockPlayerCardRepository.VerifyAll(); //_mockCardRepository.VerifyAll(); //_mockHistoryMessageManager.VerifyAll(); }
public void Init() { RoundService roundService = new RoundService(); this.taxRuleService = new TaxRuleService(roundService); }
public void Init() { RoundService roundService = new RoundService(); TaxRuleService taxRuleService = new TaxRuleService(roundService); this.employeeIncomeService = new EmployeeIncomeService(taxRuleService, roundService); }
public void Init() { this.roundService = new RoundService(); }