Преглед на файлове

Move Plot into its own class, do some reworking

master
Noëlle преди 4 години
родител
ревизия
bdc11c9ef8
променени са 1 файла, в които са добавени 73 реда и са изтрити 82 реда
  1. 73
    82
      koboldgen.py

+ 73
- 82
koboldgen.py Целия файл

@@ -4,11 +4,13 @@ import argparse
beg = ["a","e","i","o","u","ba","be","bi","bo","bu","by","y","da","de","di","do","du","dy","fa","fi","fo","fe","fu","ga","ge","gi","go","gu","ka","ke","ki","ko","ku","ky","ma","me","mi","mo","mu","na","ne","ni","no","nu","pa","pe","pi","po","pu","ra","re","ri","ro","ru","ry","sa","se","si","so","su","ta","te","ti","to","tu","ty","wa","we","wi","wo","wy","za","ze","zi","zo","zu","zy"]
mid = beg + ["l","x","n","r"]

def gen_name(n=None):
if n == None:
lgt = r.randint(3,9)
def gen_name(length=None, minimum=None, maximum=None):
if length == None:
minimum = 3 if minimum == None else minimum
maximum = 9 if maximum == None else maximum
lgt = r.randint(maximum,maximum)
else:
lgt = n
lgt = length
morae = []
while len("".join(morae)) < lgt:
if len(morae) == 0:
@@ -21,6 +23,47 @@ def gen_name(n=None):
morae.append(mora)
return "".join(morae)

class Plot:
loc1 = ["a friendly","a hostile","a derelict","an airless","a poison-filled/covered","an overgrown","a looted","a burning","a frozen","a haunted","an infested"]
loc2 = ["asteroid","moon","space station","spaceship","ringworld","Dyson sphere","planet","Space Whale","pocket of folded space","time vortex","Reroll"]
miss = ["to explore!","to loot everything not bolted down too securely","to find the last group of kobolds who came here","to find a rumored secret weapon","to find a way to break someone else’s secret weapon","to claim this place in the name of the Kobold Empire!","to make friends!","to rediscover lost technology","to find lost magical items","to find and defeat a powerful enemy"]
prob = ["an Undead Sample Pack (swarm of zombies and skeletons)","a rival band of kobolds","a detachment from the Elf Armada","refugees with parasites. Big parasites","an artificial intelligence bent on multi-world domination","robot spiders","semi-intelligent metal eating slime","a living asteroid that intends to follow the kobolds home like the largest puppy","an old lich that wants everyone to stay off of their “lawn”","elder gods hailing from the dark spaces between the stars","a Flying Brain Monster"]
pstats = [[0,5,2,6],[3,3,4,4],[4,3,5,4],[2,4,0,0],[4,1,6,3],[3,3,2,4],[0,2,1,5],[2,3,1,6],[5,2,6,3],[6,6,6,6],[2,3,6,1]]
def __init__(self):
self.loc_desc = Plot.loc1[r.randint(0, len(Plot.loc1)-1)]
self.location = Plot.loc2[r.randint(0, len(Plot.loc2)-1)]
self.missIndex = r.randint(0, len(Plot.miss)-1)
self.oops = r.randint(1,12)
self.mission = ""
if self.oops == 12:
self.mission += "...well, they weren't paying attention, so don't tell them, but they're supposed "
self.mission += Plot.miss[r.randint(0, len(Plot.miss)-1)]
self.probIndex = r.randint(0, len(Plot.prob)-1)
self.problem = Plot.prob[self.probIndex]
self.problemStats = Plot.pstats[self.probIndex]
self.secProblem = None
self.secProbStats = None
self.thirdProblem = None
self.thirdProbStats = None
if self.probIndex in [1,2]:
self.problem += " led by " + gen_name()
if self.probIndex in [4,7,8,10]:
self.problem += " named " + gen_name(minimum=5, maximum=12)
if self.probIndex == 3:
self.secProblem = "Parasites"
self.secProbStats = [3,4,2,3]
elif self.probIndex == len(Plot.prob) - 1:
self.secProbIndex = r.randint(0, len(Plot.prob)-2)
self.secProblem = Plot.prob[self.secProbIndex]
self.secProbStats = Plot.pstats[self.secProbIndex]
if self.secProbIndex == 3:
self.thirdProblem = "Parasites"
self.thirdProbStats = [3,4,2,3]
self.fullProblem = self.problem
if self.secProblem and self.secProblem != "Parasites":
self.fullProblem += ", and its minion, " + self.secProblem


class Character:
def __init__(self):
@@ -37,7 +80,7 @@ class Character:
self.name = gen_name()

def gen_stats(self, n=12):
if n < 4:
if n < 0:
print("Too few stat points!")
return [0,0,0,0]
stats = [0,0,0,0]
@@ -48,23 +91,11 @@ class Character:
while tgl == False:
slt = r.choice(slots)
if slt <= 1:
if stats[slt] == 6:
continue
if stats[slt] == 5:
if r.randint(0,1) != 1:
continue
if stats[slt] == 6: continue
if stats[slt] == 5 and r.randint(0,1) != 1: continue
else:
if stats[slt] == 6:
continue
if stats[slt] == 5:
if r.randint(0,3) != 1:
continue
if stats[slt] == 4:
if r.randint(0,2) != 1:
continue
if stats[slt] == 3:
if r.randint(0,1) != 1:
continue
if stats[slt] == 6: continue
if stats[slt] > 2 and r.randint(0,stats[slt]-2) != 1: continue
stats[slt] += 1
tgl = True
stats[3] = stats[3] + 2
@@ -98,78 +129,38 @@ class Ship:

def print(self):
print(f"The {self.fullname} {self.gqual}, but {self.bqual}.")
print()

class Campaign:
def __init__(self, n=None):
def __init__(self, n=None, makeChars=True):
n = 6 if n == None else n
self.ship = Ship()
self.gen_plot()
self.characters = []
for _ in range(n):
c = Character()
c.generate()
self.characters.append(c)
self.art = "an" if self.params[1][0] in ["A","E","I","O","U"] else "a"

def gen_plot(self):
loc1 = ["a friendly","a hostile","a derelict","an airless","a poison-filled/covered","an overgrown","a looted","a burning","a frozen","a haunted","an infested"]
loc2 = ["asteroid","moon","space station","spaceship","ringworld","Dyson sphere","planet","Space Whale","pocket of folded space","time vortex","Reroll"]
miss = ["to explore!","to loot everything not bolted down too securely","to find the last group of kobolds who came here","to find a rumored secret weapon","to find a way to break someone else’s secret weapon","to claim this place in the name of the Kobold Empire!","to make friends!","to rediscover lost technology","to find lost magical items","to find and defeat a powerful enemy","Reroll"]
prob = ["an Undead Sample Pack (swarm of zombies and skeletons)","a rival band of kobolds","a detachment from the Elf Armada","refugees with parasites. Big parasites","an artificial intelligence bent on multi-world domination","robot spiders","semi-intelligent metal eating slime","a living asteroid that intends to follow the kobolds home like the largest puppy","an old lich that wants everyone to stay off of their “lawn”","elder gods hailing from the dark spaces between the stars","Reroll"]
pstats = {
"an Undead Sample Pack (swarm of zombies and skeletons)": [0,5,2,6],
"a rival band of kobolds": [3,3,4,4],
"a detachment from the Elf Armada": [4,3,5,4],
"refugees with parasites. Big parasites": [2,4,0,0],
"an artificial intelligence bent on multi-world domination": [4,1,6,3],
"robot spiders": [3,3,2,4],
"semi-intelligent metal eating slime": [0,2,1,5],
"a living asteroid that intends to follow the kobolds home like the largest puppy": [2,3,1,6],
"an old lich that wants everyone to stay off of their “lawn”": [5,2,6,3],
"elder gods hailing from the dark spaces between the stars": [6,6,6,6],
"Reroll": [2,3,6,1]
}
cl1 = r.choice(loc1)
cl2 = r.choice(loc2)
cm = r.choice(miss)
cp = r.choice(prob)
cs1 = pstats[cp]
cs2 = None
cs3 = None
if cp == "refugees with parasites. Big parasites":
cs2 = [3,4,2,3]
if cl2 == "Reroll":
cl2p = r.choice(loc2[:-1])
if cl2p == "Asteroid":
cl2 = "battlefield on an asteroid"
else:
cl2 = "battlefield on a " + cl2p
if cm == "Reroll":
cm = "to ...well, the kobolds weren't paying attention, so don't tell them, but they're supposed to " + r.choice(miss[:-1])
if cp == "Reroll":
newprob = r.choice(prob[:-1])
if newprob == "refugees with parasites. Big parasites":
cs3 = [3,4,2,3]
cs2 = pstats[newprob]
cp = "a Floating Brain Monster and its minion, " + newprob
self.params = [cl1, cl2, cm, cp, cs1, cs2, cs3]
self.params = Plot()
if makeChars:
self.characters = []
for _ in range(n):
c = Character()
c.generate()
self.characters.append(c)
self.art = "an" if self.params.loc_desc in ["A","E","I","O","U"] else "a"


def print_params(self, endc=""):
st = ["Order:", "Chaos:", "Brains:", "Body:"]
print(f"The Kobolds of the {self.ship.fullname} ", end=endc)
print(f"have been sent out to {self.art} {self.params[0]} {self.params[1]} ", end=endc)
print(f"in order {self.params[2]} ", end=endc)
print(f"-- but they're challenged by {self.params[3]}!")
cst = ", ".join([" ".join(y) for y in list(zip(st, [str(x) for x in self.params[4]]))])
print(f"have been sent out to {self.art} {self.params.loc_desc} {self.params.location} ", end=endc)
print(f"in order {self.params.mission} ", end=endc)
print(f"-- but they're challenged by {self.params.fullProblem}!")
cst = ", ".join([" ".join(y) for y in list(zip(st, [str(x) for x in self.params.problemStats]))])
print(f"The challenger's stats: {cst}")
if self.params[5] != None:
mst = ", ".join([" ".join(y) for y in list(zip(st, [str(x) for x in self.params[5]]))])
if self.params[3][0] == "r":
if self.params.secProblem != None:
mst = ", ".join([" ".join(y) for y in list(zip(st, [str(x) for x in self.params.secProbStats]))])
if self.params.secProblem == "Parasites":
print(f"- The parasites' stats: {mst}")
else:
print(f"- Its minion's stats: {mst}")
if self.params[6] != None:
pst = ", ".join([" ".join(y) for y in list(zip(st, [str(x) for x in self.params[6]]))])
if self.params.thirdProblem != None:
pst = ", ".join([" ".join(y) for y in list(zip(st, [str(x) for x in self.params.thirdProbStats]))])
print(f"- - The parasites' stats: {pst}")
print()
self.ship.print()
@@ -194,7 +185,7 @@ if __name__ == "__main__":
cmp.print_params()
cmp.print_chars()
elif args.params:
cmp = Campaign()
cmp = Campaign(makeChars=False)
cmp.print_params()
elif args.ship:
ship = Ship()

Loading…
Отказ
Запис