original_docstring: Check and update game variables.
docstring: Check and update game variables.
docstring_tokens: Check and update game variables .
code: def update_game_variables(self):
          """Check and update game variables."""
          # read game variables
          new_v = {k: self.game.get_game_variable(v) for k, v in game_variables}
          assert all(v.is_integer() or k[-2:] in ['_x', '_y', '_z'] for k, v in new_v.items())   ## except postions(floats) all other game variables are ints.
          new_v = {k: (int(v) if v.is_integer() else float(v)) for k, v in new_v.items()}
          health = new_v['health']
          armor = new_v['armor']
          sel_weapon = new_v['sel_weapon']
          sel_ammo = new_v['sel_ammo']
          bullets = new_v['bullets']
          shells = new_v['shells']
          rockets = new_v['rockets']
          cells = new_v['cells']
          fist = new_v['fist']
          pistol = new_v['pistol']
          shotgun = new_v['shotgun']
          chaingun = new_v['chaingun']
          rocketlauncher = new_v['rocketlauncher']
          plasmarifle = new_v['plasmarifle']
          bfg9000 = new_v['bfg9000']
  
          # check game variables
          if sel_weapon == -1:
              logger.warning("SELECTED WEAPON is -1!")
              new_v['sel_weapon'] = 1
              sel_weapon = 1
          if sel_ammo == -1:
              logger.warning("SELECTED AMMO is -1!")
              new_v['sel_ammo'] = 0
              sel_ammo = 0
          assert sel_weapon in range(1, 8), sel_weapon
          assert sel_ammo >= 0, sel_ammo
          assert all(x in [0, 1] for x in [fist, pistol, shotgun, chaingun,
                                           rocketlauncher, plasmarifle, bfg9000])
          assert 0 <= health <= 200 or health < 0 and self.game.is_player_dead()
          assert 0 <= armor <= 200, (health, armor)
          assert 0 <= bullets <= 200 and 0 <= shells <= 50
          assert 0 <= rockets <= 50 and 0 <= cells <= 300
  
          # fist
          if sel_weapon == 1:
              assert sel_ammo == 0
          # pistol
          elif sel_weapon == 2:
              assert pistol and sel_ammo == bullets
          # shotgun
          elif sel_weapon == 3:
              assert shotgun and sel_ammo == shells
          # chaingun
          elif sel_weapon == 4:
              assert chaingun and sel_ammo == bullets
          # rocket launcher
          elif sel_weapon == 5:
              assert rocketlauncher and sel_ammo == rockets
          # plasma rifle
          elif sel_weapon == 6:
              assert plasmarifle and sel_ammo == cells
          # BFG9000
          elif sel_weapon == 7:
              assert bfg9000 and sel_ammo == cells
  
          # update actor properties
          self.prev_properties = self.properties
          self.properties = new_v
code_tokens: def update_game_variables ( self ) : new_v = { k : self . game . get_game_variable ( v ) for k , v in game_variables } assert all ( v . is_integer ( ) or k [ - 2 : ] in [ '_x' , '_y' , '_z' ] for k , v in new_v . items ( ) ) new_v = { k : ( int ( v ) if v . is_integer ( ) else float ( v ) ) for k , v in new_v . items ( ) } health = new_v [ 'health' ] armor = new_v [ 'armor' ] sel_weapon = new_v [ 'sel_weapon' ] sel_ammo = new_v [ 'sel_ammo' ] bullets = new_v [ 'bullets' ] shells = new_v [ 'shells' ] rockets = new_v [ 'rockets' ] cells = new_v [ 'cells' ] fist = new_v [ 'fist' ] pistol = new_v [ 'pistol' ] shotgun = new_v [ 'shotgun' ] chaingun = new_v [ 'chaingun' ] rocketlauncher = new_v [ 'rocketlauncher' ] plasmarifle = new_v [ 'plasmarifle' ] bfg9000 = new_v [ 'bfg9000' ] if sel_weapon == - 1 : logger . warning ( "SELECTED WEAPON is -1!" ) new_v [ 'sel_weapon' ] = 1 sel_weapon = 1 if sel_ammo == - 1 : logger . warning ( "SELECTED AMMO is -1!" ) new_v [ 'sel_ammo' ] = 0 sel_ammo = 0 assert sel_weapon in range ( 1 , 8 ) , sel_weapon assert sel_ammo >= 0 , sel_ammo assert all ( x in [ 0 , 1 ] for x in [ fist , pistol , shotgun , chaingun , rocketlauncher , plasmarifle , bfg9000 ] ) assert 0 <= health <= 200 or health < 0 and self . game . is_player_dead ( ) assert 0 <= armor <= 200 , ( health , armor ) assert 0 <= bullets <= 200 and 0 <= shells <= 50 assert 0 <= rockets <= 50 and 0 <= cells <= 300 if sel_weapon == 1 : assert sel_ammo == 0 elif sel_weapon == 2 : assert pistol and sel_ammo == bullets elif sel_weapon == 3 : assert shotgun and sel_ammo == shells elif sel_weapon == 4 : assert chaingun and sel_ammo == bullets elif sel_weapon == 5 : assert rocketlauncher and sel_ammo == rockets elif sel_weapon == 6 : assert plasmarifle and sel_ammo == cells elif sel_weapon == 7 : assert bfg9000 and sel_ammo == cells self . prev_properties = self . properties self . properties = new_v
short_docstring: Check and update game variables.
short_docstring_tokens: Check and update game variables .
comment: """Check and update game variables."""$SEP$# read game variables$SEP$## except postions(floats) all other game variables are ints.$SEP$# check game variables$SEP$# fist$SEP$# pistol$SEP$# shotgun$SEP$# chaingun$SEP$# rocket launcher$SEP$# plasma rifle$SEP$# BFG9000$SEP$# update actor properties