Beispiel #1
0
 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()
     ))
Beispiel #2
0
 def ai_thinking(self, action):
     print(View.render(
         template=TEMPLATE_PATH + '/ai-thinking.txt',
         action=action,
     ))
     if not self.ai_only:
         sleep(0.8)
Beispiel #3
0
 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()
     ))
Beispiel #4
0
 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()
     )
Beispiel #5
0
 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
Beispiel #6
0
 def has_someone_knocked(self):
     if self.round.knocked:
         print(View.render(template=TEMPLATE_PATH + '/knocked.txt'))
Beispiel #7
0
 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()))
Beispiel #8
0
 def hand_data(score):
     return TextTemplate.render(TEMPLATE_PATH + '/ai-hand-data.txt',
                                score=str(score))
Beispiel #9
0
 def discarded(discard):
     return TextTemplate.render(TEMPLATE_PATH + '/player-discarded.txt',
                                discard=discard)
Beispiel #10
0
 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"
Beispiel #13
0
 def discarded(player):
     return TextTemplate.render(
         TEMPLATE_PATH + '/player-discarded.txt',
         discard=player.round.deck.inspect_discard()
     )
Beispiel #14
0
 def turn_end(player):
     return TextTemplate.render(
         TEMPLATE_PATH + '/player-turn-end.txt',
         hand=str(player.hand),
         key=player.hand.get_key()
     )
Beispiel #15
0
 def render_ai_turn_end(self):
     print(View.render(
         template=TEMPLATE_PATH + '/ai-turn-end.txt',
         hand=str(self.hand),
     ))
Beispiel #16
0
 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()
     ))
Beispiel #17
0
 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')
Beispiel #19
0
 def turn_end(player):
     return TextTemplate.render(TEMPLATE_PATH + '/ai-turn-end.txt',
                                hand=str(player.hand))
Beispiel #20
0
 def this_round_score(round_scores, game_scores):
     return TextTemplate.render(TEMPLATE_PATH + '/round-end.txt',
                                round_scores=round_scores,
                                game_scores=game_scores)
Beispiel #21
0
 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)))
Beispiel #22
0
 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())
Beispiel #23
0
 def prepare_template(template, **kwargs):
     complete_template = TEMPLATE_PATH + template
     return TextTemplate.render(complete_template, **kwargs)
Beispiel #24
0
 def knocked():
     return TextTemplate.render(
         TEMPLATE_PATH + '/knocked.txt'
     )