Skip to content
Open
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
3 changes: 3 additions & 0 deletions .claude/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"enableAllProjectMcpServers": true
}
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,7 @@ obj/
*.csproj.user
*.suo
*.tmp
.vscode
.vscode

# BenchmarkDotNet
BenchmarkDotNet.Artifacts/
9 changes: 9 additions & 0 deletions .mcp.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"mcpServers": {
"rogueelemens": {
"type": "stdio",
"command": "node",
"args": ["mcp-server/dist/index.js"]
}
}
}
138 changes: 138 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
# RogueElements

C# library for procedural roguelike map generation using a pipeline architecture.

## Claude Code Rules

- **Do not commit without explicit user consent** - Always ask before running `git commit`
- **Do not push without explicit user consent** - Always ask before running `git push`

## Quick Start

```bash
# Build
dotnet build RogueElements.sln

# Test
dotnet test RogueElements.Tests/RogueElements.Tests.csproj

# Run examples
dotnet run --project RogueElements.Examples/RogueElements.Examples.csproj
```

## Architecture

Pipeline pattern: `MapGen<T>` orchestrates `GenStep<T>` passes that modify `IGenContext`.

```
MapGen.GenMap(seed)
→ GenStep.Apply(context) // repeated for each step
→ GenStep.Apply(context)
→ ...
→ returns IGenContext
```

### Core Abstractions

| Class/Interface | Purpose |
|-----------------|---------|
| `MapGen<T>` | Orchestrator - holds priority-ordered GenSteps, calls `GenMap(seed)` |
| `GenStep<T>` | Base class for generation passes - implement `Apply(T map)` |
| `IGenContext` | Base interface for map state - provides `Rand`, `InitSeed()`, `FinishGen()` |
| `Priority` | Ordering mechanism for GenSteps (lower = earlier) |
| `PriorityList<T>` | Container holding GenSteps by Priority |

### Key Context Interfaces

Implement these to enable specific GenStep types:

| Interface | Enables |
|-----------|---------|
| `ITiledGenContext` | Tile-based operations (get/set tiles, wall detection) |
| `IFloorPlanGenContext` | Freeform room placement via `FloorPlan` |
| `IRoomGridGenContext` | Grid-based room layouts via `GridPlan` |
| `IPlaceableGenContext<T>` | Spawning entities (items, stairs, mobs) |

## Key Entry Points

- `RogueElements/MapGen/MapGen.cs` - Main orchestrator
- `RogueElements/MapGen/GenStep.cs` - Base step class
- `RogueElements.Examples/Program.cs` - Interactive examples runner

## Directory Guide

| Directory | Purpose |
|-----------|---------|
| `RogueElements/` | Core library |
| `RogueElements/MapGen/` | Generation pipeline (GenStep, MapGen, contexts) |
| `RogueElements/MapGen/FloorPlan/` | Freeform room-based generation |
| `RogueElements/MapGen/Grid/` | Grid-based room layouts |
| `RogueElements/MapGen/Rooms/` | Room shape generators (RoomGenSquare, RoomGenCave, etc.) |
| `RogueElements/MapGen/Spawning/` | Entity placement (items, stairs, mobs) |
| `RogueElements/MapGen/Tiles/` | Tile manipulation and water generation |
| `RogueElements/Rand/` | RNG utilities (RandRange, SpawnList, noise) |
| `RogueElements/Priority/` | Priority queue for step ordering |
| `RogueElements.Examples/` | 8 progressive examples (Ex1-Ex8) |
| `RogueElements.Tests/` | NUnit tests with Moq |

## Examples Progression

| Example | Concept |
|---------|---------|
| Ex1_Tiles | Static tiles, `InitTilesStep` |
| Ex2_Rooms | Freeform rooms via `FloorPlan` |
| Ex3_Grid | Grid-based layouts via `GridPlan` |
| Ex4_Stairs | Stair placement |
| Ex5_Terrain | Water/terrain via Perlin noise |
| Ex6_Items | Item spawning |
| Ex7_Special | Special room placement |
| Ex8_Integration | Full pipeline combining all concepts |

## Patterns & Conventions

- **Naming**: PascalCase for all public members, `Step` suffix for GenStep subclasses
- **Generics**: GenSteps constrain `T` to required context interfaces
- **Serialization**: All GenSteps are `[Serializable]` for save/load support
- **Testing**: NUnit + Moq, test files mirror source structure
- **Style**: StyleCop + CodeCracker analyzers enforced

## Creating Custom Steps

1. Inherit from `GenStep<T>` where T implements needed interfaces
2. Override `Apply(T map)` with generation logic
3. Add to MapGen via `layout.GenSteps.Add(priority, step)`

```csharp
public class MyStep : GenStep<ITiledGenContext>
{
public override void Apply(ITiledGenContext map)
{
// modify map.Tiles, use map.Rand for randomness
}
}
```

## Creating Custom Contexts

1. Inherit from `IGenContext` (minimum)
2. Add interfaces as needed (ITiledGenContext, IFloorPlanGenContext, etc.)
3. See `RogueElements.Examples/Common/BaseMapGenContext.cs` for reference

## Deep Dive Documentation

For detailed architecture and code flow documentation, see `docs/claude/`:

| Document | Purpose |
|----------|---------|
| [architecture.md](docs/claude/architecture.md) | Interface hierarchy, GenStep categories, data flow diagrams |
| [flows.md](docs/claude/flows.md) | Traced code paths for key operations |
| [patterns.md](docs/claude/patterns.md) | Step-by-step recipes for common modifications |

## Debug Support

```csharp
GenContextDebug.OnInit += handler; // Map initialization
GenContextDebug.OnStep += handler; // Each step execution
GenContextDebug.OnStepIn += handler; // Step entry
GenContextDebug.OnStepOut += handler; // Step exit
```
88 changes: 88 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# Code Of Conduct

## 1. Overview

The developers elected to govern their interactions with each other, with their clients, and with the larger user community in accordance with the "instruments of good works" from chapter 4 of The Rule of St. Benedict (hereafter: "The Rule"). This Rule has proven its mettle in thousands of diverse communities for over 1,500 years, and has served as a baseline for many civil law codes since the time of Charlemagne.

The Rule is strict, and none are able to comply perfectly. Grace is readily granted for minor transgressions. All are encouraged to follow this rule closely, as in so doing they may expect to live happier, healthier, and more productive lives. The entire Rule is good and wholesome, and yet we make no enforcement of the more introspective aspects.

We view The Rule as our promise to all users of this project of how the developers are expected to behave. This is a one-way promise, or covenant. In other words, the developers are saying: "We will treat you this way regardless of how you treat us."

## 2. The Rule

1. First of all, love the Lord God with your whole heart, your whole soul, and your whole strength.
2. Then, love your neighbor as yourself.
3. Do not murder.
4. Do not commit adultery.
5. Do not steal.
6. Do not covet.
7. Do not bear false witness.
8. Honor all.
9. Do not do to another what you would not have done to yourself.
10. Deny oneself in order to follow Christ.
11. Chastise the body.
12. Do not become attached to pleasures.
13. Love fasting.
14. Relieve the poor.
15. Clothe the naked.
16. Visit the sick.
17. Bury the dead.
18. Be a help in times of trouble.
19. Console the sorrowing.
20. Be a stranger to the world's ways.
21. Prefer nothing more than the love of Christ.
22. Do not give way to anger.
23. Do not nurse a grudge.
24. Do not entertain deceit in your heart.
25. Do not give a false peace.
26. Do not forsake charity.
27. Do not swear, for fear of perjuring yourself.
28. Utter only truth from heart and mouth.
29. Do not return evil for evil.
30. Do no wrong to anyone, and bear patiently wrongs done to yourself.
31. Love your enemies.
32. Do not curse those who curse you, but rather bless them.
33. Bear persecution for justice's sake.
34. Be not proud.
35. Be not addicted to wine.
36. Be not a great eater.
37. Be not drowsy.
38. Be not lazy.
39. Be not a grumbler.
40. Be not a detractor.
41. Put your hope in God.
42. Attribute to God, and not to self, whatever good you see in yourself.
43. Recognize always that evil is your own doing, and to impute it to yourself.
44. Fear the Day of Judgment.
45. Be in dread of hell.
46. Desire eternal life with all the passion of the spirit.
47. Keep death daily before your eyes.
48. Keep constant guard over the actions of your life.
49. Know for certain that God sees you everywhere.
50. When wrongful thoughts come into your heart, dash them against Christ immediately.
51. Disclose wrongful thoughts to your spiritual mentor.
52. Guard your tongue against evil and depraved speech.
53. Do not love much talking.
54. Speak no useless words or words that move to laughter.
55. Do not love much or boisterous laughter.
56. Listen willingly to holy reading.
57. Devote yourself frequently to prayer.
58. Daily in your prayers, with tears and sighs, confess your past sins to God, and amend them for the future.
59. Fulfill not the desires of the flesh; hate your own will.
60. Obey in all things the commands of those whom God has placed in authority over you even though they (which God forbid) should act otherwise, mindful of the Lord's precept, "Do what they say, but not what they do."
61. Do not wish to be called holy before one is holy; but first to be holy, that you may be truly so called.
62. Fulfill God's commandments daily in your deeds.
63. Love chastity.
64. Hate no one.
65. Be not jealous, nor harbor envy.
66. Do not love quarreling.
67. Shun arrogance.
68. Respect your seniors.
69. Love your juniors.
70. Pray for your enemies in the love of Christ.
71. Make peace with your adversary before the sun sets.
72. Never despair of God's mercy.

## 3. Attribution

This code of conduct was taken from [The rule of St. Benedict, as your Code of Conduct](https://github.com/saint-benedict/code-of-conduct) which in turn was adapted from [SQLite's Code of conduct](https://web.archive.org/web/20181024103452/https://sqlite.org/codeofconduct.html) and now [Code of Ethics](https://sqlite.org/codeofethics.html).
80 changes: 80 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# Contributing to RogueElements

First off, **thank you** for considering contributing! I truly believe in open source and the power of community collaboration. Unlike many repositories, I actively welcome contributions of all kinds - from bug fixes to new features.

## My Promise to Contributors

- **I will respond to every PR and issue** - I guarantee feedback on all contributions
- **Bug fixes are obvious accepts** - If it fixes a bug, it's getting merged
- **New features are welcome** - I'm genuinely open to new ideas and enhancements
- **Direct line of communication** - If I'm not responding to a PR or issue, email me directly at johnvondrashek@gmail.com

## Ways to Contribute

### Bug Fixes
Found a bug in dungeon generation? Room placement acting strange? Stairs spawning in walls? Open a PR - these are obvious accepts.

### New Features
Ideas that would be great additions:
- New `GenStep` implementations (terrain types, room shapes, spawning strategies)
- Additional `RoomGen` variants for different dungeon aesthetics
- Improved corridor algorithms
- New utility classes for procedural generation

### Documentation
- Example tutorials (Ex9 and beyond!)
- Integration guides for game engines (Unity, Godot, MonoGame)
- API documentation improvements

### Tests
More test coverage is always welcome. The project uses NUnit with Moq.

## Getting Started

```bash
# Clone your fork
git clone https://github.com/YOUR_USERNAME/RogueElements.git

# Build
dotnet build RogueElements.sln

# Run tests
dotnet test RogueElements.Tests/RogueElements.Tests.csproj

# Run examples to understand the library
dotnet run --project RogueElements.Examples/RogueElements.Examples.csproj
```

## Pull Request Guidelines

1. **Target `master` branch** for most contributions
2. **Include tests** for new functionality when possible
3. **Follow existing code style** - the project uses StyleCop and CodeCracker analyzers
4. **Keep commits focused** - one logical change per commit
5. **Write clear commit messages** describing the "why"

## Creating Custom GenSteps

If you're adding a new generation step, follow this pattern:

```csharp
[Serializable]
public class MyCustomStep<T> : GenStep<T>
where T : /* required context interfaces */
{
public override void Apply(T map)
{
// Your generation logic here
// Use map.Rand for deterministic randomness
}
}
```

## Code of Conduct

This project follows the [Rule of St. Benedict](CODE_OF_CONDUCT.md) as its code of conduct.

## Questions?

- Open an issue
- Email: johnvondrashek@gmail.com
Loading