PHPackages                             ernestdefoe/roleplay - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. ernestdefoe/roleplay

ActiveFlarum-extension[Utility &amp; Helpers](/categories/utility)

ernestdefoe/roleplay
====================

Role-play for Flarum: play a character, post in-character, and run a card-based tactical game inside your discussions.

00PHP

Since Jun 26Pushed todayCompare

[ Source](https://github.com/ernestdefoe/roleplay)[ Packagist](https://packagist.org/packages/ernestdefoe/roleplay)[ RSS](/packages/ernestdefoe-roleplay/feed)WikiDiscussions master Synced today

READMEChangelog (2)DependenciesVersions (1)Used By (0)

Role-Play for Flarum
====================

[](#role-play-for-flarum)

**Play a character, post in-character, and run a card-based tactical game — right inside your Flarum discussions.**

[![License: MIT](https://camo.githubusercontent.com/7013272bd27ece47364536a221edb554cd69683b68a46fc0ee96881174c4214c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e737667)](LICENSE)[![Flarum 2.0+](https://camo.githubusercontent.com/0ec72437f5a7d6512150775722da402bbc7b571d14c1504386baaad13035dc00/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f466c6172756d2d322e302532422d6f72616e67652e737667)](https://flarum.org)

Role-Play turns an ordinary Flarum forum into a home for tabletop-style play. Members create characters, write posts *as* those characters, and storytellers can run full turn-based combat encounters — with dice, cards, initiative and live HP bars — without anyone leaving the thread.

It touches **no core tables** (everything lives in its own `rp_*` tables) and is **free and MIT-licensed**.

 [![The live combat tracker in a discussion sidebar](images/combat-tracker.png)](images/combat-tracker.png)

---

Three features, one extension
-----------------------------

[](#three-features-one-extension)

### 🎭 Characters

[](#-characters)

Members manage their cast at **`/characters`** ("My Characters" in the account menu): a name, an accent colour, an optional avatar and bio. Characters are yours; archive them any time and their old posts keep their identity.

[![My Characters page](images/characters.png)](images/characters.png)

### 💬 Post in-character

[](#-post-in-character)

When replying, pick **"Post as …"** in the composer and your reply is authored as that character — its coloured badge and name replace your own, with a quiet *"Played by you"* underneath so nothing is hidden. Perfect for narrative threads where several people each speak as their characters.

### ⚔️ A tactical card game

[](#️-a-tactical-card-game)

This is where Role-Play goes further than any other Flarum RP add-on. Build a **deck** of cards, then run **encounters** — turn-based fights that play out live in the discussion sidebar.

---

The deck builder
----------------

[](#the-deck-builder)

At **`/deck`** ("My Deck" in the account menu) each member crafts cards — **abilities, items, spells and enemies** — each with dice formulas the game engine actually rolls:

- **Attack roll** (e.g. `1d20+5`) — checked against the target's defense
- **Damage roll** (e.g. `3d6`) — applied on a hit, **doubled on a natural-max crit**
- Optional **defense**, **HP**, **cost**, a **Font Awesome icon**, and a description
- Mark a card **public** to share it into everyone's deck

[![The deck / card builder](images/deck.png)](images/deck.png)

Dice expressions are validated server-side — a malformed formula is rejected, never silently ignored.

---

Running an encounter
--------------------

[](#running-an-encounter)

Any member can start an encounter inside a discussion and becomes its **storyteller (GM)**. From the tracker in the sidebar you:

1. **Build the field** — add party members and foes by hand, **spawn a foe straight from an enemy card** (its HP and defense seed automatically), and let players **join with one of their own characters**.
2. **Roll initiative &amp; start** — every combatant rolls `1d20 + agility`; the tracker sorts them into turn order.
3. **Play it out** — on each turn the active combatant **plays a card at a target**. The engine rolls to-hit vs. defense, rolls damage on a hit (×2 on a crit), and updates HP. A rolling **action log** narrates every play — hits, misses and crits.
4. **Advance** until one side is down — a **Victory / Defeat banner** appears, and the GM ends the encounter.

The tracker shows the initiative order, colour-coded HP bars (green party / red foes), the active turn, and adapts its controls to who's looking — the GM drives the fight; a player only acts on their own character's turn.

### Live for the whole table

[](#live-for-the-whole-table)

When [flarum/realtime](https://flarum.org) is installed, every play, turn and HP change is **broadcast over WebSocket** — the whole table sees the fight update instantly, no refresh. Without realtime, the tracker falls back to a lightweight poll, so it still stays in sync.

---

Installation
------------

[](#installation)

```
composer require ernestdefoe/roleplay
php flarum cache:clear
```

That's it — the six `rp_*` tables are created automatically on enable. Then:

- Members find **My Characters** and **My Deck** in their account menu.
- Anyone can start an encounter from a discussion's sidebar.
- For instant multi-viewer combat, install and configure **flarum/realtime** (optional).

### Requirements

[](#requirements)

- Flarum **2.0+**
- PHP 8.1+
- *(Optional)* flarum/realtime for live updates

---

How the dice work
-----------------

[](#how-the-dice-work)

The engine (`src/Game.php`) is a small, pure core:

StepRule**Dice**Any `XdY+Z` expression, e.g. `2d6+1`, `1d20`, `3d8-2`**Initiative**`1d20 + agility`, highest goes first**To-hit**Attack total ≥ target defense (defense `0` = always hits)**Crit**A natural maximum on any attack die → **double damage****Down**A combatant at `0` HP is out; turns skip them---

Building from source
--------------------

[](#building-from-source)

The PHP runs as-is; the front-end compiles with the Flarum webpack toolchain:

```
cd js
npm install
npm run build
```

---

License
-------

[](#license)

[MIT](LICENSE) © Ernest Defoe. Free to use, fork and build on.

###  Health Score

20

—

LowBetter than 13% of packages

Maintenance65

Regular maintenance activity

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity11

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/c9978664264055711c21fbcf73c937f758df771d9cb40f6a25370b10123e7abc?d=identicon)[ernestdefoe](/maintainers/ernestdefoe)

---

Top Contributors

[![ernestdefoe](https://avatars.githubusercontent.com/u/24905286?v=4)](https://github.com/ernestdefoe "ernestdefoe (10 commits)")

---

Tags

flarumflarum-extensionphproleplaytabletop

### Embed Badge

![Health badge](/badges/ernestdefoe-roleplay/health.svg)

```
[![Health](https://phpackages.com/badges/ernestdefoe-roleplay/health.svg)](https://phpackages.com/packages/ernestdefoe-roleplay)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
