Example #1
0
    def getCycleFuncIDresid(self, serverInfo=None):
        l = []
        for v in Game.res_mgr.res_cycle.values():
            if v.activityID == self.id:
                l.append(v)

        for v in l:
            if v.openDayRange:

                openDay = get_days(serverInfo.get("opentime", 0)) + 1

                if v.openDayRange[1] == 0:
                    v.openDayRange[1] = 3650000

                # print("=========",v.openDayRange[0],openDay,v.openDayRange[1])

                if v.openDayRange[0] <= openDay <= v.openDayRange[1]:
                    return v.id

            if v.mergeDayRange:

                mergeDay = get_days(serverInfo.get("mergetime", 0)) + 1

                if v.mergeDayRange[1] == 0:
                    v.mergeDayRange[1] = 3650000

                if v.mergeDayRange[0] <= mergeDay <= v.mergeDayRange[1]:
                    return v.id

            if v.day:
                # TODO
                return 0

        return 0
Example #2
0
    def isOpen(self, serverInfo):
        now = int(time.time())
        if self.openDayRange:
            openDay = get_days(serverInfo.get("opentime", 0)) + 1
            if openDay < self.openDayRange[0] or (
                    self.openDayRange[1] != 0
                    and openDay > self.openDayRange[1]):
                return 0
        elif self.mergeDayRange:
            mergeDay = get_days(serverInfo.get("mergetime", 0)) + 1
            if mergeDay < self.mergeDayRange[0] or (
                    self.mergeDayRange[1] != 0
                    and mergeDay > self.mergeDayRange[1]):
                return 0

        if self.everyday:
            startTime, endTime = self.getEverydayTime()
            if now < startTime or now > endTime:
                return 0
        elif self.everyweek:
            startTime, endTime = self.getEveryweekTime()
            if now < startTime or now > endTime:
                return 0
        elif self.dateRange:
            startTime, endTime = self.getDateRangeTime()
            if now < startTime or now > endTime:
                return 0
        return 1
Example #3
0
    def getCycleEndTime(self, serverInfo=None):
        l = []
        for v in Game.res_mgr.res_cycle.values():
            if v.activityID == self.id:
                l.append(v)

        for v in l:
            if v.openDayRange:

                openDay = get_days(serverInfo.get("opentime", 0)) + 1

                dd = v.openDayRange[1]
                if v.openDayRange[1] == 0:
                    v.openDayRange[1] = 3650000

                # print("=========",v.openDayRange[0],openDay,v.openDayRange[1])

                if v.openDayRange[0] <= openDay <= v.openDayRange[1]:
                    if not dd:
                        return 0

                    xx = v.openDayRange[1] - (openDay - 1)
                    zero_day_time = int(cur_day_hour_time(24 * xx))

                    return zero_day_time

            if v.mergeDayRange:

                mergeDay = get_days(serverInfo.get("mergetime", 0)) + 1

                dd = v.mergeDayRange[1]
                if v.mergeDayRange[1] == 0:
                    v.mergeDayRange[1] = 3650000

                if v.mergeDayRange[0] <= mergeDay <= v.mergeDayRange[1]:
                    if not dd:
                        return 0

                    xx = v.mergeDayRange[1] - (mergeDay - 1)
                    zero_day_time = int(cur_day_hour_time(24 * xx))

                    return zero_day_time

            if v.day:
                # TODO
                return 0

        return 0
Example #4
0
    def addJJnum(self, type, lv):
        lvs = self.JJnum.get(type, {})
        num = lvs.get(lv, 0)

        num += 1

        lvs[lv] = num
        self.JJnum[type] = lvs

        self.markDirty()

        resAct = Game.res_mgr.res_activity.get(constant.ACTIVITY_QMJJ)
        serverInfo = Game.rpc_server_info.GetServerInfo()
        openDay = get_days(serverInfo.get("opentime", 0)) + 1

        currtype = -1
        for kk, vv in Game.res_mgr.res_qmjj.items():
            if vv.day == openDay:
                currtype = vv.type
                break

        # print("3333333",currtype,type,lv,resAct,serverInfo,resAct.isOpen(serverInfo),str(currtype)==type)

        if str(currtype) == type:
            if resAct.isOpen(serverInfo):
                for addr, logic in Game.rpc_logic_game:
                    if logic:
                        logic.crJJnum(self.getJJnum(type), _no_result=True)

        return num
Example #5
0
 def _activity_reward(self):
     serverInfo = Game.rpc_server_info.GetServerInfo()
     openDay = get_days(serverInfo.get("opentime", 0)) + 1
     for actRankRes in Game.res_mgr.res_actRank.values():
         activityRes = Game.res_mgr.res_activity.get(actRankRes.actId)
         if not activityRes:
             continue
         rankType = constant.MAP_ACT_RANK_MOD_TYPE.get(activityRes.type)
         if not rankType:
             continue
         rankObj = self.ranks.get(rankType)
         if not rankObj:
             continue
         activityReward = rankObj.getActivityReward()
         if openDay - 1 >= activityRes.openDayRange[
                 1] and actRankRes.id not in activityReward:
             activityReward.append(actRankRes.id)
             rankObj.setActivityReward(activityReward)
             mailRes = Game.res_mgr.res_mail.get(
                 constant.MAIL_ID_RANK_REWRAD, None)
             rankList = rankObj.getRankList()
             rankList = rankList[actRankRes.minRank - 1:actRankRes.maxRank]
             for playerInfo in rankList:
                 pid = playerInfo.get("id", 0)
                 rank = playerInfo.get("rank", 0)
                 content = mailRes.content % (activityRes.name, str(rank))
                 if pid:
                     Game.rpc_mail_mgr.sendPersonMail(pid,
                                                      mailRes.title,
                                                      content,
                                                      actRankRes.reward,
                                                      push=False)
Example #6
0
 def GetOpenDay(self):
     """获取开服天数"""
     day = get_days(self.opentime) + 1
     return day
Example #7
0
 def GetServerMergeDay(self):
     """获取合服天数"""
     day = get_days(self.serverMergeTime) + 1
     return day
Example #8
0
 def GetServerOpenDay(self):
     """获取开服天数"""
     day = get_days(self.serverOpenTime) + 1
     return day
Example #9
0
    def _activity_reward_kfkh(self):
        serverInfo = Game.rpc_server_info.GetServerInfo()
        openDay = get_days(serverInfo.get("opentime", 0)) + 1

        for actRankRes in Game.res_mgr.res_actKfkh.values():
            activityRes = Game.res_mgr.res_activity.get(actRankRes.actId)
            if not activityRes:
                continue

            if activityRes.openDayRange[1] != openDay - 1:
                continue

            rankType = constant.KFKH_ACT_RANK_MOD_TYPE.get(
                actRankRes.type, None)
            if not rankType:
                continue
            rankObj = self.ranks.get(rankType)
            if not rankObj:
                continue

            if not actRankRes.minRank:
                continue

            rankList = rankObj.getRankList()

            rankList = rankList[actRankRes.minRank - 1:actRankRes.maxRank]
            for playerInfo in rankList:
                pid = playerInfo.get("id", 0)
                rank = playerInfo.get("rank", 0)

                playerInfo["reward"] = 0

                mailRes = {}
                if actRankRes.type == constant.KFKH_RANK_TYPE_7001:
                    if playerInfo["sortEle"][0] < actRankRes.value:
                        continue
                    mailRes = Game.res_mgr.res_mail.get(
                        constant.MAIL_ID_KFKH_RANK_7001, None)
                elif actRankRes.type == constant.KFKH_RANK_TYPE_7002:
                    if playerInfo["sortEle"][0] < actRankRes.value:
                        continue
                    mailRes = Game.res_mgr.res_mail.get(
                        constant.MAIL_ID_KFKH_RANK_7002, None)

                elif actRankRes.type == constant.KFKH_RANK_TYPE_7006:
                    if playerInfo["sortEle"][0] < actRankRes.value:
                        continue
                    mailRes = Game.res_mgr.res_mail.get(
                        constant.MAIL_ID_KFKH_RANK_7006, None)

                elif actRankRes.type == constant.KFKH_RANK_TYPE_7008:
                    if playerInfo["sortEle"][0] < actRankRes.value:
                        continue
                    mailRes = Game.res_mgr.res_mail.get(
                        constant.MAIL_ID_KFKH_RANK_7008, None)
                else:
                    continue

                content = mailRes.content % str(rank)
                if pid:
                    playerInfo["reward"] = 1
                    Game.rpc_mail_mgr.sendPersonMail(pid,
                                                     mailRes.title,
                                                     content,
                                                     actRankRes.reward,
                                                     push=False)

            rankObj.SetSnapshot()