src/Game/GameFactory.cs
/// <summary>
/// Process reaction as move for game context under given id of message.
/// Only author of game can make moves.
/// </summary>
/// <param name="messageId">Message, which got reaction.</param>
/// <param name="reaction">Reaction for message.</param>
Process reaction as move for game context under given id of message.
Only author of game can make moves.
Process reaction as move for game context under given id of message . Only author of game can make moves .
public async Task ProcessReactionAsync(ulong messageId, SocketReaction reaction)
        {
            var move = FindMove(reaction.Emote);
            DatabaseGames.TryGet(messageId, out var gameContext);
            if (move == null || gameContext.AuthorId != reaction.UserId || gameContext.TryLock() != true)
            {
                return;
            }
            var (game, message) = (gameContext.Game, gameContext.Message);
            game.MakeMove(move);
            await message.ModifyAsync(msg => msg.Content = (string) game.Render());
            gameContext.Unlock();
        }
public async Task ProcessReactionAsync ( ulong messageId , SocketReaction reaction ) { var move = FindMove ( reaction . Emote ) ; DatabaseGames . TryGet ( messageId , out var gameContext ) ; if ( move == null || gameContext . AuthorId != reaction . UserId || gameContext . TryLock ( ) != true ) { return ; } var ( game , message ) = ( gameContext . Game , gameContext . Message ) ; game . MakeMove ( move ) ; await message . ModifyAsync ( msg => msg . Content = ( string ) game . Render ( ) ) ; gameContext . Unlock ( ) ; }
Process reaction as move for game context under given id of message.
Process reaction as move for game context under given id of message .
messageId
ulong
Message, which got reaction.
Message which got reaction .
reaction
SocketReaction
Reaction for message.
Reaction for message .