-
Notifications
You must be signed in to change notification settings - Fork 0
/
Learena.py
84 lines (63 loc) · 2.12 KB
/
Learena.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/usr/bin/python
# -*- coding: utf-8 -*-
from __future__ import division, print_function, unicode_literals
from Arena import Arena
from Combat import Combat
from Player import Player, RandomPlayer
from rules import *
import logging
import sys
handler = logging.StreamHandler(sys.stdout)
frm = logging.Formatter("%(levelname)s:\t%(message)s")
handler.setFormatter(frm)
logger = logging.getLogger()
logger.addHandler(handler)
logger.setLevel(logging.DEBUG)
logger.critical("Ein wirklich kritischer Fehler")
logger.warning("Und eine Warnung hinterher")
logger.info("Dies hingegen ist nur eine Info")
# Create two characters
from rules.Announcement import Action, Announcement
hieb0 = maneuvers["Hieb"].copy()
hieb1 = maneuvers["Hieb"].copy()
hieb1.level = 1
hieb2 = maneuvers["Hieb"].copy()
hieb2.level = 2
hieb3 = maneuvers["Hieb"].copy()
hieb3.level = 3
block0 = maneuvers["Block"].copy()
block1 = maneuvers["Block"].copy()
block1.level = 1
block2 = maneuvers["Block"].copy()
block2.level = 2
block3 = maneuvers["Block"].copy()
block3.level = 3
gladius = weapons["Gladius"]
char1 = readCharacterFromXML(os.path.join(basedir, "res/Charactere/Agilitus.xml"))
char1.name = "Hugo"
action1 = Action(char1, hieb0, gladius)
reaction1 = Action(char1, block0, gladius)
char2 = readCharacterFromXML(os.path.join(basedir, "res/Charactere/Agilitus.xml"))
char2.name = "Herbert"
action2 = Action(char2, hieb0, gladius)
reaction2 = Action(char2, block0, gladius)
arena = Arena()
arena.addTeam("blue", [char1])
arena.addTeam("red", [char2])
print (arena.getCharacters())
# Create a Player for each character
player1 = RandomPlayer("Player1", char1, arena, action1, reaction1)
player2 = RandomPlayer("Player2", char2, arena, action2, reaction2)
players = [player1, player2]
points = [0,0]
for round in range(100):
# reset chars
char1.reset()
char2.reset()
# Create a combat
combat = Combat(arena, players)
# fight till the death of one team
combat.fightTillDefeat()
points[0] += 1 if char1.isAlive() else 0
points[1] += 1 if char2.isAlive() else 0
print("%s VS %s => (%d : %d)"%(char1.name, char2.name, points[0], points[1]))