def render_ai_turn_start(self): print(View.render( template=TEMPLATE_PATH + '/turn-start.txt', turn_number=self.round.turn, player_number=self.round.current_player + 1, discard=self.round.deck.show_discard() ))
def ai_thinking(self, action): print(View.render( template=TEMPLATE_PATH + '/ai-thinking.txt', action=action, )) if not self.ai_only: sleep(0.8)
def render_turn_start(self): print(View.render( template=TEMPLATE_PATH + '/player-turn-start.txt', turn_number=self.round.turn, player_number=self.round.current_player + 1, score=self.hand.get_score(), hand=str(self.hand), discard=self.round.deck.show_discard() ))
def turn_start(player): return TextTemplate.render( TEMPLATE_PATH + '/player-turn-start.txt', turn_number=player.round.turn, player_number=player.round.current_player + 1, score=player.hand.get_score(), hand=str(player.hand), discard=player.round.deck.show_discard() )
def get_end_of_round_scores(self): output = '' for p in self.players: score = p.hand.get_score() output += View.render(template=TEMPLATE_PATH + '/hand-score.txt', player=p.get_name(), hand=str(p.hand), score=score) return output
def has_someone_knocked(self): if self.round.knocked: print(View.render(template=TEMPLATE_PATH + '/knocked.txt'))
def render_this_round_score(self): print( View.render(template=TEMPLATE_PATH + '/round-end.txt', round_scores=self.get_end_of_round_scores(), game_scores=self.get_current_game_scores()))
def hand_data(score): return TextTemplate.render(TEMPLATE_PATH + '/ai-hand-data.txt', score=str(score))
def discarded(discard): return TextTemplate.render(TEMPLATE_PATH + '/player-discarded.txt', discard=discard)
def turn_start(player): return TextTemplate.render(TEMPLATE_PATH + '/turn-start.txt', turn_number=player.round.turn, player_number=player.round.current_player + 1, discard=player.round.deck.show_discard())
def test_colour(): assert view.render( template=a_view_with_ansi_colours ) == "\033[0;36mI'm Blue\033[0m\n\033[0;31mI'm Red\033[0m\n"
def test_view(): assert view.render( template=a_view, variable="two", another_variable='three' ) == "One, two and three\nNew line here\n"
def discarded(player): return TextTemplate.render( TEMPLATE_PATH + '/player-discarded.txt', discard=player.round.deck.inspect_discard() )
def turn_end(player): return TextTemplate.render( TEMPLATE_PATH + '/player-turn-end.txt', hand=str(player.hand), key=player.hand.get_key() )
def render_ai_turn_end(self): print(View.render( template=TEMPLATE_PATH + '/ai-turn-end.txt', hand=str(self.hand), ))
def render_player_turn_end(self): print(View.render( template=TEMPLATE_PATH + '/player-turn-end.txt', hand=str(self.hand), key=self.hand.get_key() ))
def thinking(ai, action): output = TextTemplate.render(TEMPLATE_PATH + '/ai-thinking.txt', action=action) if not ai.ai_only: sleep(0.8) return output
def test_exception(): with pytest.raises(OSError) as context: view.render(template='no_file.txt')
def turn_end(player): return TextTemplate.render(TEMPLATE_PATH + '/ai-turn-end.txt', hand=str(player.hand))
def this_round_score(round_scores, game_scores): return TextTemplate.render(TEMPLATE_PATH + '/round-end.txt', round_scores=round_scores, game_scores=game_scores)
def discard_data(current_score, scores): return TextTemplate.render(TEMPLATE_PATH + '/ai-discard-data.txt', current_score=str(current_score), scores=str(scores), min_score=str(min(scores)))
def end_of_round_scores(player): return TextTemplate.render(TEMPLATE_PATH + '/hand-score.txt', player=player.get_name(), hand=str(player.hand), score=player.hand.get_score())
def prepare_template(template, **kwargs): complete_template = TEMPLATE_PATH + template return TextTemplate.render(complete_template, **kwargs)
def knocked(): return TextTemplate.render( TEMPLATE_PATH + '/knocked.txt' )