Skip to content

Commit

Permalink
Remove remaining Player 1 mentions
Browse files Browse the repository at this point in the history
  • Loading branch information
stanmart committed Apr 23, 2024
1 parent 5172707 commit 3b6518f
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 10 deletions.
2 changes: 1 addition & 1 deletion _static/live_bargaining.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ for (let i = 0; i < numPlayers; i++) {

function sendOffer() {
if (totalSharedValue > 0 && !isMemberCheckboxes[0].checked) {
openPopup('Invalid proposal: the budget is zero when Player 1 is not included in the group', 'error');
openPopup(`Invalid proposal: the budget is zero when Player ${player_names['P1']} is not included in the group`, 'error');
return;
}
if (totalSharedValue > totalShareableValue) {
Expand Down
2 changes: 1 addition & 1 deletion _static/proposal_demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ function sendOffer() {
};

if (totalSharedValue > 0 && !members[0]) {
openPopup('Invalid proposal: the budget is zero when Player 1 is not included in the group', 'error');
openPopup(`Invalid proposal: the budget is zero when Player ${player_names['P1']} is not included in the group`, 'error');
return;
}
if (totalSharedValue > totalShareableValue) {
Expand Down
6 changes: 1 addition & 5 deletions live_bargaining/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,6 @@ class C(BaseConstants):
PLAYERS_PER_GROUP = 3
NUM_ROUNDS = 5 # todo: adjust for main experiment

BIG_ROLE = "Player 1"
SMALL1_ROLE = "Player 2"
SMALL2_ROLE = "Player 3"


class Subsession(BaseSubsession):
start_time = models.FloatField(initial=float("inf")) # type: ignore
Expand Down Expand Up @@ -183,7 +179,7 @@ def check_proposal_validity(player: Player, members, allocations):
return {
player.id_in_group: {
"type": "error",
"content": "Invalid allocation: allocation has to be zero when Player 1 is not included", # noqa: E501
"content": f"Invalid allocation: allocation has to be zero when Player {player.session.config['player_names']['P1']} is not included", # noqa: E501
}
}

Expand Down
7 changes: 4 additions & 3 deletions live_bargaining/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def create_offers(method, Y):
)


def test_invalid_input(method, Y, dummy_player=False):
def test_invalid_input(method, Y, dummy_player, P1_name):
non_existing_offer = method(1, {"type": "accept", "offer_id": 1})
expect(
non_existing_offer,
Expand Down Expand Up @@ -96,7 +96,7 @@ def test_invalid_input(method, Y, dummy_player=False):
{
3: {
"type": "error",
"content": "Invalid allocation: allocation has to be zero when Player 1 is not included",
"content": f"Invalid allocation: allocation has to be zero when Player {P1_name} is not included",
}
},
)
Expand Down Expand Up @@ -179,12 +179,13 @@ def call_live_method(method, **kwargs):
)

prod_fct = kwargs["group"].session.config["prod_fct"]
P1_name = kwargs["group"].session.config["player_names"]["P1"]
Y = list(prod_fct.values())[1]
dummy_player = len(prod_fct) == 2

if kwargs["round_number"] == 1:
print("Testing invalid input")
test_invalid_input(method, Y, dummy_player)
test_invalid_input(method, Y, dummy_player, P1_name)

if kwargs["round_number"] == 2:
print("Testing grand coalition")
Expand Down

0 comments on commit 3b6518f

Please sign in to comment.