Updating scoring

This commit is contained in:
Alex Yatskov 2014-05-20 08:32:11 +09:00
parent 8267e4168d
commit c18693a9e7

View File

@ -191,6 +191,8 @@ class Game:
lines_per_level = 10 lines_per_level = 10
base_speed = 800 base_speed = 800
speed_multiplier = 2 speed_multiplier = 2
soft_drop_bonus = 1
hard_drop_bonus = 2
def __init__(self): def __init__(self):
font_path = pygame.font.get_default_font() font_path = pygame.font.get_default_font()
@ -308,9 +310,8 @@ class Game:
lines_cleared = self.board.settle() lines_cleared = self.board.settle()
if lines_cleared > 0: if lines_cleared > 0:
self.score += (self.current_level() + 1) * self.line_multipliers[lines_cleared - 1] self.update_score((self.current_level() + 1) * self.line_multipliers[lines_cleared - 1])
self.lines_cleared += lines_cleared self.lines_cleared += lines_cleared
self.scoreboard_dirty = True
self.tetrad = self.tetrad_next.centered(self.board.grid_dims[0]) self.tetrad = self.tetrad_next.centered(self.board.grid_dims[0])
self.tetrad_next = Tetrad.random() self.tetrad_next = Tetrad.random()
@ -334,6 +335,7 @@ class Game:
def move_down(self): def move_down(self):
if self.active: if self.active:
self.update_score(self.soft_drop_bonus)
self.lower_tetrad() self.lower_tetrad()
@ -345,7 +347,7 @@ class Game:
def drop(self): def drop(self):
if self.active: if self.active:
while self.lower_tetrad(): while self.lower_tetrad():
pass self.update_score(self.hard_drop_bonus)
def current_level(self): def current_level(self):
@ -356,6 +358,12 @@ class Game:
return self.base_speed - self.current_level() * self.speed_multiplier return self.base_speed - self.current_level() * self.speed_multiplier
def update_score(self, value):
if value > 0:
self.score += value
self.scoreboard_dirty = True
# #
# Engine # Engine
# #