I'm currently building a project and which has different classes and I want to add "class" shortcuts for SayCommands and so more.
Instead of adding 10 SayCommands with each shortcut, and splitting the command[0] to "guess" the meant class, I thought theres probably an easier and nicer way to do that.
How can I modify or make a better decorator class?
For Example I can give 3 classes:
Knight = kt
Magician = mn
Acrobat = at
Usually I would do stuff like:
Syntax: Select all
@SayCommand('top10')
@SayCommand('kttop10')
@SayCommand('mntop10')
@SayCommand('attop10')
def command_top10(command, index, team_only):
split_command = command[0].split('top10')
if len(split_command) > 1:
# Used a class as prefix
class = get_class_from_prefix(split_command[0])
else:
# Default / Current Class
class = get_class_from_index(index)
print('Used class:' + class)
So something nicer would be:
Syntax: Select all
@ClassSayCommand('top10')
def command_top10(command, index, team_only, class)
print('Used class:' + class)