Python Forum
Thread Rating:
  • 2 Vote(s) - 3.5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
RPG game trouble
#8
Quote:
class Hero(Character):
    def __init__(self):
        super().__init__(name=player_name, health=3)

class Enemy(Character):
    def __init__(self):
        super().__init__(name=enemy.name, health = 2)

player_name and enemy.name don't exist yet, so they can't be used as default values for the variables.  But since you always name them anyway, you don't need defaults.  So just getting rid of that bit would solve that particular issue.

ie:
class Hero(Character):
   def __init__(self, name, health=3):
       super().__init__(name, health)

class Enemy(Character):
   def __init__(self, name, health=2):
       super().__init__(name, health)
Reply


Messages In This Thread
RPG game trouble - by J125 - Apr-08-2017, 05:38 PM
RE: RPG game trouble - by ichabod801 - Apr-08-2017, 06:04 PM
RE: RPG game trouble - by J125 - Apr-17-2017, 11:43 AM
RE: RPG game trouble - by ichabod801 - Apr-18-2017, 01:20 AM
RE: RPG game trouble - by J125 - Apr-20-2017, 10:25 AM
RE: RPG game trouble - by Kebap - Apr-20-2017, 05:21 PM
RE: RPG game trouble - by J125 - Apr-24-2017, 11:38 AM
RE: RPG game trouble - by nilamo - Apr-29-2017, 04:42 PM
RE: RPG game trouble - by J125 - May-03-2017, 08:34 AM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020