private TurnBasedGameTable FindGameTable(string tableCode) { TurnBasedGameTable gameTable = null; lock (m_GameTables) { if (m_GameTables.ContainsKey(tableCode)) { gameTable = m_GameTables[tableCode]; } } return(gameTable); }
public async Task <string> Load(IServerNode node) { //System.Diagnostics.Debugger.Break(); node.GetLogger().Info(this.GetType().Name + " is loading settings from config..."); TableGroupSetting tableSettings = null; try { ConfigurationManager.RefreshSection("appSettings"); await Task.Delay(100); var keys = ConfigurationManager.AppSettings.Keys; foreach (var key in keys) { if (key.ToString() == "GameTableSetting") { string settings = ConfigurationManager.AppSettings["GameTableSetting"].ToString(); tableSettings = node.GetJsonHelper().ToJsonObject <TableGroupSetting>(settings); continue; } } } catch (Exception ex) { node.GetLogger().Error("Failed to load settings from config for GameServerService: "); node.GetLogger().Error(ex.ToString()); } //if (m_Game != null) await m_Game.Open(); if (tableSettings != null) { lock (m_GameTables) { foreach (var setting in tableSettings.Tables) { if (m_GameTables.ContainsKey(setting.TableCode)) { continue; } TurnBasedGameTable gameTable = null; if (tableSettings.GameType == GameLogicBigTwo.GAME_TYPE) { gameTable = new TurnBasedGameTable(node, new GameLogicBigTwo()); } if (gameTable != null) { gameTable.TableCode = setting.TableCode; gameTable.TableType = tableSettings.TableType; gameTable.TableName = setting.TableName; gameTable.TestMerchant = tableSettings.TestMerchant; gameTable.TimeToBet = tableSettings.BettingTime; m_GameTables.Add(gameTable.TableCode, gameTable); } } } } else { node.GetLogger().Info("Failed to load game tables from app setting"); } var tables = GetGameTables(); if (tables.Count <= 0) { node.GetLogger().Info("No game table created from app setting"); } else { node.GetLogger().Info(tables.Count + " game table(s) created from app setting"); foreach (var gameTable in tables) { node.GetLogger().Info("--------------------------------------"); node.GetLogger().Info("Table Code: " + gameTable.TableCode); node.GetLogger().Info("Betting Time: " + gameTable.TimeToBet); node.GetLogger().Info("Test Merchant Code: " + gameTable.TestMerchant); await gameTable.Open(); } node.GetLogger().Info("--------------------------------------"); } await Task.Delay(100); node.GetLogger().Info(this.GetType().Name + " started"); return(""); }