Add comments

This commit is contained in:
KaseToatz1337
2024-11-07 10:18:20 +01:00
parent 32055107ab
commit 4c01b5ae79
5 changed files with 43 additions and 11 deletions

View File

@ -15,11 +15,13 @@
public int Attempts { get; set; } = 0;
public Score Scoring { get; } = new(player, 0);
// Formula to calculate score
public void CalculateScore(long endTime)
{
Scoring.Points = (int)(Math.Pow(DeckSize * 2, 2) / ((endTime - StartTime) / 1000.0 * Attempts) * 1000.0);
}
// Get the optimal grid size for the current amount of cards
public static Deck GetGridSize(int deckSize)
{
for (int i = (int)Math.Sqrt(deckSize * 2); i > 0; i--)
@ -32,6 +34,7 @@
return new(1, deckSize * 2);
}
// Create a random set of cards
public static List<Card> CreateDeck(int pairs)
{
List<Card> cards = [];
@ -65,6 +68,7 @@
Card? choice2 = GetChoice2();
if (!card.Completed)
{
// Set the card to choice1 or choice2 depending on the context
if ((choice1 == null && choice2 == null) || (choice1 != null && choice2 != null))
{
if (choice1 != null)
@ -83,6 +87,7 @@
Attempts++;
if (choice1.Matches(card))
{
// If card matches, mark as complete and check if the game is finished
choice1.Completed = true;
card.Completed = true;
if (IsFinished())