added reading character from google sheet and fixed some bugs
surrounding rolling skills from the character sheet
This commit is contained in:
@@ -5,16 +5,14 @@ import re
|
||||
|
||||
|
||||
class CommandHandler:
|
||||
def __init__(self):
|
||||
def __init__(self, skill_dict):
|
||||
self.commands = {
|
||||
'/roll': self.custom_roll,
|
||||
'/r': self.custom_roll,
|
||||
'/whisper': self.whisper,
|
||||
'/w': self.whisper
|
||||
}
|
||||
self.skill_map = {'Tera': {'Akrobatik': 25,
|
||||
'Arkane Kunde': 10}
|
||||
}
|
||||
self.skill_dict = skill_dict
|
||||
|
||||
def handle(self, char, content):
|
||||
message = content.strip('\n')
|
||||
@@ -43,10 +41,7 @@ class CommandHandler:
|
||||
return response.build_dice_roll(char, ' '.join(message), eyes, result)
|
||||
|
||||
def skill_roll(self, char, message):
|
||||
print(char)
|
||||
print(message)
|
||||
print(self.skill_map)
|
||||
if char not in self.skill_map:
|
||||
if char not in self.skill_dict:
|
||||
return response.build_system_message(char, 'Ungültiger Charakter: {}'.format(char))
|
||||
|
||||
pattern = '(?P<skill>[a-zA-ZäöüÄÖÜß .&]+)(?P<maths>(?:\s*(?:\+|\-)\s*\d+)*)(?P<type>[nrs]?)'
|
||||
@@ -55,12 +50,14 @@ class CommandHandler:
|
||||
return response.build_system_message(char,
|
||||
'Unültige Formatierung des Befehls: {}'.format(message))
|
||||
|
||||
skills = self.skill_map[char]
|
||||
if match.group('skill')[1:] not in skills:
|
||||
skills = self.skill_dict[char]
|
||||
skill = match.group('skill')[1:]
|
||||
skill = skill.rstrip(' ')
|
||||
if skill not in skills:
|
||||
return response.build_system_message(char,
|
||||
'{} hat die Fertigkeit {} nicht.'.format(char, match.group('skill')))
|
||||
'{} hat die Fertigkeit {} nicht.'.format(char, skill))
|
||||
|
||||
skill = skills[match.group('skill')[1:]]
|
||||
value = skills[skill]
|
||||
type_ = match.group('type')
|
||||
if len(type_) == 0 or type_ == 'n':
|
||||
type_ = dice.RollTypes.NORMAL
|
||||
@@ -68,10 +65,9 @@ class CommandHandler:
|
||||
type_ = dice.RollTypes.RISKY
|
||||
else:
|
||||
type_ = dice.RollTypes.SAFE
|
||||
eyes, result = dice.skill_roll(skill,
|
||||
eyes, result = dice.skill_roll(value,
|
||||
match.group('maths'),
|
||||
type_)
|
||||
print(eyes, result)
|
||||
return response.build_dice_roll(char, message, eyes, result)
|
||||
|
||||
def whisper(self, char, message):
|
||||
|
||||
Reference in New Issue
Block a user