Skip to content

Instantly share code, notes, and snippets.

@nerun
Last active June 7, 2021 15:20
Show Gist options
  • Save nerun/105cb73661ea991bb289000acd5cbb5f to your computer and use it in GitHub Desktop.
Save nerun/105cb73661ea991bb289000acd5cbb5f to your computer and use it in GitHub Desktop.
Stellar Systems Generator for GURPS Space.
import locale, os, random
## CONFIGURATION ###
try:
lang = locale.getdefaultlocale()[0][:2] # ('pt_BR', 'UTF-8')
except:
lang = "en"
# DECLARAÇÃO DE VARIÁVEIS E FUNÇÕES
########################################################################
def clearScreen():
if os.name == 'posix':
os.system('clear')
elif os.name in ('nt', 'dos', 'ce'):
os.system('cls')
else:
print ('\n' * 100)
def printc(color, text):
# color:
# 1 Red
# 2 Green
# 3 Yellow / Orange
# 4 Blue
# 5 Purple
# 6 Cyan (Light Blue)
# 7 Light Gray
# 8 Black
return '\033[9' + str(color) + 'm' + str(text) + '\033[00m'
def rolarDado(d=1, f=6, m=0):
def Soma(el):
soma = 0
for i in el:
soma += i
return soma
jogadas = []
i = 0
while i < d:
D = random.randint(1, f)
i += 1
jogadas.append(D)
resultado = Soma(jogadas) + m
return resultado
def getStar(x): # x = colunas
jogadas = []
i = 0
while i < x:
NSO = rolarDado(2,6) # 2d6 para "Normal Stelar Objects" (NSO)
if NSO <= 9:
res = "-"
elif NSO == 10:
# averiguando possibilidade de "Unusual Stelar Objects" (USO) rolando 1d6
USO = rolarDado() # Rola 1d6...
if USO == 6: #e se cair 6...
DUSO = rolarDado(3,6) # rola 3d6 na tabela de USO
dicDUSO = { 3:"N", 4:"B", 5:"R", 6:"G", 7:"G", 8:"A", 9:"A", 10:"T",
11:"T", 12:"T", 13:"T", 14:"F", 15:"C", 16:"X", 17:"E", 18:"roll for VUSO" }
res = dicDUSO.get(DUSO)
if res == "roll for VUSO":
VUSO = rolarDado(3,6) # tabela "Very Unusual Stelar Objects" (VUSO)
dicVUSO = { 3:"p", 4:"n", 5:"a", 6:"t", 7:"b", 8:"c", 9:"@", 10:"@",
11:"v", 12:"k", 13:"x", 14:"s", 15:"s", 16:"d", 17:"h", 18:"u" }
res = dicVUSO.get(VUSO)
else:
res = "-"
else: # 11-12
HabPlanet = rolarDado()
if HabPlanet <= 2: # 1-2 em 1d6
res = "O" # Estrela COM planetas
else:
res = "#" # Estrela SEM planetas
i += 1
jogadas.append(res)
return " ".join(map(str, jogadas))
# PROGRAMA
########################################################################
def title(locale="en"):
clearScreen()
print(printc(3,"+" + ("-" * 78) + "+"))
print(printc(3,"| * GURPS Stella * |"))
if locale == "pt":
print(printc(3,"""| Gerador de Sistemas Estelares para GURPS Viagem Espacial |
| versão 2.0 (17 fev. 2021) |"""))
else: # default locale "en"
print(printc(3,"""| Stellar Systems Generator for GURPS Space |
| version 2.0 (Feb. 17, 2021) |"""))
print(printc(3,"+" + ("-" * 78) + "+"))
def header(f, locale):
f.write("+---------------------------------+--------------------------------------------+") # page line number 1
if locale == "pt":
f.write("\n| SETOR | SUBSETOR |")
f.write("\n+---------------------------------+ |")
f.write("\n| CÓDIGO CÓDIGO DO | |")
f.write("\n| DO SETOR SUBSETOR | |")
else: # default locale "en"
f.write("\n| SECTOR | SUBSECTOR |")
f.write("\n+---------------------------------+ |")
f.write("\n| SECTOR SUBSECTOR | |")
f.write("\n| CODE CODE | |")
f.write("\n+---------------------------------+--------------------------------------------+")
f.write("\n\n\n\n\n\n")
def starMap(lines=30, columns=30, locale="en"):
if locale == "pt":
fname = "mapa.txt"
else: # default locale "en"
fname = "map.txt"
file = open(fname, "w")
header(file, locale)
file.write("\n 01 05 10 15 20 25 30")
i = 1
while i <= lines:
if i == 1:
lineNum = "01"
elif i == 5:
lineNum = "05"
else:
if (i % 5) == 0:
lineNum = str(i)
else:
lineNum = " "
file.write("\n %s %s"% (lineNum, getStar(columns)))
i += 1
subtitles(file, locale)
def subtitles(f, locale):
f.write("\n\n\n\n\n\n")
if locale == "pt":
f.write("\nLEGENDA")
f.write("\n")
f.write("\nO - Estrela COM planeta n - Nebulosa planetária")
f.write("\n# - Estrela SEM planeta a - Sistema de antimatéria")
f.write("\nN - Estrela de Neutrons t - Centro de nebulosa com estrelas T Tauri")
f.write("\nB - Anã Negra SEM planetas b - Anã Negra COM planetas")
f.write("\nR - Estrela de Raio-X c - Centro de uma grande nebulosa")
f.write("\nG - Anã Cinza @ - Buraco Negro com massa estelar média")
f.write("\nA - Planeta perdido gasoso v - Nova")
f.write("\nT - Planeta perdido terreste k - Buraco Negro com 10x a massa estelar média")
f.write("\nF - Estrela fulgurante x - Erupção de Raio-X")
f.write("\nC - SS Cygni s - Portal Estelar natural")
f.write("\nX - Centro de Escudo Nova d - Esfera Dysoniana")
f.write("\nE - Centro de pequena nebulosa h - Nebulosa muito grande")
f.write("\np - Pulsar u - Estrela de Neutrons com Escudo de Supernova")
else: # default locale "en"
f.write("\nSUBTITLE")
f.write("\n")
f.write("\nO - Star with planets n - Planetary nebula")
f.write("\n# - Star, no planets a - Antimatter system")
f.write("\nN - Neutron star t - Center of nebula with T Tauri protostars")
f.write("\nB - Black dwarf, no planets b - Black dwarf with planets")
f.write("\nR - X-Ray star c - Center of large nebula")
f.write("\nG - Gray dwarf @ - Black hole with average stellar mass")
f.write("\nA - Gas giant lost planet v - Nova")
f.write("\nT - Terrestrial lost planet k - Black hole with 10x average stellar mass")
f.write("\nF - Flare star x - X-Ray burster")
f.write("\nC - SS Cygni s - Natural stargate to somewhere")
f.write("\nX - Center of nova shell d - Star enclosed by Dyson sphere")
f.write("\nE - Center of small nebula h - Center of huge nebula")
f.write("\np - Pulsar u - Neutron star surrounded by supernova shell")
def start(locale):
title(locale)
if locale == "pt":
print("""
AVISO LEGAL:
GURPS e GURPS Viagem Espacial são marcas registradas da STEVE JACKSON GAMES,
e os direitos autorais sobre suas regras e arte pertencem à STEVE JACKSON
GAMES. Todos os direitos reservados à STEVE JACKSON GAMES. Este acessório de
jogo é uma criação original de DANIEL DIAS RODRIGUES e é liberado para
distribuição gratuita, e não para revenda, debaixo das permissões garantidas
pela Política Online da STEVE JACKSON GAMES:""" + printc(4,"""
<https://www.sjgames.com/general/online_policy.html>"""))
input("\n Pressione qualquer tecla para prosseguir...")
else: # default locale "en"
print("""
LEGAL NOTICE:
GURPS and GURPS Space are trademarks of STEVE JACKSON GAMES, and its rules
and art are copyrighted by STEVE JACKSON GAMES. All rights are reserved by
STEVE JACKSON GAMES. This game aid is the original creation of DANIEL DIAS
RODRIGUES and is released for free distribution, and not for resale, under
the permissions granted in the STEVE JACKSON GAMES Online Policy:""" + printc(4,"""
<https://www.sjgames.com/general/online_policy.html>"""))
input("\n Press any key to proceed...")
title(locale)
if locale == "pt":
print("""
Este programa gravará em arquivo texto (mapa.txt) um mapa estelar que pode ser
usado nas suas campanhas de GURPS Viagem Espacial. O mapa pode ser encontrado
na mesma pasta na qual você executou o programa. Cada vez que você executar o
GerSis, ele apagará o conteúdo daquele arquivo, sobrescrevendo-o com um novo
mapa.
Você pode imprimir o mapa numa folha A4: deixe a exibição em modo "retrato" e
as margens em 2,0 cm.
O mapa gerado cobre uma área bidimensional (eixos x e y) de 30 x 30 parsecs e
obedece fielmente as tabelas de geração de sistemas estelares do GURPS Viagem
Espacial. Caso precise da terceira dimensão (eixo z), imprima mais mapas e
decida arbitrariamente se eles estão acima (+) ou abaixo (-) do marco 0 do
eixo 'z'.""")
input("\n Pressione qualquer tecla para gerar um mapa...\n")
else: # default locale "en"
print("""
This software will create a stellar map in a text file (map.txt) that can be
used in yours GURPS Space campaigns. Map can be found in the same folder where
you have executed this software. Each time you run GURPS Stella, it will erase
the content of any previous map.txt, overwriting it with a new generated map.
You can print map in paper A4 or Legal: let it "portrait" and margins no
superior than 0.79in or 2.0cm. For US Letter you will need to cut off some
blank lines. A4 and Legal size papers will fit very well.
Map generated cover a bidimensional area (axis x and y) of 30 x 30 parsecs and
follow GURPS Space tables for stellar systems generation. If you need a third
dimension (axis z), print +29 maps, and choose which will be above (+) or
bellow (-) plan zero of axis 'z'.""")
input("\n Press any key to generate a map right now...\n")
starMap(locale=locale)
start(lang)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment