Skip to content

Commit 533ae66

Browse files
authored
Merge pull request #4 from Joshua154/updates
added miscast
2 parents e40baab + 8c54d23 commit 533ae66

4 files changed

Lines changed: 275 additions & 3 deletions

File tree

src/main/kotlin/de/joshua/dnd/Dice.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,15 +61,15 @@ class Dice {
6161

6262

6363
val klaxon = Klaxon()
64-
val result = arrayListOf<TableEntry>()
64+
val result = arrayListOf<CritTableEntry>()
6565
JsonReader(StringReader(file.readText())).use { reader ->
6666
reader.beginArray {
6767
while (reader.hasNext()) {
6868
/*val person = klaxon.parse<TableEntry>(reader)
6969
if (person != null) {
7070
result.add(person)
7171
}*/
72-
klaxon.parse<TableEntry>(reader)?.let { result.add(it) }
72+
klaxon.parse<CritTableEntry>(reader)?.let { result.add(it) }
7373
}
7474
}
7575
}
@@ -137,7 +137,7 @@ fun getBodyPartNumber(bodyPart: String): Int {
137137
}
138138

139139

140-
data class TableEntry(
140+
data class CritTableEntry(
141141
val max: Int,
142142
val description: String,
143143
val wounds: String,
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
package de.joshua.dnd
2+
3+
import com.beust.klaxon.JsonReader
4+
import com.beust.klaxon.Klaxon
5+
import de.joshua.DiscordBot
6+
import de.joshua.api.commands.slashcommands.SlashCommand
7+
import de.joshua.api.commands.slashcommands.SlashCommands
8+
import net.dv8tion.jda.api.EmbedBuilder
9+
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent
10+
import net.dv8tion.jda.api.interactions.commands.OptionType
11+
import net.dv8tion.jda.api.interactions.commands.build.OptionData
12+
import net.dv8tion.jda.api.interactions.commands.build.SubcommandData
13+
import net.dv8tion.jda.internal.interactions.CommandDataImpl
14+
import java.io.StringReader
15+
import java.time.Instant
16+
17+
@SlashCommands
18+
class MiscastCommand : SlashCommand {
19+
override fun commandData(): CommandDataImpl {
20+
return CommandDataImpl("miscast", "miscast")
21+
.addSubcommands(
22+
SubcommandData("minor", "minor miscast")
23+
.addOptions(
24+
OptionData(OptionType.INTEGER, "times", "Amount of roles"),
25+
OptionData(OptionType.USER, "user", "User to roll for"),
26+
OptionData(OptionType.BOOLEAN, "private", "Roles a dice privately")),
27+
SubcommandData("major", "major miscast")
28+
.addOptions(
29+
OptionData(OptionType.INTEGER, "times", "Amount of roles"),
30+
OptionData(OptionType.USER, "user", "User to roll for"),
31+
OptionData(OptionType.BOOLEAN, "private", "Roles a dice privately")))
32+
}
33+
34+
override fun onExecute(event: SlashCommandInteractionEvent) {
35+
val ephemeral = event.getOption("private") != null && event.getOption("private")?.asBoolean!!
36+
37+
var user = event.user
38+
if (event.getOption("user") != null) {
39+
user = event.getOption("user")?.asUser!!
40+
}
41+
42+
if (event.getOption("times") != null && event.getOption("times")?.asInt!! > 1) {
43+
val rolls = List(event.getOption("times")?.asInt!!) { getEntryMaxVal(getFileContent(event.subcommandName?:"minor"), Dice.rollDice(100)) }
44+
45+
val embed =
46+
EmbedBuilder()
47+
.setAuthor(user.name, null, user.avatarUrl)
48+
.setTimestamp(Instant.now())
49+
.setTitle("Rolled ${rolls.size} ${event.subcommandName?:"minor"} Miscasts")
50+
.setDescription(rolls.joinToString { "\n" + it.description })
51+
52+
event
53+
.replyEmbeds(embed.build())
54+
.setEphemeral(ephemeral)
55+
.setActionRow(Dice.getActionRow())
56+
.queue()
57+
} else {
58+
val roll = getEntryMaxVal(getFileContent(event.subcommandName?:"minor"), Dice.rollDice(100))
59+
60+
val embed =
61+
EmbedBuilder()
62+
.setAuthor(user.name, null, user.avatarUrl)
63+
.setTitle("${event.subcommandName?:"minor"} miscast")
64+
.setDescription(roll.description)
65+
.setTimestamp(Instant.now())
66+
67+
event
68+
.replyEmbeds(embed.build())
69+
.setEphemeral(ephemeral)
70+
.setActionRow(Dice.getActionRow())
71+
.queue()
72+
}
73+
}
74+
75+
private fun getFileContent(type: String): ArrayList<MiscastTableEntry> {
76+
val file = DiscordBot::class.java.getResource("/miscast/${type}.json")
77+
78+
val result = arrayListOf<MiscastTableEntry>()
79+
val klaxon = Klaxon()
80+
if (file != null) {
81+
JsonReader(StringReader(file.readText())).use { reader ->
82+
reader.beginArray {
83+
while (reader.hasNext()) {
84+
klaxon.parse<MiscastTableEntry>(reader)?.let { result.add(it) }
85+
}
86+
}
87+
}
88+
}
89+
return result
90+
}
91+
92+
private fun getEntryMaxVal(result: ArrayList<MiscastTableEntry>, number: Int): MiscastTableEntry {
93+
var index = -1
94+
for (i in result.size - 1 downTo 0) {
95+
if (result.get(i).max <= number) {
96+
index = i
97+
break
98+
}
99+
}
100+
if(index == -1) index = 0
101+
return result[index]
102+
}
103+
104+
private data class MiscastTableEntry(
105+
val max: Int,
106+
val description: String
107+
)
108+
}
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
[
2+
{
3+
"max": 5,
4+
"description": "**Ghostly Voices:**\nEveryone within Willpower yards hears darkly seductive whispering of voices emanating from the Realm of Chaos. All sentient creatures must pass an Average (+20) Cool Test or gain 1 Corruption point."
5+
},
6+
{
7+
"max": 10,
8+
"description": "**Hexeyes:**\nYour eyes turn an unnatural colour associated with your Lore for 1d10 hours. While your eyes are discoloured, you have 1 Blinded Condition that cannot be resolved by any means."
9+
},
10+
{
11+
"max": 15,
12+
"description": "**Aethyric Shock:**\nyou suffer 1d10 wounds, ignoring your Toughness Bonus and Armour Points. Pass an Average (+20) Endurance Test, or also gain a Stunned Condition.\n"
13+
},
14+
{
15+
"max": 20,
16+
"description": "**Death Walker:**\nYour footsteps leave death in their wake. For the next 1d10 hours, any plant life near you with- ers and dies.\n"
17+
},
18+
{
19+
"max": 25,
20+
"description": "**Intestinal Rebellion:**\nYour bowels move uncontrollably, and you soil yourself. Gain 1 Fatigued Condition, which cannot be removed until you can change your clothes and clean yourself up.\n"
21+
},
22+
{
23+
"max": 30,
24+
"description": "**Soulfire:**\nGain an Ablaze Condition, as you are wreathed in unholy flames with a colour associated with your Lore.\n"
25+
},
26+
{
27+
"max": 35,
28+
"description": "**Speak in Tongues:**\nYou gabble unintelligibly for 1d10 rounds. During this time, you cannot communicate verbally, or make any Casting Tests, although you may otherwise act normally.\n"
29+
},
30+
{
31+
"max": 40,
32+
"description": "**Swarmed:**\nYou are engaged by a swarm of aethyric Rats, Giant Spiders, Snakes, or similar (GM's choice). Use the standard profiles for the relevant creature type, adding the Swarm Creature Trait. After 1d10 rounds, if not yet destroyed, the swarm retreats.\n"
33+
},
34+
{
35+
"max": 45,
36+
"description": "**Ragdoll:**\nYou are flung 1d10 yards through the air in a random direction, taking 1d10 wounds on landing, ignoring Armour Points, and receiving the Prone Condition\n"
37+
},
38+
{
39+
"max": 50,
40+
"description": "**Limb frozen:**\nOne limb (randomly determined) is frozen in place for 1d10 hours. The limb is useless, as if it had been Amputated (see page 180).\n"
41+
},
42+
{
43+
"max": 55,
44+
"description": "**Darkling Sight:**\nYou lose the benefit of the Second Sight Talent for 1d10 hours. Channelling Tests also suffer a penalty of -20 for the duration.\n"
45+
},
46+
{
47+
"max": 60,
48+
"description": "**Chaotic Foresight:**\nGain a bonus pool of 1d10 Fortune points (this may take you beyond your natural limit). Every time you spend one of these points, gain 1 Corruption point. Any of these points remaining at the end of the session are lost.\n"
49+
},
50+
{
51+
"max": 65,
52+
"description": "**Levitation:**\nYou are borne aloft on the Winds of Magic, floating 1d10 yards above the ground for 1d10 min- utes. Other characters may forcibly move you, and you may move using spells, wings or similar, but will continu- ally return to your levitating position if otherwise left alone. Refer to the Falling rules (see page 166) for what happens when Levitation ends.\n"
53+
},
54+
{
55+
"max": 70,
56+
"description": "**Regurgitation:**\nYou spew uncontrollably, throwing up far more foul-smelling vomitus than your body can possibly contain. Gain the Stunned Condition, which lasts for 1d10 Rounds.\n"
57+
},
58+
{
59+
"max": 75,
60+
"description": "**Chaos Quake:**\nAll creatures within 1d100 yards must pass an Average (+20) Athletics Test or gain the Prone Condition.\n"
61+
},
62+
{
63+
"max": 80,
64+
"description": "**Traitor's Heart:**\nThe Dark Gods entice you to commit horrendous perfidy. Should you attack or otherwise betray an ally to the full extent of your capabilities, regain all Fortune points. If you cause another character to lose a Fate Point, gain +1 Fate Point.\n"
65+
},
66+
{
67+
"max": 85,
68+
"description": "**Foul Enfeeblement:**\nGain 1 Corruption point, the Prone Condition, and a Fatigued Condition\n"
69+
},
70+
{
71+
"max": 90,
72+
"description": "**Hellish Stench:**\nYou now smell really bad! You gain the Distracting Creature Trait (see page 339), and probably the enmity of anyone with a sense of smell. This lasts for 1d10 hours.\n"
73+
},
74+
{
75+
"max": 95,
76+
"description": "**Power Drain:**\nYou are unable to use the Talent used to cast the spell (usually Arcane Magic, though it could be Chaos Magic, or a similar Talent), for 1d10 minutes.\n"
77+
},
78+
{
79+
"max": 100,
80+
"description": "**Aethyric Feedback:**\nEveryone within a number of yards equal to your Willpower Bonus - friend and foe alike - suffers 1d10 wounds, ignoring Toughness Bonus and Armour Points, and receives the Prone Condition. If there are no targets in range, the magic has nowhere to vent, so your head explodes, killing you instantly.\n"
81+
}
82+
]
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
[
2+
{
3+
"max": 5,
4+
"description": "**Witchsign:**\nthe next living creature born within 1 mile is mutated."
5+
},
6+
{
7+
"max": 10,
8+
"description": "**Soured Milk:**\nAll milk within 1d100 yards goes sour instantly."
9+
},
10+
{
11+
"max": 15,
12+
"description": "**Blight:**\nWillpower Bonus fields within Willpower Bonus miles suffer a blight, and all crops rot overnight."
13+
},
14+
{
15+
"max": 20,
16+
"description": "**Soulwax:**\nYour ears clog instantly with a thick wax. Gain 1 Deafened Condition, which is not removed until someone cleans them for you (with a successful use of the Heal Skill)."
17+
},
18+
{
19+
"max": 25,
20+
"description": "**Witchlight:**\nYou glow with an eerie light related to your Lore, emitting as much light as a large bonfire, which lasts for 1d10 Rounds."
21+
},
22+
{
23+
"max": 30,
24+
"description": "**Fell Whispers:**\nPass a Routine (+20) Willpower Test or gain 1 Corruption point."
25+
},
26+
{
27+
"max": 35,
28+
"description": "**Rupture:**\nYour nose, eyes, and ears bleed profusely. Gain 1d10 Bleeding Conditions."
29+
},
30+
{
31+
"max": 40,
32+
"description": "**Soulquake:**\nGain the Prone Condition."
33+
},
34+
{
35+
"max": 45,
36+
"description": "**Unfasten:**\nOn your person, every buckle unfastens, and every lace unties, which may cause belts to fall, pouches to open, bags to fall, and armour to slip."
37+
},
38+
{
39+
"max": 50,
40+
"description": "**Wayward Garb:**\nyour clothes seem to writhe with a mind of their own. Receive 1 Entangled Condition with a Strength of 1d10x5 to resist."
41+
},
42+
{
43+
"max": 55,
44+
"description": "**Curse of Temperance:**\nAll alcohol within 1d100 yards goes bad, tasting bitter and foul."
45+
},
46+
{
47+
"max": 60,
48+
"description": "**Souldrain:**\nGain 1 Fatigued Condition, which remains for 1d10 hours."
49+
},
50+
{
51+
"max": 65,
52+
"description": "**Driven to Distraction:**\nIf engaged in combat, gain the Surprised Condition. Otherwise, you are completely startled, your heart racing, and unable to concentrate for a few moments."
53+
},
54+
{
55+
"max": 70,
56+
"description": "**Unholy Visions:**\nFleeting visions of profane and unholy acts harass you. Receive a Blinded Condition; pass a Challenging (+0) Cool Test or gain another."
57+
},
58+
{
59+
"max": 75,
60+
"description": "**Cloying Tongue:**\nAll Language Tests (including Casting Tests) suffer a -10 penalty for 1d10 Rounds."
61+
},
62+
{
63+
"max": 80,
64+
"description": "**The Horror!:**\nPass a Hard (-20) Cool Test or gain 1 Broken Condition."
65+
},
66+
{
67+
"max": 85,
68+
"description": "**Curse of Corruption:**\nGain 1 Corruption point."
69+
},
70+
{
71+
"max": 90,
72+
"description": "**Double Trouble:**\nThe effect of the spell you cast occurs elsewhere within 1d10 miles. At the GM's discretion, where possible it should have consequences."
73+
},
74+
{
75+
"max": 95,
76+
"description": "**Multiplying Misfortune:**\nRoll twice on this table, re rolling any results between 91-100."
77+
},
78+
{
79+
"max": 100,
80+
"description": "**Cascading Chaos:**\nRoll again on the Major Miscast Table."
81+
}
82+
]

0 commit comments

Comments
 (0)