Complex Nested Class

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
e463gx
Newbie
Posts: 1
Joined: Sun Sep 26, 2021 4:44 pm
Contact:

Complex Nested Class

#1 Post by e463gx »

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.

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
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?

Post Reply

Who is online

Users browsing this forum: Semrush [Bot]