56 lines
1.3 KiB
C#
56 lines
1.3 KiB
C#
using FWLAZ_Web.Data;
|
|
using Blazored.LocalStorage;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.AspNetCore.Components;
|
|
|
|
namespace FWLAZ_Web.Objects
|
|
{
|
|
public class GameState
|
|
{
|
|
public enum QuizMode
|
|
{
|
|
Practice,
|
|
Tournament
|
|
}
|
|
|
|
public const string STORAGEKEY = "QuizSetting";
|
|
public QuizMode Mode { get; set; } = QuizMode.Practice;
|
|
|
|
public int QuizId { get; }
|
|
public bool QuizIsMultipleChoice { get; set; }
|
|
public string? Title { get; set; } = null!;
|
|
|
|
|
|
public string? Username { get; set; }
|
|
public List<Question>? Questions { get; set; }
|
|
|
|
public List<QuestionAnswer>? QuestionAnswers { get; set; }
|
|
public Question? CurrentQuestion
|
|
{
|
|
get
|
|
{
|
|
return Questions?.FirstOrDefault();
|
|
}
|
|
}
|
|
|
|
public GameState() { }
|
|
|
|
public GameState(Quiz quiz)
|
|
{
|
|
QuizId = quiz.Id;
|
|
QuizIsMultipleChoice = quiz.IsMultipleChoice;
|
|
Title = quiz.Name;
|
|
}
|
|
|
|
public bool NextQuestion()
|
|
{
|
|
if (Questions == null || Questions.Count == 0)
|
|
{
|
|
return false;
|
|
}
|
|
Questions.Remove(Questions[0]);
|
|
return true;
|
|
}
|
|
}
|
|
}
|