changeset 192:5e84dfd153ab

Use the right “random” item drop function.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Thu, 27 Oct 2011 15:17:21 -0700
parents d2b58a26c908
children 9f58e2a6e950
files pytouhou/game/game.py pytouhou/vm/eclrunner.py
diffstat 2 files changed, 10 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/pytouhou/game/game.py
+++ b/pytouhou/game/game.py
@@ -48,6 +48,9 @@ class Game(object):
         self.difficulty = difficulty
         self.boss = None
         self.spellcard = None
+        self.deaths_count = 0
+        self.next_bonus = 0
+        self.bonus_list = [0,0,1,0,1,0,0,1,1,1,0,0,0,1,1,0,1,0,1,0,1,0,1,0,1,0,0,1,1,1,0,2]
         self.prng = prng or Random()
         self.frame = 0
 
--- a/pytouhou/vm/eclrunner.py
+++ b/pytouhou/vm/eclrunner.py
@@ -132,8 +132,13 @@ class ECLRunner(object):
                     enm.drop_particles(7, 0)
                     self._game.drop_bonus(enm.x, enm.y, enm._bonus_dropped)
                 elif enm._bonus_dropped == -1:
-                    enm.drop_particles(10, 0)
-                    self._game.drop_bonus(enm.x, enm.y, self._game.prng.rand_uint16() % 2) #TODO: find the formula in the binary. Can be big power sometimes.
+                    if self._game.deaths_count % 3:
+                        enm.drop_particles(10, 0)
+                        self._game.drop_bonus(enm.x, enm.y, self._game.bonus_list[self._game.next_bonus])
+                        self._game.next_bonus = (self._game.next_bonus + 1) % 32
+                    else:
+                        enm.drop_particles(4, 0)
+                    self._game.deaths_count += 1
                 else:
                     enm.drop_particles(4, 0)