норм робит
@ -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>
|
||||
|
||||
|
@ -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>
|
||||
|
@ -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();
|
||||
|
@ -1,4 +1,4 @@
|
||||
@page "/"
|
||||
@page "/home"
|
||||
|
||||
<PageTitle>Home</PageTitle>
|
||||
|
||||
|
@ -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>
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
@ -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();
|
||||
|
||||
|
BIN
wwwroot/_content/images/blackjack-logo.png
Normal file
After Width: | Height: | Size: 9.3 KiB |
BIN
wwwroot/_content/images/card-back.png
Normal file
After Width: | Height: | Size: 5.0 MiB |
BIN
wwwroot/_content/images/dealer-avatar.png
Normal file
After Width: | Height: | Size: 25 KiB |
BIN
wwwroot/_content/images/hit-icon.png
Normal file
After Width: | Height: | Size: 7.2 KiB |
BIN
wwwroot/_content/images/new-game-icon.png
Normal file
After Width: | Height: | Size: 20 KiB |
BIN
wwwroot/_content/images/player-avatar.png
Normal file
After Width: | Height: | Size: 35 KiB |
BIN
wwwroot/_content/images/stand-icon.png
Normal file
After Width: | Height: | Size: 13 KiB |
@ -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>
|
||||
|