Exemple #1
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
Exemple #2
0
    def deploy_seed(self, user_id, at_location):
        if at_location < 0:
            return
        if at_location > len(self._board):
            return

        for u_id in self._users:
            u = self._users[u_id]
            for s in u.seeds:
                if s.location == at_location:
                    return

        self._users[user_id].add_seed(at_location)
        new_seed = NewSeed()
        new_seed.location = at_location
        new_seed.owner = user_id
        self.broadcast(new_seed.encode_self())