use indoc::indoc; pub fn parse_help_topic(input: &str) -> Option { match input { "cofd" => Some(HelpTopic::ChroniclesOfDarkness), "dicepool" => Some(HelpTopic::DicePool), "dice" => Some(HelpTopic::RollingDice), "cthulhu" => Some(HelpTopic::Cthulhu), "variables" => Some(HelpTopic::Variables), "var" => Some(HelpTopic::Variables), "variable" => Some(HelpTopic::Variables), "" => Some(HelpTopic::General), _ => None, } } pub enum HelpTopic { ChroniclesOfDarkness, DicePool, Cthulhu, RollingDice, Variables, General, } const COFD_HELP: &'static str = indoc! {" Chronicles of Darkness Commands available: !pool, !rp: roll a dice pool !chance: roll a chance die See also: !help dicepool "}; const DICE_HELP: &'static str = indoc! {" Rolling basic dice Command: !roll, !r Syntax !roll Dice expression can be a basic die (e.g. 1d4), with a bonus (1d4+3), or a more complex series of dice rolls or arbitrary numbers. Parentheses are not supported. Examples: !roll 1d4 !roll 1d4+5 !roll 2d6+8 !roll 2d8 + 4d6 - 3 "}; const DICEPOOL_HELP: &'static str = indoc! {" Rolling dice pools Command: !pool, !rp Syntax: !pool : Short syntax: !pool Expression Syntax: [+/- ...] Modifiers: n = nine-again e = eight-again r = rote quality x = do not re-roll 10s s = number of successes for exceptional Examples: !pool 8 (roll a regular pool of 8 dice) !pool n:5 (roll dice pool of 5, nine-again) !pool rs3:6 (roll dice pool of 6, rote quality, 3 successes for exceptional) !pool 10 + 3 (roll dice pool of 10 + 3, which is 13) !pool myskill - 4 (roll pool of the value of myskill - 4). !pool n:myskill - 5 (roll pool of myskill - 5, with nine-again) "}; const CTHULHU_HELP: &'static str = indoc! {" Rolling Call of Cthlhu dice Commands: !cthroll (regular rolls), !cthadv (advancement rolls) Regular roll syntax: !cthroll : Advancement roll syntax: !cthadv Modifiers: b = one bonus die bb = two bonus dice p = one penalty die pp = two penalty dice Examples: !cthroll 60 (make a roll against a skill of 60) !cthroll spothidden (make a roll against variable spothidden) !cthroll bb:30 (make a roll against skill of 30 with two bonus dice) !cthadv 50 (make an advancement roll against a skill of 50) !cthadv spothidden (make an advancement roll against the number in spothidden) Note: If !cthadv is given a variable, and the roll is successful, it will update the variable with the new skill. "}; const VARIABLES_HELP: &'static str = indoc! {" Variables Commands: !get, !set, !variables Manage variables that can be substituted into roll commands. Examples: !get myvar, !set myvar 10 !get = show variable of the given name !set = set a variable to a number The !variables command will list all variables for the room. The variables command cna be used in a secure room to avoid spamming the actual room that the variable is set in. Variable names can be used in all types of dice rolls: !pool myvar + 3 !roll myvar There are some limitations on variables: they cannot themselves be dice expressions (i.e. can only be numbers), and they must be uniquely parseable in an expression (i.e 'myvard6' does not work for the !roll command). "}; const GENERAL_HELP: &'static str = indoc! {" General Help Try these help commands: !help cofd !help dice !help cthulhu "}; impl HelpTopic { pub fn message(&self) -> &str { match self { HelpTopic::ChroniclesOfDarkness => COFD_HELP, HelpTopic::DicePool => DICEPOOL_HELP, HelpTopic::Cthulhu => CTHULHU_HELP, HelpTopic::RollingDice => DICE_HELP, HelpTopic::Variables => VARIABLES_HELP, HelpTopic::General => GENERAL_HELP, } } }