Skip to content

Commit

Permalink
Merge pull request #39 from AndrewADev/chore/upgrade-python
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewADev committed Aug 20, 2023
2 parents c674c35 + 1f89c09 commit 03ad373
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 45 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ jobs:
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: "3.10"
python-version: "3.11"

- name: Install dependencies
run: |
python -m pip install --upgrade pipenv wheel
pipenv install --dev
- name: Check formatting
run: pipenv run black --target-version=py310 .
run: pipenv run black --target-version=py311 .

- name: Check types
run: pipenv run mypy rps rps-sim.py
Expand Down
2 changes: 1 addition & 1 deletion Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ mypy-extensions = "*"
mypy = "*"

[requires]
python_version = "3.10"
python_version = "3.11"

[pipenv]
allow_prereleases = true
77 changes: 41 additions & 36 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 8 additions & 4 deletions rps-sim.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,13 @@
from rps.game import play_games



@click.command
@click.option("--games", default=3, type=click.IntRange(min=1, max=1000), help="Number of games to play")
@click.option(
"--games",
default=3,
type=click.IntRange(min=1, max=1000),
help="Number of games to play",
)
@click.option("--p1-name", default="Player 1", help="Name of first player")
@click.option("--p2-name", default="Player 2", help="Name of second player")
def simple_sim(games: int, p1_name: str, p2_name: str) -> None:
Expand All @@ -22,5 +26,5 @@ def simple_sim(games: int, p1_name: str, p2_name: str) -> None:
print("Simulation finished.")


if __name__ == '__main__':
simple_sim()
if __name__ == "__main__":
simple_sim()
5 changes: 4 additions & 1 deletion rps/game.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
from .player import Player
from .play import PlayResult


def play_game(firstPlayer: Player, secondPlayer: Player) -> PlayResult:
firstPlay = firstPlayer.play()
secondPlay = secondPlayer.play()
return firstPlay.match(secondPlay)


def play_games(firstPlayer: Player, secondPlayer: Player, times: int) -> list[PlayResult]:
def play_games(
firstPlayer: Player, secondPlayer: Player, times: int
) -> list[PlayResult]:
results = []
for _ in range(times):
results.append(play_game(firstPlayer, secondPlayer))
Expand Down
2 changes: 1 addition & 1 deletion rps/player.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ def __init__(self, play_strategy: PlaySelectionStrategy, name: str = "Bot Player
self.__strategy = play_strategy
self.name = name

def play(self) -> Play:
def play(self) -> Play:
return self.__strategy.play()

0 comments on commit 03ad373

Please sign in to comment.