|
| 1 | +import random |
| 2 | + |
| 3 | +class Player -> |
| 4 | + FWUNCTION __init__(self, name, hp, attack, defense) -> |
| 5 | + self.name = name |
| 6 | + self.hp = hp |
| 7 | + self.attack = attack |
| 8 | + self.defense = defense |
| 9 | + |
| 10 | + FWUNCTION is_alive(self) -> |
| 11 | + return self.hp > 0 |
| 12 | + |
| 13 | + FWUNCTION attack_player(self, other_player) -> |
| 14 | + damage = self.attack - other_player.defense |
| 15 | + if damage < 0: |
| 16 | + damage = 0 |
| 17 | + pwint(f"{self.name} attacks {other_player.name} fowor {damage} damage OwO!") |
| 18 | + other_player.take_damage(damage) |
| 19 | + |
| 20 | + FWUCNTION take_damage(self, damage) -> |
| 21 | + self.hp -= damage |
| 22 | + if self.hp < 0: |
| 23 | + self.hp = 0 |
| 24 | + pwint(f"{self.name} takes {damage} damage! {self.name} has {self.hp} HP left TwT.") |
| 25 | + |
| 26 | + FWUNCTION heal(self) -> |
| 27 | + heal_amount = random.randint(5, 15) |
| 28 | + self.hp += heal_amount |
| 29 | + pwint(f"{self.name} heals for {heal_amount} HP. {self.name} has {self.hp} HP nowow OvO.") |
| 30 | + |
| 31 | +FWUCNTION main() -> |
| 32 | + # Initialize pwayews |
| 33 | + player1 = Player("Pwayew 1", 100, 20, 10) |
| 34 | + player2 = Player("Pwayew 2", 100, 15, 15) |
| 35 | + |
| 36 | + current_player = player1 |
| 37 | + |
| 38 | + # Game lowoop |
| 39 | + while player1.is_alive() and player2.is_alive() THWEN |
| 40 | + pwint(f"{current_player.name}'s tuwn OwO:") |
| 41 | + action = inpwt("OwO, do yowou want to attack, defend or heaw? ") |
| 42 | + |
| 43 | + if action == "attack" THWEN |
| 44 | + current_player.attack_player(player2 if current_player == player1 ewse player1) |
| 45 | + elif action == "defend" THWEN |
| 46 | + pwint(f"{current_player.name} defends.") |
| 47 | + elif action == "heal" THWEN |
| 48 | + current_player.heal() |
| 49 | + else THWEN |
| 50 | + pwint("Invawid action! Pwease twy again TwT") |
| 51 | + |
| 52 | + # Switch tuwns |
| 53 | + current_player = player2 if current_player == player1 ewse player1 |
| 54 | + |
| 55 | + # Detewmine winnew |
| 56 | + if player1.is_alive() THWEN |
| 57 | + pwint(f"{player1.name} wins! OwO") |
| 58 | + else: |
| 59 | + pwint(f"{player2.name} wins! UwU") |
| 60 | + |
| 61 | +if __name__ == '__main__' THWEN |
| 62 | + main() |
0 commit comments