Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
stevehjohn committed Mar 14, 2024
1 parent 2cd40f2 commit c6593d2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
3 changes: 2 additions & 1 deletion src/Sudoku.Console/Supporting Files/Styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,10 @@ td {
background-color: bisque;
}

.title {
.cellTitle {
font-weight: bold;
font-size: 13px;
padding-bottom: 5px;
}

.tree li a.deadEnd {
Expand Down
21 changes: 16 additions & 5 deletions src/Sudoku.Console/TreeGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ public static class TreeGenerator
{
private const string Numbers = "➊➋➌➍➎➏➐➑➒";

private const string NodeTemplate = "<li><a class='{class}' href='#'><span class='title'>{type}</span>{puzzle}</a>{children}</li>";
private const string NodeTemplate = "<li><a class='{class}' href='#'><div class='cellTitle'>{type}</div>{puzzle}</a>{children}</li>";

public static void Generate(int[] puzzle, string filename)
{
Expand Down Expand Up @@ -96,7 +96,14 @@ private static string ProcessNode(Node node)
}
else
{
puzzle.Append("<pre>&nbsp;</pre>");
if (node.Move.Type == MoveType.NoCandidates && node.Move.X == x && node.Move.Y == y)
{
puzzle.Append("<span class='added'>ⓧ</span>");
}
else
{
puzzle.Append("<pre>&nbsp;</pre>");
}
}

puzzle.Append("</td>");
Expand All @@ -106,7 +113,7 @@ private static string ProcessNode(Node node)

content = content.Replace("{puzzle}", puzzle.ToString());

if (! node.OnSolvedPath && node.Children.Count == 0)
if (! node.OnSolvedPath && node.Children.Count == 0 && node.Move.Type != MoveType.NoCandidates)
{
content = content.Replace("{class}", "deadEnd").Replace("{type}", "Unsolvable");
}
Expand All @@ -123,11 +130,15 @@ private static string ProcessNode(Node node)
break;

case MoveType.LastPossibleNumber:
content = content.Replace("{class}", "lastPossible").Replace("{type}", "Last");
content = content.Replace("{class}", "lastPossible").Replace("{type}", "Last Candidate");
break;

case MoveType.NoCandidates:
content = content.Replace("{class}", "deadEnd").Replace("{type}", $"No Candidate");
break;

default:
content = content.Replace("{class}", node.OnSolvedPath ? "solvePath" : string.Empty).Replace("{type}", "Single");
content = content.Replace("{class}", node.OnSolvedPath ? "solvePath" : string.Empty).Replace("{type}", "Hidden Single");
break;
}
}
Expand Down

0 comments on commit c6593d2

Please sign in to comment.