예제 #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)
예제 #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)
예제 #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)
예제 #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)
예제 #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)
예제 #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)
예제 #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)
예제 #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')
예제 #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)
예제 #10
0
 def test_ItemList__len__(self):
     i_l = ItemList('Burgundy Paris Burgundy',
                    self.game.variant.map.provinces)
     self.assertEqual(len(i_l), 3)
예제 #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')