норм робит

This commit is contained in:
Professional 2025-04-17 22:25:37 +07:00
parent 7427ce5067
commit daaa0fbca5
17 changed files with 744 additions and 264 deletions

View File

@ -1,4 +1,5 @@
@using Microsoft.AspNetCore.Components.Routing @using Microsoft.AspNetCore.Components.Routing
@using БлэкДжек.Components.Layout
<!DOCTYPE html> <!DOCTYPE html>
<html lang="ru"> <html lang="ru">
@ -16,7 +17,18 @@
</head> </head>
<body> <body>
<Routes @rendermode="InteractiveServer" /> <Router AppAssembly="@typeof(App).Assembly">
<Found Context="routeData">
<RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)" />
<FocusOnNavigate RouteData="@routeData" Selector="h1" />
</Found>
<NotFound>
<PageTitle>Not found</PageTitle>
<LayoutView Layout="@typeof(MainLayout)">
<p role="alert">Страница не найдена.</p>
</LayoutView>
</NotFound>
</Router>
<script src="_framework/blazor.web.js"></script> <script src="_framework/blazor.web.js"></script>
</body> </body>

View File

@ -1,9 +1,9 @@
@inherits LayoutComponentBase  @inherits LayoutComponentBase
@Body <div class="page">
<main>
<div id="blazor-error-ui"> <article class="content">
An unhandled error has occurred. @Body
<a href="" class="reload">Reload</a> </article>
<a class="dismiss">🗙</a> </main>
</div> </div>

View File

@ -1,6 +1,8 @@
@page "/blackjack" @page "/"
@page "/blackjack"
@using БлэкДжек.Components @using БлэкДжек.Components
@implements IDisposable @implements IDisposable
@rendermode InteractiveServer
<div class="casino-background"> <div class="casino-background">
<div class="blackjack-container"> <div class="blackjack-container">
@ -33,9 +35,7 @@
<div class="card-container @(DealerHand.IndexOf(card) == 0 && IsPlayerTurn ? "card-hidden" : "")"> <div class="card-container @(DealerHand.IndexOf(card) == 0 && IsPlayerTurn ? "card-hidden" : "")">
@if (DealerHand.IndexOf(card) == 0 && IsPlayerTurn) @if (DealerHand.IndexOf(card) == 0 && IsPlayerTurn)
{ {
<div class="playing-card card-back"> <div class="playing-card card-back"></div>
<div class="card-back-design"></div>
</div>
} }
else else
{ {
@ -185,7 +185,10 @@
{ {
if (!IsPlayerTurn || IsGameOver) return; if (!IsPlayerTurn || IsGameOver) return;
PlayerHand.Add(GameDeck.DealCard()); var newCard = GameDeck.DealCard();
if (newCard != null)
{
PlayerHand.Add(newCard);
if (PlayerScore > 21) if (PlayerScore > 21)
{ {
@ -195,6 +198,14 @@
{ {
PlayerStand(); PlayerStand();
} }
}
else
{
// Колода пуста, можно обработать этот случай
GameMessage = "Колода пуста! Создается новая колода...";
GameDeck = new Deck();
GameDeck.Shuffle();
}
StateHasChanged(); StateHasChanged();
} }

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
@page "/" @page "/home"
<PageTitle>Home</PageTitle> <PageTitle>Home</PageTitle>

View File

@ -1,19 +0,0 @@
@using Microsoft.AspNetCore.Components.Web
@using Microsoft.AspNetCore.Components.Routing
<Router AppAssembly="@typeof(Program).Assembly">
<Found Context="routeData">
@if (routeData.PageType.Name == "Index" || string.IsNullOrEmpty(routeData.PageType.Name))
{
<Navigate href="/blackjack" />
}
else
{
<RouteView RouteData="@routeData" />
}
</Found>
<NotFound>
<PageTitle>Не найдено</PageTitle>
<p role="alert">Извините, страница не найдена.</p>
</NotFound>
</Router>

View File

@ -51,16 +51,17 @@ namespace БлэкДжек.Components // Замените BlazorBlackjack на
{ {
if (Cards.Count == 0) if (Cards.Count == 0)
{ {
// Можно пересоздать и перемешать колоду, если она закончилась // Вместо возврата null, пересоздаем колоду
// InitializeDeck(); InitializeDeck();
// Shuffle(); Shuffle();
// Или просто вернуть null/выбросить исключение
return null;
} }
Card card = Cards[0]; Card card = Cards[0];
Cards.RemoveAt(0); Cards.RemoveAt(0);
return card; return card;
} }
} }
} }

View File

@ -9,7 +9,6 @@ builder.Services.AddRazorComponents()
.AddInteractiveServerComponents(); .AddInteractiveServerComponents();
var app = builder.Build(); var app = builder.Build();
app.UseStaticFiles();
// Configure the HTTP request pipeline. // Configure the HTTP request pipeline.
if (!app.Environment.IsDevelopment()) if (!app.Environment.IsDevelopment())
@ -20,7 +19,6 @@ if (!app.Environment.IsDevelopment())
} }
app.UseHttpsRedirection(); app.UseHttpsRedirection();
app.UseStaticFiles(); app.UseStaticFiles();
app.UseAntiforgery(); app.UseAntiforgery();

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.0 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

View File

@ -6,4 +6,14 @@
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup> </PropertyGroup>
<ItemGroup>
<None Include="wwwroot\_content\images\blackjack-logo.png" />
<None Include="wwwroot\_content\images\card-back.png" />
<None Include="wwwroot\_content\images\dealer-avatar.png" />
<None Include="wwwroot\_content\images\hit-icon.png" />
<None Include="wwwroot\_content\images\new-game-icon.png" />
<None Include="wwwroot\_content\images\player-avatar.png" />
<None Include="wwwroot\_content\images\stand-icon.png" />
</ItemGroup>
</Project> </Project>