| @@ -1,6 +1,7 @@ | |||
| import random as r | |||
| import argparse | |||
| import sys | |||
| import adversaries | |||
| 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"] | |||
| @@ -42,74 +43,75 @@ class Plot: | |||
| loc1 = ["friendly","hostile","derelict","airless","poison-filled/covered","overgrown","looted","burning","frozen","haunted","infested"] | |||
| loc2 = ["asteroid","moon","space station","spaceship","ringworld","Dyson sphere","planet","Space Whale","pocket of folded space","time vortex","Reroll"] | |||
| miss = ["explore","loot everything not bolted down too securely","find the last group of kobolds who came here","find a rumored secret weapon","find a way to break someone else's secret weapon","claim this place in the name of the Kobold Empire","make friends","rediscover lost technology","find lost magical items","find and defeat a powerful enemy"] | |||
| prob = [ | |||
| { | |||
| "id": 0, | |||
| "name": "an Undead Sample Pack (swarm of zombies and skeletons)", | |||
| "shortname": "undead", | |||
| "stats": [0,5,2,6], | |||
| }, | |||
| { | |||
| "id": 1, | |||
| "name": "a rival band of kobolds", | |||
| "shortname": "kobold rivals", | |||
| "stats": [3,3,4,4], | |||
| }, | |||
| { | |||
| "id": 2, | |||
| "name": "a detachment from the Elf Armada", | |||
| "shortname": "elves", | |||
| "stats": [4,3,5,4], | |||
| }, | |||
| { | |||
| "id": 3, | |||
| "name": "refugees with parasites. Big parasites", | |||
| "shortname": "refugees", | |||
| "stats": [2,4,0,0], | |||
| }, | |||
| { | |||
| "id": 4, | |||
| "name": "an artificial intelligence bent on multi-world domination", | |||
| "shortname": "AI", | |||
| "stats": [4,1,6,3], | |||
| }, | |||
| { | |||
| "id": 5, | |||
| "name": "robot spiders", | |||
| "shortname": "spiders", | |||
| "stats": [3,3,2,4], | |||
| }, | |||
| { | |||
| "id": 6, | |||
| "name": "semi-intelligent metal eating slime", | |||
| "shortname": "slime", | |||
| "stats": [0,2,1,5], | |||
| }, | |||
| { | |||
| "id": 7, | |||
| "name": "a living asteroid that intends to follow the kobolds home like the largest puppy", | |||
| "shortname": "asteroid", | |||
| "stats": [2,3,1,6], | |||
| }, | |||
| { | |||
| "id": 8, | |||
| "name": "an old lich that wants everyone to stay off of their 'lawn'", | |||
| "shortname": "lich", | |||
| "stats": [5,2,6,3], | |||
| }, | |||
| { | |||
| "id": 9, | |||
| "name": "elder gods hailing from the dark spaces between the stars", | |||
| "shortname": "gods", | |||
| "stats": [0,6,6,6], | |||
| }, | |||
| { | |||
| "id": 10, | |||
| "name": "a Flying Brain Monster", | |||
| "shortname": "Flying Brain Monster", | |||
| "stats": [2,3,6,1], | |||
| }, | |||
| ] | |||
| prob = adversaries.prob | |||
| # [ | |||
| # { | |||
| # "id": 0, | |||
| # "name": "an Undead Sample Pack (swarm of zombies and skeletons)", | |||
| # "shortname": "undead", | |||
| # "stats": [0,5,2,6], | |||
| # }, | |||
| # { | |||
| # "id": 1, | |||
| # "name": "a rival band of kobolds", | |||
| # "shortname": "kobold rivals", | |||
| # "stats": [3,3,4,4], | |||
| # }, | |||
| # { | |||
| # "id": 2, | |||
| # "name": "a detachment from the Elf Armada", | |||
| # "shortname": "elves", | |||
| # "stats": [4,3,5,4], | |||
| # }, | |||
| # { | |||
| # "id": 3, | |||
| # "name": "refugees with parasites. Big parasites", | |||
| # "shortname": "refugees", | |||
| # "stats": [2,4,0,0], | |||
| # }, | |||
| # { | |||
| # "id": 4, | |||
| # "name": "an artificial intelligence bent on multi-world domination", | |||
| # "shortname": "AI", | |||
| # "stats": [4,1,6,3], | |||
| # }, | |||
| # { | |||
| # "id": 5, | |||
| # "name": "robot spiders", | |||
| # "shortname": "spiders", | |||
| # "stats": [3,3,2,4], | |||
| # }, | |||
| # { | |||
| # "id": 6, | |||
| # "name": "semi-intelligent metal eating slime", | |||
| # "shortname": "slime", | |||
| # "stats": [0,2,1,5], | |||
| # }, | |||
| # { | |||
| # "id": 7, | |||
| # "name": "a living asteroid that intends to follow the kobolds home like the largest puppy", | |||
| # "shortname": "asteroid", | |||
| # "stats": [2,3,1,6], | |||
| # }, | |||
| # { | |||
| # "id": 8, | |||
| # "name": "an old lich that wants everyone to stay off of their 'lawn'", | |||
| # "shortname": "lich", | |||
| # "stats": [5,2,6,3], | |||
| # }, | |||
| # { | |||
| # "id": 9, | |||
| # "name": "elder gods hailing from the dark spaces between the stars", | |||
| # "shortname": "gods", | |||
| # "stats": [0,6,6,6], | |||
| # }, | |||
| # { | |||
| # "id": 10, | |||
| # "name": "a Flying Brain Monster", | |||
| # "shortname": "Flying Brain Monster", | |||
| # "stats": [2,3,6,1], | |||
| # }, | |||
| # ] | |||
| def __init__(self, loc_desc=None, locIndex=None, battlefield=None, location=None, missIndex=None, oops=None, mission=None, probIndex=None, problem=None, probName=None, secProblem=None, thirdProblem=None): | |||
| self.loc_desc = loc_desc if loc_desc != None else Plot.loc1[r.randint(0, len(Plot.loc1)-1)] | |||
| @@ -134,25 +136,33 @@ class Plot: | |||
| self.mission = Plot.miss[self.missIndex] | |||
| self.probIndex = probIndex if probIndex != None else r.randint(0, len(Plot.prob)-1) | |||
| self.problem = Plot.prob[self.probIndex] | |||
| if secProblem != None: | |||
| try: | |||
| self.secProblem = [x for x in Plot.prob if x["id"] == secProblem][0] | |||
| except: | |||
| self.secProblem = None | |||
| else: | |||
| self.secProblem = None | |||
| self.thirdProblem = [x for x in Plot.prob if x["id"] == thirdProblem][0] if (thirdProblem != None and thirdProblem in list(filter(lambda x:x["id"], Plot.prob))) else None | |||
| self.problem["givenname"] = probName if probName != None else gen_name() | |||
| if self.problem["id"] == 3 and self.secProblem == None: | |||
| self.secProblem = {"name": "Parasites", "shortname": "parasites", "stats": [3,4,2,3]} | |||
| if self.problem["id"] == 10 and self.secProblem == None: | |||
| self.secProbIndex = r.randint(0, len(Plot.prob)-2) | |||
| self.secProblem = Plot.prob[self.secProbIndex] | |||
| if self.secProbIndex == 3 and self.thirdProblem == None: | |||
| self.thirdProblem = {"name": "Parasites", "shortname": "parasites", "stats": [3,4,2,3]} | |||
| self.fullProblem = self.problem["givenname"] + ", " + self.problem["name"] | |||
| if self.secProblem and self.secProblem["name"] != "Parasites": | |||
| self.fullProblem += " and its minion, " + self.secProblem["name"] | |||
| if type(self.problem["name"]) != str: | |||
| self.problem["name"] = self.problem["name"]() | |||
| if self.problem["hasMinion"]: | |||
| if secProblem != None: | |||
| try: | |||
| self.secProblem = Plot.prob[self.secProblem] | |||
| except: | |||
| self.secProblem = r.choice(self.problem["potentialMinions"]) | |||
| else: | |||
| self.secProblem = r.choice(self.problem["potentialMinions"]) | |||
| self.fullProblem = "" | |||
| if self.problem["needsName"]: | |||
| self.problem["givenname"] = probName if probName != None else gen_name() | |||
| self.fullProblem += self.problem["givenname"] + ", " | |||
| if not self.problem["isPlural"]: | |||
| if self.problem["name"][0].lower() in ["a","e","i","o","u"]: | |||
| self.fullProblem += "an " | |||
| else: | |||
| self.fullProblem += "a " | |||
| self.fullProblem += self.problem["name"] | |||
| if self.problem["hasMinion"]: | |||
| self.fullProblem += " and its minion, " | |||
| # if self.secProblem["name"][0].lower() in ["a","e","i","o","u"]: | |||
| # self.fullProblem += "an " | |||
| # else: | |||
| # self.fullProblem += "a " | |||
| self.fullProblem += self.secProblem["name"] | |||
| class Character: | |||
| @@ -451,11 +461,14 @@ class Campaign: | |||
| op = bin(self.params.oops)[2:] | |||
| ms = bin(self.params.missIndex)[2:] | |||
| pb1 = bin(self.params.probIndex)[2:] | |||
| if self.params.probIndex == 10: | |||
| if self.params.problem["hasMinion"]: | |||
| pb2 = bin(self.params.secProbIndex)[2:] | |||
| else: | |||
| pb2 = bin(127)[2:] | |||
| pbname = self.encode_name(self.params.problem["givenname"]) | |||
| if self.params.problem["needsName"]: | |||
| pbname = self.encode_name(self.params.problem["givenname"]) | |||
| else: | |||
| pbname = self.encode_name("yyyyyyyy") | |||
| n1 = bin(Ship.NAME1.index(self.ship.name1))[2:] | |||
| n2 = bin(Ship.NAME2.index(self.ship.name2))[2:] | |||
| gq = bin(Ship.GQUAL.index(self.ship.gqual))[2:] | |||
| @@ -755,22 +768,22 @@ class Campaign: | |||
| else: | |||
| oops = "" | |||
| mission = oops + self.params.mission | |||
| pl = "s" if self.params.problem["isPlural"] else "" | |||
| note = self.params.problem["note"] | |||
| lines = [ | |||
| f"The Kobolds of the {self.ship.fullname}", | |||
| f"have been sent out to {self.art} {self.params.loc_desc} {self.params.location}!", | |||
| f"in order to {mission}", | |||
| f"but they're challenged by {self.params.fullProblem}!", | |||
| f"The stats of the {self.params.problem['shortname']}", | |||
| f"{note}", | |||
| f"The stats of the {self.params.problem['shortname']}{pl}", | |||
| f"{cst}" | |||
| ] | |||
| if self.params.secProblem: | |||
| if self.params.problem["hasMinion"]: | |||
| mst = ", ".join([" ".join(y) for y in list(zip(st, [str(x) for x in self.params.secProblem["stats"]]))]) | |||
| lines.append(f"The stats of the {self.params.secProblem['shortname']}") | |||
| spl = "s" if self.params.secProblem["isPlural"] else "" | |||
| lines.append(f"The stats of the {self.params.secProblem['shortname']}{spl}") | |||
| lines.append(f"{mst}") | |||
| if self.params.thirdProblem: | |||
| pst = ", ".join([" ".join(y) for y in list(zip(st, [str(x) for x in self.params.thirdProblem["stats"]]))]) | |||
| lines.append(f"The stats of the {self.params.thirdProblem['shortname']}") | |||
| lines.append("{pst}") | |||
| if html: | |||
| out = ( | |||
| f"<div id='theship' class='firstrow'>\n" | |||
| @@ -799,35 +812,30 @@ class Campaign: | |||
| f" <span class='head'>The Adversary</span>\n" | |||
| f" They're challenged by <span id='advname'>{self.params.fullProblem}</span>!\n" | |||
| f" <br>\n" | |||
| f" <span id='problemnote'>\n" | |||
| f" {self.params.problem['note']}" | |||
| f" </span>" | |||
| f" <span id='problemstats'>\n" | |||
| f" The stats of the {self.params.problem['shortname']}:<br>\n" | |||
| f" {cst}\n" | |||
| f" </span>\n" | |||
| ) | |||
| if self.params.secProblem: | |||
| if self.params.problem["hasMinion"]: | |||
| out += ( | |||
| f" <br><span id='secprobstats'>\n" | |||
| f" The stats of the {self.params.secProblem['shortname']}:<br>\n" | |||
| f" {mst}\n" | |||
| f" </span>\n" | |||
| ) | |||
| if self.params.thirdProblem: | |||
| out += ( | |||
| f" <br><span id='thirdprobstats'>\n" | |||
| f" The stats of the {self.params.thirdProblem['shortname']}:<br>\n" | |||
| f" {pst}\n" | |||
| f" </span>\n" | |||
| ) | |||
| out += f"</div>\n" | |||
| print(out) | |||
| print(f"<br clear='all'>\n") | |||
| else: | |||
| print(f"{lines[0]} {lines[1]} {lines[2]} -- {lines[3]}") | |||
| print(f"{lines[4]}: {lines[5]}") | |||
| if self.params.secProblem: | |||
| print(f"- {lines[6]}: {lines[7]}") | |||
| if self.params.thirdProblem: | |||
| print(f"- - {lines[8]}: {lines[9]}") | |||
| print(f"{lines[4]}") | |||
| print(f"{lines[5]}: {lines[6]}") | |||
| if self.params.problem["hasMinion"]: | |||
| print(f"- {lines[7]}: {lines[8]}") | |||
| print() | |||
| self.ship.print(html=html) | |||