feature(BuildCalc) Added reset button, can change micro delay, and can alter timing interval again
This commit is contained in:
@@ -5,31 +5,33 @@ using static Services.IMemoryTesterService;
|
||||
|
||||
namespace Services.Immortal;
|
||||
|
||||
public enum MemoryTesterEvent {
|
||||
public enum MemoryTesterEvent
|
||||
{
|
||||
OnVerify,
|
||||
OnRefresh
|
||||
}
|
||||
|
||||
public class MemoryTesterService : IMemoryTesterService {
|
||||
public class MemoryTesterService : IMemoryTesterService
|
||||
{
|
||||
private readonly List<MemoryEntityModel> memoryEntities = MemoryEntityModel.TestData;
|
||||
private readonly List<MemoryQuestionModel> memoryQuestions = MemoryQuestionModel.TestData;
|
||||
|
||||
|
||||
private readonly Random random = new();
|
||||
|
||||
|
||||
private event MemoryAction OnChange = null!;
|
||||
|
||||
|
||||
public void Subscribe(MemoryAction action) {
|
||||
public void Subscribe(MemoryAction action)
|
||||
{
|
||||
OnChange += action;
|
||||
}
|
||||
|
||||
public void Unsubscribe(MemoryAction action) {
|
||||
public void Unsubscribe(MemoryAction action)
|
||||
{
|
||||
OnChange -= action;
|
||||
}
|
||||
|
||||
public void GenerateQuiz() {
|
||||
public void GenerateQuiz()
|
||||
{
|
||||
memoryEntities.Clear();
|
||||
memoryQuestions.Clear();
|
||||
|
||||
@@ -42,17 +44,21 @@ public class MemoryTesterService : IMemoryTesterService {
|
||||
var entityIndex = 0;
|
||||
var questionIndex = 0;
|
||||
|
||||
foreach (var unit in units) {
|
||||
memoryEntities.Add(new MemoryEntityModel {
|
||||
foreach (var unit in units)
|
||||
{
|
||||
memoryEntities.Add(new MemoryEntityModel
|
||||
{
|
||||
Id = ++entityIndex,
|
||||
Name = unit.Info().Name
|
||||
});
|
||||
|
||||
var weaponIndex = 0;
|
||||
foreach (var weapon in unit.Weapons()) {
|
||||
foreach (var weapon in unit.Weapons())
|
||||
{
|
||||
weaponIndex++;
|
||||
|
||||
memoryQuestions.Add(new MemoryQuestionModel {
|
||||
memoryQuestions.Add(new MemoryQuestionModel
|
||||
{
|
||||
Id = ++questionIndex,
|
||||
MemoryEntityModelId = entityIndex,
|
||||
Name = $"Range (Weapon {weaponIndex})",
|
||||
@@ -61,7 +67,8 @@ public class MemoryTesterService : IMemoryTesterService {
|
||||
});
|
||||
}
|
||||
|
||||
memoryQuestions.Add(new MemoryQuestionModel {
|
||||
memoryQuestions.Add(new MemoryQuestionModel
|
||||
{
|
||||
Id = ++questionIndex,
|
||||
MemoryEntityModelId = entityIndex,
|
||||
Name = "Speed",
|
||||
@@ -73,27 +80,34 @@ public class MemoryTesterService : IMemoryTesterService {
|
||||
NotifyDataChanged(MemoryTesterEvent.OnRefresh);
|
||||
}
|
||||
|
||||
public List<MemoryEntityModel> GetEntities() {
|
||||
public List<MemoryEntityModel> GetEntities()
|
||||
{
|
||||
return memoryEntities;
|
||||
}
|
||||
|
||||
public List<MemoryQuestionModel> GetQuestions() {
|
||||
public List<MemoryQuestionModel> GetQuestions()
|
||||
{
|
||||
return memoryQuestions;
|
||||
}
|
||||
|
||||
public void Update(MemoryQuestionModel memoryQuestion) {
|
||||
public void Update(MemoryQuestionModel memoryQuestion)
|
||||
{
|
||||
memoryQuestions[memoryQuestion.Id - 1].Guess = memoryQuestion.Guess;
|
||||
}
|
||||
|
||||
public void Verify() {
|
||||
public void Verify()
|
||||
{
|
||||
NotifyDataChanged(MemoryTesterEvent.OnVerify);
|
||||
}
|
||||
|
||||
|
||||
private event MemoryAction OnChange = null!;
|
||||
|
||||
|
||||
//public delegate void MemoryAction(MemoryTesterActions memoryAction);
|
||||
|
||||
private void NotifyDataChanged(MemoryTesterEvent memoryAction) {
|
||||
private void NotifyDataChanged(MemoryTesterEvent memoryAction)
|
||||
{
|
||||
OnChange?.Invoke(memoryAction);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user