UI/StatsList.razor
@using System;
@using Sandbox;
@using Sandbox.UI;

@* The stat list with a + per stat (Flash-game order); hover a stat for what it does. *@
<root>
	@if ( P is not null )
	{
		@foreach ( var idx in Profile.StatOrder )
		{
			var i = idx;
			<div class="stat-line" onmouseover=@(() => { Hover = i; StateHasChanged(); }) onmouseout=@(() => { if ( Hover == i ) { Hover = -1; StateHasChanged(); } })>
				<div class="sas-label stat-name">@Profile.StatNames[i].ToLower()</div>
				<div class="stat-value">@P.GetStat( i )</div>
				<div class="sas-pm plus @(P.StatPoints > 0 ? "" : "off")" onclick=@(() => Spend( i ))></div>
			</div>
		}
		<div class="stat-help">@(Hover >= 0 ? Profile.StatHelp[Hover] : "")</div>
	}
</root>

@code
{
	Profile P => Profile.Current;
	int Hover = -1;

	void Spend( int idx )
	{
		GameManager.Instance?.SpendStat( idx );
		StateHasChanged();
	}

	protected override int BuildHash()
	{
		if ( P is null ) return 0;
		return HashCode.Combine( P.StatPoints, P.Strength, P.Attack, P.Defence, P.Vitality, P.Agility, P.Stamina, HashCode.Combine( P.Charisma, P.Magicka, Hover ) );
	}
}