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
[源代码]¶ 基类:
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)[源代码]¶ 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.
- 参数
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.
- 返回
int – The rolled result - sum of all dice rolled.
- 引发
TypeError – If roll_string is not on the right format or otherwise doesn’t validate.
提示
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)[源代码]¶ Base roll of d20, or 2d20, based on dis/advantage given.
- 参数
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.
提示
Disadvantage and advantage cancel each other out.
-
saving_throw
(character, bonus_type=<Ability.STR: 'strength'>, target=15, advantage=False, disadvantage=False, modifier=0)[源代码]¶ 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.
- 参数
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.
- 返回
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.
提示
Advantage and disadvantage cancel each other out.
示例
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)[源代码]¶ An saving throw that tries to beat an active opposing side.
- 参数
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.
- 返回
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.
提示
Advantage and disadvantage cancel each other out.
-
roll_random_table
(dieroll, table_choices)[源代码]¶ Make a roll on a random table.
- 参数
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.
- 返回
Any – The result of the random roll.
示例
roll table_choices = [(‘1-5’, “Blue”), (‘6-9’: “Red”), (‘10’, “Purple”)]
提示
If the roll is outside of the listing, the closest edge value is used.
-
morale_check
(defender)[源代码]¶ A morale check is done for NPCs/monsters. It’s done with a 2d6 against their morale.
- 参数
defender (NPC) – The entity trying to defend its morale.
- 返回
bool – False if morale roll failed, True otherwise.
-
heal_from_rest
(character)[源代码]¶ A meal and a full night’s rest allow for regaining 1d8 + Const bonus HP.
- 参数
character (Character) – The one resting.
-
death_map
= {'addled': 'intelligence', 'disfigured': 'charisma', 'rattled': 'wisdom', 'sickly': 'constitution', 'unsteady': 'dexterity', 'weakened': 'strength'}¶
-