diff pytouhou/game/game.py @ 188:008f90ebfdc0

Fix replay handling and add support for encrypted replays
author Thibaut Girka <thib@sitedethib.com>
date Thu, 27 Oct 2011 14:24:07 +0200
parents 54eb6b254b7b
children dbe6b7b2d3fc
line wrap: on
line diff
--- a/pytouhou/game/game.py
+++ b/pytouhou/game/game.py
@@ -27,7 +27,7 @@ from pytouhou.game.effect import Particl
 
 class Game(object):
     def __init__(self, resource_loader, player_states, stage, rank, difficulty,
-                 bullet_types, item_types, characters, nb_bullets_max=None):
+                 bullet_types, item_types, characters, prng=None, nb_bullets_max=None):
         self.resource_loader = resource_loader
 
         self.nb_bullets_max = nb_bullets_max
@@ -48,7 +48,7 @@ class Game(object):
         self.difficulty = difficulty
         self.boss = None
         self.spellcard = None
-        self.prng = Random()
+        self.prng = prng or Random()
         self.frame = 0
 
         self.enm_anm_wrapper = resource_loader.get_anm_wrapper2(('stg%denm.anm' % stage,
@@ -57,6 +57,11 @@ class Game(object):
         ecl = resource_loader.get_ecl('ecldata%d.ecl' % stage)
         self.ecl_runner = ECLMainRunner(ecl, self)
 
+        #TODO: The game calls it two times. What for?
+        # See 102h.exe@0x413220 if you think you're brave enough.
+        self.prng.rand_uint16()
+        self.prng.rand_uint16()
+
 
     def drop_bonus(self, x, y, _type, end_pos=None):
         player = self.players[0] #TODO