some cleaning up

This commit is contained in:
Nikolaj
2022-01-28 13:20:15 +01:00
parent 08435d6934
commit 2b21d43627
6 changed files with 320 additions and 325 deletions

View File

@ -13,43 +13,43 @@ class StarWarsRoll():
# Rolls the specified dice
def roll(self, abi : int = 1, prof : int = 0, dif : int = 3, cha : int = 0, boo : int = 0, setb : int = 0, force : int = 0):
result = ""
diceResult = []
dice_result = []
for _ in range(abi):
choice = random.choice(["","S","S","SS","A","A","SA","AA"])
result += choice
diceResult.append("abi"+choice)
dice_result.append("abi"+choice)
for _ in range(prof):
choice = random.choice(["","S","S","SS","SS","A","SA","SA","SA","AA","AA","R"])
result += choice
diceResult.append("prof"+choice)
dice_result.append("prof"+choice)
for _ in range(dif):
choice = random.choice(["","F","FF","H","H","H","HH","FH"])
result += choice
diceResult.append("dif"+choice)
dice_result.append("dif"+choice)
for _ in range(cha):
choice = random.choice(["","F","F","FF","FF","H","H","FH","FH","HH","HH","D"])
result += choice
diceResult.append("cha"+choice)
dice_result.append("cha"+choice)
for _ in range(boo):
choice = random.choice(["","","S","SA","AA","A"])
result += choice
diceResult.append("boo"+choice)
dice_result.append("boo"+choice)
for _ in range(setb):
choice = random.choice(["","","F","F","H","H"])
result += choice
diceResult.append("setb"+choice)
dice_result.append("setb"+choice)
for _ in range (force):
choice = random.choice(["B","B","B","B","B","B","BB","L","L","LL","LL","LL"])
result += choice
diceResult.append("force"+choice)
dice_result.append("force"+choice)
return result, diceResult
return result, dice_result
# Lets dice cancel each other out
def simplify(self, result : str):
@ -78,9 +78,9 @@ class StarWarsRoll():
return simp
# Returns emoji that symbolize the dice results
def diceResultToEmoji(self, diceResults : list):
def dice_result_to_emoji(self, dice_results : list):
emoji = ""
for result in diceResults:
for result in dice_results:
if result == "abiA":
emoji += "<:abil1a:695267684476125264> "
elif result == "abiSA":
@ -167,7 +167,7 @@ class StarWarsRoll():
return emoji
# Returns emoji that symbolize the results of the dice rolls
def resultToEmoji(self, result : str):
def result_to_emoji(self, result : str):
emoji = ""
for char in result:
if char == 'S':
@ -190,7 +190,7 @@ class StarWarsRoll():
return emoji
# Converts emoji into letters
def emojiToResult(self, emoji : str):
def emoji_to_result(self, emoji : str):
result = ""
for char in emoji:
if char == "<:light:691010089905029171>":
@ -201,7 +201,7 @@ class StarWarsRoll():
return result
# Returns emoji that symbolize the dice
def diceToEmoji(self, dice : list):
def dice_to_emoji(self, dice : list):
emoji = ""
for _ in range(dice[0]):
@ -222,7 +222,7 @@ class StarWarsRoll():
return emoji
# Rolls for obligation
def obligationRoll(self):
def obligation_roll(self):
self.bot.log("Rolling for obligation")
data = self.bot.database["starwarscharacters"]
@ -239,40 +239,40 @@ class StarWarsRoll():
return random.choice(table)
# Rolls for critical injury
async def critRoll(self, ctx, addington : int):
dd = "<:difficulty:690973992470708296>"
sd = "<:setback:690972157890658415>"
bd = "<:boost:690972178216386561>"
async def crit_roll(self, ctx, addington : int):
difficulty_die = "<:difficulty:690973992470708296>"
setback_die = "<:setback:690972157890658415>"
boost_die = "<:boost:690972178216386561>"
roll = random.randint(1,100) + addington
injuries = [
"**Minor nick**: The target suffers 1 strain, "+dd] * 5 + [
"**Slowed down**: The target can only act during the last allied initiative slot this turn, "+dd] * 5 + [
"**Sudden Jolt**: The target drops whatever is in hand, "+dd] * 5 + [
"**Distracted**: The target cannot perform a Free maneuver during his next turn, "+dd] * 5 + [
"**Off-Balance**: The target adds "+sd+" to his next skill check, "+dd] * 5 + [
"**Discouraging Wound**: Flip one light side Destiny point to a dark side Destiny point (reverse if NPC), "+dd] * 5 + [
"**Stunned**: The target is staggered until the end of his next turn, "+dd] * 5 + [
"**Stinger**: Increase the difficulty of next check by one, "+dd] * 5 + [
"**Bowled Over**: The target is knocked prone and suffers 1 strain, "+dd+dd] * 5 + [
"**Head Ringer**: The target increases the difficulty of all Intellect and Cunning checks by one until the end of the encounter, "+dd+dd] * 5 + [
"**Fearsome Wound**: The target increases the difficulty of all Presence and Willpower checks by one until the end of the encounter, "+dd+dd] * 5 + [
"**Agonizing Wound**: The target increases the difficulty of all Brawn and Agility checks by one until the end of the encounter, "+dd+dd] * 5 + [
"**Slightly Dazed**: The target is disoriented until the end of the encounter, "+dd+dd] * 5 + [
"**Scattered Senses**: The target removes all "+bd+" from skill checks until the end of the encounter, "+dd+dd] * 5 + [
"**Hamstrung**: The target loses his free maneuver until the end of the encounter, "+dd+dd] * 5 + [
"**Overpowered**: The target leaves himself open, and the attacker may immediately attempt another free attack agains him, using the exact same pool as the original, "+dd+dd] * 5 + [
"**Winded**: Until the end of the encounter, the target cannot voluntarily suffer strain to activate any abilities or gain additional maneuvers, "+dd+dd] * 5 + [
"**Compromised**: Incerase difficulty of all skill checks by one until the end of the encounter, "+dd+dd] * 5 + [
"**At the brink**: The target suffers 1 strain each time he performs an action, "+dd+dd+dd] * 5 + [
"**Crippled**: One of the target's limbs (selected by the GM) is crippled until healed or replaced. Increase difficulty of all checks that require use of that limb by one, "+dd+dd+dd] * 5 + [
"**Maimed**: One of the target's limbs (selected by the GM) is permanently lost. Unless the target has a cybernetic replacement, the target cannot perform actions that would require the use of that limb. All other actions gain "+sd+", "+dd+dd+dd] * 5 + [
"**Minor nick**: The target suffers 1 strain, "+difficulty_die] * 5 + [
"**Slowed down**: The target can only act during the last allied initiative slot this turn, "+difficulty_die] * 5 + [
"**Sudden Jolt**: The target drops whatever is in hand, "+difficulty_die] * 5 + [
"**Distracted**: The target cannot perform a Free maneuver during his next turn, "+difficulty_die] * 5 + [
"**Off-Balance**: The target adds "+setback_die+" to his next skill check, "+difficulty_die] * 5 + [
"**Discouraging Wound**: Flip one light side Destiny point to a dark side Destiny point (reverse if NPC), "+difficulty_die] * 5 + [
"**Stunned**: The target is staggered until the end of his next turn, "+difficulty_die] * 5 + [
"**Stinger**: Increase the difficulty of next check by one, "+difficulty_die] * 5 + [
"**Bowled Over**: The target is knocked prone and suffers 1 strain, "+difficulty_die+difficulty_die] * 5 + [
"**Head Ringer**: The target increases the difficulty of all Intellect and Cunning checks by one until the end of the encounter, "+difficulty_die+difficulty_die] * 5 + [
"**Fearsome Wound**: The target increases the difficulty of all Presence and Willpower checks by one until the end of the encounter, "+difficulty_die+difficulty_die] * 5 + [
"**Agonizing Wound**: The target increases the difficulty of all Brawn and Agility checks by one until the end of the encounter, "+difficulty_die+difficulty_die] * 5 + [
"**Slightly Dazed**: The target is disoriented until the end of the encounter, "+difficulty_die+difficulty_die] * 5 + [
"**Scattered Senses**: The target removes all "+boost_die+" from skill checks until the end of the encounter, "+difficulty_die+difficulty_die] * 5 + [
"**Hamstrung**: The target loses his free maneuver until the end of the encounter, "+difficulty_die+difficulty_die] * 5 + [
"**Overpowered**: The target leaves himself open, and the attacker may immediately attempt another free attack agains him, using the exact same pool as the original, "+difficulty_die+difficulty_die] * 5 + [
"**Winded**: Until the end of the encounter, the target cannot voluntarily suffer strain to activate any abilities or gain additional maneuvers, "+difficulty_die+difficulty_die] * 5 + [
"**Compromised**: Incerase difficulty of all skill checks by one until the end of the encounter, "+difficulty_die+difficulty_die] * 5 + [
"**At the brink**: The target suffers 1 strain each time he performs an action, "+difficulty_die+difficulty_die+difficulty_die] * 5 + [
"**Crippled**: One of the target's limbs (selected by the GM) is crippled until healed or replaced. Increase difficulty of all checks that require use of that limb by one, "+difficulty_die+difficulty_die+difficulty_die] * 5 + [
"**Maimed**: One of the target's limbs (selected by the GM) is permanently lost. Unless the target has a cybernetic replacement, the target cannot perform actions that would require the use of that limb. All other actions gain "+setback_die+", "+difficulty_die+difficulty_die+difficulty_die] * 5 + [
"HI"] * 5 + [
"**Temporarily Lame**: Until this critical injury is healed, the target cannot perform more than one maneuver during his turn, "+dd+dd+dd] * 5 + [
"**Blinded**: The target can no longer see. Upgrade the difficulty of all checks twice. Upgrade the difficulty of perception checks three times, "+dd+dd+dd] * 5 + [
"**Knocked Senseless**: The target is staggered for the remainder of the encounter, "+dd+dd+dd] * 5 + [
"**Temporarily Lame**: Until this critical injury is healed, the target cannot perform more than one maneuver during his turn, "+difficulty_die+difficulty_die+difficulty_die] * 5 + [
"**Blinded**: The target can no longer see. Upgrade the difficulty of all checks twice. Upgrade the difficulty of perception checks three times, "+difficulty_die+difficulty_die+difficulty_die] * 5 + [
"**Knocked Senseless**: The target is staggered for the remainder of the encounter, "+difficulty_die+difficulty_die+difficulty_die] * 5 + [
"GI"] * 5 + [
"**Bleeding Out**: Every round, the target suffers 1 wound and 1 strain at the beginning of his turn. For every five wounds he suffers beyond his wound threshold, he suffers one additional critical injury. (If he suffers this one again, roll again), "+dd+dd+dd+dd] * 10 + [
"**The End is Nigh**: The target will die after the last initiative slot during the next round, "+dd+dd+dd+dd] * 10 + [
"**Bleeding Out**: Every round, the target suffers 1 wound and 1 strain at the beginning of his turn. For every five wounds he suffers beyond his wound threshold, he suffers one additional critical injury. (If he suffers this one again, roll again), "+difficulty_die+difficulty_die+difficulty_die+difficulty_die] * 10 + [
"**The End is Nigh**: The target will die after the last initiative slot during the next round, "+difficulty_die+difficulty_die+difficulty_die+difficulty_die] * 10 + [
"**Dead**: U B Dead :("]
if roll >= len(injuries):
@ -282,56 +282,56 @@ class StarWarsRoll():
if results == "HI":
characteristic = random.choice(["brawn"] * 3 + ["agility"] * 3 + ["intellect", "cunning", "presence"])
results = "**Horrific Injury**: Until this criticil injury is healed, treat the target's "+characteristic+" as if it's one lower, "+dd+dd+dd
results = "**Horrific Injury**: Until this criticil injury is healed, treat the target's "+characteristic+" as if it's one lower, "+difficulty_die+difficulty_die+difficulty_die
if results == "GI":
characteristic = random.choice(["brawn"] * 3 + ["agility"] * 3 + ["intellect", "cunning", "presence"])
results = "**Gruesome Injury**: The target's "+characteristic+" is permanently one lower, "+dd+dd+dd+dd
results = "**Gruesome Injury**: The target's "+characteristic+" is permanently one lower, "+difficulty_die+difficulty_die+difficulty_die+difficulty_die
send_message = "Roll: "+str(roll)+"\nInjury:\n"+results
message_list = send_message.split("\n")
await ctx.send(message_list[0])
if len(message_list) > 1:
for messageItem in message_list[1:]:
await ctx.channel.send(messageItem)
for message_item in message_list[1:]:
await ctx.channel.send(message_item)
# Parses the command into something the other functions understand
async def parseRoll(self, ctx, cmd : str = ""):
async def parse_roll(self, ctx, cmd : str = ""):
user = f"#{ctx.author.id}"
cmd = re.sub(' +',' ',cmd.upper()) + " "
if cmd[0] == " ":
cmd = cmd[1:]
cmd = self.bot.star_wars.character.replaceSpaces(string.capwords(cmd))
commands = cmd.split(" ")
validCommand = False
valid_command = False
if commands[0] == "":
rollParameters = [1,0,3,0,0,0,0]
roll_parameters = [1,0,3,0,0,0,0]
else:
rollParameters = [0,0,0,0,0,0,0]
roll_parameters = [0,0,0,0,0,0,0]
if string.capwords(commands[0]) == "Obligations":
send_message = self.obligationRoll()
send_message = self.obligation_roll()
elif string.capwords(commands[0]) in skill_data:
self.bot.log("Oh look! This guy has skills!")
if self.bot.star_wars.character.userHasChar(user):
self.bot.log("They have a character. That much we know")
skillLevel = self.bot.star_wars.character.char_data(user,"Skills " + string.capwords(commands[0]))
skill_level = self.bot.star_wars.character.char_data(user,"Skills " + string.capwords(commands[0]))
if string.capwords(commands[0]) == "Lightsaber":
self.bot.log("The skill is lightsaber")
charLevel = self.bot.star_wars.character.char_data(user,"Characteristics " + self.bot.star_wars.character.lightsaberChar(user))
char_level = self.bot.star_wars.character.char_data(user,"Characteristics " + self.bot.star_wars.character.lightsaberChar(user))
else:
charLevel = self.bot.star_wars.character.char_data(user,"Characteristics " + skill_data[string.capwords(commands[0])])
char_level = self.bot.star_wars.character.char_data(user,"Characteristics " + skill_data[string.capwords(commands[0])])
abilityDice = abs(charLevel-skillLevel)
proficiencyDice = min(skillLevel,charLevel)
ability_dice = abs(char_level-skill_level)
proficiency_dice = min(skill_level,char_level)
commands = [str(abilityDice)] + [str(proficiencyDice)] + commands[1:]
commands = [str(ability_dice)] + [str(proficiency_dice)] + commands[1:]
self.bot.log("Converted skill to dice")
validCommand = True
valid_command = True
else:
self.bot.log("Okay, no they don't i guess")
send_message = "You don't have a user. You can make one with /starwarscharacter"
@ -343,49 +343,49 @@ class StarWarsRoll():
else:
send_message = "Did you mean \"Piloting - Planetary\" or \"Piloting - Space\""
else:
validCommand = True
valid_command = True
if validCommand:
if valid_command:
self.bot.log("Converting commands to dice")
for x, command in enumerate(commands):
for i, command in enumerate(commands):
if command != "":
command = command.upper()
if command[0] == "A":
rollParameters[0] = int(command.replace("A",""))
roll_parameters[0] = int(command.replace("A",""))
elif command[0] == "P":
rollParameters[1] = int(command.replace("P",""))
roll_parameters[1] = int(command.replace("P",""))
elif command[0] == "D":
rollParameters[2] = int(command.replace("D",""))
roll_parameters[2] = int(command.replace("D",""))
elif command[0] == "C":
rollParameters[3] = int(command.replace("C",""))
roll_parameters[3] = int(command.replace("C",""))
elif command[0] == "B":
rollParameters[4] = int(command.replace("B",""))
roll_parameters[4] = int(command.replace("B",""))
elif command[0] == "S":
rollParameters[5] = int(command.replace("S",""))
roll_parameters[5] = int(command.replace("S",""))
elif command[0] == "F":
rollParameters[6] = int(command.replace("F",""))
roll_parameters[6] = int(command.replace("F",""))
else:
rollParameters[x] = int(command)
roll_parameters[i] = int(command)
self.bot.log("Rolling "+str(rollParameters))
rollResults, diceResults = self.roll(rollParameters[0],rollParameters[1],rollParameters[2],rollParameters[3],rollParameters[4],rollParameters[5],rollParameters[6])
self.bot.log("Rolling "+str(roll_parameters))
roll_results, dice_results = self.roll(roll_parameters[0],roll_parameters[1],roll_parameters[2],roll_parameters[3],roll_parameters[4],roll_parameters[5],roll_parameters[6])
simplified = self.simplify(rollResults)
simplified = self.simplify(roll_results)
name = self.bot.star_wars.character.getChar_name(user)
self.bot.log("Returns results and simplified results")
if simplified == "":
send_message = name + " rolls: " + "\n" + self.diceResultToEmoji(diceResults) + "\nEverything cancels out!"
send_message = name + " rolls: " + "\n" + self.dice_result_to_emoji(dice_results) + "\nEverything cancels out!"
else:
send_message = name + " rolls: " + "\n" + self.diceResultToEmoji(diceResults) + "\n" + self.resultToEmoji(simplified)
send_message = name + " rolls: " + "\n" + self.dice_result_to_emoji(dice_results) + "\n" + self.result_to_emoji(simplified)
message_list = send_message.split("\n")
await ctx.send(message_list[0])
if len(message_list) > 1:
for messageItem in message_list[1:]:
if messageItem == "":
for message_item in message_list[1:]:
if message_item == "":
self.bot.log("Tried to send empty message")
else:
await ctx.channel.send(messageItem)
await ctx.channel.send(message_item)