-
Notifications
You must be signed in to change notification settings - Fork 0
/
character.py
72 lines (63 loc) · 2.05 KB
/
character.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
from enum import IntEnum
from utils import parse_enum_into_dict
# One hot encoding of race for mask selection
class CharacterRace(IntEnum):
unknown = 0xF
human = 1
erun = 2
doraf = 4
harvin = 8
CLASS_WEAPON_PREF = {
# Tier 3
'weapon_master': ['sword','axe'],
'holy_saber': ['sword', 'spear'],
'bishop': ['staff', 'spear'],
'hermit': ['staff', 'dagger'],
'hawkeye': ['dagger', 'gun'],
'dark_fencer': ['sword', 'dagger'],
'ogre': ['fist'],
'sidewinder': ['bow', 'gun'],
'superstar': ['harp', 'dagger'],
'valkyrie': ['spear', 'axe'],
# Tier 4
'berserker': ['sword', 'axe'],
'sage': ['staff', 'spear'],
# Extra
'alchemist': ['dagger', 'gun'],
'ninja': ['katana', 'fist'],
'samurai': ['katana', 'bow'],
'sword_master': ['sword', 'katana'],
'gunslinger': ['gun'],
'mystic': ['staff'],
'assassin': ['dagger'],
}
CHARACTER_RACE_DICT = parse_enum_into_dict(CharacterRace)
class Character(object):
def __init__(self, name, wep_pref, race):
self.name = name
self.weapon_preferences = str(wep_pref)
self.race = CHARACTER_RACE_DICT[race]
def __str__(self):
output = ""
output += "{}, {}, {}\n".format(self.name, self.race.name, self.weapon_preferences)
return output
class MainCharacter(Character):
def __init__(self, name, char_class, race):
Character.__init__(self, name, CLASS_WEAPON_PREF[char_class], race)
self.char_class = char_class
def __str__(self):
output = ""
output += "{}, {}, {}, {}\n".format(self.name, self.race.name, self.char_class, self.weapon_preferences)
return output
class Party(object):
def __init__(self, mc, pc_list):
if not (isinstance(mc, MainCharacter)):
raise AttributeError("main character class is not MainCharacter class.")
self.mc = mc
self.pc_list = pc_list
def __str__(self):
output = ""
output += str(self.mc)
for pc in self.pc_list:
output += str(pc)
return output