Exemple #1
0
        public async Task PlanetPost([Remainder] string PlanetCommand = "")
        {
            SpaceRegion spaceRegion = StarforgedUtilites.GetAnySpaceRegion(PlanetCommand);

            string PlanetName = PlanetCommand.Replace(spaceRegion.ToString(), "", StringComparison.OrdinalIgnoreCase).Trim();

            if (PlanetName == string.Empty)
            {
                PlanetName = $"P-{DateTime.Now.Ticks.ToString().Substring(7)}";
            }

            if (spaceRegion == SpaceRegion.None)
            {
                var palceHolderEmbed = new EmbedBuilder()
                                       .WithTitle("__Planet Helper__")
                                       .WithDescription(PlanetName)
                                       .WithFields(new EmbedFieldBuilder()
                                                   .WithName("Options:")
                                                   .WithValue($"{oneEmoji}: Terminus\n{twoEmoji}: Outlands\n{threeEmoji}: Expanse")
                                                   );

                var msg = await ReplyAsync(embed : palceHolderEmbed.Build());

                await msg.AddReactionAsync(new Emoji(oneEmoji));

                await msg.AddReactionAsync(new Emoji(twoEmoji));

                await msg.AddReactionAsync(new Emoji(threeEmoji));

                return;
            }

            await MakePlanetPost(spaceRegion, PlanetName);
        }
Exemple #2
0
        public async Task SettlementPost([Remainder] string SettlementCommand = "")
        {
            var region = StarforgedUtilites.GetAnySpaceRegion(SettlementCommand);

            if (region == SpaceRegion.None)
            {
                EmbedBuilder builder = new EmbedBuilder()
                                       .WithTitle(SettlementResources.SettlementHelper)
                                       .WithDescription(SettlementResources.PickSpaceRegionMessage);

                if (SettlementCommand.Length > 0)
                {
                    builder.WithFields(new EmbedFieldBuilder().WithName(SettlementResources.SettlementName).WithValue(SettlementCommand));
                }

                var msg = await ReplyAsync(embed : builder.Build());

                await msg.AddReactionAsync(oneEmoji);

                await msg.AddReactionAsync(twoEmoji);

                await msg.AddReactionAsync(threeEmoji);

                return;
            }

            string SettlementName = SettlementCommand.Replace(region.ToString(), "").Trim();
            var    settlement     = Settlement.GenerateSettlement(Services, region, SettlementName);

            //embedBuilder.ThumbnailUrl = planet.Thumbnail; //TODO (maybe location hex?)
            var message = await ReplyAsync("", false, settlement.GetEmbedBuilder().Build());

            await message.AddReactionAsync(projectEmoji);
        }
Exemple #3
0
        public Starship FromEmbed(IEmbed embed)
        {
            string      Name   = embed.Title.Replace("__", "");
            SpaceRegion region = StarforgedUtilites.GetAnySpaceRegion(embed.Description);

            this.FirstLooksToReveal = embed.Fields.Count(fld => fld.Name == StarShipResources.FirstLook);
            this.FirstLooks         = embed.Fields.Where(fld => fld.Name == StarShipResources.FirstLook)?.Select(item => item.Value).ToList() ?? new List <string>();
            this.Fleet           = embed.Fields.FirstOrDefault(fld => fld.Name == StarShipResources.Fleet).Value;
            this.InitialContact  = embed.Fields.FirstOrDefault(fld => fld.Name == StarShipResources.InitialContact).Value;
            this.MissionRevealed = embed.Fields.Any(fld => fld.Name == StarShipResources.StarshipMission);
            if (this.MissionRevealed)
            {
                this.Mission = embed.Fields.FirstOrDefault(fld => fld.Name == StarShipResources.StarshipMission).Value;
            }
            this.Name        = embed.Title.Replace("__", string.Empty);
            this.ShipType    = embed.Fields.FirstOrDefault(fld => fld.Name == StarShipResources.StarshipType).Value;
            this.SpaceRegion = StarforgedUtilites.GetAnySpaceRegion(embed.Description);

            bool hasTypicalRole = embed.Fields.Any(fld => fld.Name == StarShipResources.TypicalRole);

            this.TypicalRole = (hasTypicalRole) ? embed.Fields.FirstOrDefault(fld => fld.Name == StarShipResources.TypicalRole).Value : string.Empty;
            this.IconUrl     = embed.Thumbnail?.Url;

            return(this);
        }
Exemple #4
0
        public Settlement FromEmbed(IEmbed embed)
        {
            if (!embed.Description.Contains(SettlementResources.Settlement))
            {
                throw new ArgumentException(SettlementResources.SettlementNotFoundError);
            }

            this.Authority              = embed.Fields.FirstOrDefault(fld => fld.Name == SettlementResources.Authority).Value;
            this.FirstLooks             = embed.Fields.Where(fld => fld.Name == SettlementResources.FirstLook)?.Select(item => item.Value).ToList() ?? new List <string>();
            this.FirstLooksToReveal     = FirstLooks.Count();
            this.InitialContactRevealed = embed.Fields.Any(fld => fld.Name == SettlementResources.InitialContact);
            if (InitialContactRevealed)
            {
                this.InitialContact = embed.Fields.FirstOrDefault(fld => fld.Name == SettlementResources.InitialContact).Value;
            }
            this.Location                  = embed.Fields.FirstOrDefault(fld => fld.Name == SettlementResources.Location).Value;
            this.Name                      = embed.Title.Replace("__", "");
            this.Population                = embed.Fields.FirstOrDefault(fld => fld.Name == SettlementResources.Population).Value;
            this.Projects                  = embed.Fields.Where(fld => fld.Name == SettlementResources.SettlementProjects)?.Select(item => item.Value).ToList() ?? new List <string>();
            this.ProjectsRevealed          = embed.Fields.Count(fld => fld.Name.Contains(SettlementResources.SettlementProjects));
            this.Region                    = StarforgedUtilites.GetAnySpaceRegion(embed.Description);
            this.SettlementTroubleRevealed = embed.Fields.Any(fld => fld.Name == SettlementResources.SettlementTrouble);
            if (SettlementTroubleRevealed)
            {
                this.SettlementTrouble = embed.Fields.FirstOrDefault(fld => fld.Name == SettlementResources.SettlementTrouble).Value;
            }
            this.IconUrl = embed.Thumbnail?.Url;

            return(this);
        }
Exemple #5
0
        public async Task StarShipPost([Remainder] string StarShipCommand = "")
        {
            var region = StarforgedUtilites.GetAnySpaceRegion(StarShipCommand);

            if (region == SpaceRegion.None)
            {
                EmbedBuilder builder = new EmbedBuilder()
                                       .WithTitle(StarShipResources.StarshipHelperTitle)
                                       .WithDescription(StarShipResources.PickSpaceRegionMessage);

                if (StarShipCommand.Length > 0)
                {
                    builder.WithFields(new EmbedFieldBuilder().WithName(StarShipResources.StarshipName).WithValue(StarShipCommand));
                }

                var msg = await ReplyAsync(embed : builder.Build());

                await msg.AddReactionAsync(oneEmoji);

                await msg.AddReactionAsync(twoEmoji);

                await msg.AddReactionAsync(threeEmoji);

                return;
            }

            string ShipName = Regex.Replace(StarShipCommand, region.ToString(), "", RegexOptions.IgnoreCase).Trim();
            var    ship     = Starship.GenerateShip(Services, region, ShipName);

            var message = await ReplyAsync("", false, ship.GetEmbedBuilder().Build());

            await message.AddReactionAsync(missionEmoji);
        }
Exemple #6
0
        public static Starship FromEmbed(ServiceProvider services, IEmbed embed)
        {
            string      Name   = embed.Title.Replace("__", "");
            SpaceRegion region = StarforgedUtilites.GetAnySpaceRegion(embed.Description);

            var ship = GenerateShip(services, region, Name);

            ship.MissionRevealed = embed.Fields.Any(fld => fld.Name.Equals(StarShipResources.StarshipMission));

            return(ship);
        }
Exemple #7
0
        public Settlement FromEmbed(IEmbed embed)
        {
            if (!embed.Description.Contains(SettlementResources.Settlement))
            {
                throw new ArgumentException(SettlementResources.SettlementNotFoundError);
            }

            SpaceRegion region     = StarforgedUtilites.GetAnySpaceRegion(embed.Description);
            var         settlement = GenerateSettlement(Services, region, embed.Title.Replace("__", ""));

            settlement.FirstLooksToReveal = embed.Fields.Count(fld => fld.Name.Contains(SettlementResources.FirstLook));
            settlement.ProjectsRevealed   = embed.Fields.Count(fld => fld.Name.Contains(SettlementResources.SettlementProjects));

            return(settlement);
        }
        public async Task SettlementPost([Remainder] string SettlementCommand = "")
        {
            var region = StarforgedUtilites.GetAnySpaceRegion(SettlementCommand);

            if (region == SpaceRegion.None)
            {
                EmbedBuilder builder = new EmbedBuilder()
                                       .WithTitle(SettlementResources.SettlementHelper)
                                       .WithDescription(SettlementResources.PickSpaceRegionMessage);

                if (SettlementCommand.Length > 0)
                {
                    builder.WithFields(new EmbedFieldBuilder().WithName(SettlementResources.SettlementName).WithValue(SettlementCommand));
                }

                var msg = await ReplyAsync(embed : builder.Build());

                await msg.AddReactionAsync(GenericReactions.oneEmoji);

                await msg.AddReactionAsync(GenericReactions.twoEmoji);

                await msg.AddReactionAsync(GenericReactions.threeEmoji);

                return;
            }


            string SettlementLocation = ExtractAnySettlementLocation(ref SettlementCommand);
            string SettlementName     = SettlementCommand.Replace(region.ToString(), "", StringComparison.OrdinalIgnoreCase).Trim();

            var settlement = Settlement.GenerateSettlement(Services, region, Context.Channel.Id, SettlementName, SettlementLocation);

            //embedBuilder.ThumbnailUrl = planet.Thumbnail; //TODO (maybe location hex?)
            var message = await ReplyAsync("", false, settlement.GetEmbedBuilder().Build());

            await Task.Run(async() =>
            {
                await message.AddReactionAsync(projectEmoji);
                await message.AddReactionAsync(contactEmoji);
                await message.AddReactionAsync(troubleEmoji);
            }).ConfigureAwait(false);
        }