Example #1
0
        public async void CombatMove([FromBody] CombatMove Move)
        {
            CombatSession thisCombatSession = _combatManager.GetCombatSessionByFighterId(Move.FighterId);
            CombatResult  result            = thisCombatSession.AddMove(Move);

            //CombatResult result = _combatManager.AddMove(Move);

            if (result != null)
            {
                List <string> playerIds = new List <string>();
                playerIds.Add(thisCombatSession.Fighters.ToArray()[0].Value.ownerId);
                playerIds.Add(thisCombatSession.Fighters.ToArray()[1].Value.ownerId);
                //await _chatHubContext.SendCombatResult(playerIds, System.Text.Json.JsonSerializer.Serialize(result));
                _chatHubContext.SendCombatResult(playerIds, System.Text.Json.JsonSerializer.Serialize(result));

                //IDAL dal = new SqlDAL();

                if (result.Victory != null)
                {
                    _combatManager.DeleteSession(playerIds[0]);

                    using (IDbConnection dbConnection =
                               DbProviderFactories.GetFactory("system.data.sqlclient").CreateConnection())
                    {
                        //dbConnection.ConnectionString = "Server=tcp:cipherrex.database.windows.net,1433;Initial Catalog=cipherRexUmbraco;Persist Security Info=False;User ID=cipherrex;Password=R00ksp@wnR00ksp@wn;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;";
                        //dbConnection.Open();
                        //Models.DAL.SqlDAL sqlDAL = new Models.DAL.SqlDAL(dbConnection);

                        //IPlayerRepo playerRepo = new PlayerRepo(sqlDAL);
                        //PlayerUoW playerUoW = new PlayerUoW(sqlDAL, playerRepo);

                        //playerUoW.EndGame(
                        //    result.Victory.VictorFighterId,
                        //    thisCombatSession.Fighters.Where(x => x.Key != result.Victory.VictorFighterId).FirstOrDefault().Key
                        //    );
                    }
                }
            }
        }
Example #2
0
        public async void CombatMove([FromBody] CombatMove Move)
        {
            CombatResult result = _combatManager.Sessions[Move.SessionId].Resolve(Move);

            if (result != null)
            {
                List <string> playerIds = new List <string>();
                playerIds.Add(_combatManager.Sessions[Move.SessionId].Player1Id);
                playerIds.Add(_combatManager.Sessions[Move.SessionId].Player2Id);

                //_combatManager.Sessions[Move.SessionId].
                Console.WriteLine("WhitePlayerTotalHP: " + result.WhitePlayerTotalHP.ToString());
                Console.WriteLine("BlackPlayerTotalHP: " + result.BlackPlayerTotalHP.ToString());

                System.Diagnostics.Debug.WriteLine("white hp: " + result.WhitePlayerTotalHP);
                System.Diagnostics.Debug.WriteLine("black hp: " + result.BlackPlayerTotalHP);


                if (result.BlackPlayerTotalHP < 0)
                {
                    result.VictoryData = new Victory()
                    {
                        FighterId = _combatManager.Sessions[Move.SessionId].WhiKnightID, Condition = "DIE"
                    };
                }
                else if (result.WhitePlayerTotalHP < 0)
                {
                    result.VictoryData = new Victory()
                    {
                        FighterId = _combatManager.Sessions[Move.SessionId].BlackKnightID, Condition = "DIE"
                    };
                }

                //await _chatHubContext.Clients.All.SendAsync(Messages.ENTER_LOBBY, _userEmail, JsonSerializer.Serialize(result));
                await _chatHubContext.SendCombatResult(playerIds, System.Text.Json.JsonSerializer.Serialize(result));
            }
        }
Example #3
0
 public void SetMoveList(CombatMove move, int slot)
 {
     this.moveList[slot] = move;
 }
Example #4
0
 /// <summary>
 /// Resets move variables of the combat pawn
 /// </summary>
 public void ResetMove()
 {
     m_moveForTurn = null;
     m_hasSubmittedMove = false;
 }
Example #5
0
 public void SetMoveForTurn(CombatMove newMoveForTurn)
 {
     m_moveForTurn = newMoveForTurn;
 }