StrategyLibraryView.razor

Razor UI panel for the SOCER tactics lab that lists saved strategy plans, the current draft and an example play, drawing each with StrategyTileCanvas. Buttons call MatchController to load, create or close a plan.

@using Sandbox
@using Sandbox.UI
@using Socer
@using System
@using System.Linq
@inherits Panel

<root>
    <div class="library-header">
        <div class="library-title"><label class="library-kicker">SOCER / TACTICS LAB</label><label>Choose a play</label><label class="library-subtitle">Select a saved play or draw a new one.</label></div>
        <button class="library-close" onclick=@(()=>Game.CloseStrategyLab())>Close ↗</button>
    </div>
    <div class="library-bar"><label>YOUR PLAYS</label><label>@Game.StrategyLibrary.Count saved</label></div>
    <div class="library-scroll"><div class="library-grid">
        <button class="play-tile add-play" onclick=@(()=>Game.NewStrategy())>
            <div class="add-symbol">+</div><label>New play</label><label class="tile-subtitle">Start with an empty board</label>
        </button>
        @if(Game.StrategyDraftAvailable)
        {
            <button class="play-tile draft-play" onclick=@(()=>Game.ResumeStrategyDraft())>
                <StrategyTileCanvas class="play-sketch" Plan="@Game.StrategyDraft" />
                <div class="tile-details"><div><label class="tile-eyebrow">CONTINUE EDITING</label><label class="tile-name">@UiEnglish.Text(Game.StrategyDraft.Name,Game.StrategyDraft.Name)</label></div><label class="tile-percent">@Game.StrategyDraft.EstimatedSuccessPercent()%</label></div>
            </button>
        }
        @foreach(var saved in Game.StrategyLibrary)
        {
            var plan=saved;
            <button class="play-tile saved-play" onclick=@(()=>Game.LoadStrategy(plan))>
                <StrategyTileCanvas class="play-sketch" Plan="@plan" />
                <div class="tile-details"><div><label class="tile-eyebrow">@($"{plan.Phases.Count} PHASES")</label><label class="tile-name">@UiEnglish.Text(plan.Name,plan.Name)</label></div><label class="tile-percent">@plan.EstimatedSuccessPercent()%</label></div>
            </button>
        }
        @if(!Game.StrategyLibrary.Any(p=>p.Name==StrategyPlan.Example().Name))
        {
            <button class="play-tile example-play" onclick=@(()=>Game.LoadStrategy(StrategyPlan.Example()))>
                <StrategyTileCanvas class="play-sketch" Plan="@Example" />
                <div class="tile-details"><div><label class="tile-eyebrow">EXAMPLE PLAY</label><label class="tile-name">@Example.Name</label></div><label class="tile-percent">@Example.EstimatedSuccessPercent()%</label></div>
            </button>
        }
    </div></div>
</root>

@code {
    public MatchController Game {get;set;}
    static readonly StrategyPlan Example=StrategyPlan.Example();
    protected override int BuildHash()=>Game?.Revision??0;
}