норм робит

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 БлэкДжек.Components.Layout
<!DOCTYPE html>
<html lang="ru">
@ -16,7 +17,18 @@
</head>
<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>
</body>

View File

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

View File

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

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
@page "/"
@page "/home"
<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)
{
// Можно пересоздать и перемешать колоду, если она закончилась
// InitializeDeck();
// Shuffle();
// Или просто вернуть null/выбросить исключение
return null;
// Вместо возврата null, пересоздаем колоду
InitializeDeck();
Shuffle();
}
Card card = Cards[0];
Cards.RemoveAt(0);
return card;
}
}
}

View File

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