def define_trumpf(self, start_player_index): is_allowed_trumpf = False generator = self.players[start_player_index].choose_trumpf(geschoben=self.geschoben) chosen_trumpf = next(generator) if chosen_trumpf == Trumpf.SCHIEBEN: self.geschoben = True generator = self.players[(start_player_index + 2) % 4].choose_trumpf(geschoben=self.geschoben) chosen_trumpf = next(generator) while not is_allowed_trumpf: is_allowed_trumpf = trumpf_allowed(chosen_trumpf=chosen_trumpf, geschoben=self.geschoben) trumpf = generator.send(is_allowed_trumpf) chosen_trumpf = chosen_trumpf if trumpf is None else trumpf self.trumpf = chosen_trumpf
def is_trumpf_allowed(self, chosen_trumpf): return trumpf_allowed(chosen_trumpf, self.geschoben)
def test_trumpf(trumpf, geschoben, result): assert trumpf_allowed(chosen_trumpf=trumpf, geschoben=geschoben) == result