Skip to content

Commit

Permalink
imp - Made positions clearer in BackRace
Browse files Browse the repository at this point in the history
---

The positions have been made clearer than the previous version in BackRace. However, we've met an edge case in the centered text writer causing it not to center the text right.

---

Type: imp
Breaking: False
Doc Required: False
Part: 1/1
  • Loading branch information
AptiviCEO committed Feb 27, 2024
1 parent 59d11d5 commit 436f4a8
Showing 1 changed file with 7 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ internal static void OpenBackRace()
// Some essential variables
int chance = 30;
BackRaceHorse[] horses;
Color[] horseColors;

// Reset all the horses
void ResetAll()
Expand All @@ -59,14 +58,6 @@ void ResetAll()
new BackRaceHorse(4),
new BackRaceHorse(5),
];
horseColors =
[
ColorTools.GetRandomColor(ColorType.TrueColor),
ColorTools.GetRandomColor(ColorType.TrueColor),
ColorTools.GetRandomColor(ColorType.TrueColor),
ColorTools.GetRandomColor(ColorType.TrueColor),
ColorTools.GetRandomColor(ColorType.TrueColor)
];
}
ResetAll();

Expand All @@ -85,9 +76,10 @@ void ResetAll()
for (int i = 0; i < 5; i++)
{
// Indicate the selected horse by coloring it white
int height = consoleSixthsHeight * i + 2;
var finalColor = i + 1 == selected ? ConsoleColors.White : horseColors[i];
int height = consoleSixthsHeight * i + 3;
var horse = horses[i];
var finalColor = i + 1 == selected ? ConsoleColors.White : horse.HorseColor;
TextWriterWhereColor.WriteWhereColor(Translate.DoTranslation("Horse") + $" {horse.HorseNumber}", 1, height - 1, finalColor);
BorderColor.WriteBorder(boxLeft, height, boxWidth, 1, finalColor);
TextWriterWhereColor.WriteWhereColor($"{horse.HorseProgress:000}%", 2, height + 1, finalColor);
ProgressBarColor.WriteProgress(horse.HorseProgress, progressLeft, height, finalColor, finalColor);
Expand All @@ -108,10 +100,9 @@ void ResetAll()
.ToArray();
List<string> positions = [];
for (int i = 0; i < horsesSorted.Length; i++)
positions.Add(Translate.DoTranslation("Horse") + $" {horsesSorted[i].HorseNumber}: #{i + 1}");
positions.Add($"{KernelColorTools.GetColor(KernelColorType.NeutralText).VTSequenceForeground}#{i + 1}: {horsesSorted[i].HorseColor.VTSequenceForeground}{Translate.DoTranslation("Horse")} {horsesSorted[i].HorseNumber}{KernelColorTools.GetColor(KernelColorType.NeutralText).VTSequenceForeground}");
string renderedPositions = string.Join(" | ", positions);
int positionsPositionX = ConsoleWrapper.WindowWidth / 2 - renderedPositions.Length / 2;
TextWriters.WriteWhere(renderedPositions, positionsPositionX, bindingsPositionY, KernelColorType.NeutralText);
TextFancyWriters.WriteCentered(bindingsPositionY, renderedPositions, KernelColorType.NeutralText);

// Update each horse with their own movement
for (int i = 0; i < 5; i++)
Expand Down Expand Up @@ -187,10 +178,12 @@ internal class BackRaceHorse
{
internal int HorseNumber { get; private set; }
internal int HorseProgress { get; set; } = 0;
internal Color HorseColor { get; private set; }

internal BackRaceHorse(int horseNumber)
{
HorseNumber = horseNumber;
HorseColor = ColorTools.GetRandomColor(ColorType.TrueColor);
}
}
}

0 comments on commit 436f4a8

Please sign in to comment.