I keep on getting this error and I have absolutely no idea why, I have 3 files importing information from each other however this main one only draws information from monster_01.py and its player.py.
TypeError: player_attack() missing 1 required positional argument: 'self'
---main code---
'''Player class
Fall 2014
@author Myles Taft (mbt6)
'''
import random
import monster_01
class Player():
def __init__(self, strength = 0, player_hp = 0):
self.strength = 1
self.player_hp = 100
print(self.strength, self.player_hp)
def battle():
def player_attack(self):
print('success')
while self.enemy_hp > 0:
monster_01()
self.dice1 = random.randint(1,6)
self.dice2 = random.randint(1,6)
self.dice_sum = dice1 + dice2
self.attack = dice1 + dice2
self.decide_roll = input('Type "roll" to roll the dice:')
self.roll = print('First die:' + dice1, 'Second die:' + dice2, 'Sum of dice:' + dice_sum)
if self.roll == 2 or 4 or 6 :
print('Hit!')
self.enemy_hp == strength
print(enemy_hp)
elif self.roll == 1 or 3 or 5:
print('Miss!')
def player_block(self):
self.dice1 = random.randint(1,6)
self.dice2 = random.randint(1,6)
self.decide_roll = input('Type "roll" to roll the dice:')
self.roll = print('First die:' + dice1, 'Second die:' + dice2, 'Sum of dice:' + dice_sum)
if self.roll == 2 or 4:
print('Blocked!')
self.player_hp -= int((enemy_strength)/2)
if self.roll == 1 or 3:
self.player_hp -= int(enemy_strength)
def choice(self):
get_player_attack(get_player_attack)
self.player_choice = input('Do you attack or block?') #self.player_hp, self.strength)
if self.player_choice == 'attack':
self.player_attack()
elif self.player_choice == 'block':
self.player_block()
def get_player_attack(self):
player_attack()
choice(choice)
Player.battle()
I've been up and down this code a hundred times, any help would be much appreciated.