Skip to content

Commit 81ac761

Browse files
committed
Make flake8 happy
1 parent 1b979cf commit 81ac761

File tree

5 files changed

+13
-14
lines changed

5 files changed

+13
-14
lines changed

belabot/engine/belot.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import os
88
import random
99
import sys
10-
from functools import reduce
1110
from typing import List, Tuple, Sequence, Dict
1211
import more_itertools as mit
1312

@@ -45,7 +44,7 @@ def play(self) -> None:
4544
return
4645

4746
def round(self, dealer_index: int) -> Tuple[int, int]:
48-
### BIDDING PHASE
47+
# BIDDING PHASE
4948
first_6, talons = self.shuffle()
5049
self.deal_cards(first_6)
5150
adut, adut_caller_index = self.get_adut(dealer_index)
@@ -66,7 +65,7 @@ def round(self, dealer_index: int) -> Tuple[int, int]:
6665

6766
self.notify_pregame(all_declarations, adut, adut_caller_index)
6867

69-
### MAIN PHASE
68+
# MAIN PHASE
7069
# mi_points = random_gen.randint(0, 162)
7170
mi_points, vi_points = 0, 0
7271
# next player starts first
@@ -122,7 +121,7 @@ def notify_played(self, player: Player, card: Card) -> None:
122121
if other_player == player:
123122
player.card_accepted(card)
124123
else:
125-
other_player.notify_played(card)
124+
other_player.notify_played(player, card)
126125
return
127126

128127
def notify_turn_points(self, mi_points: int, vi_points: int) -> None:

belabot/engine/player.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
from .declarations import Declaration
33
from .util import get_valid_moves
44
from typing import List, Optional, Dict
5+
from collections import defaultdict
56
import abc
67
import random
78
import sys
89
import os
910
import logging
10-
import random
1111

1212
log = logging.getLogger(__name__)
1313
log.addHandler(logging.StreamHandler(sys.stdout))
@@ -18,7 +18,7 @@ class Player(abc.ABC):
1818
def __init__(self, name: Optional[str]) -> None:
1919
self.name: Optional[str] = name
2020
self.cards: List[Card] = []
21-
self.played: List[Card] = []
21+
self.played: Dict[Player, List[Card]] = defaultdict(list)
2222
self.points: List[int] = []
2323
self.turn_declarations: Dict[int, List[Declaration]] = dict()
2424
return
@@ -34,8 +34,8 @@ def clear_cards(self) -> None:
3434
self.cards.clear()
3535
return
3636

37-
def notify_played(self, card: Card) -> None:
38-
self.played.append(card)
37+
def notify_played(self, player: 'Player', card: Card) -> None:
38+
self.played[player].append(card)
3939
self.card_played(card)
4040
return
4141

@@ -52,6 +52,7 @@ def notify_pregame(
5252

5353
def card_accepted(self, card: Card) -> None:
5454
self.cards.remove(card)
55+
self.notify_played(self, card)
5556
return
5657

5758
def card_played(self, card: Card) -> None:

belabot/engine/util.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Tuple, List, Iterable, Callable, Optional
1+
from typing import Tuple, List, Callable
22
from .card import Card, Suit
33
from functools import cmp_to_key
44

tests/test_declarations.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,9 @@ def test_declaration_order_rank():
164164

165165
def test_declaration_order_suit():
166166
for length1 in range(3, 8 + 1):
167-
ranks1 = list(Rank)[length1 - 1 :]
167+
ranks1 = list(Rank)[length1-1:]
168168
for length2 in range(3, 8 + 1):
169-
ranks2 = list(Rank)[length2 - 1 :]
169+
ranks2 = list(Rank)[length2-1:]
170170
for (rank1, rank2) in it.product(ranks1, ranks2):
171171
for (suit1, suit2) in it.product(Suit, Suit):
172172
decl1 = SuitDeclaration(rank1, suit1, length1)
@@ -179,7 +179,7 @@ def test_declaration_order_suit():
179179

180180
def test_declarations_order_both():
181181
for suit_length in range(3, 8 + 1):
182-
suit_ranks = list(Rank)[suit_length - 1 :]
182+
suit_ranks = list(Rank)[suit_length-1:]
183183
for rank_rank in VALUES_RANK:
184184
rank_decl = RankDeclaration(rank_rank)
185185
for suit_rank in suit_ranks:

tests/test_util.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from belabot.engine.util import calculate_points, get_valid_moves, get_winner
22
from belabot.engine.card import Card, Suit, Rank
3-
from functools import cmp_to_key
43

54

65
def test_calculate_points_no_decl():
@@ -100,7 +99,7 @@ def test_valid_moves():
10099
== player_cards
101100
)
102101

103-
### two cards
102+
# two cards
104103
# uber cards without adut
105104
for adut_suit in [Suit.DIAMONDS, Suit.SPADES, Suit.CLUBS]:
106105
assert (

0 commit comments

Comments
 (0)