-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmuster.py
207 lines (177 loc) · 5.97 KB
/
muster.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
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
from dice import *
import b5_data
army_cash_table = [2000, 5000, 10000, 10000, 10000, 20000, 30000]
army_muster_table = ['Low Psg', '+1 int', '+2 edu', 'Gun', 'High Psg', 'Mid Psg', '+1 soc']
marine_cash_table = [2000, 5000, 5000, 10000, 20000, 30000, 40000]
marine_muster_table = ['Low Psg', '+2 int', '+1 edu', 'Blade', 'Travellers', 'High Psg', '+2 soc']
###################################################################
# apply_marine_muster_cash(grunt, roll)
# grunt is the character object
# roll is the result of a simulated random die roll
#
#
# Adds Book 1 muster cash roll results to the character object
#
###################################################################
#def apply_marine_muster_cash(grunt, roll):
# if 0 == roll:
# grunt.cash += marine_cash_table[0]
# if 0 < roll < 3:
# grunt.cash += marine_cash_table[1]
# if 3 == cash:
# grunt.cash += marine_cash_table[3]
# if roll == 4:
# grunt.cash += marine_cash_table[4]
# if roll == 5:
# grunt.cash += marine_cash_table[5]
# if roll == 6:
# grunt.cash += marine_cash_table[6]
###################################################################
# apply_marine_muster_benefit(roll, grunt)
# Roll is an integer ranging from 1 to 6
# grunt is the character object
# Returns nothing
#
# applies Book 1 muster benefits, updates the character object
#
###################################################################
def apply_marine_muster_benefit(roll, grunt):
print 'In apply_marine_muster benifit'
print 'roll should be 1,2 or 6'
print 'roll = ', roll #debug
if 1 == roll:
grunt.stat_change("int", 2)
if 2 == roll:
grunt.stat_change("edu", 1)
if 6 == roll:
grunt.stat_change("soc", 2)
###################################################################
# retirement_pay(grunt)
# grunt is the character object
#
# updates the character upp object with retirement pay options
#
###################################################################
def retirement_pay(grunt):
'Determine any retirement pay'
if 5 == (grunt.term):
grunt.r_pay = 4000
if 6 == (grunt.term):
grunt.r_pay = 6000
if 7 == (grunt.term):
grunt.r_pay = 8000
if 8 == (grunt.term):
grunt.r_pay = 10000
if (grunt.term - 1) > 8:
grunt.r_pay = 10000 + ((grunt.term - 8) * 2000)
# end of retirement_pay
###################################################################
# muster_out_rolls(grunt)
# grunt is the character object
#
# updates the character object with the total number of mustering
# out rolls.
#
# Returns True
#
###################################################################
def muster_out_rolls(grunt):
'Determine the number of mustering out rolls'
grunt.muster_rolls = grunt.term
if grunt.college: #Not in the Navy if in college
grunt.muster_rolls -= 1
if grunt.medschool and (grunt.academy == False):
grunt.muster_rolls -= 1
if not grunt.officer: #Have to be an officer to get extra rolls
return True
if grunt.rank < 3:
grunt.muster_rolls += 1
return True
if 3 <= grunt.rank <=4:
grunt.muster_rolls += 2
return True
if grunt.rank > 4:
grunt.muster_rolls += 3
return True
return True
#end of muster_out_rolls()
###################################################################
# apply_army_muster_benefit(roll,grunt)
# roll is an integer, the results of d6 roll
# grunt is the character object
# Returns True
#
# Applies Book 1 Army muster benefits, updates the character object
#
###################################################################
def apply_army_muster_benefit(roll, grunt):
'apply muster benefits to upp'
if 1 == roll:
grunt.stat_change("int", 1)
if 2 == roll:
grunt.stat_change("edu", 2)
if 6 == roll:
grunt.stat_change("soc", 2)
return True
#end appy_army_muster_benefit
###################################################################
# muster_out(grunt)
# grunt is the character object
# Returns nothing
#
# performs Book 1 mustering out, updates the character object
#
###################################################################
def muster_out(grunt):
'Determine what cash and loot you get out alive with'
if grunt.is_dead():
return False
if grunt.is_navy():
return b5_data.muster_out(grunt)
muster_out_rolls(grunt)
if grunt.term >= 5:
retirement_pay(grunt)
bt = 0 # number of Non Cash Loot rolls
ct = 0 # number of cash rolls
# muster_rolls is the total number of rolls available
for x in range(0,grunt.muster_rolls):
if ct >= 3: #arbitary - max of 3 cash rolls
bt += 1
else:
if coin_flip(): # flip a coin.
ct += 1
else:
bt += 1
if (bt > 0) and (ct == 0): #Make sure there is at least 1 cash roll
bt -= 1
ct += 1
for x in range(0, ct):
roll = dice()
# alternate code skill.list.has_key('Gambling')
# will return True if it is the list
if "Gambling" in grunt.skills:
roll += 1
if grunt.is_army():
cash = army_cash_table[roll-1]
else:
cash = marine_cash_table[roll-1]
grunt.muster_cash.append(cash)
grunt.cash += cash
s = 'Muster out Benefit of Cr%d' % cash
grunt.history.append(s)
for x in range(0, bt):
roll = dice()
if grunt.rank > 4:
roll += 1
if grunt.is_army():
loot = army_muster_table[roll-1]
apply_army_muster_benefit(roll-1, grunt)
elif grunt.is_marine():
loot = marine_muster_table[roll-1]
apply_marine_muster_benefit(roll-1, grunt)
grunt.muster_loot.append(loot)
s = 'Muster out Benefit of %s' % loot
grunt.apply_skill(loot)
grunt.history.append(s)
return True
# end of muster_out()