private async Task <TwoPlayersWithOneFursuitToken> SetupTwoPlayersWithOneFursuitTokenAsync()
        {
            var result = new TwoPlayersWithOneFursuitToken();

            result.player1WithFursuit = await CreateRegSysIdentityAsync();

            result.player1Token = await CreateTokenAsync();

            result.player1FursuitBadge = await CreateFursuitBadgeAsync(result.player1WithFursuit.Uid);

            await _collectingGameService.RegisterTokenForFursuitBadgeForOwnerAsync(
                result.player1WithFursuit.Uid,
                result.player1FursuitBadge.Id,
                result.player1Token.Value
                );

            result.player2WithoutFursuit = await CreateRegSysIdentityAsync();

            return(result);
        }
示例#2
0
        private async Task CommandCollectionGameRegisterFursuit()
        {
            Func <Task> askForRegNo = null, askForFursuitBadgeNo = null, askTokenValue = null;

            var title = "Collection Game Fursuit Registration";

            askForRegNo = () => AskAsync($"*{title} - Step 1 of 3*\nPlease enter the `attendee registration number` on the con badge.",
                                         async regNoAsString =>
            {
                await ClearLastAskResponseOptions();

                int regNo;
                if (!Int32.TryParse(regNoAsString, out regNo))
                {
                    await ReplyAsync($"*{regNoAsString}* is not a valid number.");
                    await askForRegNo();
                    return;
                }

                askForFursuitBadgeNo = () => AskAsync($"*{title} - Step 2 of 3*\nPlease enter the `fursuit badge number`.",
                                                      async fursuitBadgeNoAsString =>
                {
                    await ClearLastAskResponseOptions();

                    int fursuitBadgeNo;
                    if (!Int32.TryParse(fursuitBadgeNoAsString, out fursuitBadgeNo))
                    {
                        await ReplyAsync($"*{fursuitBadgeNo}* is not a valid number.");
                        await askForFursuitBadgeNo();
                        return;
                    }

                    var badge = await _fursuitBadgeRepository.FindOneAsync(
                        a => a.ExternalReference == fursuitBadgeNo.ToString());

                    if (badge == null)
                    {
                        await ReplyAsync($"*Error:* No fursuit badge with no *{fursuitBadgeNo}* found. Aborting.");
                        return;
                    }

                    if (badge.OwnerUid != $"RegSys:{_conventionSettings.ConventionNumber}:{regNo}")
                    {
                        await ReplyAsync($"*Error*: Fursuit badge with no *{fursuitBadgeNo}* exists, but does *not* belong to reg no *{regNo}*. Aborting.");
                        return;
                    }

                    await ReplyAsync(
                        $"*{badge.Name.EscapeMarkdown()}* ({badge.Species.EscapeMarkdown()}, {badge.Gender.EscapeMarkdown()})");
                    await BotClient.SendPhotoAsync(ChatId, new FileToSend(new Uri($@"https://app.eurofurence.org/api/v2/Fursuits/Badges/{badge.Id}/Image")));

                    askTokenValue = () => AskAsync(
                        $"*{title} - Step 3 of 3*\nPlease enter the `code/token` on the sticker that was applied to the badge.",
                        async tokenValue =>
                    {
                        tokenValue             = tokenValue.ToUpper();
                        var registrationResult = await _collectingGameService.RegisterTokenForFursuitBadgeForOwnerAsync(
                            badge.OwnerUid, badge.Id, tokenValue);

                        if (registrationResult.IsSuccessful)
                        {
                            await ReplyAsync(
                                $"*{title} Result*\n`Success!` - Token *{tokenValue}* successfully linked to *({badge.ExternalReference}) {badge.Name}*!\n\nNext one? /collectionGameRegisterFursuit");
                        }
                        else
                        {
                            await ReplyAsync(
                                $"*Error*: `{registrationResult.ErrorMessage}`");
                            await askTokenValue();
                        }
                    }, "Cancel=/cancel");
                    await askTokenValue();
                }, "Cancel=/cancel");
                await askForFursuitBadgeNo();
            }, "Cancel=/cancel");
            await askForRegNo();
        }
示例#3
0
        public async Task <ActionResult> RegisterTokenForFursuitBadgeForOwnerAsync([FromRoute] Guid FursuitBadgeId, [FromBody] string TokenValue)
        {
            var result = await _collectingGameService.RegisterTokenForFursuitBadgeForOwnerAsync(_apiPrincipal.Uid, FursuitBadgeId, TokenValue.ToUpper());

            return(result.AsActionResult());
        }