-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtests.py
100 lines (80 loc) · 4.47 KB
/
tests.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
from otree.api import Currency as c, currency_range
from . import pages
from ._builtin import Bot
from otree.api import Submission
from .models import Constants
from otree.common import safe_json
import random
class PlayerBot(Bot):
def play_round(self):
scenarios_list = self.participant.vars["scenarios_list"]
mitigated_this_scenario = self.participant.vars["mitigated_this_scenario"]
if self.round_number == 1:
yield (pages.Welcome, {'opened': 0})
yield (pages.Overview, {'opened': 0})
yield (pages.Earnings, {'opened': 0})
yield (pages.BuyHouse, {'opened': 0, 'buy_house': 'bought'})
yield (pages.Instructions)
yield (pages.Instructions2)
if self.player.has_loan:
yield (pages.Instructions2a)
yield (pages.Instructions3)
if self.round_number <= len(self.participant.vars["scenarios_list"]) - Constants.useless_rounds and self.participant.vars["scenarios_list"][self.round_number - 1] != self.participant.vars["scenarios_list"][self.round_number - 2]:
yield Submission(pages.WaitForNewScenario, {'opened': 0}, timeout_happened=True, check_html=False, )
if self.round_number <= len(self.participant.vars["scenarios_list"]) - Constants.useless_rounds and \
self.participant.vars["scenarios_list"][self.round_number - 1] \
!= self.participant.vars["scenarios_list"][self.round_number - 2] :
yield (pages.NewScenario, {'opened': 2})
if self.round_number > len(scenarios_list) - Constants.useless_rounds: # end of game
pass
elif self.player.year == 1:
yield (pages.Invest, {'mitigate': 1, 'opened':0})
if self.round_number == 1:
pass
elif self.round_number > len(scenarios_list) - Constants.useless_rounds: # end of game
pass
elif self.player.year == 1:
pass
elif self.player.year > 1:
yield (pages.Invest2, {'mitigate': 1, 'opened':0})
else:
pass
if self.player.should_pay_installment():
yield (pages.PayInstallment, {'pay_installment': 'paid_installment', 'opened': 0})
if self.player.should_pay_final_installment():
yield (pages.PayFinalInstallment, {'repay_loan': 'repaid_loan', 'opened': 0})
if not self.player.has_insurance:
pass
elif self.round_number > len(scenarios_list) - Constants.useless_rounds: # end of game
pass
elif int(self.player.year) > 0:
yield (pages.Premium, {'pay_premium': 'paid_premium', 'opened': 0})
if self.player.flooded and self.player.has_insurance: # only show button to pay deductible if player is flooded and has insurance
# print("***** deductible should be paid")
yield (pages.Floodrisk, {'pay_deductible': 'paid_deductible', 'opened':0})
elif self.player.mitigate == 0 and self.player.flooded and not self.player.has_insurance: # only show button to pay damage if player is flooded and no insurance was offered
yield (pages.Floodrisk, {'pay_damage': 'paid_damage', 'opened':0})
else:
yield (pages.Floodrisk, {'opened':0})
if self.round_number == Constants.num_test_rounds:
yield Submission(pages.UnderstandingQuestions, check_html=False)
if self.round_number == len(self.participant.vars["years"]) - Constants.useless_rounds:
yield (pages.Payment, {'selected':1, 'opened':0})
yield (pages.Payment2, {'opened':0})
yield (pages.List_R3, {'switching_point_risk2': 5})
yield (pages.List_R, {'switching_point_risk': 6})
yield (pages.BRET, {'bomb_BRET': 0, 'boxes_collected_BRET': 20, 'bomb_row_BRET': 1,
'bomb_col_BRET': 1, 'opened': 0})
yield (pages.PaymentAdditional)
yield (pages.PaymentAdditional2)
if self.participant.vars["selected_additional"] == 1:
yield(pages.List_R4)
elif self.participant.vars["selected_additional"] == 2:
yield(pages.List_R2)
elif self.participant.vars["selected_additional"] == 3:
yield(pages.BRET_2)
yield (pages.List_T, {'switching_point_time': 100.0})
yield (pages.List_T2)
yield (pages.PaymentPrize, {'selected_button': 'selected'})
yield (pages.PaymentPrize2)
yield (pages.TotalPayment)