Пример #1
0
 def test_save_read_void(self):
     """ test save 0"""
     my_state = state.StateList()
     my_state.save("/tmp/state.txt")
     my_state = state.StateList("/tmp/state.txt")
     logger.info("%s" % my_state.current)
     self.assertEqual(my_state.current, [])
Пример #2
0
 def test_save_read_1(self):
     """ test save 1"""
     my_state = state.StateList()
     my_state.current.append(state.LevelState.Instantiated)
     my_state.save("/tmp/state.txt")
     my_state = state.StateList("/tmp/state.txt")
     logger.info("%s" % my_state.current)
     self.assertEqual(my_state.current, [state.LevelState.Instantiated])
Пример #3
0
 def test_append_check(self):
     my_state = state.StateList()
     self.assertFalse(my_state.has_state(state.LevelState.Instantiated))
     my_state.add_state(state.LevelState.Instantiated)
     self.assertTrue(my_state.has_state(state.LevelState.Instantiated))
     self.assertFalse(my_state.has_state(state.LevelState.Personalized))
     my_state.add_state(state.LevelState.Personalized)
     self.assertTrue(my_state.has_state(state.LevelState.Instantiated))
     self.assertTrue(my_state.has_state(state.LevelState.Personalized))
Пример #4
0
 def load(self, directory, load_state):
     self.directory = directory
     self.state = state.StateList(directory + "/state.txt")
     logger.info("Saved states are: %s" % self.state)
     if not self.state.has_state(load_state):
         raise Exception("Level has no saved state %s" % load_state)
     logger.info(self.status_to_filename[load_state])
     obj = json_helper.load_and_validate_json(
         directory + "/" + self.status_to_filename[load_state],
         "file_rooms_logic.json",
         decode_hook=decode_level(directory, self.status, self.selector))
     self.status = load_state
     self.values = DefaultMunch.fromDict(obj)
     self.structure_check_coherency()
Пример #5
0
 def read_state_list(self, directory):
     return state.StateList(directory + "/state.txt")
Пример #6
0
    def __init__(self, _selector):

        self.status = state.LevelState.New
        self.selector = _selector
        self.state = state.StateList()
Пример #7
0
 def test_init_void(self):
     """ test void init"""
     my_state = state.StateList()
     self.assertEqual(my_state.current, [])