From 3b6518ff5b82d1cddcf3d97c77b94c7173dfd140 Mon Sep 17 00:00:00 2001 From: Martin Stancsics Date: Tue, 23 Apr 2024 12:09:42 +0200 Subject: [PATCH] Remove remaining Player 1 mentions --- _static/live_bargaining.js | 2 +- _static/proposal_demo.js | 2 +- live_bargaining/__init__.py | 6 +----- live_bargaining/tests.py | 7 ++++--- 4 files changed, 7 insertions(+), 10 deletions(-) diff --git a/_static/live_bargaining.js b/_static/live_bargaining.js index e9a0d7e..6d0c0f4 100644 --- a/_static/live_bargaining.js +++ b/_static/live_bargaining.js @@ -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) { diff --git a/_static/proposal_demo.js b/_static/proposal_demo.js index 4aece75..77f9c5a 100644 --- a/_static/proposal_demo.js +++ b/_static/proposal_demo.js @@ -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) { diff --git a/live_bargaining/__init__.py b/live_bargaining/__init__.py index 1647078..9be9387 100644 --- a/live_bargaining/__init__.py +++ b/live_bargaining/__init__.py @@ -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 @@ -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 } } diff --git a/live_bargaining/tests.py b/live_bargaining/tests.py index cc904a6..69ac4c4 100644 --- a/live_bargaining/tests.py +++ b/live_bargaining/tests.py @@ -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, @@ -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", } }, ) @@ -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")