Generates and prints a random Costume Fairy Adventures character. Uses only
the basics - no custom Kinds, no alternate powers. It does, however, shuffle
the standard facet array rather than use the dice method in the book.
Feel free to ignore any parts and pick your own values per the usual
rules. It's *your* fairy after all!
"""
def randomquirk(facet, hl):
"""Picks a random fairy quirk.
facet is a string from FACETS.
hl is a string, either 'high' for a high quirk or 'low' for a low
quirk. (If it's something else, we assume low.)
"""
if hl == "high":
return random.choice(QUIRKS[facet][0])
return random.choice(QUIRKS[facet][1])
class Fairy:
"""Represent a Costume Fairy Adventures character."""
def highestfacet(self):
sv = 0
sf = ""
for f, v in self.facets.items():
if v > sv:
sv = v
sf = f
return sf
def lowestfacet(self):
sv = float("inf") # No more maxint, but 'infinity' will do.
sf = ""
for f, v in self.facets.items():
if v < sv:
sv = v
sf = f
return sf
class RandomFairy(Fairy):
"""Creates a random Fairy."""
def __init__(self):
self.kind = random.choice(KINDS)
self.powers = POWERS[self.kind].copy()
self.facets = {f: v for f, v in
zip(FACETS, random.sample([4, 3, 2, 2, 1], 5))}
self.quirks = []
self.quirks.append(randomquirk(self.highestfacet(), "high"))
self.quirks.append(randomquirk(self.lowestfacet(), "low"))
if "Resiliant" in self.powers:
self.stresslimit = 15
else:
self.stresslimit = 10
def main():
fairy = RandomFairy()
print("Kind: " + fairy.kind)
for f,v in fairy.facets.items():
print(f + ": " + str(v))
print("Stress Limit: " + str(fairy.stresslimit))
for q in fairy.quirks:
print("Quirk: " + q)
for p in fairy.powers:
print("Power: " + p)