Package schlachtfeld ::
Module Group
|
|
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 Characters and methods for use in schlachtfeld module.
26 Characters act on their own now and can be imported and saved via amov module.
27 '''
28
29
30
31
32
33 from random import randrange as rnd
34 from random import shuffle
35 import math
36
37 import sys
38
39 from ews import pmw6
40
41 import namen
42
43 from amov import Charakter, Versionsverwaltung
44
45
46
47
48
49
50
51
52
53 name_objekt = namen.Name()
54
55
56 line_cut = 5
57
58
59 powervalue = 0.2
60
61
62
63
64
65
66
67
69 """Do one roll with the plusminus d6 die (wrapper for a function in pmw6)."""
70 return pmw6.pmw6()
71
73 """Check if a given skill test reached a min-value (wrapper for a function in pmw6)."""
74 return pmw6.check(skill,MW)
75
77 """Return the degree of success / failure for a skill check (wrapper for a function in pmw6)."""
78 return pmw6.ocheck(skill,MW)
79
81 '''Return a name corresponding to the characters language.'''
82 return name_object.erzuege(language)
83
84
85
86
87
88
89
90
92 """A group of fighters of one type"""
93 - def __init__(self,name=u'unknown group',resign=0.1,flee=0.3):
94
95 self.situation = [12,0,0,0,0]
96 self.command = (resign,flee)
97
98 self.active = []
99 self.inactive = []
100 self.dead = []
101 self.fled = []
102
103 self.leader = None
104 self.enemy = None
105 self.battlefield = None
106 self.name = name
107 self.grouptype = "Gruppe"
108
109 self.nact = 0
110 self.ninact = 0
111 self.n = self.nact + self.ninact
112 self.powerratio = 1
113 self.aliveratio = 1
114 self.empty = True
115 self.status = None
116 return
117
118
120
121 scribble = self.name
122 scribble += '\nTypus: ' + `self.grouptype`
123 scribble += '\nAktiv: ' + `self.nact`
124 scribble += '\nInaktiv: ' + `self.ninact`
125 scribble += '\nTot, geflohen: ' + `len(self.dead)` + `len(self.fled)`
126 return scribble
127
128
130 '''Count through the lines to establish size of group.'''
131 self.nact = len(self.active)
132 if self.nact > 0:
133 self.empty = False
134 else:
135 self.empty = True
136 self.ninact = len(self.inactive)
137 self.line = max(self.nact, int(round(line_cut*math.sqrt(self.nact))))
138 return
139
140
142 if self.powerratio < self.command[1] or self.aliveratio < self.command[1] * powervalue:
143 self.battlefield.fGroups.append(self.enemy)
144 self.status = 'fled'
145 elif self.powerratio < self.command[0] or self.aliveratio < self.command[0] * powervalue:
146 self.status = 'resigned'
147 self.battlefield.fGroups.append(self.enemy)
148 return
149
150
152 '''Convey information about the enemy to a group.'''
153 self.enemy = enemy
154 return
155
156
158 self.battlefield = battlefield
159 return
160
161
162
164 """One of the sides. Can contain of several Groups and is in itself a group. Army leaders affect all groups."""
165 - def __init__(self,aname=u'unknown army',aresign=0.1,aflee=0.3):
166 Group.__init__(self,name=aname,resign=aresign,flee=aflee)
167 self.groups = []
168 self.grouptype = "Armee"
169 return
170
171
172
173