-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcharacter.py
113 lines (90 loc) · 3.2 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
class Character():
# Create a character
def __init__(self, char_name, char_description):
self.name = char_name
self.description = char_description
self.conversation = None
self.direction = None
# Describe this character
def describe(self):
print( self.name + " is here!" )
print( self.description )
# Set what this character will say when talked to
def set_conversation(self, conversation):
self.conversation = conversation
# Talk to this character
def talk(self):
if self.conversation is not None:
print("[" + self.name + " says]: " + self.conversation)
else:
print(self.name + "is very busy, you should let them get on with what they are doing")
def give(self, give_item):
print(self.name + " doesn't want to your " + give_item)
return False
def fight(self, combat_item):
print(self.name + " doesn't want to fight with you")
return 3
class Enemy(Character):
enemies_defeated = 0
def __init__(self, char_name, char_description):
super().__init__(char_name, char_description)
self.weakness = None
# Fight with an enemy
def fight(self, combat_item):
if combat_item == self.weakness:
print("You fend " + self.name + " off with the " + combat_item + "successfully")
Enemy.enemies_defeated += 1
return True
else:
print(self.name + " crushes you, puny adventurer!")
return False
def set_weakness(self, item_weakness, direction=''):
self.weakness = item_weakness
self.direction = direction
def get_weakness(self):
return self.weakness
# Getters and setters for the enemies_defeated variable
def get_defeated(self):
return Enemy.enemies_defeated
def set_defeated(self, number_defeated):
Enemy.enemies_defeated = number_defeated
def steal(self):
print("You steal from " + self.name)
# How will you decide what this character has to steal?
class Neutral(Character):
def __init__(self, char_name, char_description):
super().__init__(char_name, char_description)
self.weakness = None
# Fight with an enemy
def give(self, give_item):
if give_item == self.weakness:
print("You give " + self.name + " the " + give_item)
return True
else:
print(self.name + " doesnt want your " + give_item + "!")
return False
def set_weakness(self, item_weakness, direction=''):
self.weakness = item_weakness
self.direction = direction
def get_weakness(self):
return self.weakness
def steal(self):
print("You steal from " + self.name)
class Friend(Character):
def __init__(self, char_name, char_description):
super().__init__(char_name, char_description)
self.feeling = None
def set_want(self, want, direction=''):
self.want = want
self.direction = direction
def get_want(self):
return self.want
def give(self, give_item):
if give_item == self.want:
print("You give " + self.name + " a " + give_item)
return True
else:
print(self.name + ' doesnt want your ' + give_item)
return False
def hug(self):
print(self.name + " hugs you back!")