-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add injury command, readme, and cleanup
- Loading branch information
Showing
21 changed files
with
518 additions
and
216 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
# Dice Boy | ||
|
||
A discord bot for runnning Fallout RPG games. | ||
|
||
## Usage | ||
|
||
To run a command with **Dice Boy**, use the `!vats` command or `@Dice Boy` command. For example, `!vats command` or `@Dice Boy command`. | ||
|
||
Use the `!vats help <command>` command to view detailed information about a specific command. | ||
Use `!vats help all` help all to view a list of all commands, not just available ones. | ||
|
||
Available commands for **Dice Boy** | ||
|
||
### Rolls: 1. Be Smart 2. Be Safe 3. Don't Screw Up! | ||
|
||
#### `combat` | ||
|
||
Spread Democracy for Uncle Sam! Uses the Vault-Tec recommended `{dice} {damage type} [{effects,...}] [{hit location}] [{hit location type}]` notation. | ||
|
||
```bash | ||
| Description | Formula | | ||
| ------------------------------ | ------------------- | | ||
| 1 Physical | 1 ph | | ||
| 2 Radiation Vicious | 2 ra vicious | | ||
| 3 Energy Piercing 2 Stun | 3 en piercing2,stun | | ||
| 4 Poison Stun Head | 4 po stun h | | ||
| 1 Energy Stun Mr. Handy | 1 en stun handy | | ||
| 1 Energy Stun Optics Mr. Handy | 1 en stun o handy | | ||
| ---------------------------------------------------- | | ||
``` | ||
|
||
#### `roll` | ||
|
||
Try your luck with some dice! Uses [standard dice notation](https://greenimp.github.io/rpg-dice-roller/guide/notation/). | ||
|
||
#### `skill` | ||
|
||
Use your skills to help your fellow citizens! Uses the Vault-Tec recommended `{target} [d{dice}][t{tag}][c{complication}] [{difficulty}]` notation. | ||
|
||
```bash | ||
| Description | Formula | | ||
| -------------------------- | ------------ | | ||
| 10 Target | 10 | | ||
| 10 Target, 2 Difficulty | 10 2 | | ||
| 10 Target, 3 Dice | 10 d3 | | ||
| 10 Target, 4 Tag | 10 t4 | | ||
| 10 Target, 19 Complication | 10 c19 | | ||
| A little bit of everything | 10 3dt4c19 2 | | ||
| ----------------------------------------- | | ||
``` | ||
|
||
### Rules: Knowledge is power, and knowing is half the battle! | ||
|
||
#### `injury` | ||
|
||
The outside world can never hurt you! Uses the Vault-Tec recommended `{hit location} [{hit location type}]` notation. | ||
|
||
```bash | ||
| Description | Formula | | ||
| ---------------- | ------- | | ||
| Head | h | | ||
| Mr. Handy Optics | o handy | | ||
| -------------------------- | | ||
``` | ||
|
||
### Utility | ||
|
||
`help`: Displays a list of available commands, or detailed information for a specified command. | ||
`ping`: Checks the bot's ping to the Discord server. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
import { MessageEmbed, TextChannel } from "discord.js"; | ||
import { Command, CommandoClient, CommandoMessage } from "discord.js-commando"; | ||
import { Menu } from "discord.js-menu"; | ||
|
||
import { getAuthorData } from "../../utils/author"; | ||
import { | ||
injuryNotation, | ||
injuryNotationRegex, | ||
} from "../../utils/rolls/notation"; | ||
import { | ||
getCriticalHitLocation, | ||
HitLocation, | ||
HitLocationType, | ||
} from "../../utils/hit-locations"; | ||
import { infoColor, warningColor } from "../../utils/color"; | ||
import { | ||
criticalHitInjuries, | ||
CriticalHitLocation, | ||
} from "../../utils/damage/critical-hit"; | ||
import { capitalize } from "../../utils/text/capitalize"; | ||
|
||
class CombatRollCommand extends Command { | ||
constructor(client: CommandoClient) { | ||
super(client, { | ||
name: "injury", | ||
aliases: ["i"], | ||
group: "rules", | ||
memberName: "injury", | ||
description: `The outside world can never hurt you! Uses the Vault-Tec recommended ${injuryNotation} notation.`, | ||
clientPermissions: ["MANAGE_MESSAGES"], | ||
args: [ | ||
{ | ||
key: "formula", | ||
type: "string", | ||
prompt: `Enter a enter hit location and optional type using the \`${injuryNotation}\` notation.\nNote: \`{}\` indicate where a value should be entered, \`[]\` indicate an optional value. Do not include either \`{}\` or \`[]\` in your formula.\n`, | ||
}, | ||
], | ||
}); | ||
} | ||
|
||
private showResultsMessage = ( | ||
message: CommandoMessage, | ||
location: CriticalHitLocation | ||
) => { | ||
new Menu(message.channel as TextChannel, message.author.id, [ | ||
{ | ||
name: "main", | ||
content: new MessageEmbed({ | ||
...getAuthorData(this.client), | ||
title: "Injury!", | ||
color: infoColor, | ||
|
||
description: "> The outside world can never hurt you!", | ||
fields: [ | ||
{ | ||
name: "Location", | ||
value: capitalize(location), | ||
inline: false, | ||
}, | ||
{ | ||
name: "Injury", | ||
value: criticalHitInjuries[location], | ||
inline: false, | ||
}, | ||
], | ||
}), | ||
reactions: {}, | ||
}, | ||
]).start(); | ||
}; | ||
|
||
public run = ( | ||
message: CommandoMessage, | ||
{ formula }: { formula: string } | ||
): null => { | ||
const authorData = getAuthorData(this.client); | ||
|
||
const showError = (error?: Error): null => { | ||
const errorMessage = error && `**Vault-Tec Error: ${error.message}.**`; | ||
|
||
message.say( | ||
new MessageEmbed({ | ||
...authorData, | ||
title: "Error", | ||
description: `Uh oh, there was a problem with your formula. Please use the Vault-Tec approved \`${injuryNotation}\` notation and try again!\n\t | ||
Here is a few examples: | ||
\`\`\` | ||
| Description | Formula | | ||
| ---------------- | ------- | | ||
| Head | h | | ||
| Mr. Handy Optics | o handy | | ||
| -------------------------- | | ||
\`\`\`\n | ||
${errorMessage || ""}`, | ||
color: warningColor, | ||
}) | ||
); | ||
|
||
return null; | ||
}; | ||
|
||
if (injuryNotationRegex.test(formula)) { | ||
try { | ||
const args = formula.split(" "); | ||
const hitLocation = args[0] as HitLocation; | ||
const hitLocationType = | ||
(args[1] as HitLocationType) || HitLocationType.Default; | ||
|
||
if (!hitLocation || !hitLocationType) { | ||
return showError(); | ||
} | ||
|
||
const location = getCriticalHitLocation(hitLocationType, hitLocation); | ||
|
||
this.showResultsMessage(message, location); | ||
|
||
return null; | ||
} catch (error) { | ||
return showError(error); | ||
} | ||
} | ||
|
||
return showError(); | ||
}; | ||
} | ||
|
||
export default CombatRollCommand; |
Oops, something went wrong.