feat(battle-xp): wire free-battle /finish through IBattleXpService
- FreeBattleController.Finish (rotation + unlimited URLs) now grants win/loss XP via IBattleXpService with BattleXpMode.Free. - Preserves the strict field subset (no rank/master fields). - Tests updated: win asserts XP+level-up; new loss test on rotation URL. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -114,22 +114,24 @@ public class FreeBattleControllerTests
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task Finish_emits_battle_result_echo_and_four_field_minimum()
|
||||
public async Task Finish_win_grants_class_xp_with_strict_field_subset()
|
||||
{
|
||||
await using var factory = new SVSimTestFactory();
|
||||
var viewerId = await factory.SeedViewerAsync();
|
||||
var client = factory.CreateAuthenticatedClient(viewerId);
|
||||
|
||||
var resp = await client.PostAsJsonAsync("/unlimited_free_battle/finish", FinishBody(battleResult: 1));
|
||||
var resp = await client.PostAsJsonAsync(
|
||||
"/unlimited_free_battle/finish", FinishBody(battleResult: 1, classId: 1));
|
||||
|
||||
Assert.That(resp.IsSuccessStatusCode, Is.True);
|
||||
var raw = await resp.Content.ReadAsStringAsync();
|
||||
using var doc = JsonDocument.Parse(raw);
|
||||
var data = doc.RootElement;
|
||||
Assert.That(data.GetProperty("battle_result").GetInt32(), Is.EqualTo(1));
|
||||
Assert.That(data.GetProperty("get_class_experience").GetInt32(), Is.EqualTo(0));
|
||||
Assert.That(data.GetProperty("class_experience").GetInt32(), Is.EqualTo(0));
|
||||
Assert.That(data.GetProperty("class_level").GetInt32(), Is.EqualTo(1));
|
||||
// XpPerWin=100, classexp.csv L1=50 → L2 with 50 carry.
|
||||
Assert.That(data.GetProperty("get_class_experience").GetInt32(), Is.EqualTo(100));
|
||||
Assert.That(data.GetProperty("class_experience").GetInt32(), Is.EqualTo(50));
|
||||
Assert.That(data.GetProperty("class_level").GetInt32(), Is.EqualTo(2));
|
||||
|
||||
// Strict subset — no rank fields. The client doesn't read them on free-battle
|
||||
// finish; emitting them would be wire-format pollution.
|
||||
@@ -140,16 +142,20 @@ public class FreeBattleControllerTests
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task Finish_with_consistency_result_echoes_2_on_rotation_url()
|
||||
public async Task Finish_loss_grants_loss_xp_on_rotation_url()
|
||||
{
|
||||
await using var factory = new SVSimTestFactory();
|
||||
var viewerId = await factory.SeedViewerAsync();
|
||||
var client = factory.CreateAuthenticatedClient(viewerId);
|
||||
|
||||
var resp = await client.PostAsJsonAsync("/rotation_free_battle/finish", FinishBody(battleResult: 2));
|
||||
var resp = await client.PostAsJsonAsync(
|
||||
"/rotation_free_battle/finish", FinishBody(battleResult: 2, classId: 1));
|
||||
|
||||
using var doc = JsonDocument.Parse(await resp.Content.ReadAsStringAsync());
|
||||
Assert.That(doc.RootElement.GetProperty("battle_result").GetInt32(), Is.EqualTo(2));
|
||||
Assert.That(doc.RootElement.GetProperty("get_class_experience").GetInt32(), Is.EqualTo(25));
|
||||
Assert.That(doc.RootElement.GetProperty("class_experience").GetInt32(), Is.EqualTo(25));
|
||||
Assert.That(doc.RootElement.GetProperty("class_level").GetInt32(), Is.EqualTo(1));
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
||||
Reference in New Issue
Block a user