Click here to Skip to main content
15,888,113 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Python
class character():
    def __init__(self):
        self.name = " "
        self.race = " "
        self.characterClass = " "
        self.gender = " "
        self.strength = strength
        self.dexterity = dexterity
        self.constitution = constitution
        self.intelligence = intelligence
        self.wisdom = wisdom
        self.charisma = charisma
        self.advantage = advantage = False
        self.languages = []
        magic_sleep_immunity = 0 
        low_light_vision = 0
        self.proficincy = []
        Darkvision = 0
        stonecunning = 0
        stability = 0
        strength = random.randint(3,18)
        dexterity = random.randint(3,18)
        constitution = random.randint(3,18)
        intelligence = random.randint(3,18)
        wisdom = random.randint(3,18)
        charisma = random.randint(3,18)
            
    def __getRace__(self):

        races = ['human', 'elf', 'dwarf',]
        racec = input()
        if racec in races:
            if racec == "human":
                self.race = "human"
                size = "medium"
                self.languages.append("Common")
                speed = 30
                human_desc = "Humans are versitile in any role but do not have a specialized role"
                print(human_desc)
            elif racec == "elf":
                race = "elf"
                dexterity += 2
                constitution -= 2
                size = "medium"
                speed = 30
                magic_sleep_immunity = 1
                low_light_vision = 1
                proficincy.append("longsword")
                proficincy.append("rapier")
                proficincy.append("longbow")
                proficincy.append("shortbow")
                #Gains advantage on Listen, Search, and Spot checks
                languages.append("Common", "Elvish")
                elf_desc = "Elves are skillful but frail. They are good as wizards and marksman"
                print(elf_desc)
            elif racec == "dwarf":
                race = "race"
                self.constitution += 2
                charisma -= 2
                size = "medium"
                speed = 20 # However, dwarves can move at this speed even when wearing medium or heavy armor or whose speed is reduced in such conditions).
                Darkvision = 1
                stonecunning = 1
                stability = 1
                self.proficincy.append("dwarven waraxe")
                self.proficincy.append("dwarven urgrosh")
                #Advantage on: Poison, spells, against orcs and gobilnoids, dodging giants, and apraise and craft checks that include metal or precious gems
                self.languages.append("Common", "Dwarvish")
                dwarf_desc = "Dwarves are tougher but gruff and a bit slower, They are great warriors"


This is the class

Python
import Actual_Functions as ac


This is how I import the file

Python
ac.character.__getRace__()


This is me calling the method to the program and I get:

Python
Traceback (most recent call last):
  File "main.py", line 36, in <module>
    ac.character.__getRace__()
TypeError: __getRace__() missing 1 required positional argument: 'self'


I know the answer is right there but I'm thankful for anyone's help

What I have tried:

Google, Documentation, and Blogs.
Posted
Updated 29-Oct-22 19:08pm
Comments
Richard MacCutchan 30-Oct-22 4:22am    
It looks like you are trying to call the __getRace__ function without using an object of the character class. But we need to see a bit more code to be sure.
Brennon Nevels 30-Oct-22 8:06am    
This is all the code relating to the class but I think I see how I messed up, Thanks.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900