comparison gamelib/gameover.py @ 562:80725d647569

Neaten up gameover screen.
author Simon Cross <hodgestar@gmail.com>
date Sat, 28 Nov 2009 18:42:39 +0000
parents 8cd13b82585e
children fb8ab1ee3eaf
comparison
equal deleted inserted replaced
561:7f037ee2a6c8 562:80725d647569
94 94
95 score = gameboard.cash + \ 95 score = gameboard.cash + \
96 level.sell_price_chicken * len(gameboard.chickens) + \ 96 level.sell_price_chicken * len(gameboard.chickens) + \
97 level.sell_price_egg * gameboard.eggs 97 level.sell_price_egg * gameboard.eggs
98 98
99 self.tr()
100 made_list = scoreboard.check(score) is not None 99 made_list = scoreboard.check(score) is not None
101 if level.is_game_over(gameboard): 100 if level.is_game_over(gameboard):
102 if len(gameboard.chickens) > 0: 101 if len(gameboard.chickens) > 0:
103 self.survived = WON 102 self.survived = WON
104 scoreboard.submit(score, 'Player') 103 scoreboard.submit(score, 'Player')
107 self.survived = LOST 106 self.survived = LOST
108 message = random.choice(LOST_MESSAGES) 107 message = random.choice(LOST_MESSAGES)
109 else: 108 else:
110 self.survived = LEFT 109 self.survived = LEFT
111 message = random.choice(LEFT_MESSAGES) 110 message = random.choice(LEFT_MESSAGES)
111
112 self.tr()
112 self.td(gui.Label(message, color=constants.FG_COLOR), 113 self.td(gui.Label(message, color=constants.FG_COLOR),
113 colspan=3) 114 colspan=3)
114 self.add_spacer() 115 self.add_spacer()
116
117 # heading options
118 head_kwargs = {
119 'color': constants.FG_COLOR,
120 'style': {
121 'padding_top': 10,
122 'padding_bottom': 5,
123 },
124 }
125
115 # show the scoreboard 126 # show the scoreboard
116 127
117 self.tr() 128 self.tr()
118 self.td(gui.Label('Level: %s' % level.level_name, color=constants.FG_COLOR), 129 self.td(html.HTML('<b>High Scores for Level<i>%s:</i></b>'
119 colspan=3) 130 % level.level_name, **head_kwargs),
131 colspan=3)
120 132
121 for highscore in scoreboard: 133 for highscore in scoreboard:
122 self.tr() 134 self.tr()
123 self.td(gui.Label(highscore.name, color=constants.FG_COLOR), colspan=2) 135 self.td(gui.Label(highscore.name, color=constants.FG_COLOR), colspan=2)
124 self.td(gui.Label('%d' % highscore.score, color=constants.FG_COLOR)) 136 self.td(gui.Label('%d' % highscore.score, color=constants.FG_COLOR))
137
138 # show player score
139
140 self.tr()
141 self.td(html.HTML('<b>Your Score:</b>', **head_kwargs), colspan=3)
125 142
126 self.tr() 143 self.tr()
127 self.td(gui.Label("Groats : %d" % gameboard.cash, 144 self.td(gui.Label("Groats : %d" % gameboard.cash,
128 color=constants.FG_COLOR)) 145 color=constants.FG_COLOR))
129 self.td(gui.Label(" Chickens : %d " % len(gameboard.chickens), 146 self.td(gui.Label(" Chickens : %d " % len(gameboard.chickens),
136 color=constants.FG_COLOR), colspan=3) 153 color=constants.FG_COLOR), colspan=3)
137 self.add_spacer() 154 self.add_spacer()
138 self.tr() 155 self.tr()
139 self.td(gui.Label("Final score : %d" % score, 156 self.td(gui.Label("Final score : %d" % score,
140 color=constants.FG_COLOR), colspan=3) 157 color=constants.FG_COLOR), colspan=3)
158
141 if made_list: 159 if made_list:
142 scoreboard.save()
143 self.tr() 160 self.tr()
144 if self.survived == WON: 161 if self.survived == WON:
145 self.td(gui.Label("You made the high scores", 162 msg = "You made the high scores!"
146 color=constants.FG_COLOR), colspan=3) 163 scoreboard.save()
147 else: 164 else:
148 self.td(gui.Label("Pity, you could have made the high scores", 165 msg = "Pity, you could have made the high scores."
149 color=constants.FG_COLOR), colspan=3) 166 self.td(html.HTML("<b>%s</b>" % msg, **head_kwargs)
167 , colspan=3)
150 168
151 self.add_spacer(50) 169 self.add_spacer(50)
152 170
153 return_button = gui.Button("Return to Main Menu") 171 return_button = gui.Button("Return to Main Menu")
154 return_button.connect(gui.CLICK, return_pressed) 172 return_button.connect(gui.CLICK, return_pressed)