public static void attackAIPlayer(AiPlayer target)
    {
        if (target != null) {
            Tank tank = GameManager.instance.playerList[GameManager.instance.currentPlayerIndex].GetComponent<Tank>();
            if(isTargetInRange((int)tank.gridPosition.x, (int)tank.gridPosition.y,
                               (int)target.gridPosition.x,(int)target.gridPosition.y, tank.attackRange)){
                tank.actionPoints--;

                tank.attacking = false;

                //attack logic
                //roll to hit
                bool hit = Random.Range(0.0f, 1.0f) <= tank.attackHitRate;

                if (hit) {
                    //damage logic
                    //In future damage dealt will take in account for target's defense
                    int amountOfDamage = (int)Mathf.Floor(10 + Random.Range(0, 6));

                    target.HP -= amountOfDamage;
                } else {
                    print ("Missed");
                    isMissed=true;
                }

                //GameManager.instance.nextTurn(); //After attacking end turn
            } else {
                Debug.Log ("Target is out of range!");
            }
        }
    }
        public void Activate(object parameter)
        {
            var startData = (StartData)parameter;

            var player1 = new Player {
                Id = 1, Color = startData.Player1Color
            };
            Player player2;

            switch (startData.GameType)
            {
            case GameType.Single:
                var aiStrategy = new RandomAiStrategy();
                player2 = new AiPlayer(aiStrategy)
                {
                    Id    = 2,
                    Color = startData.Player2Color
                };
                break;

            case GameType.TwoPlayers:
                player2 = new Player {
                    Id = 2, Color = startData.Player2Color
                };
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            var players = new[] { player1, player2 };

            _game         = new Game(new ClassicGameField(), players);
            _game.OnTurn += OnTurn;
        }
    public override void join(bool choice)
    {
        joined[turn] = choice;
        if (PhotonNetwork.player.ID != turn + 1)
        {
            pop.EnableJoinBlockScreen(turn, choice);
        }
        else
        {
            pop.EnableWaitScreen();
        }
        HandleTextFile.WriteLog((GameControler.LogLine += 1) + " Player " + (turn + 1) + "'s choice has been shown to other players, #BNF-30", GameControler.SName);
        turnsPassed++;
        TurnOrder();
        SetGlow(turn);
        pop.EnableTournamentBlockScreen(players[turn], turn);
        if (choice == true)
        {
            joinedPlayers++;
        }
        HandleTextFile.WriteLog((GameControler.LogLine += 1) + " Action Log: Player " + (turn + 1) + " Joins the Tournament : " + choice + ", #BNF-30", GameControler.SName);

        if (turnsPassed > 3)
        {
            Start();
        }
        //AI Logic
        if (players[turn].GetComponent <AiPlayer>() != null)
        {
            AiPlayer temp = players[turn].GetComponent <AiPlayer>();
            temp.JoinTournament(players, Reward, this);
        }
    }
 public PlayersController(AiPlayer firstAiPlayer = null, AiPlayer secondAiPlayer = null)
 {
     this.firstAiPlayer     = firstAiPlayer;
     this.secondAiPlayer    = secondAiPlayer;
     this.currentPlayerTurn = PlayerNumber.FirstPlayer;
     this.gameEngineReady   = true;
 }
Example #5
0
        private void resetGame()
        {
            m_Players[0] = new Player(Strings.white_color, Square.eSquareColor.White);
            switch (WelcomeForm.m_GameMode)
            {
            case n_Game.Game.ePlayAgainst.PlayerVsPlayer:
                m_Players[1] = new Player(Strings.black_color, Square.eSquareColor.Black);
                break;

            case n_Game.Game.ePlayAgainst.PlayerVsComputer:
                m_Players[1] = new AiPlayer(Strings.black_color, Square.eSquareColor.Black);
                break;
            }

            setTitle(Strings.white_color);
            m_Squares = new PictureBox[WelcomeForm.m_BoardSize, WelcomeForm.m_BoardSize];
            m_Board   = new Board(WelcomeForm.m_BoardSize);
            n_Game.Game.m_MatrixSize = WelcomeForm.m_BoardSize;
            setStartSquare();
            setPlayerColorMark();
            OnCurrentTurn += m_Players[m_CurrentPlayerIndex].CheckIfSquareIsValidAndMakeMove;
            printChangedBoard(m_Board.SquareBoard);
            startPlaying(true);
            m_KeepPlaying = true;
        }
Example #6
0
        /// <summary>
        /// Creat an AI Player based off the evolutionary parameters provded.
        /// </summary>
        /// <param name="parameters">Evolutionary parameters defining the boundaries of this candidates characteristics.</param>
        /// <param name="id">AI Player id.</param>
        /// <param name="generation">The generation this AI player will belong to.</param>
        /// <returns>AI Player built.</returns>
        public IAiPlayer BuildAiPlayer(EvolutionParameters parameters, int id, int generation = 1)
        {
            // Set score boundaries
            if (!_scoreParametersSet)
            {
                SetupScoreParameters(parameters);
                _scoreParametersSet = true;
            }

            var characteristics = new Characteristics
            {
                ScoreConnectTwo         = _rand.Next(_scoreConnectTwoMin, _scoreConnectTwoMax),
                ScoreConnectThree       = _rand.Next(_scoreConnectThreeMin, _scoreConnectThreeMax),
                ScoreConnectFour        = _rand.Next(_scoreConnectFourMin, _scoreConnectFourMax),
                ScoreGivingConnectTwo   = _rand.Next(_scoreGivingConnectTwoMin, _scoreGivingConnectTwoMax),
                ScoreGivingConnectThree = _rand.Next(_scoreGivingConnectThreeMin, _scoreGivingConnectThreeMax),
                ScoreGivingConnectFour  = _rand.Next(_scoreGivingConnectFourMin, _scoreGivingConnectFourMax)
            };

            var aiPlayer = new AiPlayer(characteristics)
            {
                Id         = id,
                Generation = 1
            };

            return(aiPlayer);
        }
Example #7
0
 public DurakPage(HumanPlayer humanPlayer, AiPlayer aiPlayer, Deck deck, bool isNewbieMode)
 {
     Initialize();
     SetupTrumpCard(deck);
     SetUpPlayers(humanPlayer, aiPlayer, deck);
     InitializeDeck(deck);
     this.isNewbieMode = isNewbieMode;
 }
 public TicTacToeGame(IPlayer player1, AiMode aiMode = AiMode.Easy)
 {
     GameGrid      = new GameGrid();
     Player1       = player1;
     Player2       = new AiPlayer(aiMode, GameGrid);
     Player1Symbol = (Symbols) new Random().Next(0, 2);
     Player2Symbol = Player1Symbol == Symbols.O ? Symbols.X : Symbols.O;
 }
 private void HandleAiMove(AiPlayer player)
 {
     gameEngineReady = false;
     if (player != null)
     {
         player.MakeMove();
     }
 }
        private AiPlayer player; // dont want to give access to players regions, so I keep it private

        public AiPlayerControl(string uniqueName)
        {
            InitializeComponent();

            player = new AiPlayer(Difficulty.Medium, "PC1", KnownColor.Blue);

            difficultyComboBox.SelectedIndex = (int)player.Difficulty;
            colorButton.BackColor            = Color.FromKnownColor(player.Color);
        }
Example #11
0
        /// <summary>
        /// Returns a new default enemy player
        /// </summary>
        /// <returns></returns>
        private AiPlayer GetEnemyPlayer()
        {
            AiPlayer enemyPlayer = new AiPlayer();

            enemyPlayer.Image = Properties.Resources.robot;
            enemyPlayer.Name  = "Computer";

            return(enemyPlayer);
        }
Example #12
0
    public void AddAiPlayer(Vector2 position, IMoveableObject target, float difficulty = 1.0f)
    {
        GameObject model  = GameObject.Instantiate(PaddleModel, new Vector3(position.x, position.y), Quaternion.identity);
        AiPlayer   player = model.AddComponent <AiPlayer>();

        player.SetTarget(target);
        player.SetSpeed(8.0f);
        player.SetDifficulty(difficulty);
        Players.Add(player);
    }
Example #13
0
    public override void ExecuteAiCommand(AiPlayer aiPlayer, ClientConnectionManager aiConnection)
    {
        //@TODO: Proper AI card selection
        int cardId = aiPlayer.m_cards[0].Key;

        aiPlayer.m_cards.RemoveAt(0);
        SGC_PlayCardFromHand command = new SGC_PlayCardFromHand(cardId);

        aiConnection.TransmitStream(command.PackCommand());
    }
Example #14
0
    public void StartServer(ClientConnectionManager connectionMgr)
    {
        m_clientConMgr = connectionMgr;
        m_aiConMgr     = new ClientConnectionManager();
        m_aiPlayer     = new AiPlayer();
        m_server       = new CardGameServer();

        InitializeServer();
        ConnectClients();
        RunServer();
    }
Example #15
0
 public override void ExecuteAiCommand(AiPlayer aiPlayer, ClientConnectionManager aiConnection)
 {
     if (m_playerID == aiPlayer.m_playerID)
     {
         aiPlayer.m_lifeTotal = m_life;
     }
     else
     {
         aiPlayer.m_opponentLifeTotal = m_life;
     }
 }
Example #16
0
    public override void OnPhaseStart()
    {
        base.OnPhaseStart();
        //check if we've got any cmder to actually command
        commandableCommanders.Clear();
        worldCommandScript.Cleanup();
        Faction          playerFac     = GameModeHandler.instance.curPlayingFaction;
        List <Commander> factionCmders = playerFac.OwnedCommanders;
        GameInfo         gData         = GameController.CurGameData;

        foreach (Commander cmder in factionCmders)
        {
            if (cmder.troopsContained.Count == 0 && cmder.pointsToSpend > 0)
            {
                cmder.OrderRecruitTroops();                 //if we don't recruit, we would just disappear at the end of the turn
            }
            else
            {
                if (!gData.unifyBattlePhase ||
                    (gData.unifyBattlePhase && gData.unifiedOrdersRegistry.GetOrderGivenToCmder(cmder.ID) == null))
                {
                    commandableCommanders.Add(cmder);
                }
            }
        }
        if (commandableCommanders.Count > 0)
        {
            //sort commanders by zone so that the player's focus jumps around less often
            //(this should also help the AI)
            commandableCommanders.Sort(Commander.SortByZoneIAmIn);
            if (playerFac.isPlayer)
            {
                worldCommandScript.allowedCmders3d = GameController.CmdersToCmder3ds(commandableCommanders);
                worldCommandScript.enabled         = true;
                curCmderInfoBox.gameObject.SetActive(true);
                SelectCmder(commandableCommanders[0]);
            }
            else
            {
                AiPlayer.AiCommandPhase(playerFac, commandableCommanders, this);
                OnPhaseEnding(GameModeHandler.instance.currentTurnIsFast);
            }
        }
        else
        {
            bool fastEnd = (GameModeHandler.instance.currentTurnIsFast);
            if (!fastEnd)
            {
                SmallTextAnnouncer.instance.DoAnnouncement("No active commanders found!", Color.white);
            }
            OnPhaseEnding(fastEnd);
        }
    }
        public GameGuessTheNumber(BasePlayer player1, BasePlayer player2)
        {
            if (player2 == null)
            {
                player2 = new AiPlayer("AiPlayer", _gameSettings);
            }

            Console.WriteLine($"Start new TicTacToeGame. {player1.PlayerName} vs {player2.PlayerName}");
            ChosePlayMod(player1, player2);
            CustomizeGame();
            _mysterious.PickNumber();
        }
Example #18
0
 /*
  *Checks if target is within attacking range of player
  */
 public bool isTargetInRange(UserPlayer playerTemp, AiPlayer target)
 {
     int playerX, playerY, targetX, targetY;
     playerX = (int)playerTemp.gridPosition.x;
     playerY = (int)playerTemp.gridPosition.y;
     targetX = (int)target.gridPosition.x;
     targetY = (int)target.gridPosition.y;
     print (playerX+ " " + playerY);
     print (targetX+ " " + targetY);
     return(playerX >= targetX - attackRange && playerX <= targetX + attackRange &&
            playerY >= targetY - attackRange && playerY <= targetY + attackRange);
 }
Example #19
0
    public override void ExecuteAiCommand(AiPlayer aiPlayer, ClientConnectionManager aiConnection)
    {
        // @TODO: AI implementation
        // Sending the same deck that the player loaded for now
        string     deckFileName = m_visualManager.GetDeckFileName();
        PackedDeck deck         = new PackedDeck();

        deck.LoadFromJSON(PackedDeck.deckPath + deckFileName);
        SGC_SendDeck command = new SGC_SendDeck(deck);

        m_visualManager.TransmitStream(command.PackCommand());
    }
        void Awake()
        {
            // ===== initialise unit variables =====
            IPlayer gamePlayer = new AiPlayer(-1); // init a base game player

            GameObject[] unitPrefabs = new[] { AttackUnit, BaseUnit, DefenceUnit, ScoutUnit };
            Dictionary <College, Dictionary <int, IUnit> > defaultUnits = new Dictionary <College, Dictionary <int, IUnit> >();
            IUnit tmpUnit;

            foreach (College college in Enum.GetValues(typeof(College)))
            {
                Dictionary <int, IUnit> currentCollege = new Dictionary <int, IUnit>();
                for (int i = 0; i < unitPrefabs.Length; i++)
                {
                    tmpUnit = Instantiate(unitPrefabs[i], gameObject.transform).GetComponent <IUnit>();
                    tmpUnit.Init(gamePlayer, college);
                    tmpUnit.Transform.localPosition = new Vector3();
                    currentCollege.Add(i, tmpUnit);
                }
                defaultUnits.Add(college, currentCollege);
            }

            // pull in the game context
            // done last to collect game state
            GameContext = new Context(
                GameObject.Find("Gui").GetComponent <GuiManager>(),
                GameObject.Find("Map").GetComponent <MapManager>(),
                gameObject.GetComponent <AudioManager>(),
                unitPrefabs, defaultUnits);
            GameContext.Players.Add(gamePlayer.Id, gamePlayer);

            // ===== testing code =====
            // basic default players
            // for full game, the menu that deals with allowing users to set up the game
            // and available players in said game will add each player instance.
            IPlayer tmp = new HumanPlayer(GameContext.GetNewPlayerId())
            {
                Mana    = 120,
                MaxMana = 120
            };

            GameContext.Players.Add(tmp.Id, tmp);
            GameContext.PlayerOrder.Enqueue(tmp.Id);
            tmp = new HumanPlayer(GameContext.GetNewPlayerId())
            {
                Mana    = 120,
                MaxMana = 120
            };
            GameContext.Players.Add(tmp.Id, tmp);
            GameContext.PlayerOrder.Enqueue(tmp.Id);
            GameContext.StartingPlayerId = GameContext.CurrentPlayerId;
        }
Example #21
0
    public override void ExecuteAiCommand(AiPlayer aiPlayer, ClientConnectionManager aiConnection)
    {
        int cardID   = m_castableCards[0].cardID;
        int targetID = -1;

        if (m_castableCards[0].targets.Count > 0)
        {
            targetID = m_castableCards[0].targets[0];
        }
        SGC_CastSpellFromChannel0 command = new SGC_CastSpellFromChannel0(cardID, targetID);

        aiConnection.TransmitStream(command.PackCommand());
    }
Example #22
0
        public void SetLinkedPlayer(AiPlayer aiPlayer)
        {
            linkedPlayer = aiPlayer;
            vesselSpriteHandler.ChangeSprite(aiPlayer == null ? 0 : 1);

            if (isInteliCard)
            {
                UpdateGui();
            }

            //Set name of vessel to Ai name if we can
            GetComponent <Attributes>().ServerSetArticleName(aiPlayer.OrNull()?.PlayerScript.characterSettings.AiName ??
                                                             (isInteliCard ? "Intelicard" : "Ai Core"));
        }
Example #23
0
        public void LoadAiPlayerFromJsonTest()
        {
            AiPlayer player = JsonConvert.DeserializeObject <AiPlayer>(CandidatePlayerJson);

            Assert.AreEqual(Id, player.Id);
            Assert.AreEqual(Generation, player.Generation);

            Assert.AreEqual(ScoreConnectTwo, player.Characteristics.ScoreConnectTwo);
            Assert.AreEqual(ScoreConnectThree, player.Characteristics.ScoreConnectThree);
            Assert.AreEqual(ScoreConnectFour, player.Characteristics.ScoreConnectFour);

            Assert.AreEqual(ScoreGivingConnectTwo, player.Characteristics.ScoreGivingConnectTwo);
            Assert.AreEqual(ScoreGivingConnectThree, player.Characteristics.ScoreGivingConnectThree);
            Assert.AreEqual(ScoreGivingConnectFour, player.Characteristics.ScoreGivingConnectFour);
        }
Example #24
0
        public ChessApp(IConsoleIO console, IFileIO fileIO)
        {
            Console = console ?? throw new ArgumentNullException(nameof(console));
            FileIO  = fileIO ?? throw new ArgumentNullException(nameof(fileIO));

            RulesEngine = new RulesEngine();
            AiPlayer    = new AiPlayer(RulesEngine);
            FileStorage = new FileStorage(FileIO);

            var lazyConsolePlayer = new LateBindingPlayerAdapter();

            GameFlow  = new GameFlow(lazyConsolePlayer, AiPlayer, RulesEngine);
            ConsoleUI = new ConsoleUI(GameFlow, Console, FileStorage, RulesEngine);

            lazyConsolePlayer.Bind(ConsoleUI);
        }
Example #25
0
    // Use this for initialization
    new void Start()
    {
        m_human  = gameObject.AddComponent <HumanPlayer>();
        computer = gameObject.AddComponent <AiPlayer>();

        //assign the units
        m_human.units  = units;
        computer.units = units;

        computer.logicMachine = gameObject.GetComponent <FuzzyLogic>();

        //set the difficulty
        SetDifficulty(Settings.aiDifficulty);

        //mark the player as either a human or not
        isHuman = !Settings.playingWithAI;
    }
Example #26
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            var dimensions   = new Dimensions(10, 10);
            var battlefield1 = new Battlefield(dimensions);
            var battlefield2 = new Battlefield(dimensions);

            var numberOfShips = new NumberOfShips(1, 1, 2, 2, 3);
            var ships         = shipFactory.CreateShips(numberOfShips);

            battlefield1.PlaceShips(ships, true);
            ships = shipFactory.CreateShips(numberOfShips);
            battlefield2.PlaceShips(ships, true);

            var player1 = new Player(battlefield1, battlefield2, "Tomas");
            var player2 = new AiPlayer(battlefield2, battlefield1, "AI");

            player1.ListenTo(player2);
            player2.ListenTo(player1);

            var battlefield1View = battlefieldViewFactory.CreateBattlefieldView(battlefield1);
            var battlefield2View = battlefieldViewFactory.CreateBattlefieldView(battlefield2);

            var battlefield1ViewStyleUpdateService = new BattlefieldViewStyleUpdateService(
                battlefield1View, new BattlefieldViewStyleSettings(false, false, false)
                );
            var battlefield2ViewStyleUpdateService = new BattlefieldViewStyleUpdateService(
                battlefield2View, new BattlefieldViewStyleSettings(true, false, false)
                );
            var battlefield1ViewInteractionService = new BattlefieldViewInteractionService(
                battlefield1View, battlefield1ViewStyleUpdateService
                );
            var battlefield2ViewInteractionService = new BattlefieldViewInteractionService(
                battlefield2View, battlefield2ViewStyleUpdateService, player1
                );

            battlefield1ViewInteractionService.EnableInteraction();
            battlefield2ViewInteractionService.EnableInteraction();

            var battlefieldViewContainerInteractionService = new BattlefieldViewContainerInteractionService(battlefield2ViewInteractionService);

            battlefieldViewContainerInteractionService.EnableInteraction();

            var battlefieldViewContainer = new BattlefieldViewContainer(battlefield1View, battlefield2View);

            MainContainer.Children.Add(battlefieldViewContainer);
        }
Example #27
0
    public override void OnPhaseStart()
    {
        base.OnPhaseStart();
        //check if it's possible for the player faction to place a new cmder
        //(if the limit hasn't been reached and the faction has a zone without a commander in it)

        Faction          playerFac     = GameModeHandler.instance.curPlayingFaction;
        List <Commander> factionCmders = playerFac.OwnedCommanders;

        if (factionCmders.Count < playerFac.MaxCmders)
        {
            List <Zone> availableZones = GameController.GetZonesForNewCmdersOfFaction(playerFac);
            if (availableZones.Count > 0)
            {
                if (playerFac.isPlayer)
                {
                    CameraPanner.instance.TweenToSpot(availableZones[0].MyZoneSpot.transform.position);
                    infoTxt.text = "Select an unoccupied zone you own to place a new commander in it";
                    World.BeginNewCmderPlacement
                        (DonePlacing, GameController.ZonesToZoneSpots(availableZones));
                    skipBtn.interactable = true;
                }
                else
                {
                    AiPlayer.AiNewCmderPhase(playerFac, availableZones);
                    OnPhaseEnding(GameModeHandler.instance.currentTurnIsFast);
                }
            }
            else
            {
                infoTxt.text = "All owned zones are already occupied!";
                OnPhaseEnding(GameModeHandler.instance.currentTurnIsFast);
            }
        }
        else
        {
            infoTxt.text = "The faction's commander limit has been reached!";
            if (!GameModeHandler.instance.currentTurnIsFast)
            {
                SmallTextAnnouncer.instance.DoAnnouncement
                    ("The faction's commander limit has been reached!", Color.white);
            }
            OnPhaseEnding(GameModeHandler.instance.currentTurnIsFast);
        }
    }
        public void ServerPerformInteraction(HandApply interaction)
        {
            if (apcPoweredDevice.State == PowerState.Off)
            {
                Chat.AddExamineMsgFromServer(interaction.Performer, $"{gameObject.ExpensiveName()} has no power");
                return;
            }

            //Cycle through AIs
            if (interaction.HandObject == null)
            {
                //Only allow alive AI's cores, or alive AI's carded which have interactions enabled to have law changes
                var aiPlayers = PlayerList.Instance.GetAllByPlayersOfState(PlayerScript.PlayerStates.Ai).Where(
                    a => a.GameObject.TryGetComponent <AiPlayer>(out var aiPlayer) && aiPlayer.HasDied == false &&
                    (aiPlayer.IsCarded == false || aiPlayer.AllowRemoteAction)).ToList();

                if (lastIndex >= aiPlayers.Count)
                {
                    lastIndex = 0;
                }

                if (aiPlayers.Count == 0)
                {
                    Chat.AddExamineMsgFromServer(interaction.Performer, "There are no Ai's");
                    return;
                }

                selectedAiPlayer = aiPlayers[lastIndex].GameObject.GetComponent <AiPlayer>();

                Chat.AddExamineMsgFromServer(interaction.Performer, $"{selectedAiPlayer.gameObject.ExpensiveName()} selected");

                lastIndex++;
                return;
            }

            //Make sure Ai selected
            if (selectedAiPlayer == null)
            {
                Chat.AddExamineMsgFromServer(interaction.Performer, "Select an Ai to upload laws to first");
                return;
            }

            //Try to upload law module
            selectedAiPlayer.UploadLawModule(interaction, true);
        }
Example #29
0
    void StartGame()
    {
        gameEngine = new GameEngine();
        AiPlayer firstPlayer  = InitPlayer(PlayerNumber.FirstPlayer);
        AiPlayer secondPlayer = InitPlayer(PlayerNumber.SecondPlayer);

        aiPlayersController = new PlayersController(firstPlayer, secondPlayer);
        timePassed          = 0;
        OnBoardUpdated(gameEngine.GameState.CurrentBoard);
        gameEngine.OnBoardChanged             += OnBoardUpdated;
        gameEngine.OnGameFinished             += OnGameFinished;
        gameEngine.OnPlayerTurnChanged        += OnPlayerTurnChanged;
        gameEngine.OnPlayerTurnChanged        += aiPlayersController.OnPlayerTurnChanged;
        gameEngine.OnLastFieldSelectedChanged += UpdatePossibleMoveIndicators;
        UpdateWinningPlayerText(PlayerNumber.None);
        shouldLogToFile         = logToFileToggle.isOn;
        playButton.interactable = false;
    }
Example #30
0
    public void AiBehavior(string Stage)
    {
        AiPlayer temp = players[turn].GetComponent <AiPlayer>();

        switch (Stage)
        {
        case "Start":
            if (temp.SponserQuest(players, questCard.numberOfStages, this, CanPlayerSponsor()) == true)
            {
                SponsorQuest();
            }
            temp.SetupQuest(questCard.numberOfStages, this);
            if (hands[turn].cards.Count >= 12)
            {
                HandleTextFile.WriteLog("AI Log: Force Ai Discard " + hands[turn].cards[0].name, GameControler.SName);
                while (hands[turn].cards.Count >= 12)
                {
                    DiscardCard(0);
                }
            }
            EndTurn();
            break;

        case "Join":
            temp.joinQuest(questCard.numberOfStages, this);
            break;

        case "Play":
            temp.playStage(this);
            if (hands[turn].cards.Count >= 12)
            {
                HandleTextFile.WriteLog("AI Log: Force Ai Discard " + hands[turn].cards[0].name, GameControler.SName);
                while (hands[turn].cards.Count >= 12)
                {
                    DiscardCard(0);
                }
            }
            EndTurn();
            break;

        default:
            break;
        }
    }
Example #31
0
        public ChessApp(IConsoleIO console, IFileIO fileIO)
        {
            // TODO: How to replace this boilerplate code with auto-generated?
            // Maybe, classical DI infrastructure could be used here in a local scope?

            Console = console ?? throw new ArgumentNullException(nameof(console));
            FileIO  = fileIO ?? throw new ArgumentNullException(nameof(fileIO));

            RulesEngine = new RulesEngine();
            AiPlayer    = new AiPlayer(RulesEngine);
            FileStorage = new FileStorage(FileIO);

            var lazyConsolePlayer = new LateBindingPlayerAdapter();

            GameFlow  = new GameFlow(lazyConsolePlayer, AiPlayer, RulesEngine);
            ConsoleUI = new ConsoleUI(GameFlow, Console, FileStorage, RulesEngine);

            lazyConsolePlayer.Bind(ConsoleUI);
        }
Example #32
0
    void InitPlayers()
    {
        switch (PlayerProfile.gameMode)
        {
        case Gamemode.singlePlayer:
            players    = new Player[1];
            players[0] = new HumanPlayer();
            break;

        case Gamemode.bot:
            players    = new Player[2];
            players[0] = new HumanPlayer();
            players[1] = new AiPlayer();
            break;

        default:
            break;
        }
    }
Example #33
0
    void PlaceNewPlayersOnMap(PlayerData humanPlayer, int aiCount)
    {
        Planet home = space.getRandomEmptyStartPlanet();
        if (home == null) {
            Debug.LogError("Failed to set home planet for human player. There are no start planets on the map");
        }
        home.planetData.SetOwner(humanPlayer);

        var aiPlayers = new List<AiPlayer>();
        for (int i = 0; i < aiCount; ++i) {
            PlayerData aiData = new PlayerData();
            AiPlayer player = new AiPlayer(aiData, space);

            home = space.getRandomEmptyStartPlanet();
            if (home == null) {
                Debug.LogError("Failed to set home planet for ai. There are no start planets on the map");
                break;
            }
            aiPlayers.Add(player);
            home.planetData.SetOwner(aiData);
        }

        PlayerListData playerListData = new PlayerListData(humanPlayer, aiPlayers);
        playerManager.Init(playerListData);
    }