ui/CardIconBack.razor

Razor panel that draws the back of a card. Shows a flag icon when Card.IsFlagShown is set and a row of red crayon marks for each time the card was chosen, capped by the MaxCrayonMarks stat. BuildHash keys off those values so the panel only rebuilds when they change.

@using Sandbox;
@using Sandbox.UI;
@inherits PanelComponent

<root>
	@{
		// Log.Info($"Card.CardType: {Card.CardType} Card.GetIconFilename(Card.CardType): {Card.GetIconFilename(Card.CardType)}");
	}

	@if(Card.IsFlagShown)
	{
		<div class="icon" style="background-image: url(textures/flag.png);"></div>
	}

	@if(Card.AreRevealMarksShown)
	{
		@for(int i = 0; i < Math.Min((int)Manager.Instance.Stats[StatType.MaxCrayonMarks], Card.NumTimesChosen); i++)
		{
			<div class="reveal_mark" style="left:@(13 + i * 57)px; bottom:@(20)px;">
				🔴
			</div>
		}
	}
</root>

@code
{
	public Card Card { get; set; }

	protected override int BuildHash()
	{
		var numCrayonMarks = Manager.Instance.Stats[StatType.MaxCrayonMarks];
		return HashCode.Combine(
			Card.IsFlagShown,
			Card.AreRevealMarksShown,
			numCrayonMarks,
			numCrayonMarks > 0 ? Card.NumTimesChosen : 0
			// Time.Now
		);
	}
}