public void ChangeRules(ChangeRuleDto options) { if (IsChangingRules) { return; } if (!RoomManager.GameRuleFactory.Contains(options.MatchKey.GameRule)) { Logger.ForAccount(Master) .Error("Game rule {gameRule} does not exist", options.MatchKey.GameRule); Master.Session.SendAsync(new SServerResultInfoAckMessage(ServerResult.FailedToRequestTask)); return; } var map = GameServer.Instance.ResourceCache.GetMaps().GetValueOrDefault(options.MatchKey.Map); if (map == null) { Logger.ForAccount(Master) .Error("Map {map} does not exist", options.MatchKey.Map); Master.Session.SendAsync(new SServerResultInfoAckMessage(ServerResult.FailedToRequestTask)); return; } if (!map.GameRules.Contains(options.MatchKey.GameRule)) { Logger.ForAccount(Master) .Error("Map {mapId}({mapName}) is not available for game rule {gameRule}", map.Id, map.Name, options.MatchKey.GameRule); Master.Session.SendAsync(new SServerResultInfoAckMessage(ServerResult.FailedToRequestTask)); return; } if (Math.Max(options.MatchKey.PlayerLimit, 1) < Players.Count) { Logger.ForAccount(Master) .Error("Room has more players than the selected player limit"); Master.Session.SendAsync(new SServerResultInfoAckMessage(ServerResult.FailedToRequestTask)); return; } _changingRulesTimer = TimeSpan.Zero; IsChangingRules = true; Options.Name = options.Name; Options.MatchKey = options.MatchKey; Options.TimeLimit = options.TimeLimit; Options.ScoreLimit = options.ScoreLimit; Options.Password = options.Password; Options.IsFriendly = options.IsFriendly; Options.IsBalanced = options.IsBalanced; Options.ItemLimit = options.ItemLimit; Options.IsNoIntrusion = options.IsNoIntrusion; Broadcast(new SChangeRuleNotifyAckMessage(Options.Map <RoomCreationOptions, ChangeRuleDto>())); }
public void ChangeRules(ChangeRuleDto options) { if (IsChangingRules) { return; } if (!RoomManager.GameRuleFactory.Contains(options.MatchKey.GameRule)) { Logger.Error() .Account(Master) .Message($"Game rule {options.MatchKey.GameRule} does not exist") .Write(); Master.Session.SendAsync(new SServerResultInfoAckMessage(ServerResult.FailedToRequestTask)); return; } var map = GameServer.Instance.ResourceCache.GetMaps().GetValueOrDefault(options.MatchKey.Map); if (map == null) { Logger.Error() .Account(Master) .Message($"Map {options.MatchKey.Map} does not exist") .Write(); Master.Session.SendAsync(new SServerResultInfoAckMessage(ServerResult.FailedToRequestTask)); return; } if (!map.GameRules.Contains(options.MatchKey.GameRule)) { Logger.Error() .Account(Master) .Message($"Map {map.Id}({map.Name}) is not available for game rule {options.MatchKey.GameRule}") .Write(); Master.Session.SendAsync(new SServerResultInfoAckMessage(ServerResult.FailedToRequestTask)); return; } // ToDo check if current player count is not above the new player limit _changingRulesTimer = TimeSpan.Zero; IsChangingRules = true; Options.Name = options.Name; Options.MatchKey = options.MatchKey; Options.TimeLimit = options.TimeLimit; Options.ScoreLimit = options.ScoreLimit; Options.Password = options.Password; Options.IsFriendly = options.IsFriendly; Options.IsBalanced = options.IsBalanced; Options.ItemLimit = options.ItemLimit; Options.IsNoIntrusion = options.IsNoIntrusion; Broadcast(new SChangeRuleNotifyAckMessage(Options.Map <RoomCreationOptions, ChangeRuleDto>())); }
public void ChangeRules(ChangeRuleDto options) { if (IsChangingRules) { return; } //if (!RoomManager.GameRuleFactory.Contains(options.MatchKey.GameRule)) //{ // Logger.ForAccount(Master) // .Error("Game rule {gameRule} does not exist", options.MatchKey.GameRule); // Master.Session.SendAsync(new ServerResultAckMessage(ServerResult.FailedToRequestTask)); // return; //} //var map = GameServer.Instance.ResourceCache.GetMaps().GetValueOrDefault(options.MatchKey.Map); //if (map == null) //{ // Logger.ForAccount(Master) // .Error("Map {map} does not exist", options.MatchKey.Map); // Master.Session.SendAsync(new ServerResultAckMessage(ServerResult.FailedToRequestTask)); // return; //} //if (!map.GameRules.Contains(options.MatchKey.GameRule)) //{ // Logger.ForAccount(Master) // .Error("Map {mapId}({mapName}) is not available for game rule {gameRule}", // map.Id, map.Name, options.MatchKey.GameRule); // Master.Session.SendAsync(new ServerResultAckMessage(ServerResult.FailedToRequestTask)); // return; //} // ToDo check if current player count is not above the new player limit //_changingRulesTimer = TimeSpan.Zero; //IsChangingRules = true; //Options.Name = options.Name; //Options.MatchKey = options.MatchKey; //Options.TimeLimit = options.TimeLimit; //Options.ScoreLimit = options.ScoreLimit; //Options.Password = options.Password; //Options.IsFriendly = options.IsFriendly; //Options.IsBalanced = options.IsBalanced; //Options.ItemLimit = options.ItemLimit; //Options.IsNoIntrusion = options.IsNoIntrusion; //Broadcast(new RoomChangeRuleNotifyAckMessage(Options.Map<RoomCreationOptions, ChangeRuleDto>())); }
public CChangeRuleNotifyReqMessage() { Settings = new ChangeRuleDto(); }
public SChangeRuleAckMessage(ChangeRuleDto settings) { Settings = settings; }
public SChangeRuleAckMessage() { Settings = new ChangeRuleDto(); }
public void ChangeRules(ChangeRuleDto options) { if (IsChangingRules) { return; } if (!RoomManager.GameRuleFactory.Contains((GameRule)options.GameRule)) { Logger.ForAccount(Master) .Error("Game rule {gameRule} does not exist", options.GameRule); //throw new Exception("gamerule is not available"); Master?.Session?.SendAsync(new ServerResultAckMessage(ServerResult.FailedToRequestTask)); return; } // ToDo check if current player count is not above the new player limit var israndom = false; if ((GameRule)options.GameRule != GameRule.Practice && (GameRule)options.GameRule != GameRule.CombatTrainingTD && (GameRule)options.GameRule != GameRule.CombatTrainingDM) { if (options.Map_ID == 228 && (GameRule)options.GameRule == GameRule.BattleRoyal) //random br { israndom = true; options.Map_ID = 112; } else if (options.Map_ID == 229 && (GameRule)options.GameRule == GameRule.Chaser) //random chaser { israndom = true; options.Map_ID = 225; } else if (options.Map_ID == 231 && (GameRule)options.GameRule == GameRule.Deathmatch) //random deathmatch { israndom = true; options.Map_ID = 20; } else if (options.Map_ID == 230 && (GameRule)options.GameRule == GameRule.Touchdown) //random touchdown { israndom = true; options.Map_ID = 66; } var map = GameServer.Instance.ResourceCache.GetMaps().GetValueOrDefault(options.Map_ID); if (map == null) { Logger.ForAccount(Master) .Error($"Map {options.Map_ID} does not exist"); Master?.Session?.SendAsync(new ServerResultAckMessage(ServerResult.FailedToRequestTask)); return; } if (!map.GameRules.Contains((GameRule)options.GameRule)) { Logger.ForAccount(Master) .Error($"Map {map.Id}({map.Name}) is not available for game rule {(GameRule)options.GameRule}"); Master?.Session?.SendAsync(new ServerResultAckMessage(ServerResult.FailedToRequestTask)); return; } } if (options.Player_Limit < 1) { options.Player_Limit = 1; } if ((GameRule)options.GameRule == GameRule.CombatTrainingTD || (GameRule)options.GameRule == GameRule.CombatTrainingDM) { options.Player_Limit = 12; } var matchkey = new MatchKey(); if ((GameRule)options.GameRule == GameRule.CombatTrainingDM || (GameRule)options.GameRule == GameRule.CombatTrainingTD || (GameRule)options.GameRule == GameRule.Practice) { options.FMBurnMode = 1; } var isfriendly = false; var isbalanced = true; var isburning = false; var isWithoutStats = false; switch (options.FMBurnMode) { case 0: isbalanced = true; isfriendly = false; break; case 1: isbalanced = isfriendly = true; break; case 2: isbalanced = true; isfriendly = false; isburning = true; break; case 3: isburning = true; isbalanced = isfriendly = true; break; case 4: isWithoutStats = true; break; case 5: isWithoutStats = isfriendly = true; break; } _changingRulesTimer = TimeSpan.Zero; IsChangingRules = true; Options.Name = options.Name; Options.MapID = options.Map_ID; Options.PlayerLimit = options.Player_Limit; Options.GameRule = (GameRule)options.GameRule; Options.TimeLimit = TimeSpan.FromMinutes(options.Time); Options.ScoreLimit = (ushort)options.Points; Options.Password = options.Password; Options.IsFriendly = isfriendly; Options.IsBalanced = isbalanced; Options.IsBurning = isburning; Options.IsRandom = israndom; Options.ItemLimit = (byte)options.Weapon_Limit; Options.hasSpectator = options.HasSpectator; Options.Spectator = options.SpectatorLimit; Options.IsWithoutStats = isWithoutStats; _players.Values.ToList().ForEach(playr => { playr.RoomInfo.IsReady = false; }); RoomManager.Channel.BroadcastCencored(new RoomChangeRoomInfoAck2Message(GetRoomInfo())); Broadcast(new RoomChangeRuleNotifyAck2Message(Options.Map <RoomCreationOptions, ChangeRuleDto>())); }
public RoomChangeRuleNotifyAck2Message(ChangeRuleDto settings) { Settings = settings; }
public RoomChangeRuleNotifyAck2Message() { Settings = new ChangeRuleDto(); }
public RoomChangeHookEventArgs(Room room, ChangeRuleDto options) { Room = room; Options = options; Error = RoomChangeRulesError.OK; }
public void ChangeRules(ChangeRuleDto options) { ChangeRules2(options.Map <ChangeRuleDto, ChangeRuleDto2>()); }