11# coding=utf-8
22
3- from time import sleep
4-
53from text_template import TextTemplate
64
75from rummy .constants .resource_path import TEMPLATE_PATH
86
97
8+ # Todo: Refactor -- These look more like controllers the current controller is more like a service.
9+
10+
1011class View :
1112
1213 @staticmethod
@@ -22,85 +23,3 @@ def prepare_template(template, **kwargs):
2223 complete_template = TEMPLATE_PATH + template
2324 return TextTemplate .render (complete_template , ** kwargs )
2425
25- @staticmethod
26- def template_turn_start (player ):
27- return TextTemplate .render (
28- TEMPLATE_PATH + '/player-turn-start.txt' ,
29- turn_number = player .round .turn ,
30- player_number = player .round .current_player + 1 ,
31- score = player .hand .get_score (),
32- hand = str (player .hand ),
33- discard = player .round .deck .show_discard ()
34- )
35-
36- @staticmethod
37- def template_player_turn_end (player ):
38- return TextTemplate .render (
39- TEMPLATE_PATH + '/player-turn-end.txt' ,
40- hand = str (player .hand ),
41- key = player .hand .get_key ()
42- )
43-
44- @staticmethod
45- def template_ai_thought (ai , action ):
46- output = TextTemplate .render (
47- TEMPLATE_PATH + '/ai-thinking.txt' , action = action )
48- if not ai .ai_only :
49- sleep (0.8 )
50- return output
51-
52- @staticmethod
53- def template_ai_turn_start (player ):
54- return TextTemplate .render (
55- TEMPLATE_PATH + '/turn-start.txt' ,
56- turn_number = player .round .turn ,
57- player_number = player .round .current_player + 1 ,
58- discard = player .round .deck .show_discard ()
59- )
60-
61- @staticmethod
62- def template_ai_turn_end (player ):
63- return TextTemplate .render (
64- TEMPLATE_PATH + '/ai-turn-end.txt' ,
65- hand = str (player .hand )
66- )
67-
68- @staticmethod
69- def template_player_discarded (discard ):
70- return TextTemplate .render (
71- TEMPLATE_PATH + '/player-discarded.txt' ,
72- discard = discard
73- )
74-
75- @staticmethod
76- def template_ai_discard_data (current_score , scores ):
77- return TextTemplate .render (
78- TEMPLATE_PATH + '/ai-discard-data.txt' ,
79- current_score = str (current_score ),
80- scores = str (scores ),
81- min_score = str (min (scores ))
82- )
83-
84- @staticmethod
85- def template_ai_hand_data (score ):
86- return TextTemplate .render (
87- TEMPLATE_PATH + '/ai-hand-data.txt' ,
88- score = str (score )
89- )
90-
91- @staticmethod
92- def template_end_of_round_scores (player ):
93- return TextTemplate .render (
94- TEMPLATE_PATH + '/hand-score.txt' ,
95- player = player .get_name (),
96- hand = str (player .hand ),
97- score = player .hand .get_score ()
98- )
99-
100- @staticmethod
101- def template_this_round_score (round_scores , game_scores ):
102- return TextTemplate .render (
103- TEMPLATE_PATH + '/round-end.txt' ,
104- round_scores = round_scores ,
105- game_scores = game_scores
106- )
0 commit comments