private static void FillData(PlayerBase[] players) { for (int i = 0; i < 3; i++) { PlayerBase player; if (i % 2 == 0) { player = new OrdinaryPlayer { Name = $"player - {i}", PlayerType = PlayerType.Ordinary }; } else { player = new CheaterPlayer { Name = $"player - {i}", PlayerType = PlayerType.Cheater }; } players[i] = player; } }
static void Main(string[] args) { //Basket basket = new Basket(); //Console.WriteLine(basket); var firstPlayer = new RegularPlayer(EnumTypesOfPlayer.RegularPlayer, "Ulua_1"); Library.GetNewVariant(firstPlayer); var secondPlayer = new NotepadPlayer(EnumTypesOfPlayer.NotepadPlayer, "Anisia_2"); //Library.GetNewVariant(secondPlayer); var thirdPlayer = new UberPlayer(EnumTypesOfPlayer.UberPlayer, "Petr_3"); //Library.GetNewVariant(thirdPlayer); var fourthPlayer = new UberCheaterPlayer(EnumTypesOfPlayer.UberCheaterPlayer, "Petya_3"); //Library.GetNewVariant(fourthPlayer); var fifthPlayer = new CheaterPlayer(EnumTypesOfPlayer.CheaterPlayer, "Pavel"); //Library.GetNewVariant(fifthPlayer); var sixPlayer = new UberCheaterPlayer(EnumTypesOfPlayer.UberCheaterPlayer, "Mama"); //Library.GetNewVariant(sixPlayer); var sevenPlayer = new RegularPlayer(EnumTypesOfPlayer.RegularPlayer, "Papa"); Console.WriteLine("\n\tЛист игроков"); for (int i = 0; i < AllLists.allPlayers.Count; i++) { Console.WriteLine(" " + AllLists.allPlayers[i] + " "); } Console.WriteLine(); Library.ChangeConsole(-25, 2); Library.Game(); }
public static DefaultPlayer CreatePlayer() { var random = new Random(); PlayerId++; DefaultPlayer newPlayer = null; switch (random.Next(1, 5)) { case 1: newPlayer = new CheaterPlayer(PlayerNameGenerator.GetNextPlayerName(), PlayerId); break; case 2: newPlayer = new MemoryPlayer(PlayerNameGenerator.GetNextPlayerName(), PlayerId); break; case 3: newPlayer = new RandomPlayer(PlayerNameGenerator.GetNextPlayerName(), PlayerId); break; case 4: newPlayer = new ThoroughCheaterPlayer(PlayerNameGenerator.GetNextPlayerName(), PlayerId); break; case 5: newPlayer = new ThoroughPlayer(PlayerNameGenerator.GetNextPlayerName(), PlayerId); break; } _playersList.Add(newPlayer); return(newPlayer); }
public void AddPlayer(string name, Skills.SkillsPlayerEnum skills) { switch (skills) { case Skills.SkillsPlayerEnum.REGULARPLAYER: BasePlayer playerReg = new RegPlayer(name, 40, 140); this.NewRun += playerReg.NewRun; players.Add(playerReg); break; case Skills.SkillsPlayerEnum.NOTEPADPLAYER: BasePlayer playerNote = new NotepadPlayer(history, name, 40, 140); this.NewRun += playerNote.NewRun; players.Add(playerNote); break; case Skills.SkillsPlayerEnum.UBERPLAYER: BasePlayer playerUber = new UberPlayer(name, 40, 140); this.NewRun += playerUber.NewRun; players.Add(playerUber); break; case Skills.SkillsPlayerEnum.CHEATER: BasePlayer playerCheat = new CheaterPlayer(history, name, 40, 140); this.NewRun += playerCheat.NewRun; players.Add(playerCheat); break; case Skills.SkillsPlayerEnum.UBERCHEATER: BasePlayer playerUCheat = new UberCheatPlayer(history, name, 40, 140); this.NewRun += playerUCheat.NewRun; players.Add(playerUCheat); break; } }
public void PlayerRememberOtherPlayersGuessing() { //given var knowNumbersStub = MockRepository.GenerateStub <IKnowNumbers>(); knowNumbersStub.Stub(x => x.RememberNumbers(1)); var player = new CheaterPlayer(knowNumbersStub); //when player.NewNumberGuessed(45); //then knowNumbersStub.AssertWasCalled(x => x.RememberNumbers(1)); }
public void PlayerShouldGuessRandomNumbersBetweenSpecifiedRange() { //given var player = new CheaterPlayer(); //when var newNumber = player.GuessNumber(); //then Assert.That(newNumber, Is.GreaterThan(40)); Assert.That(newNumber, Is.LessThan(140)); //and when newNumber = player.GuessNumber(); //then Assert.That(newNumber, Is.GreaterThan(40)); Assert.That(newNumber, Is.LessThan(140)); }
public void PlayerDontRememberOwnGuess() { //given var knowNumbersStub = MockRepository.GenerateStub <IKnowNumbers>(); knowNumbersStub.Stub(x => x.RememberNumbers(1)); var player = new CheaterPlayer(knowNumbersStub); player.GuessNumber(); player.NewNumberGuessed(41); //then knowNumbersStub.AssertWasCalled(x => x.RememberNumbers(1)); var newNumber = player.GuessNumber(); //then //for this test I generate numbers in order Assert.That(newNumber, Is.EqualTo(42)); }
public static Player Start() { Player player = null; bool flag = true; int tryCounter; while (flag) { foreach (Player playerF in _Players) { switch (playerF.Type) { case "Обычный": IGame regularPlayer = new RegularPlayer(playerF.Name); _result = regularPlayer.Play(); _regularPlayerStats.Add(_result); player = playerF; break; case "Игрок-блокнот": IGame notePlayer = new NotePlayer(playerF.Name); _result = notePlayer.Play(); _notePlayerStats.Add(_result); player = playerF; break; case "Убер-игрок": IGame uberPlayer = new UberPlayer(playerF.Name); _result = uberPlayer.Play(); _uberPlayerStats.Add(_result); player = playerF; break; case "Читер": IGame cheaterPlayer = new CheaterPlayer(playerF.Name); _result = cheaterPlayer.Play(); _cheaterPlayerStats.Add(_result); player = playerF; break; case "Убер-читер": IGame uberCheaterPlayer = new UberCheaterPlayer(playerF.Name); _result = uberCheaterPlayer.Play(); _uberCheaterPlayerStats.Add(_result); player = playerF; break; } _tryCounter++; if (_tryCounter >= 100) { flag = false; player = null; break; } if (_result == _bucketWeight) { flag = false; break; } } } return(player); }
private void SetPlayersNamesAndTypes(int numberOfPlayers) { Console.WriteLine("Enter players \"Name\" and choose players types"); Console.WriteLine("Player types are:"); Console.WriteLine("1. Random player"); Console.WriteLine("2. Memory player"); Console.WriteLine("3. Thorough player"); Console.WriteLine("4. Cheater player"); Console.WriteLine("5. Thorough Cheater player"); for (int i = 0; i < numberOfPlayers; i++) { bool isCorrectPlayerInput = false; while (!isCorrectPlayerInput) { try { Console.Write("Enter Player {0} name: ", i + 1); string name = Console.ReadLine(); Console.Write("Choose type for player {0} [1 to 5]: ", i + 1); int playerTypeInput = int.Parse(Console.ReadLine()); if (playerTypeInput < 1 || 5 < playerTypeInput) { throw new FormatException("Player type must be between 1 and 5!"); } switch (playerTypeInput) { case 1: { RandomPlayer newPlayer = new RandomPlayer(name, new CustomRandom()); this.players.Add(newPlayer); break; } case 2: { MemoryPlayer newPlayer = new MemoryPlayer(name, new CustomRandom()); this.players.Add(newPlayer); break; } case 3: { ThoroughPlayer newPlayer = new ThoroughPlayer(name); this.players.Add(newPlayer); break; } case 4: { CheaterPlayer newPlayer = new CheaterPlayer(name, new CustomRandom()); this.players.Add(newPlayer); break; } case 5: { ThoroughCheaterPlayer newPlayer = new ThoroughCheaterPlayer(name); this.players.Add(newPlayer); break; } default: break; } isCorrectPlayerInput = true; } catch (FormatException ex) { Console.WriteLine(ex.Message); } catch (ArgumentNullException ex) { Console.WriteLine(ex.Message); } } } }