public async Task Process(BattleUpdate battleUpdate) { if (!IsLoggedIn) { return; } var h = battleUpdate.Header; h.Title = h.Title.Truncate(200); if ((h.BattleID == null) && (MyBattle != null)) { h.BattleID = MyBattle.BattleID; } ServerBattle bat; if (!server.Battles.TryGetValue(h.BattleID.Value, out bat)) { await Respond("No such battle exists"); return; } if ((bat.FounderName != Name) && !User.IsAdmin) { await Respond("You don't have permission to edit this battle"); return; } bat.UpdateWith(h); await server.Broadcast(server.ConnectedUsers.Keys, battleUpdate); }
public async Task Process(BattleUpdate battleUpdate) { if (!IsLoggedIn) { return; } var h = battleUpdate.Header; if (h.BattleID == null && MyBattle != null) { h.BattleID = MyBattle.BattleID; } Battle bat; if (!state.Battles.TryGetValue(h.BattleID.Value, out bat)) { await Respond("No such battle exists"); return; } if (bat.Founder != User && !User.IsAdmin) { await Respond("You don't have permission to edit this battle"); return; } bat.UpdateWith(h, (n) => state.ConnectedUsers[n].User); await state.Broadcast(state.ConnectedUsers.Keys, battleUpdate); }
public void MergeFrom(GymBattleAttackResponse other) { if (other == null) { return; } if (other.Result != 0) { Result = other.Result; } if (other.battleUpdate_ != null) { if (battleUpdate_ == null) { battleUpdate_ = new global::POGOProtos.Data.Battle.BattleUpdate(); } BattleUpdate.MergeFrom(other.BattleUpdate); } if (other.gymBadge_ != null) { if (gymBadge_ == null) { gymBadge_ = new global::POGOProtos.Data.Badge.AwardedGymBadge(); } GymBadge.MergeFrom(other.GymBadge); } }
private ProcessedCommand ProcessNewBattleCommand(BattleUpdate battleUpdate) { if (battleUpdate == BattleUpdate.Ended) { return(commandHandler.ProcessCommand(CommandUtils.ExitCommand.Keyword, new string[] { })); } else if (battleUpdate == BattleUpdate.Continue) { return(commandHandler.ProcessCommand(CommandUtils.TurnInfoCommand.Keyword, new string[] { })); } else { return(new ProcessedCommand()); } }
public override int GetHashCode() { int hash = 1; if (Result != 0) { hash ^= Result.GetHashCode(); } if (battleUpdate_ != null) { hash ^= BattleUpdate.GetHashCode(); } if (gymBadge_ != null) { hash ^= GymBadge.GetHashCode(); } return(hash); }
// Called after a command from user's input has been processed and displayed // Processes a new command if needed, e.g. displays the turn info or ends a battle after a character has played public void CommandAddedToMessages(ProcessedCommand processedCommand) { if (processedCommand.Command is null) { return; } if (battleController.InBattle) { BattleUpdate battleUpdate = battleController.CheckState(); if (battleUpdate == BattleUpdate.Error) { return; } ProcessedCommand additionalCommand = ProcessNewBattleCommand(battleUpdate); // Lets the console know a new command has been processed and needs to be displayed OnAdditionalCommandProcessed(additionalCommand); } }