Skip to content

Commit

Permalink
Pallets on the floor don't qualify to be the highest
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterJCLaw committed Nov 17, 2024
1 parent 9c0b0b2 commit a82a41a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 34 deletions.
17 changes: 0 additions & 17 deletions scoring/score.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,23 +170,6 @@ def validate(self, other_data):
code='impossible_highest_pallet',
)

# Check that the "highest" pallet is assigned in the case where a
# district has pallets from only one team.
missing_highest = {}
for name, district in self._districts.items():
highest = district['highest']
pallet_counts = district['pallet_counts']
if len(pallet_counts) == 1 and not highest:
pallet, = pallet_counts.keys()
missing_highest[name] = pallet
if missing_highest:
raise InvalidScoresheetException(
f"Some districts with pallets from a single team are missing "
"specification of the highest.\n"
f"{missing_highest!r}",
code='missing_highest_pallet',
)

# Check that the total number of pallets of each colour across the whole
# arena are less than the expected number.
totals = collections.Counter()
Expand Down
22 changes: 5 additions & 17 deletions scoring/tests/test_scoring.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,10 @@ def test_left_starting_zone(self) -> None:
)

def test_outer_single(self) -> None:
self.districts['outer_nw']['highest'] = 'G'
self.districts['outer_nw']['pallets'] = 'G'
self.assertScores(
{
'GGG': 2,
'GGG': 1,
'OOO': 0,
},
self.districts,
Expand Down Expand Up @@ -140,12 +139,11 @@ def test_outer_highest(self) -> None:
)

def test_inner_single(self) -> None:
self.districts['inner_ne']['highest'] = 'O'
self.districts['inner_ne']['pallets'] = 'O'
self.assertScores(
{
'GGG': 0,
'OOO': 4,
'OOO': 2,
},
self.districts,
)
Expand All @@ -172,12 +170,11 @@ def test_inner_highest(self) -> None:
)

def test_central_single(self) -> None:
self.districts['central']['highest'] = 'O'
self.districts['central']['pallets'] = 'O'
self.assertScores(
{
'GGG': 0,
'OOO': 6,
'OOO': 3,
},
self.districts,
)
Expand Down Expand Up @@ -205,15 +202,13 @@ def test_central_highest(self) -> None:

def test_mixed(self) -> None:
self.teams_data['OOO']['left_starting_zone'] = True
self.districts['outer_sw']['highest'] = 'O'
self.districts['outer_sw']['pallets'] = 'O'
self.districts['inner_sw']['highest'] = 'G'
self.districts['inner_sw']['pallets'] = 'G'
self.districts['central']['pallets'] = 'GO'
self.assertScores(
{
'GGG': 7,
'OOO': 6,
'GGG': 5,
'OOO': 5,
},
self.districts,
)
Expand Down Expand Up @@ -293,13 +288,6 @@ def test_highest_when_team_not_present(self) -> None:
code='impossible_highest_pallet',
)

def test_no_highest_when_only_one_team_present(self) -> None:
self.districts['outer_sw']['pallets'] = 'OO'
self.assertInvalidScoresheet(
self.districts,
code='missing_highest_pallet',
)

def test_too_many_pallets(self) -> None:
self.districts['outer_sw']['pallets'] = ('G' * 7) + 'O'
self.assertInvalidScoresheet(
Expand Down

0 comments on commit a82a41a

Please sign in to comment.