Bladeren bron

Add Ship and Campaign classes

master
Noëlle 4 jaren geleden
bovenliggende
commit
63b25b9f1a
1 gewijzigde bestanden met toevoegingen van 55 en 21 verwijderingen
  1. 55
    21
      koboldgen.py

+ 55
- 21
koboldgen.py Bestand weergeven

@@ -93,42 +93,76 @@ class Character:
def gen_career(self):
self.career = gen_career()

def print(self):
def print_name(self):
print(f"Name: {self.name} (Kobold {self.career})")

def print(self):
self.print_name()
print(f"Order: {self.stats[0]}")
print(f"Chaos: {self.stats[1]}")
print(f"Brain: {self.stats[2]}")
print(f"Body: {self.stats[3]}")

class Ship:
def __init__(self):
self.name1 = r.choice(["Red","Orange","Yellow","Green","Blue","Violet","Dark","Light","Frenzied","Maniacal","Ancient"])
self.name2 = r.choice(["Moon","Comet","Star","Saber","World-Eater","Dancer","Looter","Phlogiston","Fireball","Mecha","Raptor"])
self.gqual = r.choice(["is stealthy & unarmored","is speedy & unarmored","is maneuverable & unarmored","is always repairable","is self-repairing","is flamboyant & speedy","is slow & armored","is flamboyant & armored","is hard to maneuver & armored","has Too Many Weapons!","has a prototype hyperdrive"])
self.bqual = r.choice(["has an annoying AI","has inconveniently crossed circuits","has an unpredictable power source","drifts to the right","is haunted","was recently 'found' so the kobolds are unused to it","is too cold","has a constant odd smell","its interior design... changes","its water pressure shifts between slow drip and power wash","it leaves a visible smoke trail"])
self.fullname = f"{self.name1} {self.name2}"

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

class Campaign:
def __init__(self, n=None):
n = 6 if n == None else n
self.ship = Ship()
self.params = 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 print_params(self):
print(f"The Kobolds of the {self.ship.fullname}")
print(f"have been sent out to {self.art} {self.params[0]} {self.params[1]}")
print(f"in order {self.params[2]}")
print(f"but they're challenged by {self.params[3]}!")
print()
self.ship.print()

def print_chars(self):
print("The kobolds:")
for k in self.characters:
k.print()

if __name__ == "__main__":
parser = argparse.ArgumentParser()
group = parser.add_mutually_exclusive_group()
group.add_argument("-n", "--num", help="print this many kobolds", type=int, default=1)
group.add_argument("-k", "--kobolds", help="print this many kobolds", type=int, default=1)
group.add_argument("-n", "--names", help="print this many kobolds without stat blocks", type=int)
group.add_argument("-s", "--ship", help="print only the ship name and description", action="store_true")
group.add_argument("-c", "--campaign", help="print a full campaign block with 6 kobolds", action="store_true")
group.add_argument("-p", "--params", help="print only the parameters of a campaign", action="store_true")
args = parser.parse_args()
if args.campaign:
cs = []
for _ in range(6):
cmp = Campaign()
cmp.print_params()
cmp.print_chars()
elif args.params:
cmp = Campaign()
cmp.print_params()
elif args.ship:
ship = Ship()
ship.print()
elif args.names:
for _ in range(args.names):
c = Character()
c.generate()
cs.append(c)
parameters = gen_plot()
ship = gen_transpo()
art = "an" if parameters[1] == "Asteroid" else "a"
print(f"The Kobolds of the {ship[0]} {ship[1]}")
print(f"have been sent out to {art} {parameters[0]} {parameters[1]}")
print(f"in order {parameters[2]}")
print(f"but they're challenged by {parameters[3]}!")
print()
print(f"The {ship[0]} {ship[1]} {ship[2]}, but {ship[3]}.")
print()
print("The kobolds:")
for k in cs:
k.print()
elif args.ship:
ship = gen_transpo()
print(f"The {ship[0]} {ship[1]} {ship[2]}, but {ship[3]}.")
c.print_name()
else:
for _ in range(args.num):
c = Character()

Laden…
Annuleren
Opslaan