UI/ChurchScreen.razor
@using System;
@using Sandbox;
@using Sandbox.UI;
@* The church: the priest sells potions to drink in your fights. He stands in the 3D church. *@
<root class="screen">
<div class="bubble">@Speech</div>
<div class="parchment board">
<div class="heading">Healing for the faithful</div>
<div class="potions">
@foreach ( var po in Enum.GetValues<Potion>() )
{
var p = po;
<div class="potion @(Picked == p ? "picked" : "")" onclick=@(() => Pick( p ))>
<div class="icon" style="background-image: url('resources/sad/@(Catalog.PotionArt( p ))')"></div>
<div class="name">@Catalog.PotionName( p )</div>
<div class="price">@($"{Gm.Price( Catalog.PotionPrice( p ) )}g · you have {P.Potions[(int)p]}")</div>
</div>
}
</div>
@if ( Picked.HasValue )
{
<div class="btn" onclick=@Buy>@($"buy for {Gm.Price( Catalog.PotionPrice( Picked.Value ) )} gold")</div>
}
</div>
<div class="gold-bar"><div class="coin"></div>@P.Gold</div>
<div class="sas-round cross close" onclick=@(() => Gm.Go( GameScreen.Town ))><div class="mark"></div></div>
</root>
@code
{
GameManager Gm => GameManager.Instance;
Profile P => Profile.Current;
Potion? Picked;
string speech;
string Speech
{
get => speech ?? "Welcome, child. The arena takes a heavy toll - take a potion with you, and drink it when you need it most.";
set => speech = value;
}
void Pick( Potion p )
{
Picked = p;
Speech = $"{Catalog.PotionName( p )}\n{Catalog.PotionHelp( p )}\nYou can carry five.";
StateHasChanged();
}
void Buy()
{
if ( !Picked.HasValue ) return;
Speech = Gm.BuyPotion( Picked.Value );
StateHasChanged();
}
protected override int BuildHash() => HashCode.Combine( Picked, speech, P?.Gold, P?.Potions[0], P?.Potions[1], P?.Potions[2] );
}