Skip to content

labcabrera/rmu-api-attack

Repository files navigation

RMU API Attack

REST API for attack management in the Rolemaster Unified system using Python with MongoDB.

This project is part of RMU Online: https://github.com/labcabrera/rmu-platform

Warning
This application is an independent project developed by fans of Rolemaster Unified. It is not affiliated with, endorsed by, or licensed by Iron Crown Enterprises (ICE), the owners of the Rolemaster intellectual property. All Rolemaster trademarks, game systems, and materials are the property of Iron Crown Enterprises. This software is provided for personal, non-commercial use only. If you enjoy Rolemaster, please support the official publications and content from ICE.

Description

This API exposes endpoints to manage attack information, including creating, querying, updating, and deleting attacks according to RMU system.

API Attack Context System

Prerequisites

  • Python 3.11+

  • MongoDB (local or remote instance)

  • pip

Installation

Clone the repository and navigate to the project directory. Then execute:

Install dependencies:

python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt

Run the application:

uvicorn app.main:app --reload --host 0.0.0.0 --port 8000

Configuration

The application can be configured using environment variables:

  • MONGO_URI: MongoDB connection string (default: mongodb://localhost:27017)

  • MONGO_DATABASE: Database name (default: rmu-attacks)

  • DEBUG: Enable debug mode (default: false)

  • LOG_LEVEL: Logging level (default: INFO)

Endpoints

  • GET /v1/attacks/{attackId} - Search attack by Id

  • GET /v1/attacks/ - Search attacks with RSQL

  • POST /v1/attacks/ - Create a new attack

  • PATCH /v1/attacks/{attackId} - Update attack modifiers

  • DELETE /v1/attacks/{attackId} - Delete an attack

  • POST /v1/attacks/{attackId}/roll - Update attack roll

  • POST /v1/attacks/{attackUd}/apply - Applies the result of the attack to the tactical game system

  • GET / - Root endpoint with API information

  • GET /health - Health check endpoint with database connectivity status

Documentation

Once the application is running, you can access the interactive documentation at:

Development

Running Tests

pytest tests/ -v

Model Schema

The main entity of the domain is the Attack which has the following structure:

{
    "id": "6888972603b67e285cae95f0",
    "actionId": "action_001",
    "sourceId": "character_001",
    "targetId": "character_002",
    "status": "draft",
    "modifiers": {
        "attackType": "melee",
        "attackTable": "arming-sword",
        "attackSize": "medium",
        "at": 1,
        "actionPoints": 4,
        "fumble": 2,
        "rollModifiers": {
            "bo": 100,
            "bd": -20,
            "injuryPenalty": 0,
            "pacePenalty": 0,
            "fatiguePenalty": 0,
            "rangePenalty": 0,
            "shield": 0,
            "parry": 0,
            "customBonus": 0
        },
        "situationalModifiers": {
            "cover": "none",
            "restrictedQuarters": "none",
            "positionalSource": "none",
            "positionalTarget": "none",
            "dodge": "none",
            "disabledDB": false,
            "disabledShield": false,
            "disabledParry": false,
            "sizeDifference": 0,
            "offHand": false,
            "twoHandedWeapon": false,
            "higherGround": false,
            "sourceStatus": [],
            "targetStatus": []
        },
        "features": [],
        "sourceSkills": []
    },
    "roll": {
        "roll": 128,
        "criticalRolls": {
            "p_e_1": 12,
            "p_a_2": 45
        },
        "fumbleRoll": null
    },
    "calculated": {
        "rollModifiers": [
            {
                "key": "roll",
                "value": 128
            },
            {
                "key": "bo",
                "value": 100
            },
            {
                "key": "bd",
                "value": -20
            }
        ],
        "criticalModifiers": [
            {
                "key": "absolute-hit",
                "value": 7
            }
        ],
        "criticalSeverityModifiers": [],
        "rollTotal": 208,
        "criticalTotal": 7,
        "criticalSeverityTotal": 0
    },
    "results": {
        "attackTableEntry": {
            "text": "26FP",
            "damage": 26,
            "criticalType": "P",
            "criticalSeverity": "F"
        },
        "criticals": [
            {
                "key": "p_e_1",
                "status": "rolled",
                "criticalType": "P",
                "criticalSeverity": "E",
                "adjustedRoll": 19,
                "result": {
                    "text": "Foe flinches from blow, avoiding even greater damage to his neck.",
                    "damage": 15,
                    "location": "head",
                    "effects": [
                        {
                            "status": "bleeding",
                            "rounds": null,
                            "value": 2,
                            "delay": null,
                            "condition": null
                        },
                        {
                            "status": "stunned",
                            "rounds": 1,
                            "value": -25,
                            "delay": null,
                            "condition": null
                        }
                    ]
                }
            },
            {
                "key": "p_a_2",
                "status": "rolled",
                "criticalType": "P",
                "criticalSeverity": "A",
                "adjustedRoll": 52,
                "result": {
                    "text": "Point sinks an inch into foe's bicep muscle.",
                    "damage": 2,
                    "location": "arm",
                    "effects": [
                        {
                            "status": "bleeding",
                            "rounds": null,
                            "value": 2,
                            "delay": null,
                            "condition": null
                        },
                        {
                            "status": "penalty",
                            "rounds": null,
                            "value": -5,
                            "delay": null,
                            "condition": null
                        }
                    ]
                }
            }
        ]
    }
}

It is divided into the following blocks:

  • modifiers: values calculated in the tactical module used for the creation and update of the attack.

  • roll: information on dice rolls applicable to attack or critical rolls.

  • results: result of the attack, whether it is an attack with no effect, a damage, a set of critical hits, or a failure.

Attack Status

Attack Status State Diagram

Skills, character combat statuses and attack features

Source target skills allowed

Skill

Description

footwork

Reduces melee pace modifier.

reverse-strike

Reduces positional target bonus when attacking from the rear.

restricted-quarters

Reduces positional target bonus when attacking in restricted quarters.

Source statuses allowed

Status

Description

prone

Applies -50 penalty.

ambidextrous

Reduces off-hand penalty.

Target statuses allowed

Status

Description

stunned

Applies 20 bonus.

prone

Applies 30 bonus for melee attacks or -30 penalty for ranged attacks.

melee

Indicates that the target is in melee range, which can affect ranged attacks.

flying

Applies a -10 penalty.

Attack features

Feature

Description

slaying-attack

Values from i to v. Add a critical bonus to critical roll.

Technology Stack

  • FastAPI: Modern Python web framework

  • MongoDB: NoSQL database via Motor (async driver)

  • Pydantic: Data validation and serialization

  • Uvicorn: ASGI server

  • Pytest: Testing framework

  • Hexagonal Architecture: Clean architecture with ports and adapters pattern

TODO

  • Update actions points penalty

  • Called shots

  • Disarm attacks

  • Katas modifiers

  • Protecting others

  • Mounted combat

  • Subdual

About

Rolemaster Unified Attack API

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published