Skip to content

Commit

Permalink
Make flake8 happy
Browse files Browse the repository at this point in the history
  • Loading branch information
InCogNiTo124 committed Apr 25, 2021
1 parent 1b979cf commit 81ac761
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 14 deletions.
7 changes: 3 additions & 4 deletions belabot/engine/belot.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import os
import random
import sys
from functools import reduce
from typing import List, Tuple, Sequence, Dict
import more_itertools as mit

Expand Down Expand Up @@ -45,7 +44,7 @@ def play(self) -> None:
return

def round(self, dealer_index: int) -> Tuple[int, int]:
### BIDDING PHASE
# BIDDING PHASE
first_6, talons = self.shuffle()
self.deal_cards(first_6)
adut, adut_caller_index = self.get_adut(dealer_index)
Expand All @@ -66,7 +65,7 @@ def round(self, dealer_index: int) -> Tuple[int, int]:

self.notify_pregame(all_declarations, adut, adut_caller_index)

### MAIN PHASE
# MAIN PHASE
# mi_points = random_gen.randint(0, 162)
mi_points, vi_points = 0, 0
# next player starts first
Expand Down Expand Up @@ -122,7 +121,7 @@ def notify_played(self, player: Player, card: Card) -> None:
if other_player == player:
player.card_accepted(card)
else:
other_player.notify_played(card)
other_player.notify_played(player, card)
return

def notify_turn_points(self, mi_points: int, vi_points: int) -> None:
Expand Down
9 changes: 5 additions & 4 deletions belabot/engine/player.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
from .declarations import Declaration
from .util import get_valid_moves
from typing import List, Optional, Dict
from collections import defaultdict
import abc
import random
import sys
import os
import logging
import random

log = logging.getLogger(__name__)
log.addHandler(logging.StreamHandler(sys.stdout))
Expand All @@ -18,7 +18,7 @@ class Player(abc.ABC):
def __init__(self, name: Optional[str]) -> None:
self.name: Optional[str] = name
self.cards: List[Card] = []
self.played: List[Card] = []
self.played: Dict[Player, List[Card]] = defaultdict(list)
self.points: List[int] = []
self.turn_declarations: Dict[int, List[Declaration]] = dict()
return
Expand All @@ -34,8 +34,8 @@ def clear_cards(self) -> None:
self.cards.clear()
return

def notify_played(self, card: Card) -> None:
self.played.append(card)
def notify_played(self, player: 'Player', card: Card) -> None:
self.played[player].append(card)
self.card_played(card)
return

Expand All @@ -52,6 +52,7 @@ def notify_pregame(

def card_accepted(self, card: Card) -> None:
self.cards.remove(card)
self.notify_played(self, card)
return

def card_played(self, card: Card) -> None:
Expand Down
2 changes: 1 addition & 1 deletion belabot/engine/util.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Tuple, List, Iterable, Callable, Optional
from typing import Tuple, List, Callable
from .card import Card, Suit
from functools import cmp_to_key

Expand Down
6 changes: 3 additions & 3 deletions tests/test_declarations.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,9 @@ def test_declaration_order_rank():

def test_declaration_order_suit():
for length1 in range(3, 8 + 1):
ranks1 = list(Rank)[length1 - 1 :]
ranks1 = list(Rank)[length1-1:]
for length2 in range(3, 8 + 1):
ranks2 = list(Rank)[length2 - 1 :]
ranks2 = list(Rank)[length2-1:]
for (rank1, rank2) in it.product(ranks1, ranks2):
for (suit1, suit2) in it.product(Suit, Suit):
decl1 = SuitDeclaration(rank1, suit1, length1)
Expand All @@ -179,7 +179,7 @@ def test_declaration_order_suit():

def test_declarations_order_both():
for suit_length in range(3, 8 + 1):
suit_ranks = list(Rank)[suit_length - 1 :]
suit_ranks = list(Rank)[suit_length-1:]
for rank_rank in VALUES_RANK:
rank_decl = RankDeclaration(rank_rank)
for suit_rank in suit_ranks:
Expand Down
3 changes: 1 addition & 2 deletions tests/test_util.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from belabot.engine.util import calculate_points, get_valid_moves, get_winner
from belabot.engine.card import Card, Suit, Rank
from functools import cmp_to_key


def test_calculate_points_no_decl():
Expand Down Expand Up @@ -100,7 +99,7 @@ def test_valid_moves():
== player_cards
)

### two cards
# two cards
# uber cards without adut
for adut_suit in [Suit.DIAMONDS, Suit.SPADES, Suit.CLUBS]:
assert (
Expand Down

0 comments on commit 81ac761

Please sign in to comment.