-
Notifications
You must be signed in to change notification settings - Fork 0
/
constants.py
194 lines (154 loc) · 6.47 KB
/
constants.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
HOME_PIC = "|^|"
PLAYER_PIC = "%s>"
ENEMY_PIC = "<%s"
ARMY_PIC = {'player': PLAYER_PIC, 'computer': ENEMY_PIC}
PLAYER_FIGHTING_PIC = "%sx"
ENEMY_FIGHTING_PIC = "x%s"
ARMY_FIGHTING_PIC = {'player': PLAYER_FIGHTING_PIC,
'computer': ENEMY_FIGHTING_PIC}
DISTANCE = 70
INCOME_LINE = "." * DISTANCE
LAND = "_" * DISTANCE + '_' * len(HOME_PIC) * 2
HEALTH_LINE = ' ' * len(LAND)
TIME_TICKS_PER_TURN = 15
SPAWN_RATE_IN_TURNS = 3
SPAWN_RATE = TIME_TICKS_PER_TURN * SPAWN_RATE_IN_TURNS
CASTLE_HP = 10000
CASTLE_RECEIVE_DAMAGE = 0.1
UNIT_HP = 5
UNIT_DMG = 1
UNIT_SPD = 1
UNIT_ATSPD = 1
UNIT_REGEN = 0
GOLD = 1000
UNIT_PRICE = 5
REWARD_FOR_KILLING = 1
UPGRADE_GOLD_REWARD = 1
# Income per one piece of land owning
LAND_INCOME = 10
SPAWN_COST = 200
ATTACK_RATE = 5
UNIT_UPGRADES = {'hp': 5,
'dmg': 1,
'speed': 1,
'attack_speed': 0.1,
'regen': 1}
UNIT_UPGRADE_PRICES = {'hp': 100,
'dmg': 100,
'speed': 100,
'attack_speed': 100,
'regen': 100}
CASTLE_UPGRADES = {'income': 10,
'dmg': 5,
'regen': 10,
'hp': 1000}
CASTLE_UPGRADE_PRICES = {'income': 100,
'dmg': 300,
'regen': 200,
'hp': 500}
PLAYER_POSITIONS = {'player': 0, 'computer': DISTANCE+1}
PLAYER_MOVEMENTS = {'player': 1, 'computer': -1}
# TODO: BONUS SKILLS
BONUS_UPGRADE_POISON = 200
BONUS_UPGRADE_STUN = 200
BONUS_UPGRADE_EVASION = 200
# All costs for computer strategy
COSTS = {'spawn': SPAWN_COST, 'unit_hp': UNIT_UPGRADE_PRICES['hp'],
'unit_dmg': UNIT_UPGRADE_PRICES['dmg'],
'unit_attack_speed': UNIT_UPGRADE_PRICES['attack_speed'],
'unit_regen': UNIT_UPGRADE_PRICES['regen'],
'income': CASTLE_UPGRADE_PRICES['income'],
'castle_dmg': CASTLE_UPGRADE_PRICES['dmg'],
'castle_regen': CASTLE_UPGRADE_PRICES['regen'],
'castle_hp': CASTLE_UPGRADE_PRICES['hp']}
help_string = """<= Goal =>
Destroy enemy's Castle.
<= Units =>
Unit - the main object in game. Upgrading units doesn't affect spawned units,
but new units which are about to spawn. Units move forward for one piece of
land (cell) with each time tick or attack if it has enough attack rate.
With each time tick attack rate increases by unit's attack speed value.
Unit must have %(attack_rate)s attack rate to make damage.
<= Spawns =>
Units spawn once per %(spawn_rate)s turns and move towards enemy's castle. Each
spawn can produce one unit, but you must have enough gold for it. Income will
transformed to gold each turn before units spawn, so players should count it
also. Each upgrade give +%(upgrade_gold_reward)s to unit price.
Basic unit price - %(unit_price)s gold.
<= Income & Gold =>
You get income - %(land_income)s gold for each piece of land you own. You own
land from your castle to your army which is furthest. It is shown as "+" on
"income line". Enemy's land shown as "-". Another type of income can be
upgraded via castle upgrades. Also, you get gold for killing enemy units. Each
upgrade give +%(upgrade_gold_reward)s to gold reward for killing.
<= Upgrades =>
All upgrades have no limits, i.e. you can upgrade any attribute infinitely.
<= Castle =>
Castle can do damage to attackers. It targets army on cell next to Castle and
do damage to all units in army simultaneously with each time tick. Castle can
regenerate it's HP once per turn.
<= Time tick & Turn =>
Each turn consists of %(time_ticks_per_turn)s time ticks. Thus, basic units
with no upgrades can attack %(attacks_per_turn)s times and castle can attack
nearest units %(time_ticks_per_turn)s times.
<= Tips & Tricks =>
You can type "b*3" to build 3 spawn at once or "b**" to build spawns for all
available gold. The same works for upgrades.
<= Contacts =>
In case of any bugs or suggestions send an email to [email protected]
Thank you for playing this game! First playable version released in 2017
"""
substitute_params = {'unit_price': UNIT_PRICE, 'attack_rate': ATTACK_RATE,
'upgrade_gold_reward': UPGRADE_GOLD_REWARD,
'land_income': LAND_INCOME, 'spawn_rate': SPAWN_RATE_IN_TURNS,
'time_ticks_per_turn': TIME_TICKS_PER_TURN,
'attacks_per_turn': TIME_TICKS_PER_TURN // ATTACK_RATE}
HELP_STRING = help_string % substitute_params
HELP_ROWS_PER_PAGE = 30
def short_help_string():
""" Build short help string using defined constants """
unit_attrs = ('hp', 'dmg', 'attack_speed', 'regen')
castle_attrs = ('income', 'dmg', 'regen', 'hp')
attr_name_map = {'dmg': 'damage', 'attack_speed': 'attack_speed'}
def map_name(attr):
return attr_name_map[attr] if attr in attr_name_map else attr
short_help = 's - show upgrades e - end turn i - enemy info ' \
'h - help q - exit\n\n' \
'b - build spawn, cost: %s\n' % (SPAWN_COST,)
number = 1
for attribute in unit_attrs:
short_help += '%s - upgrade units %s +%s, cost %s\n' \
% (number,
map_name(attribute),
UNIT_UPGRADES[attribute],
UNIT_UPGRADE_PRICES[attribute])
number += 1
for attribute in castle_attrs:
short_help += '%s - upgrade castle %s +%s, cost %s\n' \
% (number,
map_name(attribute),
CASTLE_UPGRADES[attribute],
CASTLE_UPGRADE_PRICES[attribute])
number += 1
return short_help
SHORT_HELP_STRING = short_help_string()
UPGRADES_TEMPLATE = """\nUnit upgrades:
hp: %(unit_hp)s (%(unit_hp_lvl)s level)
dmg: %(unit_dmg)s (%(unit_dmg_lvl)s level)
attack speed: %(unit_as).1f (%(unit_as_lvl)s level)
regen: %(unit_regen)s (%(unit_regen_lvl)s level)
\nCastle upgrades:
income: %(castle_income)s (%(castle_income_lvl)s level)
dmg: %(castle_dmg)s (%(castle_dmg_lvl)s level)
regen: %(castle_regen)s (%(castle_regen_lvl)s level)
hp: %(castle_hp)s (%(castle_hp_lvl)s level)"""
STATISTICS_PARAMS = {'dmg_dealt_to_castle': 0,
'dmg_dealt_to_units': 0,
'kills': 0,
'gold_earned': 0}
STATISTICS_TEMPLATE = """ Game statistics:
Player name Gold earned Kills Damage to units Damage to Castle
%s
%s
"""
PLAYER_STATISTICS_TEMPLATE = "%(name)10s %(gold_earned)15s %(kills)10s %(dmg_dealt_to_units)15s %(dmg_dealt_to_castle)15s"