-
Notifications
You must be signed in to change notification settings - Fork 5
/
main.py
189 lines (168 loc) · 6 KB
/
main.py
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
import os
from config import *
from patterns import *
from algorithm import *
from image import *
def main():
print("-"*50)
print('hello world, to '+'\033[92m'+'NFT'+'\033[0m'+' generator')
print('this is developed by '+'\033[93m'+'@Oicaji'+'\033[0m')
print('\n')
print('This instance is using '+'\033[92m'+sufix_project+'\033[0m'+' project, to create collection of '+'\033[92m'+sufix_collection+'\033[0m'+' images')
print("-"*50)
menu()
def menu():
print("-"*50)
#print azul
print('\033[94m'+'TESTING MENU 0.2'+'\033[0m')
print('options: [0] exit, [1] create, [2] manual, [3] example [4] warnings')
option = input('respost: ')
print("-"*50)
clear()
if option == '0':
exit()
elif option == '1':
menuMachine()
elif option == '2':
manualInputs()
elif option == '3':
createExample()
elif option == '4':
if(sufix_collection == 'AnimeFacesWeirdo'):
print('\n'+'\033[91m'+'You ate my creator?'+'\033[0m')
option = input('[y/n] respost: ')
print('\n'+'\033[92m'+'Wharever, enjoy!\033[0m')
print('\n'+'\033[92m'+'You are the best!\033[0m')
else:
print('invalid respost')
menu()
def algorithm():
print("-"*50)
print('Really want to execute algorithm?')
print('now that the thing is serious... \n')
algorithmMenu()
def algorithmMenu():
print('options: [0] back, [1] '+sufix_project+' Behaviors, [2] others')
option = input('respost: ')
if option == '0':
menu()
elif option == '1':
menuMachine()
elif option == '2':
result = getMaxCombinations()
print('\n'+'\033[92m'+'All possibles combinations is '+str(result)+' images\033[0m')
print('you will continue with this...\n')
algorithm()
def getFiles(path):
files = []
path = 'resource/'+path
for file in os.listdir(path):
if os.path.isfile(os.path.join(path, file)):
files.append(file)
return files
def patterns_available(name):
print('\npatterns available:')
list_files = getFiles(name)
for i in list_files:
print('> '+i[:-4])
print('\n')
def thisArchiveExists(name,pattern_name):
if ( os.path.exists("resource/"+pattern_name+"/"+name) ):
return True
return False
def printAlredyAdded(pattern_added):
print('patterns already added:')
for i in pattern_added:
print('\n -'+i['name'])
def manualMenu(part, pattern_added):
print('What image add into \033[1m'+part['name']+'\033[0m position?')
print('options: [.] view patterns available, [..] view patterns already added')
option = input('file without extension: ')
if option == '.':
patterns_available(part['name'])
manualMenu(part, pattern_added)
elif option == '..':
if(pattern_added.__len__() != 0):
printAlredyAdded(pattern_added)
manualMenu(part, pattern_added)
else:
print('\n\033[91mno patterns added yet\033[0m\n')
menu()
else:
option = option + '.png'
if thisArchiveExists(option,part['name']):
pattern_added.append({'file': option, 'directory': part['name']})
if 'linked' in part:
black_list.append({'file': option, 'directory': part['parent'], 'font': part['name']})
print('\n'+'\033[92m'+'pattern added'+'\033[0m\n')
return
else:
print('\n'+'\033[91m'+'pattern not found'+'\033[0m\n')
manualMenu(part, pattern_added)
def drawRarity(part):
if 'rarity' in part:
print('You can add pattern to '+'\033[1m'+part['name']+'\033[0m'+' in you image?')
print('options: [y] add pattern, [any] no add pattern')
option = input('respost: ')
print('\n')
if option == 'y':
return True
else:
return False
else:
return True
def isLinked(part):
if 'linked' in part:
if part['linked'] == 'instead':
print('The '+'\033[1m'+part['name']+'\033[0m'+' is linked with \033[1m'+part['parent']+'\033[0m'+' you can this?')
print('options: [y] continue to linked in \033[1m'+part['parent']+'\033[0m, [any] skip')
option = input('respost: ')
if option != 'y':
#remove end of list
black_list.pop()
print('\n')
def blackListExist(name):
for i in black_list:
if i['directory'] == name:
return True
return False
def thisFileReallyExist(part, pattern_added):
suppress_name = ''
file_name = ''
idx = -1
for i in black_list:
if i['directory'] == part['name']:
suppress_name = i['font']
file_name = i['file']
idx = black_list.index(i)
print(black_list)
name_split = file_name.split(suppress_name)
name = part['name']+name_split[1]
file_objetive = part['name']+'/'+name
if( not os.path.exists("resource/"+file_objetive) ):
print('\033[91m'+'Error parent is not found')
print('Please, confirm the folder and logic in patterns.py'+'\033[0m\n')
#remove art['name'] from black_list
black_list.pop(idx)
else:
pattern_added.append({'file': name, 'directory': part['name']})
print('\n'+'\033[92m'+'pattern added'+'\033[0m\n')
decided = True
black_list = []
def manualInputs():
pattern_added = []
for part in patterns:
if drawRarity(part):
if black_list.__len__() != 0:
if(blackListExist(part['name'])):
thisFileReallyExist(part, pattern_added)
else:
manualMenu(part, pattern_added)
isLinked(part)
else:
manualMenu(part, pattern_added)
isLinked(part)
createImage(pattern_added)
if __name__ == "__main__":
clear()
main()