Add rolemaster automatic retry rolls

This commit is contained in:
2026-04-14 23:03:38 +02:00
parent 0c638e8ebe
commit 2997247eeb
16 changed files with 287 additions and 40 deletions

View File

@@ -174,4 +174,86 @@ public sealed class ServiceRolemasterRollTests
Assert.Equal("r66", badge);
Assert.Equal("66 | rolemaster", logEntry.SummaryText);
}
[Fact]
public void RollSkill_RolemasterAutoRetryPlusFive_UsesRetryResultAndMarksAttempts()
{
using var harness = ServiceTestSupport.CreateHarness(68, 42);
var service = harness.Service;
service.Register("gm-retry-five", "Password123", "GM");
var session = ServiceTestSupport.GetValue(service.Login("gm-retry-five", "Password123")).SessionToken;
var campaign = ServiceTestSupport.GetValue(service.CreateCampaign(session, "Rolemaster Retry", "rolemaster"));
var character = ServiceTestSupport.GetValue(service.CreateCharacter(session, "Hero", campaign.Id));
var skill = ServiceTestSupport.GetValue(service.CreateSkill(session, character.Id, "Awareness", "d100!+10", 0, false, null, 5, true));
var roll = ServiceTestSupport.GetValue(service.RollSkill(session, skill.Id, "public"));
var detail = ServiceTestSupport.GetValue(service.GetRollDetail(session, roll.RollId));
var logEntry = Assert.Single(ServiceTestSupport.GetValue(service.GetCampaignLogPage(session, campaign.Id, limit: 5)).Entries);
Assert.Equal(57, roll.Result);
Assert.Equal("68+10=78; retry(+5): 42+10=52; final=57", roll.Breakdown);
Assert.Equal("68 | open-ended | retry +5", logEntry.SummaryText);
Assert.Equal(["rs5"], Assert.IsType<string[]>(logEntry.EventBadges));
Assert.Equal(roll.Breakdown, detail.Breakdown);
Assert.Collection(detail.Dice, die =>
{
Assert.Equal(68, die.Roll);
Assert.Equal(1, die.Sequence);
Assert.Equal(1, die.Attempt);
Assert.Equal(RollDieKinds.RolemasterOpenEndedInitial, die.Kind);
Assert.Equal(68, die.SignedContribution);
}, die =>
{
Assert.Equal(42, die.Roll);
Assert.Equal(1, die.Sequence);
Assert.Equal(2, die.Attempt);
Assert.Equal(RollDieKinds.RolemasterOpenEndedInitial, die.Kind);
Assert.Equal(42, die.SignedContribution);
});
}
[Fact]
public void RollSkill_RolemasterAutoRetryPlusTen_UsesRetryResultAndMarksAttempts()
{
using var harness = ServiceTestSupport.CreateHarness(90, 32);
var service = harness.Service;
service.Register("gm-retry-ten", "Password123", "GM");
var session = ServiceTestSupport.GetValue(service.Login("gm-retry-ten", "Password123")).SessionToken;
var campaign = ServiceTestSupport.GetValue(service.CreateCampaign(session, "Rolemaster Retry", "rolemaster"));
var character = ServiceTestSupport.GetValue(service.CreateCharacter(session, "Hero", campaign.Id));
var skill = ServiceTestSupport.GetValue(service.CreateSkill(session, character.Id, "Awareness", "d100!+1", 0, false, null, 5, true));
var roll = ServiceTestSupport.GetValue(service.RollSkill(session, skill.Id, "public"));
var logEntry = Assert.Single(ServiceTestSupport.GetValue(service.GetCampaignLogPage(session, campaign.Id, limit: 5)).Entries);
Assert.Equal(43, roll.Result);
Assert.Equal("90+1=91; retry(+10): 32+1=33; final=43", roll.Breakdown);
Assert.Equal("90 | open-ended | retry +10", logEntry.SummaryText);
Assert.Equal(["rs10"], Assert.IsType<string[]>(logEntry.EventBadges));
Assert.All(roll.Dice, die => Assert.True(die.Attempt is 1 or 2));
}
[Fact]
public void RollSkill_RolemasterAutoRetryDisabled_KeepsOriginalResult()
{
using var harness = ServiceTestSupport.CreateHarness(68);
var service = harness.Service;
service.Register("gm-retry-off", "Password123", "GM");
var session = ServiceTestSupport.GetValue(service.Login("gm-retry-off", "Password123")).SessionToken;
var campaign = ServiceTestSupport.GetValue(service.CreateCampaign(session, "Rolemaster Retry", "rolemaster"));
var character = ServiceTestSupport.GetValue(service.CreateCharacter(session, "Hero", campaign.Id));
var skill = ServiceTestSupport.GetValue(service.CreateSkill(session, character.Id, "Awareness", "d100!+10", 0, false, null, 5));
var roll = ServiceTestSupport.GetValue(service.RollSkill(session, skill.Id, "public"));
var logEntry = Assert.Single(ServiceTestSupport.GetValue(service.GetCampaignLogPage(session, campaign.Id, limit: 5)).Entries);
Assert.Equal(78, roll.Result);
Assert.Equal("68+10=78", roll.Breakdown);
Assert.Equal("68 | open-ended", logEntry.SummaryText);
Assert.Null(logEntry.EventBadges);
Assert.All(roll.Dice, die => Assert.Null(die.Attempt));
}
}