Save and load cheater flag.
[naja.git] / naja / scenes / win.py
1 """
2 Win scene.
3 """
4
5 import pygame.locals as pgl
6
7 from naja.constants import KEYS, PALETTE
8 from naja.events import QuitGameEvent
9 from naja.scenes.scene import Scene
10 from naja.widgets.text import TextWidget, TextBoxWidget
11
12
13 class WinScene(Scene):
14     """
15     Congratulations.
16     """
17
18     def __init__(self, state):
19         super(WinScene, self).__init__(state)
20         self.add(TextWidget((50, 50), 'You won!', colour=PALETTE.WHITE))
21         if self.state.gameboard.has_cheated:
22             self.add(TextWidget(
23                 (50 + 64, 50), 'CHEATER!', colour=PALETTE.ORANGE))
24         self.add(TextBoxWidget(
25             (50, 100), '\n'.join([
26                 "You're great.",
27                 "You did well.",
28                 "You should be proud of yourself.",
29             ]),
30             colour=PALETTE.WHITE, padding=1, border=1,
31             bg_colour=PALETTE.BLACK, border_colour=PALETTE.BLACK,
32             box_width=300))
33
34     def handle_scene_event(self, ev):
35         if ev.type == pgl.KEYDOWN and ev.key in KEYS.QUIT:
36             QuitGameEvent.post()
37             return