public override Task ProcessAsync(IMessageBroadcaster broadcaster, ICommand cmd) { if (cmd.Arguments == null || cmd.Arguments.Length == 0) { broadcaster.Broadcast("Ravenfall is a Twitch idle game where you can train, craft, fight together against huge raid bosses or fight against eachother."); } else if (cmd.Arguments.Contains("help", System.StringComparison.OrdinalIgnoreCase)) { broadcaster.Broadcast("Please see https://www.ravenfall.stream/how-to-play on how to play Ravenfall. This guide is still being updated so make sure to check it out frequently."); } return(Task.CompletedTask); }
public void PlayerJoin(PlayerJoinMessage message) { _logger.LogInformation($"{message.Sender.SteamId} joined"); _world.Players.Add(message.Sender); ServerPlayerSpawnMessage spawn = new ServerPlayerSpawnMessage { Position = new NetworkVector3(0f, 10f, 0f), Player = message.Sender }; _messageBroadcaster.Broadcast(spawn); ServerPlayerListMessage list = new ServerPlayerListMessage { Players = _world.Players }; _messageBroadcaster.Broadcast(list, message.Sender); }
public override async Task ProcessAsync(IMessageBroadcaster broadcaster, ICommand cmd) { if (!await this.game.ProcessAsync(Settings.UNITY_SERVER_PORT)) { broadcaster.Send(cmd.Sender.Username, //broadcaster.Broadcast( Localization.GAME_NOT_STARTED); return; } if (!cmd.Sender.IsBroadcaster && !cmd.Sender.IsModerator && !cmd.Sender.IsSubscriber) { //broadcaster.Broadcast( broadcaster.Send(cmd.Sender.Username, "You do not have permission to set the currently observed player."); return; } var isSubscriber = cmd.Sender.IsSubscriber && !cmd.Sender.IsBroadcaster && !cmd.Sender.IsModerator; if (isSubscriber) { var user = userStore.Get(cmd.Sender.Username); var command = nameof(ObserveCommandProcessor); if (!user.CanUseCommand(command)) { var timeLeft = user.GetCooldown(command); broadcaster.Broadcast($"{cmd.Sender.Username}, You must wait another {Math.Floor(timeLeft.TotalSeconds)} secs to use that command."); return; } user.UseCommand(command, TimeSpan.FromSeconds(120)); } var targetPlayerName = cmd.Arguments?.Trim(); Models.Player player = null; if (!string.IsNullOrEmpty(targetPlayerName)) { player = playerProvider.Get(targetPlayerName); } else { player = playerProvider.Get(cmd.Sender); } await game.ObservePlayerAsync(player); }
public override async Task ProcessAsync(IMessageBroadcaster broadcaster, ICommand cmd) { if (!await this.game.ProcessAsync(Settings.UNITY_SERVER_PORT)) { //broadcaster.Broadcast( broadcaster.Send(cmd.Sender.Username, Localization.GAME_NOT_STARTED); return; } var player = playerProvider.Get(cmd.Sender); if (string.IsNullOrEmpty(cmd.Arguments)) { broadcaster.Broadcast("You can customize your character here https://www.ravenfall.stream/customization"); return; } await this.game.PlayerAppearanceUpdateAsync(player, cmd.Arguments); }
public Task ProcessAsync(IMessageBroadcaster broadcaster, ICommand cmd) { //if (string.IsNullOrEmpty(cmd.Arguments)) //{ // return Task.CompletedTask; //} var command = cmd.Arguments.Trim().ToLower(); if (command.StartsWith("add")) { if (!cmd.Sender.IsModerator && !cmd.Sender.IsBroadcaster) { broadcaster.Send(cmd.Sender.Username, //broadcaster.Broadcast( "Sorry, this command is restricted to mods and broadcaster."); return Task.CompletedTask; } var data = command.Split(' '); if (data.Length <= 1) { broadcaster.Broadcast("Insufficient parameters, use: !credits add <user> <amount>"); return Task.CompletedTask; } var name = data[1]; var amountStr = data[2]; if (int.TryParse(amountStr, out var val)) { var user = this.userStore.Get(name); user.AddCredits(val); broadcaster.Broadcast($"{val} credits was added to {name}'s stash."); } } else if (command.StartsWith("remove")) { if (!cmd.Sender.IsModerator && !cmd.Sender.IsBroadcaster) { //broadcaster.Broadcast( broadcaster.Send(cmd.Sender.Username, "Sorry, this command is restricted to mods and broadcaster."); return Task.CompletedTask; } var data = command.Split(' '); if (data.Length <= 1) { broadcaster.Broadcast("Insufficient parameters, use: !credits remove <user> <amount>"); return Task.CompletedTask; } var name = data[1]; var amountStr = data[2]; if (int.TryParse(amountStr, out var val)) { var user = this.userStore.Get(name); user.RemoveCredits(val); broadcaster.Broadcast($"{val} credits was removed from {name}'s stash."); } } else { var user = this.userStore.Get(cmd.Sender.Username); broadcaster.Send(cmd.Sender.Username, //broadcaster.Broadcast( $"{cmd.Sender.Username}, you have {user.Credits} credits left."); } return Task.CompletedTask; }
public override async Task ProcessAsync(IMessageBroadcaster broadcaster, ICommand cmd) { if (!await this.game.ProcessAsync(Settings.UNITY_SERVER_PORT)) { broadcaster.Send(cmd.Sender.Username, Localization.GAME_NOT_STARTED); return; } var player = playerProvider.Get(cmd.Sender); var isRaidWar = cmd.Command.Contains("war", StringComparison.OrdinalIgnoreCase); if (string.IsNullOrEmpty(cmd.Arguments)) { if (isRaidWar) { return; } await this.game.JoinRaidAsync(player); return; } if (!string.IsNullOrEmpty(cmd.Arguments)) { if (!cmd.Sender.IsBroadcaster && !cmd.Sender.IsModerator && !cmd.Sender.IsSubscriber) { broadcaster.Send(cmd.Sender.Username, Localization.PERMISSION_DENIED); return; } if (cmd.Arguments.Contains("start", StringComparison.OrdinalIgnoreCase)) { var isSubscriber = cmd.Sender.IsSubscriber && !cmd.Sender.IsBroadcaster && !cmd.Sender.IsModerator; if (isSubscriber) { var user = userStore.Get(cmd.Sender.Username); var command = nameof(RaidCommandProcessor); if (!user.CanUseCommand(command)) { var timeLeft = user.GetCooldown(command); broadcaster.Broadcast($"{cmd.Sender.Username}, You must wait another {Math.Floor(timeLeft.TotalSeconds)} secs to use that command."); return; } user.UseCommand(command, TimeSpan.FromHours(1)); } await this.game.RaidStartAsync(player); return; } if (!cmd.Sender.IsBroadcaster) { broadcaster.Send(cmd.Sender.Username, Localization.PERMISSION_DENIED); return; } var target = playerProvider.Get(cmd.Arguments); await this.game.RaidStreamerAsync(target, isRaidWar); } }
public Task ProcessAsync(IMessageBroadcaster broadcaster, ICommand cmd) { var command = cmd.Arguments; if (string.IsNullOrEmpty(command)) { return(Task.CompletedTask); } if (command.Trim().StartsWith("help ")) { var cmdTarget = command.Trim().Split(new string[] { "help " }, StringSplitOptions.RemoveEmptyEntries) .FirstOrDefault(); if (Witcher3Commands.TryGet(cmdTarget, out var cmdTargetInfo)) { broadcaster.Broadcast(cmdTargetInfo.Syntax + $", costs: {cmdTargetInfo.InvokeCost} credits, " + cmdTargetInfo.Description); } else { broadcaster.Broadcast(cmd.Sender.Username + ", no such command exists!"); } return(Task.CompletedTask); } if (command.Trim().Equals("commands", StringComparison.InvariantCultureIgnoreCase) || command.Trim().Equals("help", StringComparison.InvariantCultureIgnoreCase)) { broadcaster.Broadcast("For a list of commands, go to https://commands.gg/witcher3"); return(Task.CompletedTask); } if (!witcher3.IsRunning) { broadcaster.Broadcast($"{cmd.Sender.Username}, Witcher 3 is not running right now."); return(Task.CompletedTask); } if (witcher3.IsRunning) { var gameCommand = commandFactory.Create(cmd.Sender.Username, command); if (gameCommand == null) { broadcaster.Broadcast($"{cmd.Sender.Username}, no such Witcher 3 command exists!"); return(Task.CompletedTask); } var user = this.userStore.Get(cmd.Sender.Username); if (!user.CanAfford(gameCommand.InvokeCost)) { broadcaster.Broadcast($"{cmd.Sender.Username}, You have insufficient amount of credits to use this command. This costs {gameCommand.InvokeCost}, and you only have {(int)user.Credits} left."); return(Task.CompletedTask); } if (witcher3.Invoke(gameCommand)) { messageBus.Send("witcher3", gameCommand); user.RemoveCredits(gameCommand.InvokeCost); broadcaster.Broadcast($"{cmd.Sender.Username}, command executed! You now have {(int)user.Credits} credits left."); witcher3.Notify($"{cmd.Sender.Username} used {gameCommand.Name}"); } else { broadcaster.Broadcast($"{cmd.Sender.Username}, the command failed :("); } } return(Task.CompletedTask); }
public override async Task ProcessAsync(IMessageBroadcaster broadcaster, ICommand cmd) { if (!await this.game.ProcessAsync(Settings.UNITY_SERVER_PORT)) { broadcaster.Broadcast(Localization.GAME_NOT_STARTED); return; } // --- PLayers only --- //!arena leave //!arena, !arena join // --- Broadcaster Only --- //!arena start,begin //!arena cancel,cancel //!arena kick <player> //!arena add <player> var command = cmd.Arguments?.Trim().ToLower(); var player = playerProvider.Get(cmd.Sender); if (string.IsNullOrEmpty(command) || command.Equals("join")) { await game.JoinArenaAsync(player); } else if (command.Equals("leave")) { await game.LeaveArenaAsync(player); } else if (command.Equals("start") || command.Equals("begin")) { if (!cmd.Sender.IsBroadcaster && !cmd.Sender.IsModerator) { broadcaster.Send(cmd.Sender.Username, "You do not have permission to force start the arena."); //broadcaster.Broadcast("You do not have permission to force start the arena."); return; } await game.StartArenaAsync(player); } else if (command.Equals("cancel") || command.Equals("end")) { if (!cmd.Sender.IsBroadcaster && !cmd.Sender.IsModerator) { //broadcaster.Broadcast( broadcaster.Send(cmd.Sender.Username, "You do not have permission to cancel the arena."); return; } await game.CancelArenaAsync(player); } else { var targetPlayerName = command.Split(' ').LastOrDefault(); if (command.StartsWith("kick ")) { if (!cmd.Sender.IsBroadcaster && !cmd.Sender.IsModerator) { //broadcaster.Broadcast( broadcaster.Send(cmd.Sender.Username, "You do not have permission to kick a player from the arena."); return; } var targetPlayer = playerProvider.Get(cmd.Sender); await game.KickPlayerFromArenaAsync(player, targetPlayer); } else if (command.StartsWith("add ")) { if (!cmd.Sender.IsBroadcaster && !cmd.Sender.IsModerator) { //broadcaster.Broadcast( broadcaster.Send(cmd.Sender.Username, "You do not have permission to add a player to the arena."); return; } var targetPlayer = playerProvider.Get(cmd.Sender); await game.AddPlayerToArenaAsync(player, targetPlayer); } } }