C#C
C#3y ago
Uchuu

❔ need some advice

private async Task<Result> ReceiveStartCommands()
    {
        var commands = new List<IInputCommand>();
        
        foreach (var trainer in Scene.Trainers)
        {
            var command = await InputProvider.GetInput(trainer.Id); 
            commands.Add(command);
        }

        // ReSharper disable once ConvertIfStatementToReturnStatement
        if (!commands.All(command => command is BattleStartCommand))
        {
            return new InvalidOperationError("Failed to start battle because Start Commands were not received from all trainers.");
        }

        return Result.FromSuccess();
    }


I have this code that receives the start commands from every player using an input provider. However, this means that the second player must wait for the first to send their command.

What is the best practice so can I make it so these commands can be received from both players without having to wait
Was this page helpful?