Skip to content

Commit

Permalink
Show lost answer
Browse files Browse the repository at this point in the history
  • Loading branch information
PrashantUnity committed Jun 5, 2024
1 parent b7523c6 commit ebc2bd7
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 17 deletions.
33 changes: 33 additions & 0 deletions Wordle/Components/LostScreen.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<MudDialog>
<DialogContent>
<MudPaper Class="d-flex flex-row justify-center flex-grow-1 gap-1"
Style="background-color:transparent" Elevation="0">

@foreach (var point in Config.WordToFind.ToUpper())
{
<MudPaper Class="containerWord"
Width="64px"
Height="64px"
Style="@($"border-width:1px;border-radius:10px;border-color:black;background-color:blue;")">
<MudText Typo="Typo.h4" Style="@($"color:white")">
<strong>@point</strong>
</MudText>
</MudPaper>
}
</MudPaper>
</DialogContent>
<DialogActions>
<MudButton Color="Color.Primary" OnClick="Submit">Replay</MudButton>
</DialogActions>
</MudDialog>

@code {
[CascadingParameter] MudDialogInstance MudDialog { get; set; }

Check warning on line 25 in Wordle/Components/LostScreen.razor

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'MudDialog' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

[Inject]
public NavigationManager nav { get; set; }

Check warning on line 28 in Wordle/Components/LostScreen.razor

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'nav' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.
void Submit() {
MudDialog.Close(DialogResult.Ok(true));
nav.NavigateTo("",true);
}
}
1 change: 1 addition & 0 deletions Wordle/Model/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public static void Reset()
}
List.Add(ls);
}
CurrentIndex = 0;
}
}
}
9 changes: 5 additions & 4 deletions Wordle/Pages/Index.razor
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<MudPaper Width="100%" Height="32px" Elevation="0" Style="background-color:transparent" >
<MudIconButton Icon="@Icons.Material.Filled.QuestionMark"
Color="Color.Warning" OnClick="HelpDialog" />
</MudPaper>
<MudPaper Class="d-flex flex-column flex-grow-1 gap-1" Style="background-color:transparent" Elevation="0" Width="100%">
</MudPaper>
<MudPaper Class="d-flex flex-column flex-grow-1 gap-1" Style="background-color:transparent" Elevation="0" Width="100%">
@foreach (var item in list)
{
<MudPaper Class="d-flex flex-row justify-center flex-grow-1 gap-1"
Expand Down Expand Up @@ -138,7 +138,8 @@
void Submit()
{
Reset();
visible = false;
visible = false;
StateHasChanged();
}

private DialogOptions dialogOptions = new()
Expand All @@ -153,6 +154,6 @@
CloseOnEscapeKey = true,
CloseButton = true
};
DialogService.Show<HowToPlay>("HOW TO PLAY", options);
DialogService.Show<HowToPlay>("HOW TO PLAY", options);
}
}
46 changes: 33 additions & 13 deletions Wordle/Pages/Index.razor.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@

using Microsoft.AspNetCore.Components;
using Microsoft.JSInterop;
using MudBlazor;
using Wordle.Model;
using Wordle.Components;

namespace Wordle.Pages
{
public partial class Index
{
{
bool win = false;
List<List<Cell>> list = [];
readonly Random random = new();
Expand All @@ -22,13 +24,34 @@ public partial class Index
];
Dictionary<char,int> hashOfCharacter = new();
[Inject] protected IJSRuntime JSRuntime { get; set; } = null!;
private void Reset()
{
hashOfWordData = [];
listOfWordData = [];
hashOfCharacter = new();
currentword = new();
win = false;
Config.Reset();
list = Config.List;
GetRandomWords();
StateHasChanged();
}
protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (firstRender)
{
await JSRuntime.InvokeVoidAsync("blazorKeyPressed", DotNetObjectReference.Create(this));
}
}
[Inject]
public NavigationManager nav { get; set; }

Check warning on line 47 in Wordle/Pages/Index.razor.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'nav' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.
void Restart()
{
var options = new DialogOptions { CloseOnEscapeKey = true };
DialogService.Show<LostScreen>("CORRECT WORD", options);
Reset();
StateHasChanged();
}
[JSInvokable]
public void OnArrowKeyPressed(string key)
{
Expand Down Expand Up @@ -57,18 +80,22 @@ public void OnArrowKeyPressed(string key)
{
hashOfCharacter.TryAdd(i, 0);
}
}
}
currentword = new();
}
}
if (Config.CurrentIndex >= list.Count)
{
Restart();
}
StateHasChanged();
return;
}
if (stackToList.Count > 0)
{
}
if (Config.CurrentIndex >= list.Count)
{
return;
{
Restart();
}
if (key == "Backspace")
{
Expand Down Expand Up @@ -116,13 +143,6 @@ private void GetRandomWords()
{
Config.WordToFind = listOfWordData[random.Next(listOfWordData.Count)];
}
private void Reset()
{
win = false;
Config.Reset();
list = Config.List;
currentword = new();
GetRandomWords();
}

}
}

0 comments on commit ebc2bd7

Please sign in to comment.