Context
Cougr would benefit from an example focused on turn-based combat with richer state transitions than current arcade or board examples. A small RPG arena is a good fit because it introduces cooldowns, status effects, and action resolution while remaining deterministic and testable.
Goal
Create examples/rpg_arena/ as a standalone Soroban smart contract example that implements a compact turn-based combat loop.
The example should support two combatants, a small action set, status effects, cooldown tracking, and match resolution.
Scope
In scope:
- smart contract logic only
- deterministic two-combatant battle
- actions such as attack, defend, and one special ability
- status effects and cooldowns
- win detection
- README and CI workflow
Out of scope:
- exploration, inventory, quests, or narrative systems
- graphical UI
- matchmaking or progression economy
ECS Design Direction
Suggested components:
| Component |
Fields |
Purpose |
CombatantComponent |
hp, defense, speed or equivalent |
Stores battle stats |
StatusEffectComponent |
effect_kind, duration, magnitude |
Tracks active statuses |
CooldownComponent |
action_kind, remaining_turns |
Tracks ability reuse |
TurnComponent |
current_actor, round |
Tracks flow |
BattleStatusComponent |
status |
Tracks ongoing or finished match |
Suggested systems:
ActionValidationSystem
DamageResolutionSystem
StatusEffectSystem
CooldownSystem
TurnAdvanceSystem
EndConditionSystem
Contract API
fn init_battle(env: Env, player_one: Address, player_two: Address)
fn submit_action(env: Env, player: Address, action: Action)
fn get_state(env: Env) -> BattleState
fn get_combatant(env: Env, player: Address) -> CombatantState
fn is_finished(env: Env) -> bool
Tests
Add tests covering:
- initialization
- basic attack resolution
- defend interaction
- special ability cooldown handling
- status effect application and expiration
- wrong-turn rejection
- battle completion
Deliverables
examples/rpg_arena/
- contract implementation and tests
examples/rpg_arena/README.md
.github/workflows/rpg_arena.yml
Acceptance Criteria
- the combat loop is deterministic and testable
- cooldowns and status effects behave correctly
- turn order and end conditions are enforced correctly
- the example demonstrates clean Cougr-style decomposition
- documentation and commands use
wasm32v1-none
Validation Commands
cd examples/rpg_arena
cargo fmt --check
cargo clippy --all-targets --all-features -- -D warnings
cargo test
stellar contract build
Context
Cougr would benefit from an example focused on turn-based combat with richer state transitions than current arcade or board examples. A small RPG arena is a good fit because it introduces cooldowns, status effects, and action resolution while remaining deterministic and testable.
Goal
Create
examples/rpg_arena/as a standalone Soroban smart contract example that implements a compact turn-based combat loop.The example should support two combatants, a small action set, status effects, cooldown tracking, and match resolution.
Scope
In scope:
Out of scope:
ECS Design Direction
Suggested components:
CombatantComponentStatusEffectComponentCooldownComponentTurnComponentBattleStatusComponentSuggested systems:
ActionValidationSystemDamageResolutionSystemStatusEffectSystemCooldownSystemTurnAdvanceSystemEndConditionSystemContract API
Tests
Add tests covering:
Deliverables
examples/rpg_arena/examples/rpg_arena/README.md.github/workflows/rpg_arena.ymlAcceptance Criteria
wasm32v1-noneValidation Commands