This code technically works, but there HAS to be a more elegant way
Code: Select all
init python:
class Traits(object):
def __init__(self, *args, **kwargs):
self.__dict__.update(kwargs)
init python:
class TraitSelection(Traits):
STAT_DEFAULTS = {
't1' : 0,
't2' : 0,
't3' : 0,
't4' : 0,
't5' : 0,
}
default s1 = TraitSelection("s1", t1 = 1, t2 = 1, t3 = 1, t4 = 1, t5 = 1)
default s2 = TraitSelection("s2", t1 = 1, t2 = 2, t3 = 2, t4 = 2, t5 = 2)
default s3 = TraitSelection("s3", t1 = 1, t2 = 3, t3 = 3, t4 = 3, t5 = 3)
default s4 = TraitSelection("s4", t1 = 2, t2 = 1, t3 = 4, t4 = 4, t5 = 4)
default s5 = TraitSelection("s5", t1 = 3, t2 = 1, t3 = 5, t4 = 5, t5 = 5)
default s6 = TraitSelection("s6", t1 = 4, t2 = 4, t3 = 1, t4 = 6, t5 = 6)
default s7 = TraitSelection("s7", t1 = 5, t2 = 5, t3 = 1, t4 = 7, t5 = 7)
default s8 = TraitSelection("s8", t1 = 6, t2 = 6, t3 = 6, t4 = 1, t5 = 8)
default s9 = TraitSelection("s9", t1 = 7, t2 = 7, t3 = 7, t4 = 1, t5 = 9)
default s10 = TraitSelection("s10", t1 = 8, t2 = 8, t3 = 8, t4 = 8, t5 = 1)
default s11 = TraitSelection("s11", t1 = 9, t2 = 9, t3 = 9, t4 = 9, t5 = 1)
define trait_list = ["s1", "s2", "s3", "s4", "s5", "s6", "s7", "s8", "s9", "s10", "s11"]
label start:
"I need to make a random choice from the trait list"
$ random_choice = renpy.random.choice(trait_list)
if random_choice == "s1":
$ random_choice=s1
if random_choice == "s2":
$ random_choice=s2
if random_choice == "s3":
$ random_choice=s3
if random_choice == "s4":
$ random_choice=s4
if random_choice == "s5":
$ random_choice=s5
if random_choice == "s6":
$ random_choice=s6
if random_choice == "s7":
$ random_choice=s7
if random_choice == "s8":
$ random_choice=s8
if random_choice == "s9":
$ random_choice=s9
if random_choice == "s10":
$ random_choice=s10
if random_choice == "s11":
$ random_choice=s11
"Now I can have [random_choice[t3]]"
return