public async Task Process(UpdateBotStatus add) { if (!IsLoggedIn) { return; } var battle = MyBattle; if (battle != null) { BotBattleStatus ubs; if (!battle.Bots.TryGetValue(add.Name, out ubs)) { ubs = new BotBattleStatus(add.Name, Name, add.AiLib); } else if (ubs.owner != Name && !User.IsAdmin && User != battle.Founder) { await Respond(string.Format("No permissions to edit bot {0}", add.Name)); return; } ubs.UpdateWith(add); battle.Bots[ubs.Name] = ubs; await state.Broadcast(battle.Users.Keys, ubs.ToUpdateBotStatus()); } }
public async Task Process(UpdateBotStatus add) { if (!IsLoggedIn) { return; } var battle = MyBattle; if ((battle != null) && !battle.IsInGame) { if (battle.Mode != AutohostMode.None && battle.Mode != AutohostMode.GameChickens) { await Respond("Sorry, this room type does not support bots, please use cooperative or custom"); return; } BotBattleStatus ubs; if (!battle.Bots.TryGetValue(add.Name, out ubs)) { if (battle.Bots.Count < 50) { ubs = new BotBattleStatus(add.Name, Name, add.AiLib); } else { await Respond("Maximal number of bots reached"); return; } } else if ((ubs.owner != Name) && !User.IsAdmin && (Name != battle.FounderName)) { await Respond(string.Format("No permissions to edit bot {0}", add.Name)); return; } ubs.UpdateWith(add); battle.Bots[ubs.Name] = ubs; await server.Broadcast(battle.Users.Keys, ubs.ToUpdateBotStatus()); } }