public ShareHolderGui(ShareHolderSpace space, Color color, SpaceRegion spaceRegion, Rectangle bounds = new Rectangle()) { this.Space = space; this.Color = color; this.Bounds = bounds; this.SpaceRegion = spaceRegion; }
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); }
private async Task MakePlanetPost(SpaceRegion region, string PlanetName, IUserMessage message = null) { Planet planet = Planet.GeneratePlanet(PlanetName, region, Services); if (message != null) { await message.RemoveAllReactionsAsync(); await message.ModifyAsync(msg => msg.Embed = planet.GetEmbedBuilder().Build()); } else { message = await ReplyAsync(embed : planet.GetEmbedBuilder().Build()); } _ = Task.Run(async() => { await message.AddReactionAsync(new Emoji("🔍")); await message.AddReactionAsync(new Emoji("\U0001F996")); if (planet.NumberOfBiomes > 1) { var biome = new Emoji("\uD83C\uDF0D"); await message.AddReactionAsync(biome); } }).ConfigureAwait(false); }
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); }
void CreatePassage(SpaceRegion regionA, SpaceRegion regionB, Coord tileA, Coord tileB) { SpaceRegion.ConnectRegions(regionA, regionB); Vector2[] points = { CoordToWorldPoint(tileA), CoordToWorldPoint(tileB) }; //Debug.DrawLine (points [0], points [1], Color.red, 100f); passagePoints.Add(points); }
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); }
public static Starship GenerateShip(IServiceProvider services, SpaceRegion region, string name, ulong channelId) { if (region == SpaceRegion.None) { throw new ArgumentException($"Please specify a space region"); } var oracles = services.GetRequiredService <OracleService>(); Starship ship = new Starship(services, channelId); ship.Name = (name.Length > 0) ? name : oracles.RandomRow("Starship Name").Description; int seed = $"{ship.Name}{region}".GetDeterministicHashCode(); Random random = new Random(seed); ship.FirstLooksToReveal = random.Next(1, 4); for (int i = 0; i < ship.FirstLooksToReveal; i++) { ship.FirstLooks.AddRandomOracleRow("Starship First Look", GameName.Starforged, services, channelId, random); } ship.Fleet = oracles.RandomRow($"Fleet", GameName.Starforged, random).Description; if (ship.Fleet.Equals(StarShipResources.StarshipMissionOracle)) { ship.Fleet = oracles.RandomRow(string.Format(StarShipResources.StarshipMissionOracleRegionFormatter, region), GameName.Starforged).Description; } ship.InitialContact = oracles.RandomRow("Starship Initial Contact", GameName.Starforged, random).Description; var shipTypeOracle = oracles.OracleList.Single(o => o.Name == "Starship Type" && o.Game == GameName.Starforged).Oracles.GetRandomRow(random); var shipType = (shipTypeOracle.Description != "[Starship Mission]") ? shipTypeOracle.Description : $"[Starship Mission {region}]"; ship.ShipType = shipTypeOracle.GetOracleResult(services, GameName.Starforged, random, new string[] { region.ToString() }); ship.TypicalRole = string.Empty; if (shipTypeOracle?.Prompt?.Length > 0) { ship.TypicalRole = shipTypeOracle.Prompt; if (ship.TypicalRole.Equals(StarShipResources.StarshipMissionOracle, StringComparison.OrdinalIgnoreCase)) { string additionalOracleTable = string.Format(StarShipResources.StarshipMissionOracleRegionFormatter, region); ship.TypicalRole = oracles.RandomRow(additionalOracleTable, GameName.Starforged).Description; } } ship.SpaceRegion = region; return(ship); }
void ConnectClosestRegions(List <SpaceRegion> allRegions) { int bestDistance = 0; Coord bestTileA = new Coord(); Coord bestTileB = new Coord(); SpaceRegion bestRegionA = new SpaceRegion(); SpaceRegion bestRegionB = new SpaceRegion(); bool possibleConnection = false; foreach (SpaceRegion regionA in allRegions) { possibleConnection = false; foreach (SpaceRegion regionB in allRegions) { for (int tileIndexA = 0; tileIndexA < regionA.edgeTiles.Count; tileIndexA++) { if (regionA == regionB) { continue; } if (regionA.isConnected(regionB)) { possibleConnection = false; break; } for (int tileIndexB = 0; tileIndexB < regionB.edgeTiles.Count; tileIndexB++) { Coord tileA = regionA.edgeTiles [tileIndexA]; Coord tileB = regionB.edgeTiles [tileIndexB]; int distance = (int)(Mathf.Pow(tileA.tileX - tileB.tileX, 2) + Mathf.Pow(tileA.tileY - tileB.tileY, 2)); if (distance < bestDistance || !possibleConnection) { bestDistance = distance; possibleConnection = true; bestTileA = tileA; bestTileB = tileB; bestRegionA = regionA; bestRegionB = regionB; } } } } if (possibleConnection) { CreatePassage(bestRegionA, bestRegionB, bestTileA, bestTileB); } } }
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 static Settlement GenerateSettlement(ServiceProvider serviceProvider, SpaceRegion spaceRegion, string SettlementName = "") { var oracleService = serviceProvider.GetRequiredService <OracleService>(); if (SettlementName == string.Empty) { SettlementName = oracleService.RandomRow("Settlement Name").Description; } var s = new Settlement(serviceProvider); s.Seed = $"{SettlementName}{spaceRegion}".GetDeterministicHashCode(); s.Region = spaceRegion; s.Name = SettlementName; Random random = new Random(s.Seed); s.Authority = oracleService.RandomRow("Settlement Authority", GameName.Starforged, random).Description; s.FirstLooks = oracleService.OracleList.Single(o => o.Name == "Settlement First Look" && o.Game == GameName.Starforged) .Oracles.Select(o => o.GetOracleResult(serviceProvider, GameName.Starforged, random)).ToList(); s.FirstLooks.Shuffle(random); s.FirstLooksToReveal = random.Next(1, 4); s.InitialContact = oracleService.RandomRow("Settlement Initial Contact", GameName.Starforged, random).Description; s.Location = oracleService.RandomRow("Settlement Location", GameName.Starforged, random).Description; s.Population = oracleService.RandomRow($"Settlement Population {s.Region}", GameName.Starforged, random).Description; s.Projects = oracleService.OracleList.Single(o => o.Name == "Settlement Projects" && o.Game == GameName.Starforged) .Oracles.Select(o => o.GetOracleResult(serviceProvider, GameName.Starforged, random)).ToList(); s.Projects.Shuffle(random); var trouble = oracleService.RandomRow($"Settlement Trouble", GameName.Starforged, random) as StandardOracle; s.SettlementTrouble = trouble.GetOracleResult(serviceProvider, GameName.Starforged, random); return(s); }
public bool isConnected(SpaceRegion otherRegion) { return(connectedRegions.Contains(otherRegion)); }
public static void ConnectRegions(SpaceRegion regionA, SpaceRegion regionB) { regionA.connectedRegions.Add(regionB); regionB.connectedRegions.Add(regionA); }
private string GetDirectionArrow(Direction direction, SpaceRegion region) { if (region == SpaceRegion.BottomRow) { if (direction == Direction.Left) { return("←"); } else if (direction == Direction.Right) { return("→"); } else { return("↔"); } } if (region == SpaceRegion.TopRow) { if (direction == Direction.Left) { return("→"); } else if (direction == Direction.Right) { return("←"); } else { return("↔"); } } if (region == SpaceRegion.LeftRow) { if (direction == Direction.Left) { return("↑"); } else if (direction == Direction.Right) { return("↓"); } else { return("↕"); } } if (region == SpaceRegion.RightRow) { if (direction == Direction.Left) { return("↓"); } else if (direction == Direction.Right) { return("↑"); } else { return("↕"); } } if (region == SpaceRegion.TopLeftCorner) { return("←↓"); } if (region == SpaceRegion.TopRightCorner) { return("↑←"); } if (region == SpaceRegion.BottomLeftCorner) { return("↓→"); } if (region == SpaceRegion.BottomRightCorner) { return("→↑"); } return("↔"); }
public static Settlement GenerateSettlement(IServiceProvider serviceProvider, SpaceRegion spaceRegion, ulong channelId, string SettlementName = "", string SettlementLocation = "") { var oracleService = serviceProvider.GetRequiredService <OracleService>(); if (SettlementName == string.Empty) { SettlementName = oracleService.RandomRow("Settlement Name", GameName.Starforged).Description; } var s = new Settlement(serviceProvider, channelId); s.Region = spaceRegion; s.Name = SettlementName; int seed = $"{SettlementName}{spaceRegion}".GetDeterministicHashCode(); Random random = new Random(seed); s.Authority = oracleService.RandomRow("Settlement Authority", GameName.Starforged, random).Description; s.FirstLooksToReveal = random.Next(1, 4); for (int i = 0; i < s.FirstLooksToReveal; i++) { s.FirstLooks.AddRandomOracleRow("Settlement First Look", GameName.Starforged, serviceProvider, channelId, random); } s.Location = (SettlementLocation.Length > 0) ? SettlementLocation : oracleService.RandomRow("Settlement Location", GameName.Starforged, random).Description; s.Population = oracleService.RandomRow($"Settlement Population {s.Region}", GameName.Starforged, random).Description; return(s); }