コード例 #1
0
ファイル: Aain.py プロジェクト: liuyongsz/fbgServer
def te():
    rowValueMap = {}
    to_dbid = 1
    # TODO: 验证玩家有效性

    mailType = 2
    title = "das"
    from_name = "chong"
    text = "text"
    time = util.getCurrentTime()
    attachment = "sd"
    state = 1
    extern_info = "adsdasd"


    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(to_dbid) + "','"\
          +str(mailType) +"','"\
          +title+"','"\
          +from_name+"','"\
          +text +"','"\
          +str(util.getCurrentTime())+"','"\
          +attachment +"','"\
          +str(state)+"','"\
          +extern_info + \
          "' from dual where exists (select * from tbl_Avatar where id = " + str(to_dbid) +")"
    print(sql)
コード例 #2
0
 def onClientGetCoachList(self):
     period = util.getCurrentTime() - self.coachLastTime
     self.coachLastTime = util.getCurrentTime()
     for item in self.coachList:
         if item["isLock"] == 0:
             continue
         if item["useTime"] < period:
             item["useTime"] = 0
         else:
             item["useTime"] = item["useTime"] - period
     self.client.onGetCoachList(self.coachList)
コード例 #3
0
ファイル: MailsModule.py プロジェクト: liuyongsz/fbgServer
    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)
コード例 #4
0
ファイル: LotteryModule.py プロジェクト: liuyongsz/fbgServer
    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)
    def __postProcessData(self):
        #convert file paths into numpy array by reading the files
        print "Reading the training image files..." + util.getCurrentTime()
        self.trainingDataX = self.__loadImageDataParallely(self.trainingDataX)
        print "Reading the training image files..." + util.getCurrentTime()
        self.testingDataX = self.__loadImageDataParallely(self.testingDataX)

        #convert class lables into one hot encoded
        print "Creating one hot encoded vectors for training labels..." + util.getCurrentTime(
        )
        self.trainingDataY = self.__convertLabelsToOneHotVector(
            self.trainingDataY, self.numClasses)
        print "Creating one hot encoded vectors for testing labels..." + util.getCurrentTime(
        )
        self.testingDataY = self.__convertLabelsToOneHotVector(
            self.testingDataY, self.numClasses)
コード例 #6
0
 def onGetFromLastOutLinesDays(self):
     if len(self.lastTime) == 0:
         return
     hour = self.lastTime.split(",")[0]
     mintue = self.lastTime.split(",")[1]
     second = self.lastTime.split(",")[2]
     offset = 86400 - (int(hour) * 3600 + int(mintue) * 60 + int(second))
     days = 0
     period = util.getCurrentTime() - int(self.logoutTime)
     if period > offset:
         days = 1 + (period - offset) // 86400
     if days > 0:
         for Item in self.gameShopItemList:
             config = gameShopConfig.gameShopConfig[Item["itemID"]]
             Item["limitTimes"] = config["limitTimes"]
         # 购买竞技次数
         self.buyArenaTimes = int(
             vipConfig.VipConfig[self.vipLevel]["buyArenaTimes"])
         # 竞技次数
         self.arenaTimes = int(CommonConfig.CommonConfig[6]["value"])
         self.isPrompt = 0
         self.isCanEncourage = 0
         self.officialReward = 0
         self.buyLinePower = 0
         self.updateforPermissionInfo()
     ERROR_MSG("-------have  " + str(days) + "  days not enter game-------")
     return days
コード例 #7
0
    def onClientWorldChat(self, message):
        # 1、消息超过规定长度
        if self.checkMessageLen(message) is False:
            return

        # 2、等级不足
        level = self.level
        levelLimit = chatConfig.ChatConfig[1]["worldChannelLevelLimit"]
        if level < levelLimit:
            self.client.onChatError(ChatError.Chat_world_level_not_enough)
            return

        # 3、世界频道在CD
        curTime = util.getCurrentTime()
        cd = chatConfig.ChatConfig[1]["worldChannelCD"]
        if curTime - self.worldChanelSendTime < cd:
            self.client.onChatError(ChatError.Chat_world_cd)
            return
        # 4、有脏话
        if self.checkHasBadWords(message) is True:
            return

        messageInfo = self.makeMessageInfo(message)
        KBEngine.globalData["PlayerMgr"].sendWorldChat(self.databaseID,
                                                       messageInfo)
コード例 #8
0
ファイル: main.py プロジェクト: losywee/autoSplitUploadAliImg
def upload_file():
    result = {"result": False, "msg": "上传失败"}
    if request.method == 'POST':
        files = request.files.get('mp4File')
        print(files)
        f = request.files['mp4File']
        # f.filename
        (filepath, ext) = os.path.splitext(f.filename)
        filename = getCurrentTime()
        path = os.path.join(os.path.dirname(__file__), 'upload')
        if not os.path.exists(path):
            os.makedirs(path)
        upload_path = os.path.join(os.path.dirname(__file__), 'upload',
                                   filename + ext)
        f.save(upload_path)

        fileObj = {
            "fileName": f.filename,
            "filePath": upload_path,
            "id": filename
        }
        instance = FileList()
        instance.addFile(fileObj)

        result["result"] = True
        result["msg"] = "上传成功"
        result["path"] = upload_path
        return result
    return result
コード例 #9
0
ファイル: split.py プロジェクト: ylqf/autoSplitUploadAliImg
 def execShell(self, cmd,m3u8):
     keepprinting = Shell(cmd,m3u8) # keepprint will print out one line every 2 seconds
     keepprinting.run_background()
     id=getCurrentTime()
     self.taskMap.update({id: keepprinting})
     # keepprinting.print_output()
     return id
コード例 #10
0
 def makeMessageInfo(self, message):
     messageInfo = {}
     messageInfo[MessageInfoEnum.message] = message
     messageInfo[MessageInfoEnum.photoIndex] = self.photoIndex
     messageInfo[MessageInfoEnum.name] = self.name
     messageInfo[MessageInfoEnum.level] = self.level
     messageInfo[MessageInfoEnum.vipLevel] = self.vipLevel
     messageInfo[MessageInfoEnum.sendTime] = util.getCurrentTime()
     return messageInfo
コード例 #11
0
    def onClientDeath(self):
        """
        KBEngine method.
        entity丢失了客户端实体
        """
        self.addTimer(5, 5, TimerDefine.Time_destroy_avatar)
        self.lastTime = str(datetime.datetime.now().hour) + "," + str(
            datetime.datetime.now().minute) + "," + str(
                datetime.datetime.now().second)

        DEBUG_MSG("Avatar[%i].onClientDeath:" % self.id)
        # 防止正在请求创建cell的同时客户端断开了, 我们延时一段时间来执行销毁cell直到销毁base
        # 这段时间内客户端短连接登录则会激活entity
        # self._destroyTimer = self.addTimer(1, 0, SCDefine.TIMER_TYPE_DESTROY)
        cls = Avatar.__bases__
        for c in cls:
            if hasattr(c, 'onClientDeath'):
                c.onClientDeath(self)

        self.logoutTime = util.getCurrentTime()

        DEBUG_MSG("--------logoutTime   ----------------" +
                  str(self.logoutTime))

        playerInfo = {}

        playerInfo[FriendInfoKey.DBID] = self.databaseID
        playerInfo[FriendInfoKey.photoIndex] = self.photoIndex
        playerInfo[FriendInfoKey.name] = self.name

        playerInfo[FriendInfoKey.level] = self.level
        playerInfo[FriendInfoKey.clubName] = self.club
        playerInfo[FriendInfoKey.fightValue] = self.fightValue
        playerInfo[FriendInfoKey.vipLevel] = self.vipLevel
        playerInfo[FriendInfoKey.onlineState] = self.logoutTime
        playerInfo[FriendInfoKey.formation] = self.formation

        KBEngine.globalData["PlayerMgr"].playerOffline(self.databaseID,
                                                       playerInfo)

        baby = KBEngine.entities.get(self.babyID)
        if baby is not None:
            baby.destroyBaby()

        for id in self.cardIDList:
            card = KBEngine.entities.get(id)
            if card is None:
                continue
            card.destroyCard()

        if hasattr(
                self, "spaceMb"
        ) and self.spaceMb is not None and self.spaceMb.isDestroyed is not True:
            self.spaceMb.destroyClone()

        self.destroySelf()
コード例 #12
0
    def startWork(self, inputM3u8, tempFilePath):

        id = getCurrentTime()
        (fileName, extension) = os.path.splitext(inputM3u8)
        uploadTask = SplitToolMan(
            inputM3u8, fileName + "_out.m3u8",
            tempFilePath)  # keepprint will print out one line every 2 seconds
        uploadTask.runBackground()
        self.taskMap.update({id: uploadTask})
        return id
コード例 #13
0
def touch_web():
    #print "touch the web page"
    load_new_page_info()
    new_data = util.get_file_data(WPINFO_NEW)
    old_data = util.get_file_data(WPINFO_OLD)
    if cmp(new_data, old_data) != 0:
        print util.getCurrentTime() + ": The web page has been updated"
        imglist = get_image_list(new_data)
        for img in imglist:
            if not img.debug: continue  # only download debug version
            log_data = util.get_file_data(DOWNLOADLOG)
            if log_data.find(img.name) == -1:
                print "Begin to download " + img.name
                load_image(img)
            #else:
            #print img.name + " has been downloaded."
    else:
        print util.getCurrentTime() + ": The web page has no updating info"

    print "Waiting for new released image..."
コード例 #14
0
 def applyJoinGuildCB(self, argMap, guild, guildDBID, wasActive):
     playerMB = argMap["playerMB"]
     applyInfo = {
         "dbid": argMap["playerDBID"],
         "playerName": argMap["playerName"],
         "offical": argMap["officalPosition"],
         "level": argMap["playerLevel"],
         "applyTime": util.getCurrentTime(),
         "playerMB": playerMB,
     }
     guild.onCmd("applyJoinGuild", applyInfo)
コード例 #15
0
ファイル: downloader.py プロジェクト: Sgtransporterall/share
def touch_web():
    # print "touch the web page"
    load_new_page_info()
    new_data = util.get_file_data(WPINFO_NEW)
    old_data = util.get_file_data(WPINFO_OLD)
    if cmp(new_data, old_data) != 0:
        print util.getCurrentTime() + ": The web page has been updated"
        imglist = get_image_list(new_data)
        for img in imglist:
            if not img.debug:
                continue  # only download debug version
            log_data = util.get_file_data(DOWNLOADLOG)
            if log_data.find(img.name) == -1:
                print "Begin to download " + img.name
                load_image(img)
                # else:
                # print img.name + " has been downloaded."
    else:
        print util.getCurrentTime() + ": The web page has no updating info"

    print "Waiting for new released image..."
コード例 #16
0
ファイル: Mails.py プロジェクト: hw233/kbengine_fbgServer
    def sendMailToPlayer(self, mailInfo):
        mailType = mailInfo["mail_type"]
        title = mailInfo["title"]
        fromName = mailInfo["from_name"]
        to_dbid = mailInfo["to_dbid"]
        text = mailInfo["text"]
        time = util.getCurrentTime()
        attachment = mailInfo["attachment"]
        state = MailState.Unread
        extern_info = mailInfo["extern_info"]

        sql = util.getInsertSql("tbl_Mails", mailInfo)
コード例 #17
0
    def onOfflineRecoverPower(self):

        current = util.getCurrentTime()
        logout = self.logoutTime
        recoverTime = bodyPowerConfig.bodyPowerConfig[1]["recoverTime"] * 60
        addPower = (current - logout)//recoverTime
        maxPower = bodyPowerConfig.bodyPowerConfig[1]["maxPower"]

        power = self.bodyPower + addPower
        if power <= maxPower:
            self.bodyPower = power
        else:
            self.bodyPower = maxPower
コード例 #18
0
 def onClientAddCoachTime(self, itemID, coachID):
     index = 0
     findItem = None
     for item in self.coachList:
         if item["id"] == coachID:
             period = util.getCurrentTime() - item["periodTime"]
             item["periodTime"] = util.getCurrentTime()
             if item["useTime"] < period:
                 item["useTime"] = 0
             else:
                 item["useTime"] = item["useTime"] - period
             findItem = item
             break
     for itemId, num in coachConfig.coachConfig[coachID]["cost"].items():
         if itemId == itemID:
             if self.getItemNumByItemID(itemId) < 1:
                 self.client.onBallerCallBack(
                     CardMgrModuleError.Material_not_enough)
                 return
             if index == 0:
                 if findItem["useTime"] - (int(num) * 3600) < 0:
                     findItem["useTime"] = 0
                 else:
                     findItem["useTime"] = findItem["useTime"] - (int(num) *
                                                                  3600)
             elif index == 1:
                 if findItem["useTime"] - findItem["useTime"] // 2 < 0:
                     findItem["useTime"] = 0
                 else:
                     findItem["useTime"] = findItem[
                         "useTime"] - findItem["useTime"] // 2
             elif index == 2:
                 findItem["useTime"] = 0
             break
         index = index + 1
     self.client.onAddCoachTimeSucess(coachID, index, findItem["useTime"])
     self.decItem(itemId, 1)
コード例 #19
0
    def buy_stocks():
        data = {}

        start = util.getStartTime()
        end = util.getCurrentTime()
        tickers = util.load_tickers()

        for ticker in tickers:
            data[ticker] = Scraper.lookup(ticker, start, end)

        for ticker in tickers:
            if BuyModel.should_buy(ticker, data[ticker]):
                print("Buy " + ticker)
            else:
                print("Don't buy " + ticker)
コード例 #20
0
 def onEntitiesEnabled(self):
     if len(self.coachList) == 0:
         for i in range(1, 6):
             item = {}
             item["id"] = i
             item["limitTime"] = coachConfig.coachConfig[i]["limitTime"]
             item["useTime"] = 0
             item["periodTime"] = 0
             item["color"] = coachConfig.coachConfig[i]["color"]
             item["isLock"] = coachConfig.coachConfig[i]["isLock"]
             item["cost"] = ""
             for itemID, Num in coachConfig.coachConfig[i]["cost"].items():
                 item["cost"] = item["cost"] + str(itemID) + ":" + str(
                     Num) + ","
             self.coachList.append(item)
             self.coachLastTime = util.getCurrentTime()
コード例 #21
0
def helpsettings():
    global reminderlist
    if request.method == "GET":
        if session.has_key("user") and session["user"] != "":
            tmp = util.getCurrentTime(session["user"])
            time = tmp.split(":")
            if "am" in time[1]:
                amorpm = "am"
            else:
                amorpm = "pm"
            hour = time[0]
            minute = time[1][:-2]
            tmpone = util.getStatus(session["user"])
            return render_template(
                "helpsettings.html",
                minutes=minutelist,
                hourselected=int(hour),
                minuteselected=minute,
                ampm=amorpm,
                enabled=tmpone,
            )
    else:
        if request.form.has_key("Back"):
            return redirect(url_for("calendar", year=int(util.thisYear()), month=util.thisMonth()))
        if request.form.has_key("Submit"):
            hour = request.form["hourselector"]
            minute = request.form["minuteselector"]
            amorpm = request.form["ampmselect"]
            reminders = request.form["enabledselect"]
            hour = str(hour)
            if int(hour) < 10:
                hour = "0" + hour
            newtime = hour + ":" + minute + amorpm
            util.setTime(util.getUserNumber(session["user"]), newtime)
            currentEnabled = util.getStatus(session["user"])
            if currentEnabled == True and reminders == "dis":
                util.changeStatus(util.getUserNumber(session["user"]))
            if currentEnabled == False and reminders == "en":
                util.changeStatus(util.getUserNumber(session["user"]))
            reminderlist = util.getReminderTimes()
            if threading.activeCount() > 1:
                threading.enumerate()[1].cancel()
            remindersHandler(True, 0)
            return redirect(url_for("helpsettings"))
コード例 #22
0
ファイル: main.py プロジェクト: losywee/autoSplitUploadAliImg
def checkFile():
    filePath = request.args.get("filePath")
    if os.path.exists(filePath):
        pathName = getCurrentTime()
        tempPath = os.path.join(os.path.dirname(__file__), 'temp', pathName)
        (sFilePath, sFileName) = os.path.split(filePath)
        (shotname, extension) = os.path.splitext(sFileName)
        data = {
            "tempPath":
            tempPath,
            "preParam":
            preParam.format(filePathName=filePath,
                            fileName=shotname,
                            tempPath=tempPath)
        }
        obj = resultData(True, "", data)
    else:
        obj = resultData(False, "文件不存在", "")
    return obj
コード例 #23
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)
コード例 #24
0
    def onClientDeath(self):
        """
        KBEngine method.
        entity丢失了客户端实体
        """
        DEBUG_MSG("Avatar[%i].onClientDeath:" % self.id)
        # 防止正在请求创建cell的同时客户端断开了, 我们延时一段时间来执行销毁cell直到销毁base
        # 这段时间内客户端短连接登录则会激活entity
        # self._destroyTimer = self.addTimer(1, 0, SCDefine.TIMER_TYPE_DESTROY)
        self.logoutTime = util.getCurrentTime()

        DEBUG_MSG("--------logoutTime   ----------------" + str(self.logoutTime))

        playerInfo = {}

        playerInfo[FriendInfoKey.DBID] = self.databaseID
        playerInfo[FriendInfoKey.photoIndex] = self.photoIndex
        playerInfo[FriendInfoKey.name] = self.name

        playerInfo[FriendInfoKey.level] = self.level
        playerInfo[FriendInfoKey.clubName] = self.club
        playerInfo[FriendInfoKey.fightValue] = self.fightValue
        playerInfo[FriendInfoKey.vipLevel] = self.vipLevel
        playerInfo[FriendInfoKey.onlineState] = self.logoutTime

        KBEngine.globalData["PlayerMgr"].playerOffline(self.databaseID,playerInfo)


        for id in self.cardIDList:
            card = KBEngine.entities.get(id)
            if card is None:
                continue
            card.destroyCard()


        if hasattr(self,"spaceMb") and self.spaceMb is not None and self.spaceMb.isDestroyed is not True:
            self.spaceMb.destroyClone()
        self.destroySelf()
コード例 #25
0
ファイル: app.py プロジェクト: dlevylambert/project2-pd6
def helpsettings():
    global reminderlist
    if request.method =='GET':
        if session.has_key('user') and session['user'] != '':
            tmp = util.getCurrentTime(session['user'])
            time = tmp.split(':')
            if 'am' in time[1]:
                amorpm = 'am'
            else:
                amorpm = 'pm'
            hour = time[0]
            minute = time[1][:-2]
            tmpone = util.getStatus(session['user'])
            return render_template('helpsettings.html',minutes=minutelist,hourselected=int(hour),minuteselected=minute,ampm=amorpm,enabled=tmpone)
    else:
        if request.form.has_key('Back'):
            return redirect(url_for('calendar',year=int(util.thisYear()),month=util.thisMonth()))
        if request.form.has_key('Submit'):
            hour = request.form['hourselector']
            minute = request.form['minuteselector']
            amorpm = request.form['ampmselect']
            reminders = request.form['enabledselect']
            hour = str(hour)
            if int(hour) < 10:
                hour = "0" + hour
            newtime = hour+":"+minute+amorpm
            util.setTime(util.getUserNumber(session['user']),newtime)
            currentEnabled = util.getStatus(session['user'])
            if currentEnabled == True and reminders == 'dis':
                util.changeStatus(util.getUserNumber(session['user']))
            if currentEnabled == False and reminders == 'en':
                util.changeStatus(util.getUserNumber(session['user']))
            reminderlist = util.getReminderTimes()
            if threading.activeCount() > 1:
                threading.enumerate()[1].cancel()
            remindersHandler(True,0)
            return redirect(url_for('helpsettings'))
コード例 #26
0
 def onClientTouchBabyInfo(self, itemID, bodyIndex, star):
     baby = KBEngine.entities.get(self.babyID)
     if baby is None:
         self.client.onBabyCallBack(BabyModuleError.Baby_not_exist)
         return
     if itemID == 102034:
         if baby.closeTouch > 0:
             baby.closeTouch = baby.closeTouch - 1
         else:
             return
     else:
         itemCount = self.getItemNumByItemID(itemID)
         if itemCount < 1:
             self.client.onBabyCallBack(BabyModuleError.Material_not_enough)
             return
         self.decItem(itemID, 1)
     liking = int(itemsUse.itemsUseConfig[itemID]["addValue"]) * int(
         BabyLikingStarConfig.BabyLikingStarConfig[star]["addPercent"])
     config = CommonConfig.CommonConfig[4]
     time = config["value"]
     if baby.liking == 0 and baby.likingTime == 0:
         baby.likingTime = time * 60
         baby.liking = baby.liking + liking
         self.Timer_reset_baby_liking = baby.addTimer(
             time * 60, time * 60, TimerDefine.Timer_reset_baby_liking)
         self.Timer_reset_baby_likingTime = baby.addTimer(
             1, 1, TimerDefine.Timer_reset_baby_likingTime)
     else:
         if baby.liking >= BabyLikingStarConfig.BabyLikingStarConfig[5][
                 "liking"]:
             self.client.onBabyCallBack(BabyModuleError.Liking_is_max)
             return
         configs = CommonConfig.CommonConfig[5]
         index = baby.liking // configs["value"]
         baby.liking = baby.liking + liking
         nowindex = baby.liking // configs["value"]
         baby.likingTime = baby.likingTime + (nowindex - index) * time * 60
         if baby.liking >= BabyLikingStarConfig.BabyLikingStarConfig[5][
                 "liking"]:
             baby.liking = BabyLikingStarConfig.BabyLikingStarConfig[5][
                 "liking"]
             baby.fullTime = util.getCurrentTime()
             baby.periodTime = util.getCurrentTime()
             baby.isFullTime = 1
             self.addTimer(6 * 60 * 60, 60 * 60,
                           TimerDefine.Timer_reset_baby_fullTime)
             baby.delTimer(self.Timer_reset_baby_liking)
             baby.delTimer(self.Timer_reset_baby_likingTime)
             self.client.onFullTimeOver(1, baby.liking, baby.fullTime)
             return
         tech = 0.0
         health = 0.0
         for i in range(5):
             info = BabyLikingStarConfig.BabyLikingStarConfig[i +
                                                              1]["liking"]
             tech = tech + float(BabyLikingStarConfig.BabyLikingStarConfig[
                 i + 1]["teamTuple"].split(",")[1])
             health = health + float(
                 BabyLikingStarConfig.BabyLikingStarConfig[
                     i + 1]["teamTuple"].split(",")[0])
             if baby.liking <= info:
                 break
         player = KBEngine.entities.get(self.cardID)
         if player.tech != tech or player.health != health:
             player.tech = tech
             player.health = health
             self.client.onUpdateCardInfo(self.UpdateBallerInfo(player))
     self.client.onTouchSucess(baby.liking, baby.likingTime)
コード例 #27
0
    def __init__(self):

        config = CommonConfig.CommonConfig[4]
        time = config["value"]
        if util.getCurrentTime(
        ) - self.fullTime <= 6 * 60 * 60 and util.getCurrentTime(
        ) - self.fullTime > 0:
            self.addTimer(
                6 * 60 * 60 - (util.getCurrentTime() - self.fullTime),
                time * 60, TimerDefine.Timer_reset_baby_fullTime)
            return
        if self.isFullTime == 1:
            period = self.periodTime - 6 * 60 * 60
            self.isFullTime = 0
        else:
            currentTime = util.getCurrentTime()
            period = currentTime - self.periodTime
        index = period // (time * 60)
        lastTime = period % (time * 60)
        configs = CommonConfig.CommonConfig[5]
        if index > 0:
            liking = configs["value"] * index
            if self.liking >= liking:
                self.liking = self.liking - liking
            else:
                self.liking = 0
            if self.liking == 0:
                self.likingTime = 0
                return
            else:
                minute = self.liking // configs["value"]
                second = minute * time * 60 - lastTime
                self.likingTime = second
        else:
            minute = self.liking // configs["value"]
            if minute == 0:
                return
            if self.likingTime > 0:
                self.likingTime = self.likingTime - lastTime
            else:
                self.likingTime = minute * time * 60 - lastTime

        tech = 0.0
        health = 0.0
        for i in range(5):
            info = BabyLikingStarConfig.BabyLikingStarConfig[i + 1]["liking"]
            tech = tech + float(BabyLikingStarConfig.BabyLikingStarConfig[
                i + 1]["teamTuple"].split(",")[1])
            health = health + float(BabyLikingStarConfig.BabyLikingStarConfig[
                i + 1]["teamTuple"].split(",")[0])
            if self.liking <= info:
                break
        avatar = KBEngine.entities.get(self.playerID)
        player = KBEngine.entities.get(avatar.cardID)
        if player.tech != tech or player.health != health:
            player.tech = tech
            player.health = health
            self.client.onUpdateCardInfo(self.UpdateBallerInfo(player))

        avatar.Timer_reset_baby_liking = self.addTimer(
            self.likingTime % (time * 60), time * 60,
            TimerDefine.Timer_reset_baby_liking)
        avatar.Timer_reset_baby_likingTime = self.addTimer(
            1, 1, TimerDefine.Timer_reset_baby_likingTime)
        pass
コード例 #28
0
 def destroyBaby(self):
     if util.getCurrentTime() - self.fullTime > 6 * 60 * 60:
         self.periodTime = util.getCurrentTime()
     self.destroy()
コード例 #29
0
 def onClientGetUpdateCD(self):
     self.updateAreanCd = util.getCurrentTime() - self.currentArenaTimes
     if self.updateAreanCd >= 10:
         return
     self.client.onGetUpdateCD(self.updateAreanCd)
コード例 #30
0
    def onArenaMgrQueryResult(self, itemList):
        clientResult = []
        self.chanllengeMap = {}
        self.arenaInitialList = []
        inStr = ""
        for i in range(len(itemList)):
            dbid = itemList[i]["dbid"]
            rank = itemList[i]["rank"]
            isRobot = itemList[i]["isRobot"]

            self.chanllengeMap[dbid] = {
                "rank": rank,
                "isRobot": isRobot,
                "inTeamCardIDDict": {}
            }
            if isRobot == 1:
                # 填充配置文件
                clientResultItem = {}
                config = ArenaConfig.ArenaConfig[dbid]
                clientResultItem["dbid"] = dbid
                clientResultItem["rank"] = rank
                clientResultItem["isRobot"] = 1
                clientResultItem["name"] = config["playerName"]
                clientResultItem["club"] = config["clubName"]
                clientResultItem["formation"] = config["campId"]
                clientResultItem["camp"] = config["camp"]
                clientResultItem["fightValue"] = config["fightValue"]
                clientResult.append(clientResultItem)
                self.arenaInitialList.append(clientResultItem)
                continue
            clientResultItem = {}
            clientResultItem["dbid"] = dbid
            clientResultItem["isRobot"] = 0
            clientResultItem["rank"] = rank
            clientResultItem["name"] = ""
            clientResultItem["club"] = ""
            clientResultItem["formation"] = 1
            clientResultItem["camp"] = 1
            clientResultItem["fightValue"] = 1
            clientResult.append(clientResultItem)
            self.arenaInitialList.append(clientResultItem)
            inStr = inStr + str(dbid) + ","

        if inStr != "":
            inStr = inStr[:-1]

            @util.dbDeco
            def cb(result, rownum, error):
                if result is not None:
                    for i in range(len(result)):
                        dbid = int(result[i][0])
                        name = result[i][1].decode('utf-8')
                        club = result[i][2].decode('utf-8')
                        formation = int(result[i][3])
                        fightValue = int(result[i][4])
                        cardConfigID = int(result[i][5])
                        skill1 = int(result[i][6])
                        skill2 = int(result[i][7])
                        camp = int(result[i][8])
                        item = self.chanllengeMap[dbid]
                        inTeamCardIDDict = item["inTeamCardIDDict"]
                        inTeamCardIDDict[cardConfigID] = {
                            "skill1": skill1,
                            "skill2": skill2
                        }
                        for resultItem in clientResult:
                            if resultItem["dbid"] == dbid:
                                resultItem["name"] = name
                                resultItem["club"] = club
                                resultItem["fightValue"] = fightValue
                                resultItem["formation"] = formation
                                resultItem["camp"] = camp
                        for Item in self.arenaInitialList:
                            if Item["dbid"] == dbid:
                                Item["name"] = name
                                Item["club"] = club
                                Item["fightValue"] = fightValue
                                Item["formation"] = formation
                                Item["camp"] = camp

                self.client.onGetThreeArenaValue(clientResult)

            sql = "SELECT a.id, a.sm_name, a.sm_club, a.sm_formation, a.sm_fightValue,c.sm_configID, c.sm_skill1, c.sm_skill2,a.sm_camp FROM tbl_Avatar AS a, tbl_Card AS c WHERE a.id in(" + inStr + ") AND c.sm_inTeam = 1"

            KBEngine.executeRawDatabaseCommand(sql, cb)
        else:
            self.client.onGetThreeArenaValue(clientResult)

        self.updateAreanCd = 0
        if self.isFirstEnter == True:
            self.isFirstEnter = False
            return
        self.currentArenaTimes = util.getCurrentTime()
        self.client.onGetUpdateCD(self.updateAreanCd)
コード例 #31
0
    def onClientSkillLevelUp(self, skillID, skillIndex, cardId):
        if cardId not in self.cardIDList:
            self.client.onBallerCallBack(CardMgrModuleError.Card_not_exist)
            return
        skillName = ""
        card = KBEngine.entities.get(cardId)

        if card.isSelf == 1 and skillIndex == 1:
            if skillID == card.skill11 // 100:
                skillName = "skill11"
            elif skillID == card.skill12 // 100:
                skillName = "skill12"
            elif skillID == card.skill13 // 100:
                skillName = "skill13"
        else:
            skillName = self.GetSkillByIndex(skillID, cardId)
        if skillName == "":
            ERROR_MSG("skillName is empty")
            return
        currentLevel = self.GetObjectValue(cardId, skillName)
        currentLevel = currentLevel - currentLevel // 100 * 100
        if currentLevel >= len(skillLevelConfig.SkillUpTimeConfig):
            self.client.onSkillError(SkillModuleError.skill_is_max)
            return
        levelConfig = skillLevelConfig.SkillUpTimeConfig[int(currentLevel)]

        coachID = 0
        findItem = None
        for item in self.coachList:
            coachID = coachID + 1
            period = util.getCurrentTime() - item["periodTime"]
            item["periodTime"] = util.getCurrentTime()
            if item["useTime"] < period:
                item["useTime"] = 0
            else:
                item["useTime"] = item["useTime"] - period

            if item["useTime"] < item["limitTime"] and item["isLock"] == 1:
                findItem = item
                break
        if findItem == None:
            self.client.onSkillError(SkillModuleError.coach_time_not_enough)
            return
        commonIndex = 0
        if findItem["color"] == 4:
            commonIndex = 14
        elif findItem["color"] == 5:
            commonIndex = 15
        if commonIndex != 0:
            rate = CommonConfig.CommonConfig[commonIndex]["value"]
            isUseTime = random.randint(0, 100)
            if isUseTime > rate:
                findItem["useTime"] = findItem[
                    "useTime"] + levelConfig["upTime"] * 60
                self.client.onSkillLevelUpSucess(currentLevel + 1,
                                                 findItem["useTime"], coachID)
            else:
                self.client.onSkillNotUseTime(currentLevel + 1,
                                              findItem["useTime"], coachID)
        else:
            findItem[
                "useTime"] = findItem["useTime"] + levelConfig["upTime"] * 60
            self.client.onSkillLevelUpSucess(currentLevel + 1,
                                             findItem["useTime"], coachID)
        self.SetObjectValue(cardId, skillName,
                            skillID * 100 + (currentLevel + 1))
        if card.isSelf == 1 and skillIndex == 1:
            self.SetObjectValue(cardId, "skill1",
                                skillID * 100 + (currentLevel + 1))
        if skillIndex > 2:
            config = skillLevelConfig.PropSkillLevelConfig[skillID * 100 +
                                                           currentLevel]
            for itemID, Num in config["addvalue"].items():
                addValue = self.GetObjectValue(cardId, itemID) + Num
                self.SetObjectValue(cardId, itemID, addValue)
        self.client.onUpdateCardInfo(self.UpdateBallerInfo(card))
コード例 #32
0
 def onClientDeath(self):
     self.changeOnlineState(util.getCurrentTime())