diff --git a/Wordless.kv b/Wordless.kv index c38281b..4576e45 100644 --- a/Wordless.kv +++ b/Wordless.kv @@ -155,81 +155,84 @@ third: '' fourth: '' fifth: '' + Button: color: 0,0,0,1 on_press: root.manager.current = 'game' background_color: 0.2,1,2,1 - + Label: text: 'Your Score:' font_size: 60 color: 0,1,0.5,1 - pos: root.center_x - 100, root.center_y + 200 + pos: root.center_x - 110, root.center_y + 200 Label: text: str(root.your_score) font_size: 65 color: 0,1,0.5,1 - pos: root.center_x + 100, root.center_y + 200 + pos: root.center_x + 110, root.center_y + 200 Label: text: 'High Scores' - font_size: 70 + font_size: 80 color: 1,0,0.2,1 - pos: root.center_x - 80, root.center_y + 100 + pos: root.center_x - 70, root.center_y + 100 Label: text: str(root.champion) - font_size: 30 + font_size: 35 color: 0,0,0,1 - pos: root.center_x -150, root.center_y + 50 + pos: root.center_x -150, root.center_y + 35 Label: text: str(root.champ_score) - font_size: 30 + font_size: 35 color: 0,0,0,1 - pos: root.center_x +50, root.center_y + 50 + pos: root.center_x +50, root.center_y + 35 Label: text: str(root.second) - font_size: 30 + font_size: 35 color: 0,0,0,1 - pos: root.center_x -150, root.center_y + 25 + pos: root.center_x -150, root.center_y + 5 Label: text: str(root.second_score) - font_size: 30 + font_size: 35 color: 0,0,0,1 - pos: root.center_x +50, root.center_y + 25 + pos: root.center_x +50, root.center_y + 5 Label: text: str(root.third) - font_size: 30 + font_size: 35 color: 0,0,0,1 - pos: root.center_x -150, root.center_y + pos: root.center_x -150, root.center_y -25 Label: text: str(root.third_score) - font_size: 30 + font_size: 35 color: 0,0,0,1 - pos: root.center_x +50, root.center_y + pos: root.center_x +50, root.center_y -25 Label: text: str(root.fourth) - font_size: 30 + font_size: 35 color: 0,0,0,1 - pos: root.center_x -150, root.center_y - 25 + pos: root.center_x -150, root.center_y - 55 Label: text: str(root.fourth_score) - font_size: 30 + font_size: 35 color: 0,0,0,1 - pos: root.center_x +50, root.center_y - 25 + pos: root.center_x +50, root.center_y - 55 Label: text: str(root.fifth) - font_size: 30 + font_size: 35 color: 0,0,0,1 - pos: root.center_x -150, root.center_y - 50 + pos: root.center_x -150, root.center_y - 85 Label: text: str(root.fifth_score) - font_size: 30 + font_size: 35 color: 0,0,0,1 - pos: root.center_x +50, root.center_y - 50 + pos: root.center_x +50, root.center_y - 85 Label: - text: 'Click anywhere to begin new Game' + text: 'Click Anywhere to begin new Game' font_size: 40 - color: 1,1,1,1 - pos: root.center_x - 50, root.center_y - 200 - + color: 1,1,1,1 + pos: root.center_x -50, root.center_y - 200 + + + diff --git a/board.py b/board.py index e9722db..6241314 100644 --- a/board.py +++ b/board.py @@ -6,6 +6,7 @@ ListProperty from kivy.clock import Clock from kivy.uix.textinput import TextInput +from kivy.uix.popup import Popup from kivy.uix.screenmanager import ScreenManager, Screen, RiseInTransition from words import Letters, Dictograph @@ -313,7 +314,7 @@ def update(self, time_passed): elif not _Board._game_over and not _Board.footer.bubble.working\ and not Tile.anims_to_complete: _Board._game_over = True - GameOver(_Board.score) + GameOver() class Bonus(BubbleButton): @@ -327,16 +328,36 @@ def on_touch_move(self, touch): class Level(BoxLayout): pass - - -def GameOver(end_score, name = None): + +test = None +score_list = [] + +def GameOver(): # save score to file only if higher than rest saved - # see if got new high score! - if not name: - name = 'winner!' + # see if got new high score + _Board._highlighted.clear() - score_list = [] - with open('high_scores.txt', 'r') as file: + _Board.manager.transition = RiseInTransition(duration=.5) + _Board.manager.current = 'menu' + + box = BoxLayout() + text_in = TextInput(multiline = False, font_size = 40) + box.add_widget(text_in) + + popup = Popup(title='NEW HIGH SCORE! Enter Your Name') + popup.content = box + popup.size_hint = (None, None) + popup.size=(550, 120) + + text_in.on_text_validate = LastScreen + global test + test = text_in + test.popup = popup + + + # high score file must end with newline + try: + file = open('high_scores.txt', 'r') for line in file: line = line.strip().split(",") print("line:", line) @@ -346,30 +367,45 @@ def GameOver(end_score, name = None): # if blank line do nothing continue file.close() - - try: - score_list[-1][0] - except IndexError: - # if list empty append dummy zero record + print("DEBUG") + except: + # dummy score emtry if file was empty score_list.append((0, 'Falon')) + + if int(score_list[-1][0]) < _Board.score: + popup.open() + else: + LastScreen() + + +def LastScreen(): + print(test.text) + + player = test.text + + end_score = _Board.score + test.popup.dismiss() + + if int(score_list[-1][0]) < end_score: # reopen file for appending this time file_append = open('high_scores.txt', 'a') # new high score!!! # PROMPT USER FOR NAME AND SAVE AS name - score_list.append((end_score, name)) - + score_list.append((end_score, player)) file_append.write(str(end_score)) file_append.write(", ") - file_append.write(name) + file_append.write(player) + file_append.write("\n") file_append.close() print(score_list) + - Records = _Board.manager.current_screen - _Board.manager.transition = RiseInTransition(duration=.5) - _Board.manager.current = 'menu' + + + _Board.manager.current_screen.champ_score = int(score_list[-1][0]) _Board.manager.current_screen.your_score = end_score _Board.manager.current_screen.champion = score_list[-1][1] diff --git a/high_scores.txt b/high_scores.txt index 9a85e9a..486e6c5 100644 --- a/high_scores.txt +++ b/high_scores.txt @@ -1 +1,3 @@ -35, winner! \ No newline at end of file +35, winner! + +148, winner! \ No newline at end of file diff --git a/tile.py b/tile.py index 97afcef..7d733bb 100644 --- a/tile.py +++ b/tile.py @@ -191,7 +191,7 @@ def done_bubble(self, instance): _Board.score += _Board.value - if _Board.score >= 30 and _Board.level == 0: + if _Board.score >= 4 and _Board.level == 0: _Board.level = 1 _Board.progress.max = 100