From 2d593fd1d757360eec95f1d5062965abb278f6f9 Mon Sep 17 00:00:00 2001
From: Markus Opolka <markus@martialblog.de>
Date: Wed, 12 Jul 2017 11:37:00 +0200
Subject: [PATCH] Add afugabe9

---
 aufgabe9/Arena.py | 94 +++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 94 insertions(+)
 create mode 100755 aufgabe9/Arena.py

diff --git a/aufgabe9/Arena.py b/aufgabe9/Arena.py
new file mode 100755
index 0000000..8db3cef
--- /dev/null
+++ b/aufgabe9/Arena.py
@@ -0,0 +1,94 @@
+#!/usr/bin/env python3
+
+
+import random
+
+
+class Colors:
+
+    GREEN = '\033[92m'
+    BLUE = '\033[94m'
+    RED = '\033[91m'
+    RESET = '\033[0m'
+
+
+class Player:
+
+    def __init__(self, name, hp, strength):
+
+        self.name = name
+        self.hp = hp
+        self.strength = strength,
+        self.moves = {"tackle": int(strength),
+                      "fireball": 8,
+                      "heal": 3}
+
+    def attack(self, target):
+
+        choice = str.lower(input("Your move (Tackle, Fireball, or Heal):"))
+        print("{0} uses {1}{2}{3}".format(self.name, Colors.RED, choice.title(), Colors.RESET))
+
+        if choice == 'tackle':
+            target.hp -= self.moves['tackle']
+        if choice == 'fireball':
+            target.hp -= self.moves['fireball']
+        if choice == 'heal':
+            self.hp += self.moves['heal']
+
+
+class Enemy:
+
+    def __init__(self, name, hp, strength):
+
+        self.name = name
+        self.hp = hp
+        self.strength = strength,
+        self.moves = {"tackle": int(strength),
+                      "blizzard": 8,
+                      "heal": 3}
+
+    def attack(self, target):
+
+        choice = random.choice(list(self.moves.keys()))
+        print("{0} uses {1}{2}{3}".format(self.name, Colors.RED, choice.title(), Colors.RESET))
+
+        if choice == 'tackle':
+            target.hp -= self.moves['tackle']
+        if choice == 'blizzard':
+            target.hp -= self.moves['blizzard']
+        if choice == 'heal':
+            self.hp += self.moves['heal']
+
+
+def battle(player, cpu):
+
+    while player.hp > 0 and cpu.hp > 0:
+
+        player.attack(cpu)
+        if cpu.hp <= 0:
+            print("Player wins")
+            break
+
+        cpu.attack(player)
+        if player.hp <= 0:
+            print("CPU wins")
+            break
+
+        print()
+        print("{0}'s HP at {1}{2}{3}".format(cpu.name, Colors.GREEN, cpu.hp, Colors.RESET))
+        print("{0}'s HP at {1}{2}{3}".format(player.name, Colors.GREEN, player.hp, Colors.RESET))
+        print()
+
+
+def main():
+
+    player_name = str(input("Enter your Name: "))
+
+    player = Player(name=player_name, hp=20, strength=6)
+    cpu = Enemy(name="CPU", hp=20, strength=7)
+
+    battle(player, cpu)
+
+
+if __name__ == "__main__":
+    main()
-- 
GitLab