Skip to content

Commit

Permalink
Update Text renderer.
Browse files Browse the repository at this point in the history
  • Loading branch information
julian94 committed Nov 7, 2021
1 parent ce88962 commit de7bd6d
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions TravellerRenderer/TextRenderer.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace TravellerRenderer;
using System.Text;

namespace TravellerRenderer;
public class TextRenderer
{
public static string Name = "Text Grid Renderer";
Expand Down Expand Up @@ -32,11 +34,11 @@ public static async Task<string> RenderWorldsTwoLine(List<World> worlds, int X1,
var offset = 1 + i % 2;
for (int j = 0; j < rows; i++)
{
var world = worlds[0]; // Replace with LINQ query that gets world with matching position.
world ??= {" ", "____"};
var parts = WorldToTwoStrings(world);
parts[i*2+offset].Append(parts[0]+@"\")
parts[i*2+offset+1].Append(parts[1]+"/")
var world = (from entry in worlds where (entry.Position == new Position(X1 + i, Y1 + j)) select entry).FirstOrDefault();

var worldParts = WorldToTwoStrings(world);
parts[i * 2 + offset].Append(worldParts[0] + @"\");
parts[i * 2 + offset + 1].Append(worldParts[1] + "/");
}
}

Expand All @@ -63,7 +65,15 @@ public static async Task<string> RenderWorldsFourLine(List<World> worlds, int X,

public static List<string> WorldToTwoStrings(World world)
{
var strings = new List<string>(4);
var strings = new List<string>(2);

if (world == null)
{
strings.Add(" ");
strings.Add("____");
return strings;
}

// Lines are 4 characters each. For the lowest line, if they're used the underlines disappear.

var gasGiant = world.GasGiants > 0 ? 'G' : ' ';
Expand Down

0 comments on commit de7bd6d

Please sign in to comment.