evennia.contrib.tutorials.evadventure.rules

MUD ruleset based on the _Knave_ OSR tabletop RPG by Ben Milton (modified for MUD use).

The center of the rule system is the “RollEngine”, which handles all rolling of dice and determining what the outcome is.


class evennia.contrib.tutorials.evadventure.rules.EvAdventureRollEngine[source]

Bases: object

This groups all dice rolls of EvAdventure. These could all have been normal functions, but we are group them in a class to make them easier to partially override and replace later.

roll(roll_string, max_number=10)[source]

NOTE: In evennia/contribs/rpg/dice/ is a more powerful dice roller with more features, such as modifiers, secret rolls etc. This is much simpler and only gets a simple sum of normal rpg-dice.

Parameters
  • roll_string (str) – A roll using standard rpg syntax, <number>d<diesize>, like 1d6, 2d10 etc. Max die-size is 1000.

  • max_number (int) – The max number of dice to roll. Defaults to 10, which is usually more than enough.

Returns

int – The rolled result - sum of all dice rolled.

Raises

TypeError – If roll_string is not on the right format or otherwise doesn’t validate.

Notes

Since we may see user input to this function, we make sure to validate the inputs (we wouldn’t bother much with that if it was just for developer use).

roll_with_advantage_or_disadvantage(advantage=False, disadvantage=False)[source]

Base roll of d20, or 2d20, based on dis/advantage given.

Parameters
  • bonus (int) – The ability bonus to apply, like strength or charisma.

  • advantage (bool) – Roll 2d20 and use the bigger number.

  • disadvantage (bool) – Roll 2d20 and use the smaller number.

Notes

Disadvantage and advantage cancel each other out.

saving_throw(character, bonus_type=<Ability.STR: 'strength'>, target=15, advantage=False, disadvantage=False, modifier=0)[source]

A saving throw without a clear enemy to beat. In _Knave_ all unopposed saving throws always tries to beat 15, so (d20 + bonus + modifier) > 15.

Parameters
  • character (Object) – The one attempting to save themselves.

  • bonus_type (enum.Ability) – The ability bonus to apply, like strength or charisma.

  • target (int, optional) – Used for opposed throws (in Knave any regular saving through must always beat 15).

  • advantage (bool, optional) – Roll 2d20 and use the bigger number.

  • disadvantage (bool, optional) – Roll 2d20 and use the smaller number.

  • modifier (int, optional) – An additional +/- modifier to the roll.

Returns

tuple

A tuple (bool, str, str). The bool indicates if the save was passed or not.

The second element is the quality of the roll - None (normal), “critical fail” and “critical success”. Last element is a text detailing the roll, for display purposes.

Notes

Advantage and disadvantage cancel each other out.

Example

Trying to overcome the effects of poison, roll d20 + Constitution-bonus above 15.

opposed_saving_throw(attacker, defender, attack_type=<Ability.STR: 'strength'>, defense_type=<Ability.ARMOR: 'armor'>, advantage=False, disadvantage=False, modifier=0)[source]

An saving throw that tries to beat an active opposing side.

Parameters
  • attacker (Character) – The attacking party.

  • defender (Character) – The one defending.

  • attack_type (str) – Which ability to use in the attack, like ‘strength’ or ‘willpower’. Minimum is always 1.

  • defense_type (str) – Which ability to defend with, in addition to ‘armor’. Minimum is always 11 (bonus + 10 is always the defense in _Knave_).

  • advantage (bool) – Roll 2d20 and use the bigger number.

  • disadvantage (bool) – Roll 2d20 and use the smaller number.

  • modifier (int) – An additional +/- modifier to the roll.

Returns

tuple

(bool, str, str): If the attack succeed or not. The second element is the

quality of the roll - None (normal), “critical fail” and “critical success”. Last element is a text that summarizes the details of the roll.

Notes

Advantage and disadvantage cancel each other out.

roll_random_table(dieroll, table_choices)[source]

Make a roll on a random table.

Parameters
  • dieroll (str) – The dice to roll, like 1d6, 1d20, 3d6 etc).

  • table_choices (iterable) – If a list of single elements, the die roll should fully encompass the table, like a 1d20 roll for a table with 20 elements. If each element is a tuple, the first element of the tuple is assumed to be a string ‘X-Y’ indicating the range of values that should match the roll.

Returns

Any – The result of the random roll.

Example

roll table_choices = [(‘1-5’, “Blue”), (‘6-9’: “Red”), (‘10’, “Purple”)]

Notes

If the roll is outside of the listing, the closest edge value is used.

morale_check(defender)[source]

A morale check is done for NPCs/monsters. It’s done with a 2d6 against their morale.

Parameters

defender (NPC) – The entity trying to defend its morale.

Returns

bool – False if morale roll failed, True otherwise.

heal_from_rest(character)[source]

A meal and a full night’s rest allow for regaining 1d8 + Const bonus HP.

Parameters

character (Character) – The one resting.

death_map = {'addled': 'intelligence', 'disfigured': 'charisma', 'rattled': 'wisdom', 'sickly': 'constitution', 'unsteady': 'dexterity', 'weakened': 'strength'}
roll_death(character)[source]

Happens when hitting <= 0 hp. unless dead,