private void SendChoicesOrOptions() { // getting choices mulligan choices for players ... var entityChoicesPlayer1 = PowerChoicesBuilder.EntityChoices(Game, Game.Player1.Choice); var entityChoicesPlayer2 = PowerChoicesBuilder.EntityChoices(Game, Game.Player2.Choice); // getting options for currentPlayer ... PowerAllOptions options = null; if (!Game.CurrentPlayer.Options().All(p => p.PlayerTaskType != PlayerTaskType.END_TURN)) { options = PowerOptionsBuilder.AllOptions(Game, Game.CurrentPlayer.Options()); } if (entityChoicesPlayer1 != null) { SendEntityChoices(entityChoicesPlayer1); } if (entityChoicesPlayer2 != null) { SendEntityChoices(entityChoicesPlayer2); } if (options != null) { SendOptions(options); } }
private static void ChooseOneTest() { var game = new Game(new GameConfig { StartPlayer = 1, Player1HeroClass = CardClass.DRUID, Player1Deck = new List <Card>() { Cards.FromName("Stonetusk Boar"), Cards.FromName("Bloodfen Raptor"), Cards.FromName("Raven Idol"), Cards.FromName("Living Roots"), Cards.FromName("Druid of the Saber"), Cards.FromName("Wrath"), Cards.FromName("Power of the Wild"), }, Player2HeroClass = CardClass.DRUID, Player2Deck = new List <Card>() { Cards.FromName("Stonetusk Boar"), Cards.FromName("Bloodfen Raptor"), Cards.FromName("Raven Idol"), Cards.FromName("Living Roots"), Cards.FromName("Druid of the Saber"), Cards.FromName("Wrath"), Cards.FromName("Power of the Wild"), }, SkipMulligan = true, Shuffle = false, FillDecks = true }); game.StartGame(); game.Process(PlayCardTask.Minion(game.CurrentPlayer, game.CurrentPlayer.HandZone[0])); game.Process(EndTurnTask.Any(game.CurrentPlayer)); game.Process(PlayCardTask.Minion(game.CurrentPlayer, game.CurrentPlayer.HandZone[0])); game.Process(EndTurnTask.Any(game.CurrentPlayer)); game.Process(PlayCardTask.Minion(game.CurrentPlayer, game.CurrentPlayer.HandZone[0])); game.Process(EndTurnTask.Any(game.CurrentPlayer)); game.Process(PlayCardTask.Minion(game.CurrentPlayer, game.CurrentPlayer.HandZone[0])); game.Process(EndTurnTask.Any(game.CurrentPlayer)); var options = game.CurrentPlayer.Options(); Console.WriteLine($" *** - {game.CurrentPlayer.Name} options on {game.Turn}. - ***"); options.ForEach(p => Console.WriteLine(p.FullPrint())); Console.WriteLine($" *** - PowerOptions - ***"); Console.WriteLine(PowerOptionsBuilder.AllOptions(game, options)?.Print()); //ShowLog(game, LogLevel.VERBOSE); }
public void Start() { Log.Info($"[_gameId:{_gameId}] Game creation is happening in a few seconds!!!"); var newGame = new Game(new GameConfig { //StartPlayer = 1, FormatType = FormatType.FT_STANDARD, Player1HeroClass = Cards.HeroClasses[_random.Next(9)], Player1Deck = new List <Card>(), Player2HeroClass = Cards.HeroClasses[_random.Next(9)], Player2Deck = new List <Card>(), SkipMulligan = true, Shuffle = true, FillDecks = true, Logging = true, History = true }); if (_game == null) { _game = newGame; Log.Info($"[_gameId:{_gameId}] Game creation done!"); _game.StartGame(); ProcessPowerHistoryData(1, _player1, _game.PowerHistory.Last); _powerAllOptionsPlayer1 = PowerOptionsBuilder.AllOptions(_game, _game.Player1.Options()); ProcessPowerOptionsData(1, _player1, _powerAllOptionsPlayer1); ProcessPowerHistoryData(2, _player2, _game.PowerHistory.Last); _powerAllOptionsPlayer2 = PowerOptionsBuilder.AllOptions(_game, _game.Player2.Options()); ProcessPowerOptionsData(2, _player2, _powerAllOptionsPlayer2); foreach (var historyEntry in _game.PowerHistory.Last) { //Log.Info($"{historyEntry.Print()}"); } } }
public void SendOptionsOrChoicesToPlayers() { if (_game.Player1.Choice != null) { //Log.Debug($"sending Choices to player 1"); var powerChoicesPlayer1 = PowerChoicesBuilder.EntityChoices(_game, _game.Player1.Choice); SendGameData(Player1, MsgType.InGame, true, GameDataType.PowerChoices, JsonConvert.SerializeObject(new PowerChoices() { Index = powerChoicesPlayer1.Index, ChoiceType = powerChoicesPlayer1.ChoiceType, Entities = powerChoicesPlayer1.Entities })); } else { var powerAllOptionsPlayer1 = PowerOptionsBuilder.AllOptions(_game, _game.Player1.Options()); SendGameData(Player1, MsgType.InGame, true, GameDataType.PowerOptions, JsonConvert.SerializeObject(new PowerOptions() { Index = powerAllOptionsPlayer1.Index, PowerOptionList = powerAllOptionsPlayer1.PowerOptionList })); } if (_game.Player2.Choice != null) { //Log.Debug($"sending Choices to player 2"); var powerChoicesPlayer2 = PowerChoicesBuilder.EntityChoices(_game, _game.Player2.Choice); SendGameData(Player2, MsgType.InGame, true, GameDataType.PowerChoices, JsonConvert.SerializeObject(new PowerChoices() { Index = powerChoicesPlayer2.Index, ChoiceType = powerChoicesPlayer2.ChoiceType, Entities = powerChoicesPlayer2.Entities })); } else { var powerAllOptionsPlayer2 = PowerOptionsBuilder.AllOptions(_game, _game.Player2.Options()); SendGameData(Player2, MsgType.InGame, true, GameDataType.PowerOptions, JsonConvert.SerializeObject(new PowerOptions() { Index = powerAllOptionsPlayer2.Index, PowerOptionList = powerAllOptionsPlayer2.PowerOptionList })); } }
private void SendChoicesOrOptions() { // getting choices mulligan choices for players ... PowerEntityChoices entityChoicesPlayer1 = PowerChoicesBuilder.EntityChoices(_game, _game.Player1.Choice); PowerEntityChoices entityChoicesPlayer2 = PowerChoicesBuilder.EntityChoices(_game, _game.Player2.Choice); // getting options for currentPlayer ... PowerAllOptions options = PowerOptionsBuilder.AllOptions(_game, _game.CurrentPlayer.Options()); if (entityChoicesPlayer1 != null) { SendEntityChoices(entityChoicesPlayer1); } if (entityChoicesPlayer2 != null) { SendEntityChoices(entityChoicesPlayer2); } if (options != null) { SendOptions(options); } }
private static void PowerHistoryTest() { var game = new Game(new GameConfig { StartPlayer = 1, Player1HeroClass = CardClass.DRUID, //DeckPlayer1 = new List<Card> //{ // Cards.FromName("Raven Idol") //}, Player2HeroClass = CardClass.MAGE, SkipMulligan = false, Shuffle = false, FillDecks = true }); game.StartGame(); //List<PlayerTask> options; //options = game.CurrentPlayer.Options(); //Console.WriteLine($" *** - {game.CurrentPlayer.Name} options on {game.Turn}. - ***"); //options.ForEach(p => Console.WriteLine(p.FullPrint())); //Console.WriteLine("*** - START GAME - ***"); //Console.WriteLine(game.PowerHistory.Print(false)); //Console.WriteLine("*** - MULLIGAN PLAYER 1 - ***"); //Console.WriteLine(PowerChoicesBuilder.EntityChoices(game, game.Player1.Choice).Print()); //Console.WriteLine("*** - MULLIGAN PLAYER 2 - ***"); //Console.WriteLine(PowerChoicesBuilder.EntityChoices(game, game.Player2.Choice).Print()); game.Process(ChooseTask.Mulligan(game.Player1, new List <int>(game.Player1.Choice.Choices))); //options = game.CurrentPlayer.Options(); //Console.WriteLine($" *** - {game.CurrentPlayer.Name} options on {game.Turn}. - ***"); //options.ForEach(p => Console.WriteLine(p.FullPrint())); //Console.WriteLine(game.PowerHistory.Print(false)); game.Process(ChooseTask.Mulligan(game.Player2, new List <int> { })); //options = game.CurrentPlayer.Options(); //Console.WriteLine($" *** - {game.CurrentPlayer.Name} options on {game.Turn}. - ***"); //options.ForEach(p => Console.WriteLine(p.FullPrint())); //Console.WriteLine(game.PowerHistory.Print(false)); game.MainReady(); //options = game.CurrentPlayer.Options(); //Console.WriteLine($" *** - {game.CurrentPlayer.Name} options on {game.Turn}. - ***"); //options.ForEach(p => Console.WriteLine(p.FullPrint())); //Console.WriteLine(game.PowerHistory.Print(false)); //game.Process(ConcedeTask.Any(game.CurrentPlayer)); //Console.Write("*** - CONCEDE - ***"); //Console.Write(game.PowerHistory.Print(false)); //ShowLog(game, LogLevel.VERBOSE); //Console.WriteLine(PowerOptionsBuilder.AllOptions(game.CurrentPlayer.Id, game.CurrentPlayer.Options()).Print()); //game.Process(EndTurnTask.Any(game.CurrentPlayer)); //ShowLog(game, LogLevel.VERBOSE); //Console.WriteLine(PowerOptionsBuilder.AllOptions(game.CurrentPlayer.Id, game.CurrentPlayer.Options()).Print()); while (game.State != State.COMPLETE) { var options = game.CurrentPlayer.Options(); Console.WriteLine($" *** - {game.CurrentPlayer.Name} options on {game.Turn}. - ***"); options.ForEach(p => Console.WriteLine(p.FullPrint())); Console.WriteLine(PowerOptionsBuilder.AllOptions(game, options)?.Print()); PowerChoicesBuilder.EntityChoices(game, game.CurrentPlayer.Choice); var option = options[Rnd.Next(options.Count)]; game.Process(option); } //foreach (var powerAllOptionse in game.AllOptionsMap) // Console.WriteLine($"{powerAllOptionse.Key} => {powerAllOptionse.Value.Print()}"); //foreach (var entityChoice in game.EntityChoicesMap) // Console.WriteLine($"{entityChoice.Key} => {entityChoice.Value.Print()}"); //foreach (var playables in game.IdEntityDic) //{ // Console.WriteLine($"{playables.Key} => {playables.Value}"); //} ShowLog(game, LogLevel.VERBOSE); }
public void OnOptionsBlock(KettleOptionsBlock optionsBlock) { // convert that option Console.WriteLine("AI OnOptionsBlock called."); if (optionsBlock.PlayerId != PlayerId) { return; } List <PlayerTask> options = Session.Game.CurrentPlayer.Options(); // Do AI shit PlayerTask option = DoAI(options); // Convert it to poweroptions PowerAllOptions poweroptions = PowerOptionsBuilder.AllOptions(Session.Game, new List <PlayerTask> { option }); // And create a kettle block for it KettleOption chosenoption = new KettleOptionsBlock(poweroptions, Session.Game.CurrentPlayer.PlayerId).Options[0]; int mainOptionIndex = 0; int subOptionIndex = 0; int target = 0; int position = 0; // Then we try and find the kettle option that matches foreach (KettleOption koption in optionsBlock.Options) { if (koption.Type != chosenoption.Type) { continue; } if (!OptionsMatch(chosenoption.MainOption, koption.MainOption)) { continue; } if ((chosenoption.SubOptions == null || chosenoption.SubOptions.Count == 0) != (koption.SubOptions == null || koption.SubOptions.Count == 0)) { continue; } if (chosenoption.SubOptions != null) { foreach (KettleSubOption suboption in chosenoption.SubOptions) { if (OptionsMatch(chosenoption.SubOptions[0], suboption)) { subOptionIndex = koption.SubOptions.IndexOf(suboption); break; } } } mainOptionIndex = optionsBlock.Options.IndexOf(koption); if (chosenoption.MainOption != null && chosenoption.MainOption.Targets != null) { target = chosenoption.MainOption.Targets[0]; } break; } if (option is PlayCardTask) { position = ((PlayerTask)option).ZonePosition; } KettleSendOption sendoption = new KettleSendOption(); sendoption.Id = optionsBlock.Id; sendoption.MainOption = mainOptionIndex; sendoption.SubOption = subOptionIndex; sendoption.Target = target; sendoption.Position = position; Adapter.SendMessage(sendoption); }