-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #36 from AndrewADev/chore/add-types
- Loading branch information
Showing
8 changed files
with
62 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[tool.mypy] | ||
strict = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,14 @@ | ||
def play_game(firstPlayer, secondPlayer): | ||
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, secondPlayer, times): | ||
def play_games(firstPlayer: Player, secondPlayer: Player, times: int) -> list[PlayResult]: | ||
results = [] | ||
for game in range(times): | ||
for _ in range(times): | ||
results.append(play_game(firstPlayer, secondPlayer)) | ||
return results |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,18 @@ | ||
import abc | ||
|
||
from .play import Play | ||
from .strategy import PlaySelectionStrategy | ||
|
||
|
||
class Player(object): | ||
@abc.abstractmethod | ||
def play(self): | ||
def play(self) -> Play: | ||
"""Required method""" | ||
|
||
|
||
class BotPlayer(Player): | ||
def __init__(self, play_strategy): | ||
def __init__(self, play_strategy: PlaySelectionStrategy): | ||
self.__strategy = play_strategy | ||
|
||
def play(self): | ||
def play(self) -> Play: | ||
return self.__strategy.play() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters