Exemplo n.º 1
0
 def load_numbers_wrapper(*args, **kwargs):
     obj = args[0]
     try:
         obj.numbers
     except AttributeError:
         obj.numbers = ItemList(obj.string, range(10))
     return func(*args, **kwargs)
Exemplo n.º 2
0
 def load_powers_wrapper(*args, **kwargs):
     obj = args[0]
     try:
         obj.powers
     except AttributeError:
         obj.powers = ItemList(obj.string, obj.game.powers)
     return func(*args, **kwargs)
Exemplo n.º 3
0
 def load_forces_wrapper(*args, **kwargs):
     obj = args[0]
     try:
         obj.forces
     except AttributeError:
         obj.forces = ItemList(obj.string, obj.game.forces)
     return func(*args, **kwargs)
Exemplo n.º 4
0
 def test_ItemList_pos(self):
     i_l = ItemList('Burgundy Paris Burgundy',
                    self.game.variant.map.provinces)   
     self.assertEqual(i_l.pos(1), 9)
     i_l = ItemList('Burgundy',
                    self.game.variant.map.provinces)
     self.assertEqual(i_l.pos(1, require=False), None)
     with self.assertRaises(OrderInputError):
         i_l.loc(1)
Exemplo n.º 5
0
 def test_ItemList_first(self):
     i_l = ItemList('Bur Par Bur', ['Par', 'Bur', 'Mar'])   
     self.assertEqual(i_l.first(3), 'Par')
     self.assertEqual(i_l.first(6), 'Bur')
     self.assertEqual(i_l.first(after=1, before=2), None)
     i_l = ItemList('  ', ['Par', 'Bur', 'Mar'])
     self.assertEqual(i_l.first(after=1, before=5), None)
Exemplo n.º 6
0
 def load_provinces_wrapper(*args, **kwargs):
     obj = args[0]
     try:
         obj.provinces
     except AttributeError:
         obj.provinces = ItemList(obj.string,
                                  obj.map.provinces,
                                  first=True)
     return func(*args, **kwargs)
Exemplo n.º 7
0
 def load_specifiers_wrapper(*args, **kwargs):
     obj = args[0]
     try:
         obj.specifiers
     except AttributeError:
         if obj.game.season.phase == 'Diplomacy':
             specifiers = obj.unit.specifiers
         elif obj.game.season.phase == 'Retreats':
             specifiers = obj.previous.unit.specifiers
         else:
             specifiers = obj.forces.loc(0).specifiers
     obj.specifiers = ItemList(obj.string, specifiers)
     return func(*args, **kwargs)
Exemplo n.º 8
0
 def test_ItemList_getitme_(self):
     i_l = ItemList('Burgundy Paris Burgundy',
                    self.game.variant.map.provinces)   
     self.assertEqual(i_l[0].name, 'Burgundy')
     self.assertEqual(i_l[1].name, 'Paris')
Exemplo n.º 9
0
 def test_ItelList_pos__negative_entry_(self):
     i_l = ItemList('A Paris move to Burgundy',
                    self.game.variant.map.provinces)  
     self.assertEqual(i_l.pos(-1), 16)
Exemplo n.º 10
0
 def test_ItemList__len__(self):
     i_l = ItemList('Burgundy Paris Burgundy',
                    self.game.variant.map.provinces)
     self.assertEqual(len(i_l), 3)
Exemplo n.º 11
0
 def test_ItemList__str__(self):
     i_l = ItemList('Burgundy Paris Burgundy',
                    self.game.variant.map.provinces)
     self.assertEqual(str(i_l), 'Burgundy at 0\nParis at 9\nBurgundy at 15')