示例#1
0
 def test_udlr(self):
     for i in self.udlr.keys():
         n = [[10, [30, 30], i]]
         n_pos = [30, 30]
         a = Board(100, n, self.ts1b)
         for jj in range(0, 10):
             if jj == 9:
                 self.assertEqual(a.get_hit(n_pos, "a"), "SUNK")
             else:
                 self.assertEqual(a.get_hit(n_pos, "a"), "HIT")
             n_pos[0] += self.udlr[i][0]
             n_pos[1] += self.udlr[i][1]
         self.assertEqual(a.get_hit(n_pos, "a"), "NOT HIT")
示例#2
0
 def test_ship_gets_removed(self):
     a = Board(100, deepcopy(self.ts2a), self.ts1b)
     for i in range(5, 1, -1):
         self.assertEqual(a.get_hit([i, 5], "a"), "HIT")
     self.assertEqual(a.get_hit([1, 5], "a"), "SUNK")
     self.assertEqual(len(a.ships["a"]), 0)
示例#3
0
 def test_hit_remove(self):
     a = Board(100, deepcopy(self.ts2a), self.ts1b)
     self.assertEqual(a.get_hit([5, 5], "a"), "HIT")
     self.assertEqual(a.get_hit([5, 5], "a"), "NOT HIT")