Add comments
This commit is contained in:
@ -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())
|
||||
|
Reference in New Issue
Block a user