ui/PlayerCard.razor
@using System;
@using Sandbox;
@using Sandbox.UI;
@using Facepunch.BombRoyale;

@namespace Facepunch.BombRoyale.UI
@attribute [StyleSheet( "PlayerCard.razor.scss" )]
@inherits Panel

<div class="container p@(PlayerIndex) @(!IsValidPlayer() ? "empty" : "") @(IsDead() ? "dead" : "")">
    <label class="name">@GetPlayerName()</label>
    <label class="index">P@(PlayerIndex)</label>

    <div class="avatar">
        <div class="inner"></div>
        <div class="head"></div>
		
        @if ( IsDead() )
        {
            <div class="dead"></div>
        }
    </div>

    <div class="lives">
		@for ( var i = 0; i < GetLivesLeft(); i++ )
		{
			@:<div class="life"><div>
		}
    </div>

    <div class="pickups">
        <div class="pickup bombs @(HasBombDisease() ? "diseased" : "")">
            <div class="icon"></div>
            <label class="label">@GetBombsLeft()</label>
        </div>

        <div class="pickup range @(HasRangeDisease() ? "diseased" : "")">
            <div class="icon"></div>
            <label class="label">@GetBombRange()</label>
        </div>

        <div class="pickup speed @(HasSpeedDisease() ? "diseased" : "")">
            <div class="icon"></div>
            <label class="label">@GetSpeedBoosts()</label>
        </div>
		
        @if ( HasSuperBomb() )
        {
            @:<div class="superbomb"><div>
        }
    </div>
</div>

@code
{
	public Player Player => BombRoyale.GetPlayer( PlayerIndex - 1 );
    public int PlayerIndex { get; set; }

    protected override int BuildHash()
    {
	    var player = Player;
	    return player.IsValid() ? HashCode.Combine( player, player.LifeState, player.LivesLeft, player.HasSuperBomb, player.BombRange, player.GetBombsLeft(), player.SpeedBoosts, player.Disease ) : 0;
    }

    private bool HasRangeDisease() => Player.IsValid() && Player.Disease == DiseaseType.LowRange;
    private bool HasSpeedDisease() => HasFastDisease() || HasSlowDisease();
    private bool HasFastDisease() => Player.IsValid() && Player.Disease == DiseaseType.MoveFast;
    private bool HasSlowDisease() => Player.IsValid() && Player.Disease == DiseaseType.MoveSlow;
    private bool HasBombDisease() => Player.IsValid() && Player.Disease == DiseaseType.RandomBomb;

    private string GetBombsLeft() => (Player?.GetBombsLeft() ?? 0).ToString();
    private int GetLivesLeft() => Player?.LivesLeft ?? 0;
	private bool IsValidPlayer() => Player.IsValid();
	private bool HasSuperBomb() => Player?.HasSuperBomb ?? false;
	private string GetPlayerName() => Player.IsValid() ? Player.Network.Owner.DisplayName : "Player";
	private bool IsDead() => !Player.IsValid() || Player.LifeState == LifeState.Dead;

    private string GetBombRange()
    {
	    return HasBombDisease() ? "1" : (Player?.BombRange ?? 0).ToString();
    }

    private string GetSpeedBoosts()
    {
        if ( HasFastDisease() ) return "8";
        return HasSlowDisease() ? "0" : (Player?.SpeedBoosts ?? 0).ToString();
    }
}