Skip to content

Commit 94b821a

Browse files
Merge pull request #316 from jeffreykirchner/dev
store and report health generated by the house.
2 parents 7a3aeed + a7f2878 commit 94b821a

File tree

3 files changed

+39
-1
lines changed

3 files changed

+39
-1
lines changed

main/models/session.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ def setup_summary_data(self):
176176
v["end_health"] = None
177177
v["health_from_sleep"] = 0
178178
v["health_from_house"] = 0
179+
v["health_generated_by_house"] = 0
179180
v["hat_at_end"] = None
180181

181182
#total harvested / consumption
@@ -429,7 +430,7 @@ def get_download_summary_csv(self):
429430

430431
writer = csv.writer(output, quoting=csv.QUOTE_NONNUMERIC)
431432

432-
temp_header = ["Session ID", "Period", "Client #", "Label", "Group", "Period Earnings ¢", "Hat at End", "Start Health", "End Health", "Health From Sleep", "Health From House"]
433+
temp_header = ["Session ID", "Period", "Client #", "Label", "Group", "Period Earnings ¢", "Hat at End", "Start Health", "End Health", "Health From Sleep", "Health From House", "Health Generated By House"]
433434

434435
#good totals
435436
for k in main.globals.Goods.choices:
@@ -488,6 +489,7 @@ def get_download_summary_csv(self):
488489
temp_p["end_health"],
489490
temp_p["health_from_sleep"],
490491
temp_p["health_from_house"],
492+
temp_p.get("health_generated_by_house", None),
491493
]
492494

493495
#good totals

main/models/session_period.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ def do_consumption(self, world_state, parameter_set):
157157
avatar["health"] = str(Decimal(avatar["health"]) + Decimal(house["health_value"]))
158158

159159
summary_data[session_player_id]["health_from_house"] = house["health_value"]
160+
summary_data[session_player_id]["health_generated_by_house"] = house["health_value"]
160161

161162
if Decimal(avatar["health"]) > 100:
162163
health_overage = Decimal(avatar["health"]) - 100

scripts/update_health_from_house.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import main
2+
3+
from main.models import Session
4+
5+
from main.globals import convert_goods_to_health
6+
7+
print("Enter session ids, comma separated")
8+
session_ids = input().split(',')
9+
10+
for i in range(len(session_ids)):
11+
session = Session.objects.get(id=session_ids[i])
12+
13+
parameter_set = session.parameter_set.json()
14+
15+
for j in session.session_periods.all():
16+
17+
summary_data = j.summary_data
18+
19+
for k in session.session_players.all():
20+
temp_p = summary_data[str(k.id)]
21+
22+
parameter_set_player = k.parameter_set_player
23+
24+
good_one_total = temp_p["house_" + parameter_set_player.good_one]
25+
good_two_total = temp_p["house_" + parameter_set_player.good_two]
26+
good_three_total = temp_p["house_" + parameter_set_player.good_three]
27+
28+
temp_p["health_generated_by_house"] = convert_goods_to_health(good_one_total,
29+
good_two_total,
30+
good_three_total if parameter_set["good_mode"] == "Three" else 0,
31+
parameter_set)
32+
33+
print(f"Player {k.id} has {good_one_total} {parameter_set_player.good_one}, {good_two_total} {parameter_set_player.good_two}, {good_three_total} {parameter_set_player.good_three}, for a total of {temp_p['health_generated_by_house']} health")
34+
35+
j.save()

0 commit comments

Comments
 (0)