summaryrefslogtreecommitdiff
path: root/Impostor-dev/src/Impostor.Api/Games/Extensions/GameExtensions.cs
blob: a73697815109b7c6bb724a1f63afc889a6f625f3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
using System;
using System.Threading.Tasks;
using Impostor.Api.Net;
using Impostor.Api.Net.Messages;

namespace Impostor.Api.Games
{
    public static class GameExtensions
    {
        public static ValueTask SendToAllExceptAsync(this IGame game, IMessageWriter writer, LimboStates states, int? id)
        {
            return id.HasValue
                ? game.SendToAllExceptAsync(writer, id.Value, states)
                : game.SendToAllAsync(writer, states);
        }

        public static ValueTask SendToAllExceptAsync(this IGame game, IMessageWriter writer, LimboStates states, IClient client)
        {
            if (client == null)
            {
                throw new ArgumentNullException(nameof(client));
            }

            return game.SendToAllExceptAsync(writer, client.Id, states);
        }

        public static ValueTask SendToAsync(this IGame game, IMessageWriter writer, IClient client)
        {
            if (client == null)
            {
                throw new ArgumentNullException(nameof(client));
            }

            return game.SendToAsync(writer, client.Id);
        }

        public static ValueTask SendToAsync(this IGame game, IMessageWriter writer, IClientPlayer player)
        {
            return game.SendToAsync(writer, player.Client);
        }
    }
}