Skip to content

Commit e66f27c

Browse files
snow-jallenclaude
andcommitted
Hosting a match can seat Formics from the start
The Host a match form on the Account page takes an optional Formics count. Each copy takes a seat when the match is created; the server already keeps one seat open for a real bot. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01V8fdNFMnkyDNTFoKqQyD6L
1 parent 115bab8 commit e66f27c

2 files changed

Lines changed: 22 additions & 1 deletion

File tree

‎src/NetRts.Server/wwwroot/account.js‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,12 @@ export function mountAccount(root, onAccount) {
138138
<div class="field"><label for="hm-ticks">Tick limit</label>
139139
<input id="hm-ticks" name="maxTicks" type="number" min="10" max="20000" value="1800" inputmode="numeric"></div>
140140
</div>
141+
<div class="form-row">
142+
<div class="field"><label for="hm-formics">Formics <span class="muted small">(optional)</span></label>
143+
<input id="hm-formics" name="formics" type="number" min="0" max="15" value="0" inputmode="numeric"></div>
144+
<p class="muted small" style="align-self:end;margin:0">The hardest house ${say('bot', 'badger')}. Each copy takes a seat
145+
from the start; at least one seat stays open for a real ${say('bot', 'badger')}.</p>
146+
</div>
141147
<div><button class="btn" type="submit">${say('Host match', 'Host brawl')}</button></div>
142148
</form>
143149
<h3 style="margin-top:20px">Your hosted matches</h3>
@@ -293,18 +299,20 @@ export function mountAccount(root, onAccount) {
293299

294300
$('host').addEventListener('submit', (ev) => act(ev, async (form) => {
295301
const name = form.get('name').trim();
302+
const formics = Math.max(0, Math.floor(Number(form.get('formics')) || 0));
296303
await api('/api/v1/account/matches', {
297304
method: 'POST',
298305
body: {
299306
name,
300307
maxPlayers: Number(form.get('maxPlayers')) || undefined,
308+
houseBots: Array(formics).fill('formics'),
301309
settings: {
302310
tickIntervalMs: Number(form.get('tickIntervalMs')) || undefined,
303311
maxTicks: Number(form.get('maxTicks')) || undefined,
304312
},
305313
},
306314
});
307-
return `You're hosting ${name}. Bots join it by that name; start it under Your hosted matches when they're in.`;
315+
return `You're hosting ${name}${formics ? ` with ${formics} Formic${formics === 1 ? '' : 's'} seated` : ''}. Bots join it by that name; start it under Your hosted matches when they're in.`;
308316
}));
309317

310318
$('league')?.addEventListener('submit', (ev) => {

‎tests/NetRts.Server.Tests/HostedMatchTests.cs‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,19 @@ public async Task The_hosts_own_bot_can_play_in_their_match()
5454
Assert.Contains(started.Players, p => p.PlayerId == mine.PlayerId);
5555
}
5656

57+
[Fact]
58+
public async Task The_host_can_seat_Formics_and_leave_a_seat_for_a_real_bot()
59+
{
60+
var host = factory.ClientFor(await factory.NewAccountAsync());
61+
var match = await HostAsync(host, new CreateMatchRequest { Name = MatchName(), MaxPlayers = 4, HouseBots = ["formics", "formics", "formics"] });
62+
Assert.Equal(["house-formics", "house-formics 2", "house-formics 3"], match.Players.Select(p => p.Name));
63+
Assert.Equal(MatchStatus.Waiting, match.Status);
64+
65+
var full = await host.PostAsJsonAsync("/api/v1/account/matches",
66+
new CreateMatchRequest { Name = MatchName(), MaxPlayers = 4, HouseBots = ["formics", "formics", "formics", "formics"] }, NetRtsClient.JsonOptions, Ct);
67+
Assert.Equal("INVALID_SETTINGS", (await full.ErrorAsync()).Code);
68+
}
69+
5770
[Fact]
5871
public async Task Hosting_takes_a_signed_in_person_and_a_name()
5972
{

0 commit comments

Comments
 (0)