BadPython.com

Suggestion for "Monkey Patching an instance using MethodType"

idk
            
class Character():
    def __init__(self, attack_power, hp, attackphrase):
        self.hp = hp
        self.attack_power = attack_power
        self.attackphrase = attackphrase

def attack(attacker, target):
    print(attacker.attackphrase)
    target.hp -= attacker.attack_power

#create a player character
player = Character(5, 100, "I'm a player character!")

#create a monster character
monster = Character(10, 100, "I'm a monster!! RAWR!!")

#have the monster attack the player
attack(monster, player)

print(f"After being attacked, the player has {player.hp} health left")