302 lines
13 KiB
Plaintext
302 lines
13 KiB
Plaintext
@page "/"
|
|
@rendermode InteractiveServer
|
|
@inject LookupService LookupService
|
|
|
|
<PageTitle>Lookup Desk</PageTitle>
|
|
|
|
@if (referenceData is null)
|
|
{
|
|
<section class="hero-panel">
|
|
<h1 class="page-title">Summoning tables...</h1>
|
|
<p class="lede">Loading the starter attack and critical data from SQLite.</p>
|
|
</section>
|
|
}
|
|
else
|
|
{
|
|
<section class="hero-panel">
|
|
<span class="eyebrow">Rolemaster Lookup Desk</span>
|
|
<h1 class="page-title">Resolve the attack roll, then the critical, from one place.</h1>
|
|
<p class="lede">
|
|
Attack tables still come from the starter dataset, while critical lookups now read the importer-managed tables loaded into the same SQLite file.
|
|
The page surfaces both the gameplay result and the import metadata behind each critical entry.
|
|
</p>
|
|
<div class="tag-row">
|
|
<span class="tag">@referenceData.AttackTables.Count attack tables</span>
|
|
<span class="tag">@referenceData.CriticalTables.Count critical tables</span>
|
|
<span class="tag">@referenceData.ArmorTypes.Count armor types</span>
|
|
<span class="tag">SQLite file: <code>rolemaster.db</code></span>
|
|
</div>
|
|
</section>
|
|
|
|
<div class="dashboard-grid">
|
|
<section class="panel">
|
|
<h2 class="panel-title">Automatic Attack Lookup</h2>
|
|
<p class="panel-copy">Choose an attack table, armor type, and attack roll. If the attack produces a critical and you provide the critical roll, the app resolves that follow-up automatically.</p>
|
|
|
|
<div class="lookup-form">
|
|
<div class="form-grid">
|
|
<div class="field-shell">
|
|
<label for="attack-table">Attack table</label>
|
|
<select id="attack-table" class="input-shell" @bind="attackInput.AttackTable">
|
|
@foreach (var attackTable in referenceData.AttackTables)
|
|
{
|
|
<option value="@attackTable.Key">@attackTable.Label</option>
|
|
}
|
|
</select>
|
|
</div>
|
|
|
|
<div class="field-shell">
|
|
<label for="armor-type">Armor type</label>
|
|
<select id="armor-type" class="input-shell" @bind="attackInput.ArmorType">
|
|
@foreach (var armorType in referenceData.ArmorTypes)
|
|
{
|
|
<option value="@armorType.Key">@armorType.Label</option>
|
|
}
|
|
</select>
|
|
</div>
|
|
|
|
<div class="field-shell">
|
|
<label for="attack-roll">Attack roll</label>
|
|
<input id="attack-roll" class="input-shell" type="number" min="1" max="300" @bind="attackInput.AttackRoll" />
|
|
</div>
|
|
|
|
<div class="field-shell">
|
|
<label for="critical-roll">Critical roll</label>
|
|
<input id="critical-roll" class="input-shell" type="number" min="1" max="100" @bind="attackInput.CriticalRollText" />
|
|
</div>
|
|
</div>
|
|
|
|
<div class="action-row">
|
|
<button class="btn-ritual" @onclick="RunAttackLookupAsync">Resolve attack</button>
|
|
<span class="muted">Leave critical roll blank to stop after the attack table result.</span>
|
|
</div>
|
|
</div>
|
|
|
|
@if (!string.IsNullOrWhiteSpace(attackError))
|
|
{
|
|
<p class="error-text">@attackError</p>
|
|
}
|
|
|
|
@if (attackResult is not null)
|
|
{
|
|
<div class="result-shell">
|
|
<div class="result-card">
|
|
<h3>@attackResult.AttackTableName vs @attackResult.ArmorTypeLabel</h3>
|
|
<div class="result-stats">
|
|
<span class="stat-pill">Roll band: @attackResult.RollBand</span>
|
|
<span class="stat-pill">Hits: @attackResult.Hits</span>
|
|
@if (!string.IsNullOrWhiteSpace(attackResult.CriticalSeverity))
|
|
{
|
|
<span class="stat-pill">@attackResult.CriticalSeverity @attackResult.CriticalType critical</span>
|
|
}
|
|
else
|
|
{
|
|
<span class="stat-pill">No critical</span>
|
|
}
|
|
</div>
|
|
<p><strong>Table notation:</strong> @attackResult.RawNotation</p>
|
|
@if (!string.IsNullOrWhiteSpace(attackResult.Notes))
|
|
{
|
|
<p class="muted">@attackResult.Notes</p>
|
|
}
|
|
|
|
@if (attackResult.AutoCritical is not null)
|
|
{
|
|
<div class="callout">
|
|
<h4>Automatic critical resolution</h4>
|
|
<CriticalLookupResultCard Result="attackResult.AutoCritical" />
|
|
</div>
|
|
}
|
|
else if (!string.IsNullOrWhiteSpace(attackResult.CriticalSeverity))
|
|
{
|
|
<div class="callout">The attack produced a critical. Add a critical roll to resolve it automatically.</div>
|
|
}
|
|
</div>
|
|
</div>
|
|
}
|
|
</section>
|
|
|
|
<section class="panel">
|
|
<h2 class="panel-title">Direct Critical Lookup</h2>
|
|
<p class="panel-copy">Use this when you already know the critical table, column, roll, and group if the selected table has variants.</p>
|
|
|
|
<div class="lookup-form">
|
|
<div class="form-grid">
|
|
<div class="field-shell">
|
|
<label for="critical-table">Critical table</label>
|
|
<select id="critical-table" class="input-shell" value="@criticalInput.CriticalType" @onchange="HandleCriticalTableChanged">
|
|
@foreach (var criticalTable in referenceData.CriticalTables)
|
|
{
|
|
<option value="@criticalTable.Key">@criticalTable.Label</option>
|
|
}
|
|
</select>
|
|
</div>
|
|
|
|
<div class="field-shell">
|
|
<label for="critical-column">Column</label>
|
|
<select id="critical-column" class="input-shell" @bind="criticalInput.Column">
|
|
@foreach (var column in SelectedCriticalTable?.Columns ?? [])
|
|
{
|
|
<option value="@column.Key">@column.Label (@column.Role)</option>
|
|
}
|
|
</select>
|
|
</div>
|
|
|
|
@if (SelectedCriticalTable?.Groups.Count > 0)
|
|
{
|
|
<div class="field-shell">
|
|
<label for="critical-group">Group</label>
|
|
<select id="critical-group" class="input-shell" @bind="criticalInput.Group">
|
|
@foreach (var group in SelectedCriticalTable.Groups)
|
|
{
|
|
<option value="@group.Key">@group.Label</option>
|
|
}
|
|
</select>
|
|
</div>
|
|
}
|
|
|
|
<div class="field-shell">
|
|
<label for="critical-roll-direct">Critical roll</label>
|
|
<input id="critical-roll-direct" class="input-shell" type="number" min="1" max="100" @bind="criticalInput.Roll" />
|
|
</div>
|
|
</div>
|
|
|
|
<div class="action-row">
|
|
<button class="btn-ritual" @onclick="RunCriticalLookupAsync">Resolve critical</button>
|
|
</div>
|
|
</div>
|
|
|
|
@if (!string.IsNullOrWhiteSpace(criticalError))
|
|
{
|
|
<p class="error-text">@criticalError</p>
|
|
}
|
|
|
|
@if (criticalResult is not null)
|
|
{
|
|
<div class="result-shell">
|
|
<CriticalLookupResultCard Result="criticalResult" />
|
|
</div>
|
|
}
|
|
</section>
|
|
|
|
<section class="panel">
|
|
<h2 class="panel-title">Loaded Reference Data</h2>
|
|
<p class="panel-copy">Attack tables remain starter content. Critical tables below are whatever importer-managed entries are currently loaded into the app database.</p>
|
|
|
|
<div class="table-list">
|
|
@foreach (var attackTable in referenceData.AttackTables)
|
|
{
|
|
<div class="table-list-item">
|
|
<strong>@attackTable.Label</strong>
|
|
<span class="muted">Attack table key: <code>@attackTable.Key</code></span>
|
|
</div>
|
|
}
|
|
|
|
@foreach (var criticalTable in referenceData.CriticalTables)
|
|
{
|
|
<CriticalTableReferenceCard Table="criticalTable" />
|
|
}
|
|
</div>
|
|
</section>
|
|
</div>
|
|
}
|
|
|
|
@code {
|
|
private LookupReferenceData? referenceData;
|
|
private AttackLookupForm attackInput = new();
|
|
private CriticalLookupForm criticalInput = new();
|
|
private AttackLookupResponse? attackResult;
|
|
private CriticalLookupResponse? criticalResult;
|
|
private string? attackError;
|
|
private string? criticalError;
|
|
|
|
private CriticalTableReference? SelectedCriticalTable =>
|
|
referenceData?.CriticalTables.FirstOrDefault(table => table.Key == criticalInput.CriticalType);
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
referenceData = await LookupService.GetReferenceDataAsync();
|
|
|
|
attackInput.AttackTable = referenceData.AttackTables.FirstOrDefault()?.Key ?? string.Empty;
|
|
attackInput.ArmorType = referenceData.ArmorTypes.FirstOrDefault()?.Key ?? string.Empty;
|
|
|
|
var initialCriticalTable = referenceData.CriticalTables.FirstOrDefault();
|
|
criticalInput.CriticalType = initialCriticalTable?.Key ?? string.Empty;
|
|
criticalInput.Column = initialCriticalTable?.Columns.FirstOrDefault()?.Key ?? string.Empty;
|
|
criticalInput.Group = initialCriticalTable?.Groups.FirstOrDefault()?.Key ?? string.Empty;
|
|
}
|
|
|
|
private async Task RunAttackLookupAsync()
|
|
{
|
|
attackError = null;
|
|
attackResult = null;
|
|
|
|
if (!int.TryParse(attackInput.CriticalRollText, out var criticalRoll) && !string.IsNullOrWhiteSpace(attackInput.CriticalRollText))
|
|
{
|
|
attackError = "Critical roll must be empty or a whole number.";
|
|
return;
|
|
}
|
|
|
|
var response = await LookupService.LookupAttackAsync(new AttackLookupRequest(
|
|
attackInput.AttackTable,
|
|
attackInput.ArmorType,
|
|
attackInput.AttackRoll,
|
|
string.IsNullOrWhiteSpace(attackInput.CriticalRollText) ? null : criticalRoll));
|
|
|
|
if (response is null)
|
|
{
|
|
attackError = "No seeded attack result matched that table, armor type, and roll.";
|
|
return;
|
|
}
|
|
|
|
attackResult = response;
|
|
}
|
|
|
|
private async Task RunCriticalLookupAsync()
|
|
{
|
|
criticalError = null;
|
|
criticalResult = null;
|
|
|
|
var response = await LookupService.LookupCriticalAsync(new CriticalLookupRequest(
|
|
criticalInput.CriticalType,
|
|
criticalInput.Column,
|
|
criticalInput.Roll,
|
|
SelectedCriticalTable?.Groups.Count > 0 ? criticalInput.Group : null));
|
|
|
|
if (response is null)
|
|
{
|
|
criticalError = "No loaded critical result matched that table, group, column, and roll.";
|
|
return;
|
|
}
|
|
|
|
criticalResult = response;
|
|
}
|
|
|
|
private void HandleCriticalTableChanged(ChangeEventArgs args)
|
|
{
|
|
criticalInput.CriticalType = args.Value?.ToString() ?? string.Empty;
|
|
|
|
var table = referenceData?.CriticalTables.FirstOrDefault(item => item.Key == criticalInput.CriticalType);
|
|
criticalInput.Column = table?.Columns.FirstOrDefault()?.Key ?? string.Empty;
|
|
criticalInput.Group = table?.Groups.FirstOrDefault()?.Key ?? string.Empty;
|
|
criticalResult = null;
|
|
criticalError = null;
|
|
}
|
|
|
|
private sealed class AttackLookupForm
|
|
{
|
|
public string AttackTable { get; set; } = string.Empty;
|
|
public string ArmorType { get; set; } = string.Empty;
|
|
public int AttackRoll { get; set; } = 66;
|
|
public string? CriticalRollText { get; set; } = "72";
|
|
}
|
|
|
|
private sealed class CriticalLookupForm
|
|
{
|
|
public string CriticalType { get; set; } = string.Empty;
|
|
public string Column { get; set; } = string.Empty;
|
|
public string Group { get; set; } = string.Empty;
|
|
public int Roll { get; set; } = 72;
|
|
}
|
|
}
|