changeset 574:94229756abd9

Give extra lives to the player once she has reached a certain score, and increment the default score on continue.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Sat, 26 Jul 2014 13:07:26 +0200
parents 4233c1c01d90
children e4c9eafab6d0
files pytouhou/game/game.pyx pytouhou/game/player.pyx
diffstat 2 files changed, 10 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/pytouhou/game/game.pyx
+++ b/pytouhou/game/game.pyx
@@ -360,10 +360,17 @@ cdef class Game:
         for player, keystate in zip(self.players, keystates):
             player.update(keystate) #TODO: differentiate keystates (multiplayer mode)
 
+            old_effective_score = player.effective_score
             #XXX: Why 78910? Is it really the right value?
-            player.effective_score = min(player.effective_score + 78910,
+            player.effective_score = min(old_effective_score + 78910,
                                          player.score)
-            #TODO: give extra lives to the player
+            if self.stage < 7:
+                for i in [10000000, 20000000, 40000000, 60000000]:
+                    if player.effective_score >= i and old_effective_score < i:
+                        if player.lives < 8:
+                            player.lives += 1
+                        self.modify_difficulty(+2)
+                        player.play_sound('extend')
 
 
     cdef void update_effects(self):
--- a/pytouhou/game/player.pyx
+++ b/pytouhou/game/player.pyx
@@ -262,7 +262,7 @@ cdef class Player(Element):
                         self._game.drop_bonus(self.x, self.y, 4, player=self,
                                               end_pos=(self._game.prng.rand_double() * 288 + 48,
                                                        self._game.prng.rand_double() * 192 - 64))
-                    self.score = 0
+                    self.score = self.continues_used if self.continues_used <= 9 else 9
                     self.effective_score = 0
                     self.lives = 2 #TODO: use the right default.
                     self.bombs = 3 #TODO: use the right default.