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))
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))
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)
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)
def create_elements(self, elements, pos=None): self.elements.extend(Universe.create_elements(self.space, elements, self.batch, pos))
def init_elements(self): self.elements = Universe.create_elements(self.space, self.cml.molecules, self.batch)
def create_elements(self, elements, pos=None): self.elements.extend( Universe.create_elements(self.space, elements, self.batch, pos))