Complex Nested Class
Posted: Sun Sep 26, 2021 4:53 pm
Hoping to get some guidance here, as I am trying to make a somewhat complicated class system. What I would like to do is have a class that then has an inner class around popularity.
My game will have two phases: camp time and then voting time. During camp time the player will talk with some of the npc's and influence how they feel towards the player and other npc's. Therefore I would need a way to tie p1rank to a specific "survivor", p2rank to another, and so forth while being able to then sort the "ranks" come voting time.
Is this possible, or is there a better way to achieve this?
Code: Select all
class Survivor:
def __init__(self, name, strength=None, intelligence=None, agility=None, charisma=None):
self.name = name
self.strength = strength
self.intelligence = intelligence
self.agility = agility
self.charisma = charisma
class Popularity:
def __init__(self, p1rank=None, p2rank=None, p3rank=None, p4rank=None, p5rank=None, p6rank=None, p7rank=None, p8rank=None, p9rank=None):
self.p1rank = 0
self.p2rank = 0
self.p3rank = 0
self.p4rank = 0
self.p5rank = 0
self.p6rank = 0
self.p7rank = 0
self.p8rank = 0
self.p9rank = 0
Is this possible, or is there a better way to achieve this?