Skip to content

Commit

Permalink
fix illegal letters crashing the program
Browse files Browse the repository at this point in the history
  • Loading branch information
OliBomby committed Dec 8, 2022
1 parent 4e8a3ae commit 44bab19
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions SpellCastSolverLib/LetterState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,20 @@ public class LetterState
public int PointsMultiplier;
public int Multiplier;
public bool Gem;

public int Points => LetterPoints[char.ToLower(Letter)];
public readonly int Points;

public LetterState(char letter, int pointsMultiplier = 1, int multiplier = 1, bool gem = false)
{
Letter = letter;
PointsMultiplier = pointsMultiplier;
Multiplier = multiplier;
Gem = gem;
Points = GetPoints(letter);
}

public static int GetPoints(char letter)
{
return LetterPoints.ContainsKey(char.ToLower(letter)) ? LetterPoints[char.ToLower(letter)] : 0;
}

public static readonly Dictionary<char, int> LetterPoints = new() {
Expand Down

0 comments on commit 44bab19

Please sign in to comment.