-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathutils.py
More file actions
134 lines (96 loc) · 3.98 KB
/
Copy pathutils.py
File metadata and controls
134 lines (96 loc) · 3.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
import json
from language_handler import get_translation
from constants import MAX_POSITIVE_MOD, MIN_NEGATIVE_MOD, SUM, SUB, PLAYBOOK_INTERACTIONS, VALUE, LOCKED
def get_modified_num(mod, num):
if mod == SUM: return min(num, MAX_POSITIVE_MOD)
if mod == SUB: return -1 * min(num, MIN_NEGATIVE_MOD)
return num
def get_modified_num_ctx(modifier):
if modifier >= MAX_POSITIVE_MOD: return MAX_POSITIVE_MOD
if modifier <= -1 * MIN_NEGATIVE_MOD: return -1 * MIN_NEGATIVE_MOD
return modifier
def get_cap(num):
if num >= MAX_POSITIVE_MOD:
return MAX_POSITIVE_MOD
if num <= (-1 * MIN_NEGATIVE_MOD):
return (-1 * MIN_NEGATIVE_MOD)
return num
def get_cap_ctx(num):
if num >= MAX_POSITIVE_MOD:
return MAX_POSITIVE_MOD
if num <= -1 * MIN_NEGATIVE_MOD:
return -1 * MIN_NEGATIVE_MOD
return num
def get_moves(language = 'en'):
##Load in the existing moves
input_file = open (f'language_files/{language}.json', encoding='utf-8')
json_array = json.load(input_file)
return json_array
def get_key_and_content_from_message(message):
key = f'{message.channel.id}/{message.author.id}'
return f'adventures/{key}', message.content
def get_key_from_ctx(ctx):
key = f'{ctx.channel_id}/{ctx.author.id}'
return f'adventures/{key}'
def get_channel_from_ctx(ctx):
key = f'{ctx.channel_id}/'
return f'adventures/{key}'
def get_key_and_content_from_ctx(ctx):
key = f'{ctx.channel_id}/{ctx.author.id}'
return f'adventures/{key}'
def get_replicate_key_and_content_from_message(message):
link_channel = get_args_from_content(message.content)
key = f'{link_channel}/{message.author.id}'
return f'adventures/{key}', message.content
def get_folder_from_message(message):
key = f'{message.channel.id}/'
return f'adventures/{key}', message.content
def get_args_from_content(content):
from tssplit import tssplit
#splited = content.split(" ")
splited = tssplit(content, quote='"', delimiter=' ')
if len(splited) == 2:
return splited[1]
return splited[1:]
def format_labels(labels, lang):
response = get_translation(lang, f'{PLAYBOOK_INTERACTIONS}.labels_base')
for label in labels:
name = get_translation(lang, f'labels.{label}').capitalize()
value = labels[label][VALUE]
if labels[label][LOCKED]:
is_locked = get_translation(lang, f'{PLAYBOOK_INTERACTIONS}.locked')
else:
is_locked = ''
response = response + f'{name}: {value} {is_locked}\n'
return response
def format_labels_changed(labels, lang, labelup, labeldown):
response = get_translation(lang, f'{PLAYBOOK_INTERACTIONS}.labels_change')(labelup.capitalize(), labeldown.capitalize())
response = response + get_translation(lang, f'{PLAYBOOK_INTERACTIONS}.labels_base')
for label in labels:
name = get_translation(lang, f'labels.{label}').capitalize()
value = labels[label][VALUE]
if labels[label][LOCKED]:
is_locked = get_translation(lang, f'{PLAYBOOK_INTERACTIONS}.locked')
else:
is_locked = ''
response = response + f'{name}: {value} {is_locked}\n'
return response
def validate_labels(lang, inputed_labels):
result = ''
labels = get_translation(lang, f'inverted_labels')
for label in inputed_labels:
if label not in labels:
result += get_translation(lang, f'{PLAYBOOK_INTERACTIONS}.invalid_label')(label)
return result
def format_flares(lang, flares):
response = get_translation(lang, 'playbooks.nova.yourFlares')
for flare in flares:
if flare:
translated_flare = get_translation(lang, f'playbooks.nova.names.{flare}').capitalize()
response += f'\n• {translated_flare}'
def get_move(move, language = 'en'):
##Load in the existing moves
input_file = open (f'language_files/{language}.json', encoding='utf-8')
json_array = json.load(input_file)
move_data = json_array['moves'][move]
return move_data