Example #1
0
 def addIncTiLi(self, count=1):
     hasCount = self.playerData.get("tl", 0)
     self.mongo_obj.update({"openId": self.openId},
                           {"$set": {
                               "tl": hasCount + count
                           }})
     ftlog.info(self.openId, count)
Example #2
0
 def addItem(self, item, count):
     hasCount = self.bag.get(item, 0)
     self.mongo_obj.update({"openId": self.openId},
                           {"$set": {
                               "bag.%s" % item: hasCount + count
                           }})
     ftlog.info(self.openId, item, count)
Example #3
0
 def useItem(self, id, count):
     hasCount = self.bag.get(id, 0)
     if hasCount < count:
         return False
     else:
         self.addItem(id, -count)
         ftlog.info(self.openId, id, count)
         return True
Example #4
0
    def useItem(self, openId, item, count):
        res = self.mongo.find_one({"openId": openId}, {"bag.%s" % item: 1})
        if res:
            hasCount = res.get("bag", {}).get(item, 0)
            if int(hasCount) < count:
                return False
            else:
                self.mongo.update({"openId": openId}, )

                ftlog.info(openId, item, count)
        else:
            return False
Example #5
0
def unMD5(data):
    import _md5
    s = ''
    pw = "dasfqdasfafa1e32"  # 秘钥
    if 'time' not in data:
        ftlog.info("status time error")
        return False
    if isinstance(data['time'],
                  int) and 0 <= int(time.time()) - data['time'] <= 2:
        keys = list(data.keys())
        keys.sort()
        for k in keys:
            if k == "code":
                continue
            s += k + str(data[k])
        s += pw
        if data["code"] == _md5.md5(s.encode()).hexdigest():
            return True
        else:
            ftlog.info("status code error")
    return False