Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 33 additions & 16 deletions PROMPT.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,19 @@
> - See CLAUDE.local.md "CRITICAL: Verify Both Git and GitHub CLI Credentials" section
> - All changes need to be done via feature branch and merged via PR
> - Work as `Contributor` implementing code changes and raising PR's. Do not review PR's unless explicitly prompted by the user - just monitor active PR and Issues for comment feedback.
> - **BLOCKING: Active PR Polling Loop - DO NOT STOP**
> - **MUST run at the start of EVERY iteration**: `gh pr list --author martincjarvis --state open`
> - **IF open PRs exist**: Execute polling loop (DO NOT proceed to new tasks)
> - **Polling loop actions** (repeat until PR is merged/closed):
> 1. Check PR status: `gh pr view <PR#> --json state,reviewDecision,mergedAt,comments`
> 2. Check CI status: `gh pr checks <PR#>`
> 3. Check for new comments (compare timestamps)
> 4. IF new feedback/comments: Implement fixes immediately using TDD, commit, push, reply
> 5. IF CI failing: Check logs, fix issues, commit, push, reply
> 6. IF all green (CI passing, no new feedback): Report status and continue polling
> 7. IF merged/closed: Proceed to next task
> - **DO NOT exit polling loop** until PR is merged or closed
> - **DO NOT assume** Maintainer will notify you - actively poll for updates

</EXTREMELY-IMPORTANT>

Expand Down Expand Up @@ -110,15 +123,17 @@ See **[docs/plans/rules-engine-design.md](docs/plans/rules-engine-design.md)** f

1. **FIRST: Verify credentials** - Run `./scripts/verify-credentials.sh contributor` before any work
2. Work as Contributor
3. Check for GitHub issue before any work
4. Create feature branch: `feature/<issue>-<description>`
5. Write failing tests first
6. Implement to pass tests
7. Run `dotnet build --warnaserror && dotnet test`
8. **BEFORE COMMIT: Re-verify credentials** - Run `./scripts/verify-credentials.sh contributor`
9. Commit with: `<type>: <description>\n\nRefs #<issue>`
10. **BEFORE PR: Re-verify credentials** - Run `./scripts/verify-credentials.sh contributor`
11. Create PR and request review
3. **BLOCKING: Check for open PR feedback** - Run `gh pr list --author martincjarvis --state open` and check for review comments
4. **If PR has feedback**: Implement requested changes immediately (skip to new tasks only after all feedback resolved)
5. Check for GitHub issue before any work
6. Create feature branch: `feature/<issue>-<description>`
7. Write failing tests first
8. Implement to pass tests
9. Run `dotnet build --warnaserror && dotnet test`
10. **BEFORE COMMIT: Re-verify credentials** - Run `./scripts/verify-credentials.sh contributor`
11. Commit with: `<type>: <description>

Refs #<issue>`12. **BEFORE PR: Re-verify credentials** - Run`./scripts/verify-credentials.sh contributor` 13. Create PR and request review 14. **AFTER PR: Monitor for feedback** - Check PR regularly for review comments and respond immediately

### Commit Types

Expand All @@ -139,10 +154,12 @@ Reference `docs/design/` for game mechanics specifications (gdd-core.md, gdd-cla
1. Read these files in order:
- `CLAUDE.md` and `AGENTS.md` - Project rules and workflows
- `docs/plans/rules-engine-design.md` - Architecture, design, and progress
2. Check Epic Status Overview for current progress and next tasks
3. For completed epics, examine Code Reference paths for implementation patterns
4. Reference `docs/design/gdd-*.md` for game mechanics details
5. Always reference the GitHub issue in commits
6. Use TDD - write failing tests before implementation
7. Run verification: `dotnet build --warnaserror && dotnet test`
8. Update progress tracking after completing tasks
2. **BLOCKING: Check for open PR feedback FIRST** - Run `gh pr list --author martincjarvis --state open` and prioritize addressing any review comments
3. Check Epic Status Overview for current progress and next tasks
4. For completed epics, examine Code Reference paths for implementation patterns
5. Reference `docs/design/gdd-*.md` for game mechanics details
6. Always reference the GitHub issue in commits
7. Use TDD - write failing tests before implementation
8. Run verification: `dotnet build --warnaserror && dotnet test`
9. Update progress tracking after completing tasks
10. After creating PR, monitor for feedback and respond immediately
50 changes: 32 additions & 18 deletions docs/plans/rules-engine-design.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,25 @@ Epic 4 (Crafting and Class Progression) complete! Next: Epic 5 (Economy and Inve

### Epic Status Overview

| Epic | Title | Status | Progress | GitHub Issue |
| ---- | -------------------------------- | ----------- | -------- | ------------ |
| 1 | Project Foundation | ✅ Complete | 5/5 | #3 |
| 2 | Time and Simulation Loop | ✅ Complete | 6/6 | #4 |
| 3 | NPC Decision Making | ✅ Complete | 6/6 | #5 |
| 4 | Crafting and Class Progression | ✅ Complete | 8/8 | #6 |
| 5 | Economy and Inventory | ⏳ Planned | 0/6 | #7 |
| 6 | Contracts and Commitments | 🔄 Partial | 2/6 | #8 |
| 7 | Settlement and Guild | ⏳ Planned | 0/6 | #9 |
| 8 | Scenario Testing Framework | ⏳ Planned | 0/7 | #10 |
| 9 | Persistence | ⏳ Planned | 0/4 | #11 |
| 10 | Apprenticeship and Role Stacking | ⏳ Planned | 0/4 | #12 |
| 11 | Full Progression Scenario | ⏳ Planned | 0/5 | #13 |

**Total Progress**: 27/58 tasks complete (47%)
| Epic | Title | Status | Progress | GitHub Issue |
| ---- | -------------------------------- | -------------- | -------- | ------------ |
| 1 | Project Foundation | ✅ Complete | 5/5 | #3 |
| 2 | Time and Simulation Loop | ✅ Complete | 6/6 | #4 |
| 3 | NPC Decision Making | ✅ Complete | 6/6 | #5 |
| 4 | Crafting and Class Progression | ✅ Complete | 8/8 | #6 |
| 5 | Economy and Inventory | 🔄 In Progress | 1/6 | #7 |
| 6 | Contracts and Commitments | 🔄 Partial | 2/6 | #8 |
| 7 | Settlement and Guild | ⏳ Planned | 0/6 | #9 |
| 8 | Scenario Testing Framework | ⏳ Planned | 0/7 | #10 |
| 9 | Persistence | ⏳ Planned | 0/4 | #11 |
| 10 | Apprenticeship and Role Stacking | ⏳ Planned | 0/4 | #12 |
| 11 | Full Progression Scenario | ⏳ Planned | 0/5 | #13 |

**Total Progress**: 28/58 tasks complete (48%)

### Recent Completions

- ✅ **2026-01-19**: Epic 5.1 - Currency value object (#40, PR #139 - awaiting review)
- ✅ **2026-01-19**: Epic 4.8 - Masterwork → Master rank trigger (#39, PR #136)
- ✅ **2026-01-19**: Epic 4.7 - CraftingSystem (#38, PR #135)
- ✅ **2026-01-19**: Epic 4.6 - CraftingOutcomeRule (#37, PR #134)
Expand All @@ -49,8 +50,9 @@ Epic 4 (Crafting and Class Progression) complete! Next: Epic 5 (Economy and Inve

Priority order for remaining work:

1. **Epic 5** - #7: Economy and Inventory (0/6 tasks)
2. **Epic 6** - #8: Complete Contracts and Commitments (4/6 remaining)
1. **Epic 5.2** - #41: Implement InventoryComponent
2. **Epic 5** - #7: Complete Economy and Inventory (5/6 remaining)
3. **Epic 6** - #8: Complete Contracts and Commitments (4/6 remaining)

## Key Design Decisions

Expand Down Expand Up @@ -262,11 +264,23 @@ _For implementation patterns, examine referenced code paths._

---

## Epic 5: Economy and Inventory (🔄 1/6 tasks)

**5.1 Implement Currency value object** ✅ _Issue #40, PR #139 (awaiting review)_

- ✅ FromSilver(), FromGold(), FromMixed() factory methods
- ✅ Silver and Gold properties for denomination access
- ✅ ToBreakdown() for converting to (gold, silver, copper) tuple
- ✅ Conversion rates: 1 silver = 10 copper, 1 gold = 100 copper
- **Verified**: 6 tests pass, all 517 tests pass

---

### Planned Epics

| Epic | Title | Status | Issue | Key Components |
| ---- | -------------------------------- | ------ | ----- | --------------------------------------------- |
| 5 | Economy and Inventory | ⏳ 0/6 | #7 | Currency, InventoryComponent, PriceCalculator |
| 5 | Economy and Inventory | 🔄 1/6 | #7 | Currency, InventoryComponent, PriceCalculator |
| 6 | Contracts and Commitments | 🔄 2/6 | #8 | Commitment types, ContractActions |
| 7 | Settlement and Guild | ⏳ 0/6 | #9 | Settlement, Guild, leadership |
| 8 | Scenario Testing Framework | ⏳ 0/7 | #10 | WorldBuilder, CharacterBuilder |
Expand Down
45 changes: 43 additions & 2 deletions src/FantasyRpgWorld.Core/Domain/ValueObjects/Currency.cs
Original file line number Diff line number Diff line change
@@ -1,21 +1,62 @@
namespace FantasyRpgWorld.Core.Domain.ValueObjects;

/// <summary>
/// Represents currency in copper pieces.
/// Simplified currency for Epic 6; detailed economy in Epic 5.
/// Represents currency with copper, silver, and gold denominations.
/// Conversion: 1 silver = 10 copper, 1 gold = 100 copper.
/// </summary>
public readonly record struct Currency(int Copper)
{
private const int CopperPerSilver = 10;
private const int CopperPerGold = 100;

/// <summary>
/// Creates currency from a copper amount.
/// </summary>
public static Currency FromCopper(int copper) => new(copper);

/// <summary>
/// Creates currency from a silver amount.
/// </summary>
public static Currency FromSilver(int silver) => new(silver * CopperPerSilver);

/// <summary>
/// Creates currency from a gold amount.
/// </summary>
public static Currency FromGold(int gold) => new(gold * CopperPerGold);

/// <summary>
/// Creates currency from mixed denominations.
/// </summary>
public static Currency FromMixed(int gold, int silver, int copper) =>
new(gold * CopperPerGold + silver * CopperPerSilver + copper);

/// <summary>
/// Returns zero currency.
/// </summary>
public static Currency Zero => new(0);

/// <summary>
/// Gets the silver value (whole silver pieces, not including copper remainder).
/// </summary>
public int Silver => Copper / CopperPerSilver;

/// <summary>
/// Gets the gold value (whole gold pieces, not including copper/silver remainder).
/// </summary>
public int Gold => Copper / CopperPerGold;

/// <summary>
/// Breaks down the currency into gold, silver, and copper components.
/// </summary>
public (int Gold, int Silver, int Copper) ToBreakdown()
{
int gold = Copper / CopperPerGold;
int remaining = Copper % CopperPerGold;
int silver = remaining / CopperPerSilver;
int copper = remaining % CopperPerSilver;
return (gold, silver, copper);
}

public static Currency operator +(Currency a, Currency b) =>
new(a.Copper + b.Copper);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,75 @@ public void Equality_WorksCorrectly()
Assert.Equal(a, b);
Assert.NotEqual(a, c);
}

[Fact]
public void FromSilver_ConvertsToCopperCorrectly()
{
// Act
var currency = Currency.FromSilver(5);

// Assert
Assert.Equal(50, currency.Copper);
}

[Fact]
public void FromGold_ConvertsToCopperCorrectly()
{
// Act
var currency = Currency.FromGold(3);

// Assert
Assert.Equal(300, currency.Copper);
}

[Fact]
public void Silver_Property_ReturnsCorrectValue()
{
// Arrange
var currency = Currency.FromCopper(75);

// Act
int silver = currency.Silver;

// Assert
Assert.Equal(7, silver); // 75 copper = 7 silver (with 5 copper remaining)
}

[Fact]
public void Gold_Property_ReturnsCorrectValue()
{
// Arrange
var currency = Currency.FromCopper(350);

// Act
int gold = currency.Gold;

// Assert
Assert.Equal(3, gold); // 350 copper = 3 gold (with 50 copper remaining)
}

[Fact]
public void FromMixed_CreatesCurrencyFromMultipleDenominations()
{
// Act
var currency = Currency.FromMixed(gold: 2, silver: 3, copper: 5);

// Assert
Assert.Equal(235, currency.Copper); // 2*100 + 3*10 + 5 = 235
}

[Fact]
public void ToBreakdown_ReturnsCorrectDenominations()
{
// Arrange
var currency = Currency.FromCopper(347);

// Act
var (gold, silver, copper) = currency.ToBreakdown();

// Assert
Assert.Equal(3, gold); // 300 copper
Assert.Equal(4, silver); // 40 copper
Assert.Equal(7, copper); // 7 copper remaining
}
}