Example #1
0
    def loadItems(self):

        # load effects
        d = yield self.dbo.runQuery("SELECT * FROM " + self.config.prefix + "effect;")
        with G.lock:
            for s in d:
                G.effects[int(s[0])] = effect(s)
        logging.info("db; effects; loaded; %i", len(G.effects))

        # load spells
        d = yield self.dbo.runQuery("SELECT * FROM " + self.config.prefix + "spell;")
        with G.lock:
            for s in d:
                G.spells[int(s[0])] = spell(s)
        logging.info("db; spells; loaded; %i", len(G.spells))

        # load items
        d = yield self.dbo.runQuery("SELECT * FROM " + self.config.prefix + "item;")
        with G.lock:
            for r in d:
                G.items[r[0]] = item(r)
        logging.info("db; items; loaded; %i", len(G.items))

        # also load items in play
        d = yield self.dbo.runQuery("SELECT * FROM " + self.config.prefix + "item_inplay;")
        with G.lock:
            for r in d:
                loc = (r[2], r[3], r[4]) if r[2] else None
                ci = item_avatar(G.items[r[1]], loc, r[7] if r[7] else None)
                ci.uid = int(r[0])
                ci.player = r[5]
                ci.slot = r[6]
                ci.shop = r[9] if r[9] else None
                G.item_live[ci.uid] = ci
        logging.info("db; items_live; loaded; %i", len(G.item_live))
Example #2
0
 def handle_GIVEITEM(self, action, data, id):
     ci = item_avatar(G.items[int(data)], None, G.round, self.char.id)
     #save the item
     q, uid = yield G.db.runOperation("""INSERT INTO """+ SQLConfig.prefix + """item_inplay
                   (item_inplay_item_id, 
                    item_inplay_char_id) 
                    VALUES (%s, %s)""", \
                  (ci.i.id, \
                   ci.player))
     ci.uid = int(uid)
     G.item_live[ci.uid] = ci