示例#1
0
 def check_state(self):
     game = storage.get_value("game")
     if not game:  # User never played tort.ooo before
         self.about()
     elif self.countdown == 0:  # User already played today
         self.state = State.GAME_OVER
         self.game_over()
     storage.set_value("game", self.game)
示例#2
0
    def update_time(self):
        if self.state == State.PLAY:
            self.countdown -= 1
            storage.set_value("countdown", self.countdown)
            self.timer.textContent = count2sec(self.countdown)

        if self.countdown == 0 and self.state == State.PLAY:
            self.game_over()
示例#3
0
 def update_score(self, length):
     idx = min(8, length) - 3
     keys = ["w3", "w4", "w5", "w6", "w7", "w8"]
     scores = [1, 1, 2, 3, 5, 11]
     self.score += scores[idx]
     storage.set_value("score", self.score)
     self.word_counts[idx] += 1
     storage.increment_key(keys[idx])
     self.score_label.textContent = f"PONTOS: {self.score}"
     return scores[idx]
示例#4
0
 def init_game(self):
     self.game = get_day_game()
     self.letters = get_letters(16, random_seed=self.game)
     self.act_letters = [False for _ in range(16)]
     self.last_pos = None
     self.played = False
     self.state = State.PLAY
     game = storage.get_value("game")
     if game == self.game: # Game in progress
         self.score = storage.get_value("score")
         self.countdown = storage.get_value("countdown")
         self.guesses = storage.get_guesses()
         self.word_counts = storage.get_word_counts()
         self.area_content = storage.get_area()
     else: # A new game
         self.score = 0
         storage.set_value("score", self.score)
         self.countdown = 180
         storage.set_value("countdown", self.countdown)
         self.guesses = []
         storage.set_guesses(self.guesses)
         self.word_counts = [0 for i in range(6)]
         storage.set_word_counts(self.word_counts)
         self.area_content = ""
         storage.set_value("area", self.area_content)
示例#5
0
    def init_game(self):
        self.game = get_day_game()
        self.letters = get_letters(16, random_seed=self.game)
        self.act_letters = [False for _ in range(16)]
        self.last_pos = None
        self.played = False
        self.state = State.PLAY

        self.score = 0
        storage.set_value("score", self.score)
        self.countdown = 300
        storage.set_value("countdown", self.countdown)
        self.guesses = []
        storage.set_guesses(self.guesses)
        self.word_counts = [0 for i in range(6)]
        storage.set_word_counts(self.word_counts)
        self.area_content = ""
        storage.set_value("area", self.area_content)
示例#6
0
 def update_area(self, word, s):
     self.area_content += f"{word}-{s} "
     self.area.textContent = self.area_content
     storage.set_value("area", self.area_content)