diff --git a/.github/workflows/pylint.yml b/.github/workflows/pylint.yml index 383e65c..622510a 100644 --- a/.github/workflows/pylint.yml +++ b/.github/workflows/pylint.yml @@ -7,7 +7,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ["3.8", "3.9", "3.10"] + python-version: ["3.8"] steps: - uses: actions/checkout@v3 - name: Set up Python ${{ matrix.python-version }} diff --git a/azul/Floor.py b/azul/Floor.py index 275cdc3..fdbacea 100644 --- a/azul/Floor.py +++ b/azul/Floor.py @@ -5,6 +5,7 @@ from typing import List from itertools import chain, repeat, islice + class Floor: _pointPattern: List[Points] _usedTiles: UsedTilesGiveInterface @@ -17,17 +18,15 @@ def __init__(self, pointPattern: List[Points], _usedTiles: UsedTilesGiveInterfac def put(self, tiles: List[Tile]) -> None: self._tiles.extend(tiles) - + def finishRound(self) -> Points: - extendedPattern = chain(self._pointPattern, repeat(self._pointPattern[-1])) - points: Points = Points.sum(list(islice(extendedPattern, 0, len(self._tiles)))) + extendedPattern = chain( + self._pointPattern, repeat(self._pointPattern[-1])) + points: Points = Points.sum( + list(islice(extendedPattern, 0, len(self._tiles)))) self._usedTiles.give(self._tiles.copy()) self._tiles = [] return points - + def state(self) -> str: return compressTileList(self._tiles) - - - - diff --git a/azul/Points.py b/azul/Points.py index a71f55e..1ff562f 100644 --- a/azul/Points.py +++ b/azul/Points.py @@ -1,6 +1,7 @@ from __future__ import annotations from typing import List + class Points: _value: int @@ -10,7 +11,6 @@ def __init__(self, value: int): @staticmethod def sum(pointsList: List[Points]) -> Points: return Points(sum([x._value for x in pointsList])) - + def __str__(self) -> str: return str(self._value) - diff --git a/azul/Tile.py b/azul/Tile.py index 686024e..5ca771b 100644 --- a/azul/Tile.py +++ b/azul/Tile.py @@ -2,14 +2,16 @@ from enum import Enum from typing import List + class Tile: _representation: str def __init__(self, representation: str): self._representation = representation - + def __str__(self) -> str: - return self._representation + return self._representation + STARTING_PLAYER: Tile = Tile("S") RED: Tile = Tile("R") @@ -18,5 +20,6 @@ def __str__(self) -> str: GREEN: Tile = Tile("G") BLACK: Tile = Tile("L") + def compressTileList(tiles: List[Tile]) -> str: return "".join([str(x) for x in tiles]) diff --git a/azul/UsedTilesGiveInterface.py b/azul/UsedTilesGiveInterface.py index fc59629..3dc12bc 100644 --- a/azul/UsedTilesGiveInterface.py +++ b/azul/UsedTilesGiveInterface.py @@ -2,8 +2,7 @@ from azul.Tile import Tile from typing import List + class UsedTilesGiveInterface: def give(self, tiles: List[Tile]) -> None: - pass - - + pass diff --git a/test/test_floor.py b/test/test_floor.py index 2d8af5e..d5eca64 100644 --- a/test/test_floor.py +++ b/test/test_floor.py @@ -1,22 +1,27 @@ from __future__ import annotations import unittest -from azul.UsedTilesGiveInterface import UsedTilesGiveInterface +from azul.UsedTilesGiveInterface import UsedTilesGiveInterface from azul.Tile import Tile, STARTING_PLAYER, RED, GREEN from azul.Floor import Floor from azul.Points import Points from typing import List + class FakeUsedTiles(UsedTilesGiveInterface): tilesGiven: List[Tile] + def __init__(self) -> None: self.tilesGiven = [] + def give(self, tiles: List[Tile]) -> None: - self.tilesGiven.extend(tiles) + self.tilesGiven.extend(tiles) + class TestFloor(unittest.TestCase): def setUp(self) -> None: self.usedTiles: FakeUsedTiles = FakeUsedTiles() - self.floor: Floor = Floor([Points(1), Points(2), Points(2)], self.usedTiles) + self.floor: Floor = Floor( + [Points(1), Points(2), Points(2)], self.usedTiles) def test_many_tiles(self) -> None: tiles = [STARTING_PLAYER, RED, GREEN, RED] @@ -24,6 +29,7 @@ def test_many_tiles(self) -> None: points: Points = self.floor.finishRound() self.assertEquals(str(points), "7") self.assertCountEqual(tiles, self.usedTiles.tilesGiven) - + + if __name__ == '__main__': unittest.main()