Esempio n. 1
0
        private async Task EnableAssetTwo(IUserMessage message, ISocketMessageChannel channel, SocketReaction reaction, IUser user)
        {
            var ship = new PlayerShip(Services).PopulateFromEmbed(message.Embeds.FirstOrDefault());

            if (ship == null)
            {
                return;
            }
            await channel.SendMessageAsync("This feature isn't ready, but the reaction is in place so that you don't have to recreate the card in the future.");
        }
Esempio n. 2
0
        private async Task IncreaseIntegrity(IUserMessage message, ISocketMessageChannel channel, SocketReaction reaction, IUser user)
        {
            var ship = new PlayerShip(Services).PopulateFromEmbed(message.Embeds.FirstOrDefault());

            if (ship == null)
            {
                return;
            }
            await message.RemoveReactionAsync(reaction.Emote, user).ConfigureAwait(false);

            ship.Integrity++;
            await message.ModifyAsync(msg => msg.Embed = ship.GetEmbed()).ConfigureAwait(false);
        }
Esempio n. 3
0
        public async Task CreatePlayerShip([Remainder] string ShipNameInput = "")
        {
            string[] randomWords = PlayerShipResources.RandomWords.Split(',');
            for (int i = 0; i < randomWords.Length; i++)
            {
                randomWords[i] = randomWords[i].Trim();
            }

            string[] skipWords = PlayerShipResources.SkipWords.Split(',');
            for (int i = 0; i < skipWords.Length; i++)
            {
                skipWords[i] = skipWords[i].Trim();
            }

            string[] yesWords = PlayerShipResources.YesWords.Split(',');
            for (int i = 0; i < yesWords.Length; i++)
            {
                yesWords[i] = yesWords[i].Trim();
            }

            var helperEmbed = new EmbedBuilder()
                              .WithTitle(PlayerShipResources.HelperTitle)
                              .WithDescription(PlayerShipResources.HelperSetShipName)
                              .WithFooter(PlayerShipResources.HelperFooter);

            IUserMessage post = null;

            if (ShipNameInput.Length == 0)
            {
                post = await ReplyAsync(embed : helperEmbed.Build()).ConfigureAwait(false);

                var shipNameMsg = await NextMessageAsync(timeout : TimeSpan.FromMinutes(2));

                if (shipNameMsg == null)
                {
                    await ShipCreationFailed(post); return;
                }
                ShipNameInput = shipNameMsg.Content;
                await shipNameMsg.DeleteAsync();
            }

            var valuesSoFarField = new EmbedFieldBuilder().WithName(PlayerShipResources.SelectedItems).WithValue(ShipNameInput);

            helperEmbed.WithDescription(PlayerShipResources.HelperSetHistory)
            .AddField(valuesSoFarField);

            if (post != null)
            {
                await post.ModifyAsync(msg => msg.Embed = helperEmbed.Build()).ConfigureAwait(false);
            }
            else
            {
                post = await ReplyAsync(embed : helperEmbed.Build()).ConfigureAwait(false);
            }

            var shipHistoryMessage = await NextMessageAsync(timeout : TimeSpan.FromMinutes(2));

            if (shipHistoryMessage == null)
            {
                await ShipCreationFailed(post); return;
            }
            string shipHistory = shipHistoryMessage.Content;

            if (skipWords.Any(skipWord => shipHistory.Equals(skipWord, StringComparison.OrdinalIgnoreCase)))
            {
                shipHistory = string.Empty;
            }
            if (randomWords.Any(randWord => shipHistory.Equals(randWord, StringComparison.OrdinalIgnoreCase)))
            {
                shipHistory = OracleService.RandomOracleResult("Starship History", Services, GameCore.GameName.Starforged);
            }
            await shipHistoryMessage.DeleteAsync().ConfigureAwait(false);

            valuesSoFarField.WithValue($"{valuesSoFarField.Value}\n{shipHistory}".Trim('\n'));
            await post.ModifyAsync(msg => msg.Embed = helperEmbed
                                   .WithDescription(PlayerShipResources.HelperSetLooks).Build()).ConfigureAwait(false);

            var shipLooksMessage = await NextMessageAsync(timeout : TimeSpan.FromMinutes(2));

            if (shipLooksMessage == null)
            {
                await ShipCreationFailed(post); return;
            }
            string shipLooks = shipLooksMessage.Content;

            if (skipWords.Any(skipWord => shipLooks.Equals(skipWord, StringComparison.OrdinalIgnoreCase)))
            {
                shipLooks = string.Empty;
            }
            if (randomWords.Any(randWord => shipLooks.Equals(randWord, StringComparison.OrdinalIgnoreCase)))
            {
                shipLooks = OracleService.RandomOracleResult("Starship Quirks", Services, GameCore.GameName.Starforged);
            }
            await shipLooksMessage.DeleteAsync().ConfigureAwait(false);

            valuesSoFarField.WithValue($"{valuesSoFarField.Value}\n{shipLooks}".Trim('\n'));
            await post.ModifyAsync(msg => msg.Embed = helperEmbed.WithDescription(PlayerShipResources.HelperIncludeSupply).Build()).ConfigureAwait(false);

            var useSupplyMsg = await NextMessageAsync(timeout : TimeSpan.FromMinutes(2));

            if (useSupplyMsg == null)
            {
                await ShipCreationFailed(post); return;
            }
            await useSupplyMsg.DeleteAsync().ConfigureAwait(false);

            var ship = new PlayerShip(Services);

            ship.Name      = ShipNameInput;
            ship.UseSupply = yesWords.Any(yesWord => useSupplyMsg.Content.Contains(yesWord, StringComparison.OrdinalIgnoreCase));

            ship.Description = shipHistory.Length > 0 ? string.Format(PlayerShipResources.ShipHistory, shipHistory) : string.Empty;
            if (ship.Description.Length > 0 && shipLooks.Length > 0)
            {
                ship.Description += "\n";
            }
            ship.Description += shipLooks.Length > 0 ? string.Format(PlayerShipResources.ShipLooks, shipLooks) : string.Empty;

            await post.ModifyAsync(msg => msg.Embed = ship.GetEmbed()).ConfigureAwait(false);

            await Task.Run(async() =>
            {
                await post.RemoveAllReactionsAsync();
                await post.AddReactionAsync(DecreaseIntegrityEmoji);
                await post.AddReactionAsync(IncreaseIntegrityEmoji);
                if (ship.UseSupply)
                {
                    await post.AddReactionAsync(SupplyDownEmoji);
                }
                if (ship.UseSupply)
                {
                    await post.AddReactionAsync(SupplyUpEmoji);
                }
                await post.AddReactionAsync(GenericReactions.twoEmoji);
                await post.AddReactionAsync(GenericReactions.threeEmoji);
            }).ConfigureAwait(false);
        }