Пример #1
0
	def createPenguinIgloo(self, _id):
		igloo = self.penguin.engine.iglooCrumbs.getPenguinIgloo(_id)
		if igloo is not None:
			returnValue(igloo)

		exists = yield self.penguin.db_getPenguin('id = ?', _id)
		if exists is None:
			returnValue(None)

		igloo = exists.igloo
		if igloo == 0:
			igloo = yield Igloo(owner = exists.id, location = 1, furniture = '', likes = '[]').save()
			exists.igloo = igloo.id
			exists.save()
		else:
			igloo = yield Igloo.find(igloo)


		iglooRoom = IglooRoom(self.penguin.engine.roomHandler, (1000 + exists.id), '{} igloo'.format(exists.id), "{}'s Igloo".format(exists.nickname), 100, False, False, None)
		iglooRoom.owner = int(exists.id)
		iglooRoom.opened = not bool(igloo.locked)
		iglooRoom._id = int(igloo.id)

		self.penguin.engine.iglooCrumbs.penguinIgloos.append(iglooRoom)

		returnValue(iglooRoom)
Пример #2
0
    def initPenguinIglooRoom(self, penguin_id):
        penguin = (
            yield Penguin.find(penguin_id)
        ) if penguin_id != self.penguin['id'] else self.penguin.dbpenguin
        if penguin is None:
            returnValue(None)

        iglooRoom = self.penguin.engine.iglooCrumbs.getPenguinIgloo(penguin_id)

        currentIgloo = int(penguin.igloo)
        igloo = yield Igloo.find(currentIgloo)
        if igloo is None:
            igloo = Igloo(penguin_id=penguin_id)
            yield igloo.save()

            currentIgloo = penguin.igloo = int(igloo.id)
            yield penguin.save()
            yield igloo.refresh()

        if iglooRoom is None:
            iglooRoom = IglooRoom(self.penguin.engine.roomHandler,
                                  (1000 + penguin_id),
                                  '{} igloo'.format(penguin_id),
                                  "{}'s Igloo".format(penguin.nickname), 100,
                                  False, False, None)

            self.penguin.engine.iglooCrumbs.penguinIgloos.append(iglooRoom)
            self.penguin.engine.roomHandler.rooms.append(iglooRoom)

        iglooRoom.owner = int(penguin_id)
        iglooRoom.opened = not bool(igloo.locked)
        iglooRoom._id = int(igloo.id)

        returnValue(iglooRoom)
Пример #3
0
    def loadCurrentIgloo(self):
        if self.find(self.penguin.dbpenguin.igloo) is None:
            igloo = yield Igloo(owner=self.penguin['id'],
                                location=1,
                                furniture='',
                                likes='[]').save()
            yield igloo.refresh()
            self.penguin.dbpenguin.igloo = igloo.id
            self.penguin.dbpenguin.save()

        else:
            igloo = self.find(self.penguin.dbpenguin.igloo)

        self.currentIgloo = igloo

        iglooRoom = self.penguin.engine.iglooCrumbs.getPenguinIgloo(
            self.penguin['id'])
        if iglooRoom == None:
            iglooRoom = IglooRoom(
                self.penguin, (1000 + self.penguin['id']),
                '{} igloo'.format(self.penguin['id']),
                "{}'s Igloo".format(self.penguin['nickname']), 100, False,
                False, None)
            iglooRoom.owner = int(self.penguin['id'])

            iglooRoom.opened = not bool(self.currentIgloo.locked)
            iglooRoom._id = int(self.currentIgloo.id)

            self.penguin.engine.iglooCrumbs.penguinIgloos.append(iglooRoom)

        self.penguin.penguin.igloo = iglooRoom