예제 #1
0
파일: world.py 프로젝트: nikitaosyak/ld32
    def deploy_bomb(self, at_location):
        # pass
        cell = self._board[at_location]
        for i in range(-1, 2):
            for j in range(-1, 2):
                if i == 0 and j == 0:
                    continue
                target_x = cell.t_x + i
                target_y = cell.t_y + j

                if target_x < 0:
                    target_x = self._size_x-1
                if target_x >= self._size_x:
                    target_x = 0
                if target_y < 0:
                    target_y = self._size_y-1
                if target_y >= self._size_y:
                    target_y = 0

                n = self.temp[target_x][target_y]
                self._board[n.idx].reset()

        for u_id in self._users:
            u = self._users[u_id]
            for s in u.seeds:
                if s.location == at_location:
                    s.damage(1)
                    if s.is_dead():
                        u.remove_seed(at_location)
                        d = SeedDestroyed()
                        d.location = at_location
                        self.broadcast(d.encode_self())
                    break
예제 #2
0
    def __init__(self, owner_id, location):
        self.owner_id = owner_id
        self.location = location
        self.health = 3
        self.configuration = 0

        self.new_cmd = NewSeed()
        self.new_cmd.location = location
        self.new_cmd.owner = owner_id
        self.new_cmd = self.new_cmd.encode_self()

        self.destr_cmd = SeedDestroyed()
        self.destr_cmd.location = location
        self.destr_cmd = self.destr_cmd.encode_self()

        self.pento = [0, -1,
                      1, -1,
                      -1, 0,
                      0, 0,
                      0, 1]

        self.glider = [1, -1,
                       -1, 0,
                       1, 0,
                       0, 1,
                       1, 1]

        self.s_counter = 2