Last active
September 28, 2020 00:34
-
-
Save otaviocorrea/c4ce58474a722d688de7826d2113f21a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// no41 (Campo de Armia) | |
// ******************************************** | |
# [ 122] | |
MinuteGenerate: 1 | |
MaxNumMob: 1 | |
MinGroup: 0 | |
MaxGroup: 0 | |
Leader: Gremlin | |
Follower: Gremlin | |
RouteType: 2 | |
Formation: 0 | |
StartX: 2184 | |
StartY: 2129 | |
StartRange: 6 | |
StartWait: 9 | |
Segment1X: 2184 | |
Segment1Y: 2129 | |
Segment1Range: 6 | |
Segment1Wait: 4 | |
Segment2X: 2184 | |
Segment2Y: 2129 | |
Segment2Range: 6 | |
Segment2Wait: 8 | |
DestX: 2184 | |
DestY: 2129 | |
DestRange: 6 | |
DestWait: 6 | |
// no42 (Campo de Armia) | |
// ******************************************** | |
# [ 123] | |
MinuteGenerate: 1 | |
MaxNumMob: 1 | |
MinGroup: 0 | |
MaxGroup: 0 | |
Leader: Gremlin | |
Follower: Gremlin | |
RouteType: 2 | |
Formation: 0 | |
StartX: 2184 | |
StartY: 2118 | |
StartRange: 6 | |
StartWait: 9 | |
Segment1X: 2184 | |
Segment1Y: 2118 | |
Segment1Range: 6 | |
Segment1Wait: 4 | |
Segment2X: 2184 | |
Segment2Y: 2118 | |
Segment2Range: 6 | |
Segment2Wait: 8 | |
DestX: 2184 | |
DestY: 2118 | |
DestRange: 6 | |
DestWait: 6 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
while True: | |
encode = "ISO-8859-1" | |
if (input("Deseja receber instruções? [Y/N]").upper() == "Y"): | |
print("╔════════════════════════════════════════════════════════════════════════════════════════════════╗") | |
print("║ ARQUIVO ║") | |
print("╠════════════════════════════════════════════════════════════════════════════════════════════════╣") | |
print("║ Caso não seja passado o nome do arquivo o sistema ira buscar por padrão o arquivo NPCGener.txt ║") | |
print("║ na mesma pasta onde se encontra este executavel, se o arquivo estiver em outra pasta deve-se ║") | |
print("║ passar o caminho completo + nome do arquivo EX: C:/Temp/File.txt ║") | |
print("╠════════════════════════════════════════════════════════════════════════════════════════════════╣") | |
print("║ NUMERO INICIAL ║") | |
print("╠════════════════════════════════════════════════════════════════════════════════════════════════╣") | |
print("║ Se passar um numero, alterara a todos os IDs na lista passada iniciando pelo numero informado ║") | |
print("║ se deixar em branco, mantem os IDs originais. ║") | |
print("╠════════════════════════════════════════════════════════════════════════════════════════════════╣") | |
print("║ NOVO NOME ║") | |
print("╠════════════════════════════════════════════════════════════════════════════════════════════════╣") | |
print("║ Se passar um Nome, alterara a todos os Nomes de Leader e Follower na lista passada para o ║") | |
print("║ nome definido ║") | |
print("╚════════════════════════════════════════════════════════════════════════════════════════════════╝") | |
print("\n") | |
print("╔════════════════════════════════════════════════════════════════════════════════════════════════╗") | |
print("║ OPÇÕES AVANÇADAS ║") | |
print("╚════════════════════════════════════════════════════════════════════════════════════════════════╝") | |
print("Observação: Nenhum parametro de opões avançadas é opcional, caso queira utiliza-las, todas as\nopções devem ser preenchidas") | |
print("\n") | |
print("╔════════════════════════════════════════════════════════════════════════════════════════════════╗") | |
print("║ ENCODE ║") | |
print("╠════════════════════════════════════════════════════════════════════════════════════════════════╣") | |
print("║ Permite definir o encode que a ser utilizado para ler e gravar o arquivo, por default o valor ║") | |
print("║ é ISO-8859-1 ║") | |
print("╚════════════════════════════════════════════════════════════════════════════════════════════════╝") | |
print("\n") | |
print("╔════════════════════════════════════════════════════════════════════════════════════════════════╗") | |
print("║ INFORMAÇÔES UTEIS ║") | |
print("╚════════════════════════════════════════════════════════════════════════════════════════════════╝") | |
print("\n") | |
print("╔════════════════════════════════════════════════════════════════════════════════════════════════╗") | |
print("║ ARQUIVO DE SAÍDA ║") | |
print("╠════════════════════════════════════════════════════════════════════════════════════════════════╣") | |
print("║ O arquivo gerado após o processamento é salvo na mesama pasta que o arquivo original, porém a ║") | |
print("║ diferencça básica entre os dois é de que o arquivo gerado irá conter '_NEW' no seu nome ║") | |
print("╠════════════════════════════════════════════════════════════════════════════════════════════════╣") | |
print("║ CODIGO FONTE ║") | |
print("╠════════════════════════════════════════════════════════════════════════════════════════════════╣") | |
print("║ Código fonte disponível em: ║") | |
print("║ https://gist.github.com/otaviocorrea/c4ce58474a722d688de7826d2113f21a ║") | |
print("╚════════════════════════════════════════════════════════════════════════════════════════════════╝") | |
file = input("Arquivo: ") | |
initialNumber = input("Numero Inicial: ") | |
newName = input("Novo nome: ") | |
if input("Opções avançadas: [Y/N]").upper() == "Y": | |
encode = input("Encode: ") | |
# VALIDATIONS | |
file = "NPCGener.txt" if not file else file | |
initialNumber = False if not initialNumber else int(initialNumber) | |
newName = False if not newName else newName | |
# AUX | |
i = initialNumber | |
actualizedDocument = "" | |
print("╔═════════════════════════════════════════════════════════════════════╗") | |
print("║ ║") | |
print("║ SPONSORED BY TAVINHOZK1 MASTER OF CODE ║") | |
print("║ github.com/otaviocorrea ║") | |
print("╚═════════════════════════════════════════════════════════════════════╝\n\n") | |
print("░░░░░░░░░░░░░░░░░░░░░░░░░░INICIANDO ALTERAÇÕES░░░░░░░░░░░░░░░░░░░░░░░░░ \n\n") | |
print("CFG::\nArquivo: {0} \nNumero Inicial: {1} \nNovo nome para NPC: {2} \nEncode: {3}\n".format(file, initialNumber, newName, encode)) | |
#Percorre cada linha do arquivo | |
for line in open(file, "rt", encoding=encode): | |
#Verifica se é a linha do ID | |
if (line.find('#') == 0) & (initialNumber != False): | |
id = str(i) | |
idLen = len(id) | |
#Formata o numero para adicionar espaços em branco caso seja menor do que 4 caracteres | |
if idLen < 4: | |
spaces = " " * (4 - idLen) | |
id = spaces + id | |
# Monta nova linha | |
actualizedLine = "# ["+str(id)+"]\n" | |
# Substitui a linha atual pela nova linha | |
line = actualizedLine | |
i+=1 | |
elif (line.find('Leader') == 1) & (newName != False) : | |
# Monta nova linha | |
actualizedLine = " Leader: "+ newName +"\n" | |
# Substitui a linha atual pela nova linha | |
line = actualizedLine | |
elif (line.find('Follower') == 1) & (newName != False) : | |
# Monta nova linha | |
actualizedLine = " Follower: "+ newName +"\n" | |
# Substitui a linha atual pela nova linha | |
line = actualizedLine | |
#Monta variavel para armazenar o novo documento formatado | |
actualizedDocument += line | |
open(file.replace(".txt", "_NEW.txt"), "+w", encoding=encode).write(actualizedDocument) | |
print("\n░░░░░░░░░░░░░░░░░░░░░░░░░ALTERAÇÕES FINALIZADAS░░░░░░░░░░░░░░░░░░░░░░░░ \n") | |
if (input("\n\nDESEJA EXECUTAR NOVAMENTE? [Y/N]").upper() != "Y"): | |
break | |
os.system('cls') or None |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment