норм робит
@ -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>
|
||||||
|
|
||||||
|
@ -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>
|
||||||
|
@ -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();
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
@page "/"
|
@page "/home"
|
||||||
|
|
||||||
<PageTitle>Home</PageTitle>
|
<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)
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -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();
|
||||||
|
|
||||||
|
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>
|
<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>
|
||||||
|