Пример #1
0
    def diamondLottery(self,configDict):
        result = ""
        op = ErrorCode.LotteryError.Success
        # 检查冷却时间
        # 检查免费次数
        #

        cdTime = configDict["cdTime"]
        moneyCount = configDict["moneyCount"]
        dropIds = configDict["dropIds"]

        lastTime = self.diamondLastTime
        nowTime = util.getCurrentTime()
        period = nowTime - lastTime
        # 免费抽取
        if period >= cdTime and self.diamondFreeTimes < configDict["freeTime"] :

            self.diamondFreeTimes = self.diamondFreeTimes + 1

            self.diamondLastTime = nowTime

            for key in dropIds:
                result += str(key) + ","

            DEBUG_MSG("diamondLottery ----------" + result)
            return (op, result)
        # 钻石抽取
        if  self.diamond >= moneyCount:
            self.diamond = self.diamond - moneyCount
            for key in dropIds:
                self.putItemInBag(key, 1)
                result += str(key) + ","

            DEBUG_MSG("diamondLottery ----------" + result)
            return (op, result)
Пример #2
0
    def tenLottery(self,configDict):
        result =""
        op = ErrorCode.LotteryError.Success

        moneyCount = configDict["moneyCount"]

        if self.diamond >= moneyCount:
            self.diamond = self.diamond - moneyCount
        else:
            return (ErrorCode.LotteryError.Diamond_not_enough, "")

        count = 10
        dropIds = configDict["dropIds"]
        tenDropIds = configDict["tenDropIds"]
        if self.tenFirstCall == 0:
            count = count -1
            for key in tenDropIds:
                result += str(key) + ","

            self.tenFirstCall = 1


        for i in range(count):
            for key in dropIds:
                self.putItemInBag(key, 1)
                result += str(key) + ","

        DEBUG_MSG("tenLottery ----------" + result)
        return (op, result)
Пример #3
0
    def onClientLottery(self,lotteryType):

        DEBUG_MSG("lotteryType:--------------------------------" + str(lotteryType))
        if lotteryType not in lotteryConfig.lottery.keys():
            DEBUG_MSG("---------------dont have key")
            return

        lonfig = lotteryConfig.lottery[lotteryType]
        if lotteryType == Lottery_Type_Euro:
            result = self.euroLottery(lonfig)
        elif lotteryType == Lottery_Type_Diamond:
            result = self.diamondLottery(lonfig)
        elif lotteryType == Lottery_Type_Ten:
            result = self.tenLottery(lonfig)
        DEBUG_MSG("lotteryResult:-----" + str(result[0])+"----------------------" + str(result[1]))
        self.client.lotteryResult(result[0],result[1])
Пример #4
0
    def euroLottery(self, configDict):
        result = ""
        op = ErrorCode.LotteryError.Success
        # 检查冷却时间
        # 检查免费次数
        #
        cdTime = configDict["cdTime"]
        moneyCount = configDict["moneyCount"]
        dropIds = configDict["dropIds"]

        lastTime = self.euroLastTime
        nowTime = util.getCurrentTime()
        period = nowTime - lastTime

        DEBUG_MSG(" period  " + str(period) + "   lasttime  " + str(lastTime) +
                  "  now  " + str(nowTime))
        # 免费抽取
        if period >= cdTime and self.euroFreeTimes < configDict["freeTime"]:

            self.euroFreeTimes = self.euroFreeTimes + 1

            self.euroLastTime = nowTime
            DEBUG_MSG("-------dropIds len--------" + str(len(dropIds)))
            for key in dropIds:
                result += str(key) + ","
                self.putItemInBag(key, 1)

            DEBUG_MSG("euroLottery----------" + result)
            return (op, result)
        # 欧元抽取
        if self.euro >= moneyCount:
            self.useEuro(moneyCount)

            for key in dropIds:
                result += str(key) + ","
                self.putItemInBag(key, 1)

            DEBUG_MSG("euroLottery----------" + result)
            return (op, result)
        # 钱不够,时间不够(抽卡失败)TODO:
        return (ErrorCode.LotteryError.Fail, result)
Пример #5
0
        def onMailsSaveCB(result, rownum, error):

            if rownum == 1:
                del rowValueMap["to_dbid"]
                KBEngine.globalData["PlayerMgr"].onCmdByDBID(
                    self.databaseID, "recNewMail", rowValueMap)
                # self.recNewMail(mailType, self.name, rowValueMap["time"], title, text, attachment, extern_info)
                # 通知另外一个人
                self.client.onOperateSuc("sendMail")
            else:

                DEBUG_MSG("----------sendMail 茶如失败-------------------------")
Пример #6
0
    def recNewMail(self, mail):
        # mail = {}
        # mail["mail_type"] = mailType
        # mail["title"] = title
        # mail["from_name"] = from_name
        # mail["text"] = text
        # mail["time"] = time
        # mail["attachment"] = attachment
        # mail["state"] = Mails.Mail_State_Not_Open
        # mail["extern_info"] = extern_info

        DEBUG_MSG("recNewMail--------------------" + mail["title"])
        self.mails.append(mail)
Пример #7
0
    def sendMail(self,
                 to_dbid,
                 mailType,
                 title,
                 text,
                 attachment=None,
                 extern_info=None):
        rowValueMap = {}
        rowValueMap["to_dbid"] = to_dbid
        rowValueMap["mail_type"] = mailType
        rowValueMap["title"] = title
        rowValueMap["from_name"] = self.name
        rowValueMap["text"] = text
        rowValueMap["time"] = util.getCurrentTime()
        rowValueMap["attachment"] = attachment
        rowValueMap["state"] = Mails.Mail_State_Not_Open
        rowValueMap["extern_info"] = extern_info

        # TODO:后期修改 self.databaseID
        sql = "insert into tbl_Mails(sm_to_dbid,sm_mail_type,sm_title,sm_from_name,sm_text,sm_time,sm_attachment,sm_state,sm_extern_info) " \
          "select '" + str(self.databaseID) + "','"\
          +str(mailType) +"','"\
          +title+"','"\
          +self.name+"','"\
          +text +"','"\
          +str(util.getCurrentTime())+"','"\
          +attachment +"','"\
          +str(Mails.Mail_State_Not_Open)+"','"\
          +extern_info + \
          "' from dual where exists (select * from tbl_Avatar where id = " + str(to_dbid) +")"

        DEBUG_MSG("sendMail             " + sql)

        @util.dbDeco
        def onMailsSaveCB(result, rownum, error):

            if rownum == 1:
                del rowValueMap["to_dbid"]
                KBEngine.globalData["PlayerMgr"].onCmdByDBID(
                    self.databaseID, "recNewMail", rowValueMap)
                # self.recNewMail(mailType, self.name, rowValueMap["time"], title, text, attachment, extern_info)
                # 通知另外一个人
                self.client.onOperateSuc("sendMail")
            else:

                DEBUG_MSG("----------sendMail 茶如失败-------------------------")

        KBEngine.executeRawDatabaseCommand(sql, onMailsSaveCB)
Пример #8
0
    def onTimer(self, tid, userArg):
        # ERROR_MSG("ontimer" + str(userArg))
        if userArg == TimerDefine.Timer_body_power_reset_buy_times:
            self.bodyPowerBuyTimes = 0

        # 每N分钟体力恢复1点
        if TimerDefine.Timer_body_power_recover == userArg:

            if self.bodyPower < bodyPowerConfig.bodyPowerConfig[1]["maxPower"]:

                DEBUG_MSG("----------------  Timer_body_power_recover  -----------------------")
                self.bodyPower = self.bodyPower + 1

        if TimerDefine.Timer_reset_buy_euro == userArg:
            self.euroBuyTimes = 0
        pass
Пример #9
0
        def onMailsLoadCB(result, rownum, error):
            """
            加载邮件
            """
            if result is None:
                return

            for i in range(len(result)):
                mail = {}
                mail["mail_type"] = int(result[i][3])
                mail["title"] = result[i][4].decode('utf-8')
                mail["from_name"] = result[i][5].decode('utf-8')
                mail["text"] = result[i][6].decode('utf-8')
                mail["time"] = int(result[i][7])
                mail["attachment"] = result[i][8].decode('utf-8')
                mail["state"] = int(result[i][9])
                mail["extern_info"] = result[i][10].decode('utf-8')

                self.mails.insert(i, mail)

            DEBUG_MSG("mails load complete!")
Пример #10
0
 def sayHello(self):
     DEBUG_MSG(" wo shi hello")