Exemple #1
0
 def testDestroyElements(self):
     levels = Levels("data/levels", window=WindowMock())
     l = levels.next_level()
     batch = pyglet.graphics.Batch()
     l.elements.extend(
         Universe.create_elements(l.space, ["O2(g)", "O2(g)", "CH4(g)"],
                                  batch, None))
Exemple #2
0
    def testLevels(self):
        levels = Levels("data/levels", window=WindowMock())
        l = levels.next_level()
        expected = ['H+(g)', 'O(g)', 'O(g)', 'H+(g)', 'P(g)', 'F(g)', 'Al(s)']
        self.assertEqual(l.cml.molecules, expected)
        self.assertEqual(l.cml.victory_condition, ["H2O"])
        self.assertEqual(l.cml.objective, "Create a water molecule")
        self.assertEqual(l.cml.hint, "H + H + O => H2O")
        self.assertEqual(l.victory(), False)
        batch = pyglet.graphics.Batch()
        l.elements.extend(
            Universe.create_elements(l.space, "H2O(g)", batch, None))
        victory_effect = l.hud.horizontal.victory
        victory_effect.put_element(l.elements.pop())
        self.assertEqual(l.victory(), True)

        l = levels.next_level()
        expected = [
            'H+(g)', 'O(g)', 'O(g)', 'H+(g)', 'OH-(aq)', 'CO2(g)', 'CH4(g)'
        ]
        self.assertEqual(l.cml.molecules, expected)
        self.assertEqual(l.cml.victory_condition, ['CO', 'H2', 'H2', 'H2'])
        self.assertEqual(l.cml.objective, "Create a CO and 3 H2 molecules")
        self.assertEqual(l.cml.hint, "H2O + CH4 + Heat => CO + 3H2")
        levels.current_level = 1000
        l = levels.next_level()
        self.assertEqual(l, None)
Exemple #3
0
 def testAllLevels(self):
     levels = Levels("data/levels", window=WindowMock())
     for level in levels.level_iter():
         self.assertIsNotNone(level.cml.objective)
         self.assertEqual(level.victory(), False)
Exemple #4
0
def getLevel1():
    levels = Levels("data/levels", window=WindowMock())
    level1 = levels.next_level()
    return level1
Exemple #5
0
 def start(self):
     pyglet.gl.glClearColor(250/256.0, 250/256.0, 250/256.0, 0)
     self.levels = Levels("data/levels", Config.current.level, window=self)
     self.switch_level()
     pyglet.clock.schedule_interval(self.update, 1/100.0)