예제 #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()
     ))
예제 #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)
예제 #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()
     ))
예제 #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()
     )
예제 #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
예제 #6
0
 def has_someone_knocked(self):
     if self.round.knocked:
         print(View.render(template=TEMPLATE_PATH + '/knocked.txt'))
예제 #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()))
예제 #8
0
 def hand_data(score):
     return TextTemplate.render(TEMPLATE_PATH + '/ai-hand-data.txt',
                                score=str(score))
예제 #9
0
 def discarded(discard):
     return TextTemplate.render(TEMPLATE_PATH + '/player-discarded.txt',
                                discard=discard)
예제 #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"
예제 #13
0
 def discarded(player):
     return TextTemplate.render(
         TEMPLATE_PATH + '/player-discarded.txt',
         discard=player.round.deck.inspect_discard()
     )
예제 #14
0
 def turn_end(player):
     return TextTemplate.render(
         TEMPLATE_PATH + '/player-turn-end.txt',
         hand=str(player.hand),
         key=player.hand.get_key()
     )
예제 #15
0
 def render_ai_turn_end(self):
     print(View.render(
         template=TEMPLATE_PATH + '/ai-turn-end.txt',
         hand=str(self.hand),
     ))
예제 #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()
     ))
예제 #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')
예제 #19
0
 def turn_end(player):
     return TextTemplate.render(TEMPLATE_PATH + '/ai-turn-end.txt',
                                hand=str(player.hand))
예제 #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)
예제 #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)))
예제 #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())
예제 #23
0
 def prepare_template(template, **kwargs):
     complete_template = TEMPLATE_PATH + template
     return TextTemplate.render(complete_template, **kwargs)
예제 #24
0
 def knocked():
     return TextTemplate.render(
         TEMPLATE_PATH + '/knocked.txt'
     )