-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctions.py
More file actions
210 lines (167 loc) · 4.74 KB
/
functions.py
File metadata and controls
210 lines (167 loc) · 4.74 KB
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
import classes
from pygame import sprite
import fonts
from screens import *
from constants import *
import text
import items
import text_data.zombisad, text_data.monk
#import npc
def end_dialog(self, hero):
hero.move = True
hero.control.k_e = False
hero.collide_control = False
hero.start_conv = True
hero.view.a = 0
if self.branch_do == 'go':
self.branch_do = 'done'
self.branch = self.branch_id
self.s = 1
self.n = 0
def br_change(self, branch):
self.branch = branch
self.s = 1
self.n = 0
def br_auto(self):
if self.branch_do == 'go':
self.branch_do = 'done'
self.branch = self.branch_id
self.s = 1
self.n = 0
def war(self, hero):
hero.son.clear_text ()
hero.control.k_e = False
self.agression = True
hero.turn_main = True
hero.start_conv = True
hero.view.a = 0
# a = random.randint (1,6)
self.branch_do = 'done'
self.s = 1
self.n = 0
self.branch = self.branch_id
# if a >3:
def interaction_special(self, hero):
pass
def dialog_special(self, hero):
if self.add_information == 'take' and hero.control.k_e == True:
hero.move = True
hero.control.k_e = False
hero.son.clear_text ()
hero.son.change_text (1, 'Вы получили предмет: %s' % items.dogma.name)
hero.inv.append(items.dogma)
hero.collide_control = False
hero.start_conv = True
if self.branch_do == 'go':
self.branch_do = 'done'
self.branch = self.branch_id
self.s = 1
self.n = 0
if self.add_information == 'end':
hero.move = True
hero.control.k_e = False
hero.collide_control = False
hero.start_conv = True
hero.view.a = 0
if self.branch_do == 'go':
self.branch_do = 'done'
self.branch = self.branch_id
self.s = 1
self.n = 0
def journal_update (self, hero, add_information, concept):
if self.add_information == add_information and self.control.k_e == True:
hero.move = True
x = 0
for i in hero.journal:
if i.name == 'Пусто':
hero.jornal.insert (x, concept)
break
x +=1
class Son ():
'''render text information'''
def __init__ (self):
self.b1 = self.b2 = self.b3 = self.b4 = self.b5 = self.b6 = self.b7 = ''
self.strokelist = [self.b1, self.b2, self.b3, self.b4, self.b5, self.b6, self.b7]
self.all_strokes = []
self.n = 0
def render_text (self):
n = 0
for i in self.strokelist:
information_screen.blit(fonts.font5.render (str(i), True, (250,250,250)),(2,22*n))
n += 1
def change_text (self, n, a):
self.strokelist[n-1] = str(a)
def clear_text (self):
for i in range (len(self.strokelist)):
self.strokelist[i] = ''
def change_text_tree (self, x):
self.clear_text ()
text_tree, n = x
self.n = n
self.all_strokes = text_tree
counter = 0
for i in self.strokelist:
try:
self.strokelist[counter] = self.all_strokes [self.n+counter]
# information_screen.blit(fonts.font2.render (str(self.strokelist[counter]), True, (250,250,250)),(2,counter*22))
counter = counter + 1
except IndexError:
pass
class Compose_dialog_tree ():
'''split text for dialog and render it at dialog screen'''
def __init__ (self, control,son):
#Son.__init__ (self)
self.n = 0
self.a = 0
self.control = control
self.empty = ''
self.stroke_size = 70
self.son = son
self.arrowUp = image.load('images/arrow2.png')
self.arrowDw = image.load('images/arrow.png')
def text_splitter (self, text):
text_splitted = text.split (" ")
rec = []
s = ""
for i in text_splitted:
if len(s + i) < self.stroke_size:
s = s + " " + i
continue
rec.append (s)
s = " " + i
rec.append (s)
return rec
def render_text (self, text, answer):
s1 = s2 = s3 = s4 = s5 = s6 = s7 = ''
ss = [s1,s2,s3,s4,s5,s6,s7]
all_strokes = self.text_splitter (text)
all_strokes_ans = self.text_splitter (answer)
all_strokes.append (self.empty)
all_strokes.extend(all_strokes_ans)
self.n = (self.a * 7)
if self.control.down == True and self.a < int((len(all_strokes)+1) // 8):
self.control.down = False
self.a = self.a+1
if self.control.up == True and self.a > 0:
self.control.up = False
self.a = self.a-1
if self.a < int((len(all_strokes)+1) // 9):
information_screen.blit (self.arrowDw, (600, 70))
if self.a !=0:
information_screen.blit (self.arrowUp, (600, 0))
return all_strokes, self.n
class Battle ():
def main_loop (self, hero, monster):
if hero.status != 'dead' and monster.status != 'killed':
hero.battle_action_main ()
monster.death_check (hero)
monster.battle_action (hero)
hero.check_for_death ()
monster.render_monster_inf ()
def combat (hero, monster):
# if hero.status != 'dead' and monster.status != 'killed':
hero.battle_action_main ()
monster.death_check (hero)
monster.battle_action (hero)
hero.check_for_death ()
monster.render_monster_inf ()