Esempio n. 1
0
    def add(self, oid):
        assert oid in HORSE

        embedded_horse = MongoEmbeddedHorse()
        embedded_horse.oid = oid
        embedded_horse.attack = 0
        embedded_horse.defense = 0
        embedded_horse.hp = 0

        new_id = id_generator('equipment')[0]

        self.mongo_horse.horses[str(new_id)] = embedded_horse
        self.mongo_horse.save()

        hobj = OneHorse(
            new_id,
            embedded_horse.oid,
            embedded_horse.attack,
            embedded_horse.defense,
            embedded_horse.hp
        )

        msg = HorsesAddNotify()
        msg_h = msg.horses.add()
        msg_h.MergeFrom(hobj.make_msg())
        publish_to_char(self.char_id, pack_msg(msg))
Esempio n. 2
0
 def to_mongo_record(self):
     m = MongoEmbeddedHorse()
     m.oid = self.oid
     m.attack = self.attack
     m.defense = self.defense
     m.hp = self.hp
     return m
Esempio n. 3
0
 def to_mongo_record(self):
     m = MongoEmbeddedHorse()
     m.oid = self.oid
     m.attack = self.attack
     m.defense = self.defense
     m.hp = self.hp
     return m
Esempio n. 4
0
    def add(self, oid):
        assert oid in HORSE

        embedded_horse = MongoEmbeddedHorse()
        embedded_horse.oid = oid
        embedded_horse.attack = 0
        embedded_horse.defense = 0
        embedded_horse.hp = 0

        new_id = id_generator('equipment')[0]

        self.mongo_horse.horses[str(new_id)] = embedded_horse
        self.mongo_horse.save()

        hobj = OneHorse(new_id, embedded_horse.oid, embedded_horse.attack,
                        embedded_horse.defense, embedded_horse.hp)

        msg = HorsesAddNotify()
        msg_h = msg.horses.add()
        msg_h.MergeFrom(hobj.make_msg())
        publish_to_char(self.char_id, pack_msg(msg))