#!/usr/bin/python
|
# -*- coding: GBK -*-
|
#---------------------------------------------------------------------
|
#
|
#---------------------------------------------------------------------
|
##@package PlayerFamily
|
#¼Ò×åÂß¼´¦Àí
|
#
|
# @author eggxp
|
# @date 2010-4-23
|
# @version 1.0
|
#
|
#---------------------------------------------------------------------
|
#"""Version = 2017-07-12 21:00"""
|
#---------------------------------------------------------------------
|
import IPY_GameWorld
|
import GameWorld
|
import EventShell
|
import FBLogic
|
import ChConfig
|
import PlayerControl
|
import ShareDefine
|
import ReadChConfig
|
import PlayerTruck
|
import NetPackCommon
|
import ChPyNetSendPack
|
import DataRecordPack
|
import GameLogic_FamilyWar
|
import GameLogic_FamilyBoss
|
import ChMapToGamePyPack
|
import PlayerFamilyTech
|
import PlayerFamilyRedPacket
|
import PlayerFamilyZhenfa
|
import PlayerTongTianLing
|
import PlayerWeekParty
|
import PlayerActivity
|
import ItemControler
|
import SkillCommon
|
import BuffSkill
|
import ItemCommon
|
import PlayerSuccess
|
import GameFuncComm
|
import PlayerTJG
|
import IpyGameDataPY
|
import cPickle
|
|
import time
|
import random
|
#---------------------------------------------------------------------
|
#¼Ò×åË¢ÐÂ
|
#class IPY_MFamilyRefresh
|
#{
|
#public:
|
#
|
# int GetFamilyID();
|
#
|
# char * GetFamilyName();
|
#};
|
## ¼Ò×åË¢ÐÂ
|
# @param index Íæ¼ÒË÷Òý
|
# @param tick µ±Ç°Ê±¼ä
|
# @return None
|
# @remarks º¯ÊýÏêϸ˵Ã÷.
|
def GameServer_FamilyRefresh(index, tick):
|
curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
|
refreshPack = IPY_GameWorld.IPY_MFamilyRefresh()
|
|
if curPlayer.GetID() != refreshPack.GetPlayerID():
|
#²»ÊÇ×Ô¼º
|
return
|
|
lastFamilyID = curPlayer.GetFamilyID()
|
|
#************×峤±ä¸üɾ³ý·¢²¼ÈÎÎñ*************************************************
|
if (curPlayer.GetFamilyMemberLV() == IPY_GameWorld.fmlLeader
|
and refreshPack.GetFamilyMemberLV()!= IPY_GameWorld.fmlLeader):
|
EventShell.EventResponse_OnMemberChange(curPlayer)
|
#*******************************************************************
|
|
#---¸ù¾Ý·â°üÐÞ¸ÄÍæ¼Ò¼Ò×åÊôÐÔ---
|
if lastFamilyID != refreshPack.GetFamilyID():
|
curPlayer.SetFamilyID(refreshPack.GetFamilyID())
|
familyIDChangeTime = int(time.time())
|
#PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_FamilyIDChangeTime, familyIDChangeTime)
|
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_LastFamilyID, lastFamilyID)
|
GameWorld.Log("¼Ç¼¼Ò×å±ä¸üʱ¼ä...familyIDChangeTime=%s,lastFamilyID=%s,nextFamilyID=%s"
|
% (familyIDChangeTime, lastFamilyID, refreshPack.GetFamilyID()), curPlayer.GetPlayerID())
|
|
#´¥·¢Íæ¼Ò¼ÓÈë¼Ò×åʼþ
|
EventShell.EventResponse_OnFamilyAdd(curPlayer)
|
|
if curPlayer.GetFamilyName() != refreshPack.GetFamilyName():
|
curPlayer.SetFamilyName(refreshPack.GetFamilyName())
|
#֪ͨÖÜÎ§Íæ¼Ò¼Ò×åÃû³ÆË¢ÐÂ
|
curPlayer.Notify_FamilyNameRefresh()
|
|
refreshFamilyLV = refreshPack.GetFamilyLV()
|
lastFamilyLV = curPlayer.GetFamilyLV()
|
if lastFamilyLV != refreshFamilyLV:
|
#ÈÎÎñÐèÇ󣬼ǼÏÈǰµÄ¼Ò×åµÈ¼¶
|
curPlayer.SetDict(ChConfig.Def_PlayerKey_FamilyLVLeave, lastFamilyLV)
|
|
isLVUP = False
|
if lastFamilyLV and refreshFamilyLV > 0:
|
#´¥·¢¼Ò×åÉý¼¶Ê¼þ
|
isLVUP = True
|
|
curPlayer.SetFamilyLV(refreshFamilyLV)
|
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_FamilyLV, refreshFamilyLV)
|
|
__OnFamilyLVBuffChange(curPlayer, tick)
|
#´¥·¢¼Ò×åÉý¼¶Ê¼þ, ÔÚSetFamilyLVÖ®ºó£¬ÈÎÎñ¿ÉÒÔÈ¡µÈ¼¶Åж¨
|
if isLVUP:
|
EventShell.EventResponse_OnFamilyLVUp(curPlayer)
|
|
if curPlayer.GetFamilyMemberLV() != refreshPack.GetFamilyMemberLV():
|
# ÒòΪÏÉÃËְλûÓдæDBPlayer£¬¶ø¿ç·þºóÓÖûÓÐFamilyÐÅÏ¢£¬ËùÒÔÕâÀï×ö¸ö´æ´¢£¬ÓÃÓÚ¿ç·þÓÃ
|
curPlayer.SetReceivedSalary(refreshPack.GetFamilyMemberLV())
|
curPlayer.SetFamilyMemberLV(refreshPack.GetFamilyMemberLV())
|
#֪ͨÖÜÎ§Íæ¼Ò¼Ò×åְλˢÐÂ
|
#curPlayer.Notify_FamilyMemberLVRefresh()
|
GameLogic_FamilyWar.DoCheckChampionFamilyTitle(curPlayer)
|
|
if curPlayer.GetFamilyMoney() != refreshPack.GetFamilyMoney():
|
curPlayer.SetFamilyMoney(refreshPack.GetFamilyMoney())
|
|
if curPlayer.GetFamilyLastWeekActiveValue() != refreshPack.GetLastWeekFamilyActiveValue():
|
curPlayer.SetFamilyLastWeekActiveValue(refreshPack.GetLastWeekFamilyActiveValue())
|
|
if PlayerControl.GetFamilyEmblemID(curPlayer) != refreshPack.GetExtra6():
|
PlayerControl.SetFamilyEmblemID(curPlayer, refreshPack.GetExtra6())
|
|
#---´¦ÀíÌØÊâÂß¼, ½øÈëÍ˳ö¼Ò×å---
|
|
if lastFamilyID != 0 and curPlayer.GetFamilyID() == 0:
|
#Íæ¼ÒÀ뿪¼Ò×å
|
__OnLeaveFamily(curPlayer, tick)
|
|
#¸Ä±äïÚ³µÉíÉϼǼµÄÖ÷ÈËÐÅÏ¢
|
PlayerTruck.ChangeTruckNoteInfo(curPlayer)
|
|
elif lastFamilyID == 0 and curPlayer.GetFamilyID() != 0:
|
#¸Õ½ø¼Ò×岢Ϊ×峤,´¥·¢½¨¼Ò×åʼþ
|
if curPlayer.GetFamilyMemberLV() == IPY_GameWorld.fmlLeader:
|
EventShell.EventResponse_OnCreateFamily(curPlayer)
|
|
#½øÈë¼Ò×å´¥·¢Ê¼þ
|
__OnEnterFamily(curPlayer, tick)
|
|
#¸Ä±äïÚ³µÉíÉϼǼµÄÖ÷ÈËÐÅÏ¢
|
PlayerTruck.ChangeTruckNoteInfo(curPlayer)
|
|
#---֪ͨ¿Í»§¶ËË¢ÐÂÊôÐÔ---
|
curPlayer.View_FamilyInfoRefresh()
|
return
|
|
## ½øÈë¼Ò×å´¥·¢Ê¼þ
|
# @param curPlayer µ±Ç°Íæ¼Ò
|
# @param tick µ±Ç°Ê±¼ä
|
# @return None
|
# @remarks º¯ÊýÏêϸ˵Ã÷.
|
def __OnEnterFamily(curPlayer, tick):
|
EventShell.EventResponse_OnFamily(curPlayer)
|
__OnFamilyLVBuffChange(curPlayer, tick)
|
__FamilyAffair_CheckReset(curPlayer)
|
PlayerFamilyTech.Sync_PlayerFamilyTechLV(curPlayer)
|
DelAddFamilyRecord(curPlayer)
|
GameLogic_FamilyWar.DoCheckChampionFamilyTitle(curPlayer)
|
GameLogic_FamilyBoss.OnEnterFamily(curPlayer)
|
PlayerFamilyRedPacket.CreatCacheRedPacktet(curPlayer)
|
PlayerFamilyZhenfa.OnEnterFamily(curPlayer)
|
return
|
|
## Í˳ö¼Ò×å´¥·¢Ê¼þ
|
# @param curPlayer µ±Ç°Íæ¼Ò
|
# @param tick µ±Ç°Ê±¼ä
|
# @return None
|
# @remarks º¯ÊýÏêϸ˵Ã÷.
|
def __OnLeaveFamily(curPlayer, tick):
|
#---Çå¿Õ¼Ò×åÏà¹ØÐÅÏ¢---
|
curPlayer.SetPerExp(0)
|
curPlayer.SetFamilyHornor(0)
|
curPlayer.SetFamilyActiveValue(0)
|
curPlayer.SetLastWeekFamilyActiveValue(0)
|
curPlayer.SetFamilyLV(0)
|
PlayerControl.SetLeaveFamilyTimeEx(curPlayer, int(time.time()))
|
|
#´¥·¢Íæ¼ÒÀ뿪¼Ò×åµÄÈÎÎñ
|
EventShell.EventResponse_OnLeaveFamily(curPlayer)
|
|
#ÉèÖÃÁì½±ÏÞÖÆ
|
__SetForbidFamilyAward(curPlayer)
|
FBLogic.OnLeaveFamily(curPlayer, tick)
|
|
__OnFamilyLVBuffChange(curPlayer, tick)
|
#Çå¿Õ²Ö¿â»ý·Ö
|
PlayerControl.SetPlayerCurrency(curPlayer, ShareDefine.TYPE_Price_FamilyStoreScore, 0)
|
GameLogic_FamilyWar.DoCheckChampionFamilyTitle(curPlayer)
|
PlayerFamilyZhenfa.OnLeaveFamily(curPlayer)
|
return
|
|
## ¼Ò×åµÈ¼¶¼Ó³Öbuff±ä¸ü´¦Àí(½ø¡¢Í˼Ò×åʱ ¼° ¼Ò×åµÈ¼¶±ä¸üʱ)
|
def __OnFamilyLVBuffChange(curPlayer, tick):
|
return
|
# ¿ç·þ·þÎñÆ÷²»´¦Àí£¬·ÀÖ¹µÇ¼¿ç·þ·þÎñÆ÷ºóÎÞÕ½Ã˵¼ÖÂÕ½Á¦Ï½µ
|
if GameWorld.IsCrossServer():
|
return
|
|
familyLVBuffSkillTypeID = ReadChConfig.GetEvalChConfig("FamilyLVBuff")
|
if not familyLVBuffSkillTypeID:
|
return
|
|
# ÏÈɾºó¼Ó
|
playerSkillManager = curPlayer.GetSkillManager()
|
BuffSkill.DelBuffBySkillID(curPlayer, familyLVBuffSkillTypeID, tick)
|
playerSkillManager.DeleteSkillBySkillTypeID(familyLVBuffSkillTypeID)
|
familyLV = curPlayer.GetFamilyLV()
|
GameWorld.DebugLog("__OnFamilyLVBuffChange familyLV=%s,familyLVBuffSkillTypeID=%s" % (familyLV, familyLVBuffSkillTypeID))
|
if familyLV > 0:
|
curSkill = GameWorld.GetGameData().FindSkillByType(familyLVBuffSkillTypeID , familyLV)
|
if not curSkill:
|
return
|
skillID = curSkill.GetSkillID()
|
playerSkillManager.LVUPSkillByID(skillID)
|
SkillCommon.AddBuffBySkillType(curPlayer, familyLVBuffSkillTypeID, tick, familyLV)
|
|
curControl = PlayerControl.PlayerControl(curPlayer)
|
#curControl.CalcPassiveBuffAttr()
|
curControl.RefreshPlayerAttrByBuff()
|
return
|
|
def GetPlayerChangeFamilyPastHour(curPlayer):
|
## »ñÈ¡Íæ¼Ò¼Ò×å±ä¸üÒѾ¾¹ýÁ˶೤ʱ¼ä
|
curTime = int(time.time())
|
changeTime = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_FamilyIDChangeTime)
|
return (curTime - changeTime) / 3600
|
|
#
|
#//////////////////////////////////////////////////////////////
|
#//08 04 ÉêÇë¼Ò×åÕ½#tagMRequestFamilyWar
|
#tagMRequestFamilyWar * GettagMRequestFamilyWar();
|
#
|
#class IPY_MRequestFamilyWar
|
#{
|
#public:
|
#
|
# int GetFamilyID();
|
#
|
# char * GetFamilyName();
|
#
|
# int GetVSFamilyID();
|
#
|
# char * GetVSFamilyName();
|
#};
|
## 08 04 ÉêÇë¼Ò×åÕ½#
|
# @param index Íæ¼ÒË÷Òý
|
# @param tick µ±Ç°Ê±¼ä
|
# @return None
|
# @remarks º¯ÊýÏêϸ˵Ã÷.
|
def GameServer_RequestFamilyWar(index, tick):
|
#===============================================================================
|
# curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
|
# pack = IPY_GameWorld.IPY_MRequestFamilyWar()
|
# familyID = pack.GetFamilyID()
|
# familyName = pack.GetFamilyName()
|
# vsFamilyID = pack.GetVSFamilyID()
|
# vsFamilyName = pack.GetVSFamilyName()
|
# FBLogic.OnRequestFamilyWar(curPlayer, familyID, familyName, vsFamilyID, vsFamilyName, tick)
|
#===============================================================================
|
GameWorld.ErrLog('GameServer_RequestFamilyWar, ´Ë½Ó¿Ú·ÏÆú')
|
return
|
#---------------------------------------------------------------------
|
##Íæ¼Ò½ðǮת»»Îª¼Ò×å½ðÇ®
|
# @param playerMoney Íæ¼Ò½ðÇ®
|
# @return ¼Ò×å½ðÇ®
|
# @remarks Íæ¼Ò½ðǮת»»Îª¼Ò×å½ðÇ®
|
def GetPlayerMoney_Change_FamilyMoney(playerMoney):
|
return int(playerMoney * ShareDefine.Def_PlayerMoney_Change_FamilyMoney_Rate)
|
#---------------------------------------------------------------------
|
##Íæ¼Ò»îÔ¾¶Èת»»Îª¼Ò×å»îÔ¾¶È
|
# @param activeValue Íæ¼Ò»îÔ¾¶È
|
# @return ¼Ò×å»îÔ¾¶È
|
# @remarks Íæ¼Ò»îÔ¾¶Èת»»Îª¼Ò×å»îÔ¾¶È
|
def GetPlayerActiveValue_Change_ActiveValue(activeValue):
|
return activeValue
|
|
#---------------------------------------------------------------------
|
##ÀÛ¼ÓÍæ¼ÒµÄ¼Ò×å»îÔ¾¶È
|
# @param curPlayer Íæ¼ÒʵÀý
|
# @param addValue Ìí¼ÓµÄÊýÖµ
|
# @param sendPackGameServer ÊÇ·ñ֪ͨGameServerÀÛ¼Ó¼Ò×å»îÔ¾¶È
|
# @param reason À´Ô´, ÔÒò
|
# @return None
|
# @remarks ÀÛ¼ÓÍæ¼ÒµÄ¼Ò×å»îÔ¾¶È
|
def AddPlayerFamilyActiveValue(curPlayer, addValue, sendPackGameServer = False, reason = 0, isSysMsg=False):
|
if addValue <= 0:
|
#GameWorld.ErrLog("AddPlayerFamilyActiveValue Err = %s"%(addValue))
|
return
|
|
curActiveValue = curPlayer.GetFamilyActiveValue()
|
totalActiveValue = curPlayer.GetLastWeekFamilyActiveValue()
|
|
#---ÀÛ¼ÓÍæ¼Ò¼Ò×å»îÔ¾¶È---
|
if curActiveValue < ChConfig.Def_UpperLimit_DWord:
|
#ÀۼƻîÔ¾¶È
|
curPlayer.SetFamilyActiveValue(min(curActiveValue + addValue, ChConfig.Def_UpperLimit_DWord))
|
curPlayer.SetLastWeekFamilyActiveValue(min(totalActiveValue + addValue, ChConfig.Def_UpperLimit_DWord))
|
|
#Ôö¼Ó¹±Ï×¶È
|
PlayerControl.GiveMoney(curPlayer, ShareDefine.TYPE_Price_Family_Contribution, addValue, isSysHint=isSysMsg)
|
|
#Á÷Ïò¼Ç¼:
|
DataRecordPack.DR_AddPlayerFamilyActiveValue(curPlayer, addValue, curPlayer.GetFamilyActiveValue(), reason)
|
|
#---֪ͨÊÀ½ç·þÎñÆ÷ÀÛ¼Ó¼Ò×å»îÔ¾¶È---
|
#@warning: µ¶½£Ð¦ÏîÄ¿, Íæ¼Ò¼Ò×å»îÔ¾¶ÈÀÛ¼ÓͬʱÀÛ¼Ó¼Ò×å»îÔ¾¶È
|
# Èç¹ûÕâ±ßûÓмÓÉÏÈ¥ÔÚÍâÃæÒª´¦ÀíÒ»´ÎÀÛ¼Ó¼Ò×å»îÔ¾¶È
|
if not sendPackGameServer:
|
return True
|
|
#µ¶½£Ð¦ÒªÇó, Íæ¼Ò»îÔ¾¶ÈÀÛ¼ÓµÄͬʱÀÛ¼Ó¼Ò×å»îÔ¾¶È 1»îÔ¾=1×ʽð
|
SendPack_GameServer_AddFamilyDetailEx(curPlayer, addValue, addValue, resion=reason)
|
return True
|
|
#---------------------------------------------------------------------
|
##֪ͨÊÀ½ç·þÎñÆ÷ÀÛ¼Ó¼Ò×åÊôÐÔ
|
# @param curPlayer Íæ¼ÒʵÀý
|
# @param addFamilyHornor Ìí¼Ó¼Ò×åÊÞÁ¸
|
# @param addFamilyMoney Ìí¼Ó¼Ò×å×ʽð
|
# @param addFamilyActiveValue Ôö¼Ó¼Ò×å»îÔ¾¶È
|
# @return ·µ»ØÖµÎÞÒâÒå
|
# @remarks ֪ͨÊÀ½ç·þÎñÆ÷ÀÛ¼Ó¼Ò×åÊôÐÔ
|
def SendPack_GameServer_AddFamilyDetail(curPlayer, addFamilyHornor = 0, addFamilyMoney = 0, addFamilyActiveValue = 0, resion=0):
|
# //Ôö¼Ó¼Ò×åÈÙÓþ
|
# int GetAddFamilyHornor();
|
# //Ôö¼Ó¼Ò×å×ʽð
|
# int GetAddFamilyMoney();
|
# //Ôö¼Ó¼Ò×å»îÔ¾¶È
|
# int GetFamilyActiveValue();
|
# GameWorld.Log('addFamilyHornor = %s, addFamilyMoney = %s, addFamilyActiveValue = %s'%
|
# (addFamilyHornor, addFamilyMoney, addFamilyActiveValue))
|
|
#curPlayer.GameServer_AddFamilyDetail(addFamilyHornor, addFamilyMoney, addFamilyActiveValue)
|
#¸ÄΪPY°ü
|
if not curPlayer.GetFamilyID():
|
return
|
sendPack = ChMapToGamePyPack.tagMGAddFamilyDetail()
|
sendPack.PlayerID = curPlayer.GetPlayerID()
|
sendPack.AddFamilyHornor = addFamilyHornor
|
sendPack.AddFamilyMoney = addFamilyMoney
|
sendPack.FamilyActiveValue = addFamilyActiveValue
|
sendPack.AddResion = resion
|
NetPackCommon.SendPyPackToGameServer(sendPack)
|
GameWorld.DebugLog("AddFamilyDetail addFamilyHornor=%s,addFamilyMoney=%s,addFamilyActiveValue=%s, resion=%s"
|
% (addFamilyHornor, addFamilyMoney, addFamilyActiveValue, resion), curPlayer.GetPlayerID())
|
return
|
#---------------------------------------------------------------------
|
##֪ͨÊÀ½ç·þÎñÆ÷ÀÛ¼Ó¼Ò×åÊôÐÔ
|
# @param curPlayer Íæ¼ÒʵÀý
|
# @param addFamilyActiveValue Ôö¼ÓÍæ¼Ò¼Ò×å»îÔ¾¶È
|
# @param addFamilyHornor Ìí¼Ó¼Ò×åÈÙÓþ
|
# @param addFamilyMoney Ìí¼Ó¼Ò×å×ʽð
|
# @return ·µ»ØÖµÎÞÒâÒå
|
# @remarks ֪ͨÊÀ½ç·þÎñÆ÷ÀÛ¼Ó¼Ò×åÊôÐÔ
|
def SendPack_GameServer_AddFamilyDetailEx(curPlayer, addPlayerActiveValue, addFamilyMoney = 0, addFamilyHornor = 0, resion=0):
|
|
#µ¶½£Ð¦Ôö¼ÓÍæ¼Ò»îÔ¾¶ÈĬÈÏÐÂÔö¼Ò×å»îÔ¾¶È
|
addFamilyActiveValue = GetPlayerActiveValue_Change_ActiveValue(addPlayerActiveValue)
|
|
SendPack_GameServer_AddFamilyDetail(curPlayer, addFamilyHornor, addFamilyMoney, addFamilyActiveValue, resion)
|
|
return
|
#---------------------------------------------------------------------
|
##֪ͨGameServer, ¿Í»§¶Ë¿ªÊ¼´´½¨¼Ò×å
|
# @param curPlayer Íæ¼ÒʵÀý
|
# @return ·µ»ØÖµÎÞÒâÒå
|
# @remarks ֪ͨGameServer, ¿Í»§¶Ë¿ªÊ¼´´½¨¼Ò×å
|
def SendPack_GameServer_InputFamilyName(curPlayer):
|
#֪ͨGameServerÉèÖò鿴״̬, ·ÀÍâ¹Ò
|
curPlayer.GameServer_SetPlayerViewFamilyState(ShareDefine.TViewFamilyType_CreateFamily)
|
#֪ͨ¿Í»§¶Ë´ò¿ªÊäÈë¼Ò×åÃû½çÃæ
|
curPlayer.Frm_InputFamilyName()
|
return
|
|
##֪ͨGameServer, ¿Í»§¶Ë¿ªÊ¼ä¯ÀÀ¼Ò×åÐÅÏ¢
|
# @param curPlayer Íæ¼ÒʵÀý
|
# @return ·µ»ØÖµÎÞÒâÒå
|
# @remarks ֪ͨGameServer, ¿Í»§¶Ë¿ªÊ¼ä¯ÀÀ¼Ò×åÐÅÏ¢
|
def SendPack_GameServer_ViewAllFamily(curPlayer):
|
#֪ͨGameServerÉèÖò鿴״̬, ·ÀÍâ¹Ò
|
curPlayer.GameServer_SetPlayerViewFamilyState(ShareDefine.TViewFamilyType_FamilyWar)
|
#֪ͨGameServer¸ø¿Í»§¶Ë¼Ò×åÐÅÏ¢
|
curPlayer.GameServer_ViewAllFamily()
|
return
|
|
##֪ͨGameServer, Çå³ý¿Í»§¶Ëä¯ÀÀ¼Ò×å״̬
|
# @param curPlayer Íæ¼ÒʵÀý
|
# @return ·µ»ØÖµÎÞÒâÒå
|
# @remarks ֪ͨGameServer, ֪ͨGameServer, Çå³ý¿Í»§¶Ëä¯ÀÀ¼Ò×å״̬
|
def SendPack_GameServer_ClearViewFamilyState(curPlayer):
|
#MapServer¸æËßGameServer×Ô¼ºÊÇ·ñÔÚ´´½¨¼Ò×å״̬
|
#ÒòΪ¼Ò×å·â°üÊÇÔÚGameServer´¦ÀíµÄ, ·ÀÖ¹±»Æ
|
if curPlayer.GetViewFamilyState() in [ShareDefine.TViewFamilyType_None,
|
ShareDefine.TViewFamilyType_CreateFamily]:
|
#TViewFamilyType_CreateFamily״̬ÔÚGameServer DoCreateFamily½áÊøºó½â³ý
|
return
|
|
curPlayer.GameServer_SetPlayerViewFamilyState(ShareDefine.TViewFamilyType_None)
|
return
|
|
def __SetForbidFamilyAward(curPlayer):
|
''' ÉèÖüÒ×åÏà¹Ø»î¶¯Áì½±ÏÞÖÆ
|
Èç¹ûÍ˳öʱ½ñÈÕÒÑ¿ªÊ¼¹ý¶ÔÓ¦»î¶¯£¬ÔòÉèÖÃÁì½±ÏÞÖÆ
|
'''
|
|
playerID = curPlayer.GetPlayerID()
|
openState = GameWorld.GetGameWorld().GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_FamilyActivityDayState)
|
forbidState = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_ForbidFamilyAward)
|
GameWorld.DebugLog("Í˳ö¼Ò×å´¦Àí¼Ò×å»î¶¯½±ÀøÁìÈ¡ÏÞÖÆ! openState=%s,forbidState=%s" % (openState, forbidState), playerID)
|
|
updForbidState = forbidState
|
for activityType in ShareDefine.Def_FamActivityList:
|
|
if not openState&pow(2, activityType):
|
GameWorld.DebugLog(" ¸Ã¼Ò×å»î¶¯½ñÈÕ먦Æô¹ý£¡ ²»ÉèÖÃÏÞÖÆÁì½±! activityType=%s" % activityType, playerID)
|
continue
|
updForbidState = updForbidState|pow(2, activityType)
|
GameWorld.DebugLog(" ¼Ò×å»î¶¯Áì½±ÏÞÖÆ activityType=%s,updForbidState=%s" % (activityType, updForbidState), playerID)
|
|
if updForbidState != forbidState:
|
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_ForbidFamilyAward, updForbidState)
|
GameWorld.DebugLog(" ¸üмÒ×å»î¶¯Áì½±ÏÞÖÆ: forbidState=%s,updForbidState=%s" % (forbidState, updForbidState), playerID)
|
|
return
|
|
## ÉèÖÃÍæ¼ÒÊÇ·ñ¿ÉÒԲμӼÒ×å»î¶¯
|
# @param curPlayer Íæ¼ÒʵÀý
|
# @param isForbid ÊÇ·ñÏÞÖÆ
|
# @return ·µ»ØÖµÎÞÒâÒå
|
def SetForbidFamilyAction(curPlayer, isForbid):
|
#===============================================================================================
|
# if curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_ForbidFamilyAction) != isForbid:
|
# PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_ForbidFamilyAction, isForbid)
|
#
|
# # Í¨ÖªÍæ¼ÒÊÇ·ñ¿ÉÒԲμӼÒ×å»î¶¯
|
# SendClientForbidFamilyAction(curPlayer)
|
#===============================================================================================
|
return
|
|
|
## Í¨ÖªÍæ¼ÒÊÇ·ñ¿ÉÒԲμӼÒ×å»î¶¯
|
# @param curPlayer Íæ¼ÒʵÀý
|
# @return ·µ»ØÖµÎÞÒâÒå
|
def SendClientForbidFamilyAction(curPlayer):
|
# isForbid = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_ForbidFamilyAction)
|
#
|
# outCardsCDTime = ChPyNetSendPack.tagPyFamilyActionForbid()
|
# outCardsCDTime.Clear()
|
#
|
# outCardsCDTime.IsForbid = isForbid
|
# NetPackCommon.SendFakePack(curPlayer, outCardsCDTime)
|
return
|
|
|
#===============================================================================
|
# //A6 01 ÏòÍæ¼ÒÉêÇë¼ÓÈë¼Ò×å #tagCGRequestJoinFamilyByPlayer
|
#
|
# struct tagCGRequestJoinFamilyByPlayer
|
#
|
# {
|
# tagHead Head;
|
# DWORD AddPlayerID; //ÉêÇë¼ÓÈëµÄÍæ¼ÒID
|
# };
|
#===============================================================================
|
## ͨ¹ýÉêÇë¼ÓÈë¼Ò×å
|
# @param index: Íæ¼ÒË÷Òý
|
# @param clientData: ·â°ü½á¹¹Ìå
|
# @param tick: ʱ¼ä´Á
|
# @return: None
|
def RequestAddFamilyByID(index, clientData, tick):
|
curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
|
|
addPlayerID = clientData.AddPlayerID #ÉêÇë½øÈëµÄ¼Ò×åID
|
|
addPlayer = GameWorld.GetPlayerManager().FindPlayerByID(addPlayerID)
|
#¶Ô·½ÏÂÏß
|
if not addPlayer:
|
return
|
|
addFamilyID = addPlayer.GetFamilyID()
|
#¶Ô·½Ã»ÓмÒ×å
|
if addFamilyID <= 0:
|
return
|
|
#ÉêÇë¼ÓÈë
|
AddFamily(curPlayer, addFamilyID)
|
|
#֪ͨµ±Ç°ÉêÇë¼ÓÈëµÄÄÄЩ¼Ò×å
|
#Sync_RequestAddFamilyInfo(curPlayer)
|
return
|
|
|
#===============================================================================
|
# //A6 02 ÉêÇë¼ÓÈë¼Ò×å#tagCGRequesJoinFamily
|
#
|
# struct tagCGRequesJoinFamily
|
#
|
# {
|
# tagHead Head;
|
# BYTE Type; //ÉêÇëÀàÐÍ
|
# DWORD AddFamilyID; //ÉêÇë¼ÓÈëµÄ¼Ò×å
|
# };
|
#===============================================================================
|
## ÉêÇë¼ÓÈë¼Ò×å
|
# @param index: Íæ¼ÒË÷Òý
|
# @param clientData: ·â°ü½á¹¹Ìå
|
# @param tick: ʱ¼ä´Á
|
# @return: None
|
def RequestAddFamily(index, clientData, tick):
|
curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
|
|
addFamilyID = clientData.AddFamilyID # ÉêÇë½øÈëµÄ¼Ò×åID
|
requestType = clientData.Type # ÉêÇëÀàÐÍ(ÉêÇë/³·Ïú)
|
|
if requestType == 0:
|
#ÉêÇë¼ÓÈë
|
AddFamily(curPlayer, addFamilyID)
|
|
elif requestType == 1:
|
DelAddFamilyRecord()
|
|
|
#֪ͨµ±Ç°ÉêÇë¼ÓÈëµÄÄÄЩ¼Ò×å
|
Sync_RequestAddFamilyInfo(curPlayer)
|
return
|
|
def DelAddFamilyRecord(curPlayer):
|
for index in range(0, ChConfig.Def_Player_RequestAddFamilyMaxCnt):
|
|
#ÉêÇë¼ÓÈëµÄ¼Ò×åID
|
requestAddFamilyID = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_RequestAddFamilyID%index)
|
if not requestAddFamilyID:
|
continue
|
#±¾°æ±¾ÒòΪ¿Í»§¶ËûÓе¥¸öÈ¡ÏûÉêÇëµÄ²Ù×÷£¬´Ë´¦·¢Ò»´Î°üÒ»´ÎÐÔÈ«²¿È¡Ïû
|
# if addFamilyID != requestAddFamilyID:
|
# continue
|
|
#ÉêÇëÊýÁ¿-1
|
requestAddFamilyCnt = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_RequestAddFamilyCnt)
|
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_RequestAddFamilyCnt, requestAddFamilyCnt - 1)
|
|
#Çå³ý³·ÏúÉêÇëµÄ¼Ò×åID¼Ç¼
|
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_RequestAddFamilyID%index, 0)
|
|
#ÏòGameServer·¢ËÍÇëÇóɾ³ý¸ÃÍæ¼ÒµÄÉêÇë¼Ò×åÐÅÏ¢Çé¿ö
|
sendMsg = str(requestAddFamilyID)
|
curPlayer.GameServer_QueryPlayerByID(ChConfig.queryType_DelFamilyAction,
|
ShareDefine.Def_ActionType_FamilyAdd, '', sendMsg, len(sendMsg))
|
|
Sync_RequestAddFamilyInfo(curPlayer)
|
return
|
|
## ֪ͨµ±Ç°ÉêÇë¼ÓÈëµÄÄÄЩ¼Ò×å
|
# @param curPlayer:Íæ¼ÒʵÀý
|
# @return: None
|
def Sync_RequestAddFamilyInfo(curPlayer):
|
requestAddFamilyCnt = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_RequestAddFamilyCnt)
|
|
packList = []
|
for index in range(0, ChConfig.Def_Player_RequestAddFamilyMaxCnt):
|
familyID = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_RequestAddFamilyID%index)
|
if familyID == 0:
|
continue
|
|
requestAddFamilyInfo = ChPyNetSendPack.tagRequestJoinFamily()
|
requestAddFamilyInfo.RequestFamilyID = familyID
|
packList.append(requestAddFamilyInfo)
|
|
requestAddFamily = ChPyNetSendPack.tagMCNotifyRequestJoinFamilyInfo()
|
requestAddFamily.Clear()
|
requestAddFamily.RequestCount = len(packList)
|
requestAddFamily.RequestAddFamilyInfo = packList
|
|
NetPackCommon.SendFakePack(curPlayer, requestAddFamily)
|
return
|
|
|
## ÉêÇë¼ÓÈë°ï»á
|
#@param curPlayer ¼Ò×åʵÀý
|
#@param familyID ¼Ò×åID
|
#@return ·µ»ØÖµÎÞÒâÒå
|
def AddFamily(curPlayer, familyID):
|
|
requestAddFamilyCnt = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_RequestAddFamilyCnt)
|
if requestAddFamilyCnt >= ChConfig.Def_Player_RequestAddFamilyMaxCnt:
|
# jiazu_pan_21675 ¸ÄΪ jiazu_lhs_31379 ×î¶àͬʱÏò%s¸ö°ï»á·¢³öÉêÇë
|
PlayerControl.NotifyCode(curPlayer, "jiazu_lhs_31379", [ChConfig.Def_Player_RequestAddFamilyMaxCnt])
|
return
|
|
#ÊÇ·ñÒѾÉêÇëÁË
|
for index in range(0, ChConfig.Def_Player_RequestAddFamilyMaxCnt):
|
if curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_RequestAddFamilyID%index) == familyID:
|
GameWorld.DebugLog('ÒѾÔÚÉêÇëÁбíÖÐ')
|
#ÒѾÔÚÉêÇëÁбíÖÐ
|
return
|
|
#ÇëÇó¼Ç¼ÉêÇë½øÈë¼Ò×åÐÅÏ¢
|
sendMsg = cPickle.dumps([familyID, PlayerControl.GetFightPower(curPlayer)], 2)
|
curPlayer.GameServer_QueryPlayerByID(ChConfig.queryType_AddFamilyAction,
|
ShareDefine.Def_ActionType_FamilyAdd, '', sendMsg, len(sendMsg))
|
|
#µÈGameServer·´À¡½á¹ûÔÙ´¦Àí
|
return
|
|
#¼Ç¼¸öÈËÉêÇë¼ÓÈëµÄ¼Ò×åID
|
for index in range(0, ChConfig.Def_Player_RequestAddFamilyMaxCnt):
|
if curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_RequestAddFamilyID%index) == 0:
|
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_RequestAddFamilyID%index, familyID)
|
break
|
|
#¼Ç¼¸öÈËÉêÇë¼ÓÈë¼Ò×åµÄ¸öÊý
|
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_RequestAddFamilyCnt, requestAddFamilyCnt + 1)
|
|
return
|
|
|
|
|
|
## Õ½ÃËÍæ¼ÒOnDay
|
# @param curPlayer
|
# @return None
|
def FamilyPlayerOnDay(curPlayer):
|
if not GameFuncComm.GetFuncCanUse(curPlayer, ShareDefine.GameFuncID_Family):
|
return
|
#ÿÈÕ¸£Àû½±Àø
|
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_FamilyDayAward, 0)
|
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_FamilyMoneyDonateCount, 0)
|
Sync_FamilyDayRewardState(curPlayer)
|
__FamilyAffair_Refresh(curPlayer, True)
|
|
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_FamilyZhenbaogeCut, 0)
|
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_FamilyZhenbaogeBuy, 0)
|
Sync_ZhenbaogeInfo(curPlayer)
|
return
|
|
|
## Õ½ÃËÍæ¼ÒOnLogin
|
# @param curPlayer
|
# @return None
|
def FamilyPlayerOnLogin(curPlayer, tick):
|
if not GameFuncComm.GetFuncCanUse(curPlayer, ShareDefine.GameFuncID_Family):
|
return
|
|
PlayerFamilyTech.Sync_PlayerFamilyTechLV(curPlayer)
|
SyncFamilyActivityInfo(curPlayer)
|
Sync_FamilyDayRewardState(curPlayer)
|
__FamilyAffair_CheckReset(curPlayer)
|
PlayerFamilyZhenfa.OnPlayerLogin(curPlayer)
|
Sync_ZhenbaogeInfo(curPlayer)
|
return
|
|
def FamilyPlayerOnLoginCross(curPlayer):
|
## µÇ¼¿ç·þ·þÎñÆ÷
|
crossFamilyMemberLV = curPlayer.GetReceivedSalary()
|
if crossFamilyMemberLV:
|
curPlayer.SetFamilyMemberLV(crossFamilyMemberLV)
|
GameWorld.DebugLog("¿ç·þµÇ¼ÉèÖÃÏÉÃËְλµÈ¼¶: %s" % crossFamilyMemberLV, curPlayer.GetPlayerID())
|
|
return
|
|
|
|
|
## ֪ͨGameServerÔö¼Ó¼Ò×åÏà¹ØÐÅÏ¢Öµ
|
# @param curPlayer Íæ¼ÒʵÀý
|
# @param infoDict ÐÅÏ¢×Öµä
|
# @return
|
def Send_GameServer_PyAddFamilyInfoValue(curPlayer, infoDict={}):
|
if not isinstance(infoDict, dict) or not infoDict:
|
GameWorld.DebugLog("Send_GameServer_PyAddFamilyInfoValue infoDict=%s err!" % str(infoDict))
|
return
|
|
sendMsg = '%s'%(infoDict)
|
#GameWorld.DebugLog("Send_GameServer_PyAddFamilyInfoValue sendMsg=%s" % sendMsg)
|
GameWorld.GetPlayerManager().GameServer_QueryPlayerResult(curPlayer.GetID(), 0, 0, 'PyAddFamilyInfoValue', sendMsg, len(sendMsg))
|
return
|
|
#---------------------------------------------------------------------
|
|
|
|
## Ìí¼Ó¼Ò×åʼþ¼Ç¼
|
def AddFamilyEventNote(curPlayer, eventType, valueList):
|
##ͬ²½¼Ç¼µ½GameServer, eventTypeĬÈÏΪvalue1
|
sendMsg = cPickle.dumps([eventType] + valueList, 2)
|
curPlayer.GameServer_QueryPlayerByID(ChConfig.queryType_AddFamilyAction, ShareDefine.Def_ActionType_FamilyEvent, '', sendMsg, len(sendMsg))
|
GameWorld.DebugLog("AddFamilyEventNote sendMsg=%s" % sendMsg)
|
return
|
|
|
## --------------------------------- ÏÉÃË»îÔ¾ -----------------------------------
|
def OnWeekEx(curPlayer):
|
#ÖØÖÃ
|
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FamilyActivityAwardRecord, 0)
|
for actionid in ShareDefine.FamilyActiveIDList:
|
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FamilyActivityFinishCnt%actionid, 0)
|
|
SyncFamilyActivityInfo(curPlayer)
|
return
|
|
## ÁìÈ¡ÏÉÃË»îÔ¾¶È½±Àø
|
# @param curPlayer
|
# @param awardIndex
|
# @return None
|
def GetFamilyActivityAward(curPlayer, awardIndex):
|
return
|
familyActiveList = IpyGameDataPY.GetFuncEvalCfg('FamilyActive')
|
familyActiveAwardList = IpyGameDataPY.GetFuncEvalCfg('FamilyActive', 2)
|
if awardIndex < 0 or awardIndex >= len(familyActiveList):
|
GameWorld.ErrLog("»îÔ¾¶È½±ÀøË÷Òý²»ºÏ·¨,index=%s,Len=%s" % (awardIndex, len(familyActiveList)))
|
return
|
|
# ÅжÏÊÇ·ñÒÑÁìÈ¡
|
getAwardRecord = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FamilyActivityAwardRecord, 0)
|
if getAwardRecord & pow(2, awardIndex):
|
GameWorld.Log("ÒѾÁìÈ¡¹ý¸Ã»îÔ¾¶È½±Àø,index=%s" % (awardIndex))
|
return
|
|
|
needActivity = familyActiveList[awardIndex]
|
totalActivity = __GetTotalFamilyActivity(curPlayer)#×Ü»îÔ¾¶È
|
|
# ÅжϻîÔ¾¶È
|
if totalActivity < needActivity:
|
GameWorld.Log("Áì½±»îÔ¾¶È²»×ã,index=%s,needActivity=%s,totalActivity=%s"
|
% (awardIndex, needActivity, totalActivity))
|
return
|
|
activityValue = familyActiveAwardList[awardIndex]
|
PlayerControl.GiveMoney(curPlayer, ShareDefine.TYPE_Price_FamilyActivity, activityValue)
|
|
# ¸üÐÂÒÑÁìÈ¡³É¹¦±ê¼Ç
|
updAwardRecord = getAwardRecord | (1 << awardIndex)
|
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FamilyActivityAwardRecord, updAwardRecord)
|
|
SyncFamilyActivityInfo(curPlayer)
|
GameWorld.DebugLog("ÁìÈ¡ÏÉÃË»îÔ¾¶È½±ÀøOK£¡ index=%s,needActivity=%s,totalActivity=%s,awardRecord=%s"
|
% (awardIndex, needActivity, totalActivity, updAwardRecord))
|
return
|
|
def AddFamilyActivity(curPlayer, actionid, addCnt=1):
|
return
|
ipyData = IpyGameDataPY.GetIpyGameData('FamilyActivity', actionid)
|
if not ipyData:
|
return
|
if not GameFuncComm.GetFuncCanUse(curPlayer, ipyData.GetUnLockFuncID()):
|
return
|
finishCnt = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FamilyActivityFinishCnt%actionid, 0)
|
maxCnt = ipyData.GetTotalActivityTime()
|
if finishCnt >= maxCnt:
|
return
|
newCnt = min(maxCnt, finishCnt+addCnt)
|
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FamilyActivityFinishCnt%actionid, newCnt)
|
SyncFamilyActivityInfo(curPlayer, actionid)
|
GameWorld.DebugLog(' ÏÉÃË»îÔ¾Íê³É´ÎÊý actionid=%s,newCnt=%s'%(actionid, newCnt))
|
return
|
|
def __GetTotalFamilyActivity(curPlayer):
|
##»ñÈ¡×ÜÏÉÃË»îÔ¾¶È
|
totalPoint = 0
|
ipyDataMgr = IpyGameDataPY.IPY_Data()
|
for i in xrange(ipyDataMgr.GetFamilyActivityCount()):
|
ipyData = ipyDataMgr.GetFamilyActivityByIndex(i)
|
actionid = ipyData.GetID()
|
curTimes = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FamilyActivityFinishCnt%actionid, 0)
|
totalPoint += curTimes/ipyData.GetSingleTimes()*ipyData.GetSingleActiveValue()
|
return totalPoint
|
|
def SyncFamilyActivityInfo(curPlayer, syncActionid=-1):
|
return
|
#֪ͨ»îÔ¾ÁìÈ¡Çé¿ö
|
syncActionIDList = ShareDefine.FamilyActiveIDList if syncActionid==-1 else [syncActionid]
|
sendPack = ChPyNetSendPack.tagMCFamilyActivityInfo()
|
sendPack.Clear()
|
sendPack.AwardRecord = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FamilyActivityAwardRecord, 0)
|
sendPack.InfoList = []
|
for actionid in syncActionIDList:
|
activityInfo = ChPyNetSendPack.tagMCFamilyActionCnt()
|
activityInfo.ActionID = actionid
|
activityInfo.FinishCnt = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FamilyActivityFinishCnt%actionid, 0)
|
sendPack.InfoList.append(activityInfo)
|
sendPack.Count = len(sendPack.InfoList)
|
NetPackCommon.SendFakePack(curPlayer, sendPack)
|
return
|
|
#=================ÏÉÃ˸ÄÃû======================
|
#// A6 11 ¼Ò×å¸ÄÃû #tagCMRenameFamily
|
#
|
#struct tagCMRenameFamily
|
#{
|
# tagHead Head;
|
# BYTE NewNameLen;
|
# char NewName[NewNameLen];
|
# BYTE ItemIndex; //¸ÄÃûÎïÆ·ÔÚ±³°üÖеÄλÖÃ
|
#};
|
def UpdateFamilyName(index, clientData, tick):
|
|
curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
|
if GameWorld.IsCrossServer():
|
#itemuse_lzxkoy_0:²»¿ÉÔÚ¿ç·þ»·¾³ÏÂʹÓøÄÃû¹¦ÄÜ¡£
|
PlayerControl.NotifyCode(curPlayer, "itemuse_lzxkoy_0")
|
return
|
|
if not curPlayer.GetFamilyID():
|
return
|
|
if curPlayer.GetDictByKey(ChConfig.Def_Player_Dict_UpdateFamilyName):
|
#ÕýÔÚ¸ÄÃûÖÐ
|
GameWorld.Log("ÏÉÃËÒѾÔÚ¸ÄÃûÖÐ...", curPlayer.GetID())
|
return
|
|
#ÐÂÃû×Ö
|
newName = clientData.NewName
|
itemIndex = clientData.ItemIndex
|
|
itemPack = curPlayer.GetItemManager().GetPack(IPY_GameWorld.rptItem)
|
curItem = itemPack.GetAt(itemIndex)
|
if not ItemCommon.CheckItemCanUse(curItem):
|
return
|
if curItem.GetType() != ChConfig.Def_ItemType_ChangeFamilyName:
|
return
|
|
#¸ÄÃûÎïÆ·ÔÚ±³°üµÄλÖÃ
|
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_UpdateFamilyNameItemIndex, itemIndex)
|
|
#ÉèÖÃÕýÔÚ¸ÄÃûÖÐ...
|
curPlayer.SetDict(ChConfig.Def_Player_Dict_UpdateFamilyName, 1)
|
|
#֪ͨGameServerÕýʽ¸ÄÃû
|
newNameMsg = str(newName)
|
GameWorld.Log("UpdateFamilyName ֪ͨGameServerÕýʽ¸ÄÃûΪ:%s"%newNameMsg, curPlayer.GetID())
|
GameWorld.GetPlayerManager().GameServer_QueryPlayerResult(curPlayer.GetID(), 0, 0, 'UpdateFamilyName', newNameMsg, len(newNameMsg))
|
return
|
|
|
## ¿Û³ý¸ÄÃûÏûºÄ
|
# @param curPlayer: Íæ¼ÒʵÀý
|
# @return: None
|
def PayUpdateFamilyNameCost(curPlayer):
|
itemIndex = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_UpdateFamilyNameItemIndex)
|
#¿Û³ýÎïÆ·
|
itemPack = curPlayer.GetItemManager().GetPack(IPY_GameWorld.rptItem)
|
curItem = itemPack.GetAt(itemIndex)
|
if curItem:
|
ItemCommon.DelItem(curPlayer, curItem, 1, True, 'UpdateFamilyName')
|
|
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_UpdateFamilyNameItemIndex, 0)
|
return
|
|
def GetFamilyDayAward(curPlayer):
|
##ÁìÈ¡ÏÉÃËÿÈÕ½±Àø 2СʱÍÑ»ú¹Òʱ¼ä
|
if not curPlayer.GetFamilyID():
|
return
|
hasGot = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_FamilyDayAward)
|
if hasGot:
|
GameWorld.DebugLog('ÁìÈ¡ÏÉÃËÿÈÕ½±Àø µ±ÈÕÒÑÁìÈ¡£¡')
|
return
|
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_FamilyDayAward, 1)
|
#addTime = IpyGameDataPY.GetFuncCfg('FamilyDayAward')
|
#PlayerTJG.AddTJGTime(curPlayer, addTime)
|
#֪ͨ
|
Sync_FamilyDayRewardState(curPlayer)
|
#PlayerControl.NotifyCode(curPlayer, 'OfflinePlugSuccess', [addTime/60/60])
|
|
return
|
|
def Sync_FamilyDayRewardState(curPlayer):
|
clientPack = ChPyNetSendPack.tagMCFamilyDayAward()
|
clientPack.GetState = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_FamilyDayAward)
|
clientPack.MoneyDonateCount = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_FamilyMoneyDonateCount)
|
NetPackCommon.SendFakePack(curPlayer, clientPack)
|
return
|
|
|
#// A6 06 ¼Ò×å¶Ò»»»îÔ¾Áî #tagCMFamilyActivityExchange
|
#
|
#struct tagCMFamilyActivityExchange
|
#{
|
# tagHead Head;
|
# BYTE Count; //²ÄÁÏËùÔÚ±³°üË÷ÒýµÄÊýÁ¿
|
# WORD IndexList[Count]; //²ÄÁÏËùÔÚ±³°üË÷ÒýÁбí
|
# DWORD ItemIDList[Count]; //²ÄÁÏËùÔÚ±³°üÎïÆ·IDÁбí
|
#};
|
## ¼Ò×å¶Ò»»»îÔ¾Áî
|
# @param playerIndex Íæ¼ÒË÷Òý
|
# @param clientData ¿Í»§¶Ë·â°ü
|
# @param tick ʱ¼ä
|
# @return None
|
def OnFamilyActivityExchange(index, clientData, tick):
|
curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
|
if not clientData.Count:
|
return
|
playerID = curPlayer.GetID()
|
eatIndexList = clientData.IndexList
|
eatItemIDList = clientData.ItemIDList
|
givePoint = 0 #·Ö½âµÃµ½»îÔ¾Áî
|
familyDonateDict = IpyGameDataPY.GetFuncEvalCfg('FamilyDonate', 1, {})
|
familyDonateSpecialDict = IpyGameDataPY.GetFuncEvalCfg('FamilyDonate', 2, {})
|
itemPack = curPlayer.GetItemManager().GetPack(IPY_GameWorld.rptItem)
|
for i, index in enumerate(eatIndexList):
|
eatItem = itemPack.GetAt(index)
|
if not ItemCommon.CheckItemCanUse(eatItem):
|
GameWorld.DebugLog("ÎïÆ·²»¿ÉÓã¬ÎÞ·¨¶Ò»»£¡itemIndex=%s" % index)
|
continue
|
eatItemID = eatItem.GetItemTypeID()
|
if eatItemID != eatItemIDList[i]:
|
GameWorld.Log('¼Ò×å¶Ò»»»îÔ¾Áî ·¢µÄÎïÆ·ID²»¶ÔÓ¦index=%s eatItemID=%s,ItemIDList[i]=%s' % (index, eatItemID, eatItemIDList[i]), playerID)
|
continue
|
#if eatItem.GetIsBind():
|
# GameWorld.DebugLog("×°±¸ÒѰ󶨣¬ÎÞ·¨¶Ò»»£¡itemIndex=%s" % index)
|
# continue
|
if eatItem.GetEndureReduceType():
|
GameWorld.DebugLog("ÓÐʱЧÄ;ÃÎïÆ·£¬ÎÞ·¨¶Ò»»£¡itemIndex=%s" % index)
|
continue
|
if eatItemID in familyDonateSpecialDict:
|
addPoint = familyDonateSpecialDict[eatItemID]
|
else:
|
if not ItemCommon.CheckItemIsEquip(eatItem):
|
GameWorld.DebugLog("·Ç×°±¸£¬ÎÞ·¨¶Ò»»£¡itemIndex=%s" % index)
|
continue
|
itemColor = eatItem.GetItemColor()
|
if str(itemColor) not in familyDonateDict:
|
continue
|
isSuite = eatItem.GetSuiteID()
|
addPoint = familyDonateDict[str(itemColor)][1 if isSuite else 0]
|
itemCnt = eatItem.GetCount()
|
givePoint += addPoint * itemCnt
|
ItemCommon.DelItem(curPlayer, eatItem, itemCnt, True, ChConfig.ItemDel_FamilyStore, {'addPoint':addPoint}, True)
|
|
if not givePoint:
|
GameWorld.DebugLog("¼Ò×å¶Ò»»»îÔ¾ÁûÓÐ×°±¸¿É¶Ò»»£¡")
|
return
|
PlayerControl.GiveMoney(curPlayer, ShareDefine.TYPE_Price_FamilyActivity, givePoint)
|
|
#֪ͨ½á¹û
|
packData = ChPyNetSendPack.tagMCFamilyActivityExchangeResult()
|
packData.Clear()
|
packData.Point = givePoint
|
NetPackCommon.SendFakePack(curPlayer, packData)
|
return
|
|
#// A6 12 ¼Ò×å¾èÏ×»õ±Ò #tagCMFamilyMoneyDonate
|
#
|
#struct tagCMFamilyMoneyDonate
|
#{
|
# tagHead Head;
|
# BYTE MoneyType; // ¾èÏ×»õ±ÒÀàÐÍ
|
#};
|
def OnFamilyMoneyDonate(index, clientData, tick):
|
curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
|
moneyType = clientData.MoneyType
|
playerID = curPlayer.GetPlayerID()
|
|
dailyDonateCountMax = IpyGameDataPY.GetFuncCfg('FamilyDonate', 3)
|
donateCount = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_FamilyMoneyDonateCount)
|
if dailyDonateCountMax and donateCount >= dailyDonateCountMax:
|
GameWorld.DebugLog("½ñÈÕ»õ±Ò¾èÏ×´ÎÊýÒÑ´ïÉÏÏÞ. donateCount=%s" % donateCount, playerID)
|
return
|
|
donatePrizeInfo = IpyGameDataPY.GetFuncEvalCfg('FamilyDonate', 4, {})
|
if str(moneyType) not in donatePrizeInfo:
|
GameWorld.DebugLog("²»´æÔڸûõ±ÒÀàÐ;èÏ×: moneyType=%s" % moneyType, playerID)
|
return
|
needMoney, contribution, familyActivity = donatePrizeInfo[str(moneyType)]
|
if not PlayerControl.PayMoney(curPlayer, moneyType, needMoney, "FamilyMoneyDonate"):
|
return
|
|
updDonateCount = donateCount + 1
|
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_FamilyMoneyDonateCount, updDonateCount)
|
Sync_FamilyDayRewardState(curPlayer)
|
GameWorld.DebugLog("»õ±Ò¾èÏ×: moneyType=%s,needMoney=%s,updDonateCount=%s,contribution=%s,familyActivity=%s"
|
% (moneyType, needMoney, updDonateCount, contribution, familyActivity), playerID)
|
|
if contribution > 0:
|
AddPlayerFamilyActiveValue(curPlayer, contribution, True, ShareDefine.Def_AddFAVReason_FamilyDonateItem, True)
|
|
if familyActivity > 0:
|
PlayerControl.GiveMoney(curPlayer, ShareDefine.TYPE_Price_FamilyActivity, familyActivity)
|
|
return
|
|
|
##--------------------------------------- ÏÉÃËÊÂÎñ --------------------------------------------------
|
AffairState_None = 0 # ÎÞ
|
AffairState_Underway = 1 # ½øÐÐÖÐ
|
AffairState_Finish = 2 # ÒÑÍê³É
|
|
#// A6 13 ¼Ò×åÊÂÎñ²Ù×÷ #tagCMFamilyAffairOP
|
#
|
#struct tagCMFamilyAffairOP
|
#{
|
# tagHead Head;
|
# BYTE OPType; // ²Ù×÷ÀàÐÍ£º1-Ë¢ÐÂÊÂÎñ£»2-¿ªÊ¼ÊÂÎñ£»3-ÁìÈ¡ÊÂÎñ½±Àø£»
|
# WORD AffairID; // ÊÂÎñID£¬¿ÉÑ¡
|
#};
|
def OnFamilyAffairOP(index, clientData, tick):
|
curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
|
opType = clientData.OPType
|
affairID = clientData.AffairID
|
|
if opType == 1:
|
__FamilyAffair_Refresh(curPlayer)
|
elif opType == 2:
|
__FamilyAffair_Start(curPlayer, affairID)
|
elif opType == 3:
|
__FamilyAffair_GetAward(curPlayer, affairID)
|
return
|
|
def __FamilyAffair_CheckReset(curPlayer):
|
## ¼ì²éÈÎÎñÖØÖ㬵Ǽ£¬½øÈëÏÉÃË´¥·¢
|
info = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_FamilyAffairInfo % 1)
|
if not info:
|
# ÈÎÎñ1»¹Ã»·ÖÅ䣬ĬÈÏÇ¿ÖÆÖØÖÃ
|
__FamilyAffair_Refresh(curPlayer, True)
|
else:
|
SyncFamilyAffairInfo(curPlayer)
|
return
|
|
def __FamilyAffair_Refresh(curPlayer, isReset=False):
|
## Ë¢ÐÂÊÂÎñ
|
|
playerID = curPlayer.GetPlayerID()
|
moneyType, moneyValue = 0, 0
|
dayRefreshFreeCount = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_FamilyAffairRefreshFree)
|
if not isReset:
|
freeCountMax = IpyGameDataPY.GetFuncCfg("FamilyAffair", 2)
|
if freeCountMax and dayRefreshFreeCount >= freeCountMax:
|
moneyType, moneyValue = IpyGameDataPY.GetFuncEvalCfg("FamilyAffair", 3)
|
if not PlayerControl.HaveMoney(curPlayer, moneyType, moneyValue):
|
return
|
|
sendMailAffairList = []
|
refreshAffairIDList = []
|
affairCountMax = IpyGameDataPY.GetFuncCfg("FamilyAffair", 1)
|
affairStarDict = IpyGameDataPY.GetFuncEvalCfg("FamilyAffair", 4)
|
maxStar = 0
|
starWeightList = []
|
for starStr, starInfo in affairStarDict.items():
|
star = int(starStr)
|
if star > maxStar:
|
maxStar = star
|
starWeightList.append([starInfo[0], star])
|
|
for affairID in range(1, affairCountMax + 1):
|
star, state = __GetAffairInfo(curPlayer, affairID)
|
if isReset:
|
# ÖØÖÃʱ»¹ÔÚ½øÐÐÖеÄÖ±½Ó·¢½±Àø
|
if state == AffairState_Underway:
|
sendMailAffairList.append([affairID, star])
|
refreshAffairIDList.append(affairID)
|
else:
|
# ·ÇÖØÖÃÖ»´¦ÀíûÓÐ״̬·Ç×î¸ßÐǵÄ
|
if state == AffairState_None and star < maxStar:
|
refreshAffairIDList.append(affairID)
|
|
GameWorld.DebugLog("Ë¢ÐÂÊÂÎñ: isReset=%s,moneyType=%s,moneyValue=%s,dayRefreshFreeCount=%s"
|
% (isReset, moneyType, moneyValue, dayRefreshFreeCount), playerID)
|
GameWorld.DebugLog(" sendMailAffairList=%s" % sendMailAffairList, playerID)
|
|
for mailInfo in sendMailAffairList:
|
affairID, star = mailInfo
|
if str(star) not in affairStarDict:
|
continue
|
paramList = [affairID, star]
|
addItemList = affairStarDict[str(star)][2]
|
PlayerControl.SendMailByKey("FamilyAffairAward", [playerID], addItemList, paramList)
|
|
if isReset:
|
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_FamilyAffairRefreshFree, 0)
|
for affairID in range(1, affairCountMax + 1):
|
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_FamilyAffairInfo % affairID, 0)
|
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_FamilyAffairStartTime % affairID, 0)
|
else:
|
if moneyType and moneyValue:
|
PlayerControl.PayMoney(curPlayer, moneyType, moneyValue, "FamilyAffair")
|
else:
|
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_FamilyAffairRefreshFree, dayRefreshFreeCount + 1)
|
|
GameWorld.DebugLog(" starWeightList=%s" % starWeightList, playerID)
|
GameWorld.DebugLog(" refreshAffairIDList=%s" % refreshAffairIDList, playerID)
|
for affairID in refreshAffairIDList:
|
star = GameWorld.GetResultByWeightList(starWeightList, 1)
|
__SetAffairInfo(curPlayer, affairID, star, AffairState_None)
|
GameWorld.DebugLog(" Ëæ»úÊÂÎñ:affairID=%s,star=%s" % (affairID, star), playerID)
|
|
SyncFamilyAffairInfo(curPlayer)
|
return
|
|
def __FamilyAffair_Start(curPlayer, affairID):
|
## ¿ªÊ¼ÊÂÎñ
|
playerID = curPlayer.GetPlayerID()
|
star, state = __GetAffairInfo(curPlayer, affairID)
|
if not star:
|
return
|
if state != AffairState_None:
|
GameWorld.DebugLog("ÏÉÃËÊÂÎñÒѾ½øÐÐÖлòÒÑÍê³É£¬ÎÞ·¨¿ªÊ¼: affairID=%s,star=%s,state=%s" % (affairID, star, state), playerID)
|
return
|
startTime = int(time.time())
|
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_FamilyAffairStartTime % affairID, startTime)
|
__SetAffairInfo(curPlayer, affairID, star, AffairState_Underway)
|
GameWorld.DebugLog("ÏÉÃËÊÂÎñ¿ªÊ¼: affairID=%s,star=%s,startTime=%s" % (affairID, star, startTime), playerID)
|
SyncFamilyAffairInfo(curPlayer, affairID)
|
return
|
|
def __FamilyAffair_GetAward(curPlayer, affairID):
|
## ÁìÈ¡ÊÂÎñ½±Àø
|
playerID = curPlayer.GetPlayerID()
|
curTime = int(time.time())
|
affairStarDict = IpyGameDataPY.GetFuncEvalCfg("FamilyAffair", 4)
|
star, state = __GetAffairInfo(curPlayer, affairID)
|
if state != AffairState_Underway:
|
GameWorld.DebugLog("ÏÉÃËÊÂÎñ״̬·Ç½øÐÐÖÐÎÞ·¨ÁìÈ¡: affairID=%s,star=%s,state=%s" % (affairID, star, state), playerID)
|
SyncFamilyAffairInfo(curPlayer, affairID)
|
return
|
startTime = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_FamilyAffairStartTime % affairID)
|
remainDuration = __GetAffairRemainDuration(curPlayer, affairID, star, curTime, affairStarDict)
|
if remainDuration != 0:
|
GameWorld.DebugLog("ÏÉÃËÊÂÎñµ±Ç°Ê£Óàʱ³¤Î´Íê³É: affairID=%s,remainDuration=%s,startTime=%s"
|
% (affairID, remainDuration, startTime), playerID)
|
SyncFamilyAffairInfo(curPlayer, affairID)
|
return
|
if str(star) not in affairStarDict:
|
return
|
addItemList = affairStarDict[str(star)][2]
|
if not ItemCommon.GiveAwardItem(curPlayer, addItemList):
|
return
|
__SetAffairInfo(curPlayer, affairID, star, AffairState_Finish)
|
GameWorld.DebugLog("ÏÉÃËÊÂÎñÁì½±: affairID=%s,star=%s" % (affairID, star), playerID)
|
SyncFamilyAffairInfo(curPlayer, affairID)
|
return
|
|
def __GetAffairInfo(curPlayer, affairID):
|
affairInfo = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_FamilyAffairInfo % affairID)
|
star, state = affairInfo / 10, affairInfo % 10
|
return star, state
|
def __SetAffairInfo(curPlayer, affairID, star, state):
|
info = star * 10 + state
|
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_FamilyAffairInfo % affairID, info)
|
return
|
def __GetAffairRemainDuration(curPlayer, affairID, star, curTime, affairStarDict):
|
## -1-δ¿ªÊ¼£»>=0-Ê£Óàʱ³¤
|
startTime = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_FamilyAffairStartTime % affairID)
|
if not startTime:
|
return -1
|
starInfo = affairStarDict.get(str(star), [])
|
needDuration = starInfo[1] if len(starInfo) > 1 else 0
|
# ¿ÉÀ©Õ¹¼õʱ³¤ÊôÐÔ
|
speedPer = PlayerControl.GetAffairSpeedPer(curPlayer)
|
if speedPer:
|
needDuration = int(needDuration * max(10000 - speedPer, 0) / 10000.0)
|
#GameWorld.DebugLog("ÊÂÎñ¼ÓËÙ: needDuration=%s,speedPer=%s" % (needDuration, speedPer), curPlayer.GetPlayerID())
|
|
remainDuration = max(needDuration - (curTime - startTime), 0)
|
return remainDuration
|
|
def SyncFamilyAffairInfo(curPlayer, affairID=None):
|
if affairID == None:
|
affairIDList = []
|
affairCountMax = IpyGameDataPY.GetFuncCfg("FamilyAffair", 1)
|
for affairID in range(1, affairCountMax + 1):
|
affairIDList.append(affairID)
|
else:
|
affairIDList = [affairID]
|
|
curTime = int(time.time())
|
affairStarDict = IpyGameDataPY.GetFuncEvalCfg("FamilyAffair", 4)
|
affairInfoList = []
|
for affairID in affairIDList:
|
star, state = __GetAffairInfo(curPlayer, affairID)
|
remainDuration = __GetAffairRemainDuration(curPlayer, affairID, star, curTime, affairStarDict)
|
affairInfo = ChPyNetSendPack.tagMCFamilyAffair()
|
affairInfo.AffairID = affairID
|
affairInfo.Star = star
|
affairInfo.State = state
|
affairInfo.RemainDuration = max(0, remainDuration)
|
affairInfoList.append(affairInfo)
|
|
if not affairInfoList:
|
return
|
clientPack = ChPyNetSendPack.tagMCFamilyAffairInfo()
|
clientPack.Clear()
|
clientPack.RefreshFreeCount = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_FamilyAffairRefreshFree)
|
clientPack.AffairInfoList = affairInfoList
|
clientPack.Count = len(clientPack.AffairInfoList)
|
NetPackCommon.SendFakePack(curPlayer, clientPack)
|
return
|
|
##--------------------------------------------------------------------------------------------------
|
##--------------------------------------- ÏÉÃË´«¹¦ --------------------------------------------------
|
#// A6 15 ´«¹¦²Ù×÷ #tagCMChuangongOP
|
#
|
#struct tagCMChuangongOP
|
#{
|
# tagHead Head;
|
# BYTE OPType; // ²Ù×÷ÀàÐÍ£º1-ÑûÇ룻2-»ØÓ¦£»3-Áì½±£»
|
# DWORD PlayerID; // Ä¿±êÍæ¼ÒID£»»ØÓ¦Ê±ÎªÑûÇë·½Íæ¼ÒID
|
# BYTE OPData; // ²Ù×÷Êý¾Ý£¬¿ÉÑ¡£º»ØÓ¦Ê±ÎªÊÇ·ñͬÒâ
|
#};
|
def OnChuangongOP(index, clientData, tick):
|
curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
|
opType = clientData.OPType
|
tagPlayerID = clientData.PlayerID
|
opData = clientData.OPData
|
|
if tagPlayerID and curPlayer.GetPlayerID() == tagPlayerID:
|
GameWorld.DebugLog("²»ÄÜ×Ô¼º´«¹¦")
|
return
|
|
if opType == 1:
|
__Chuangong_Invite(curPlayer, tagPlayerID)
|
elif opType == 2:
|
__Chuangong_Response(curPlayer, tagPlayerID, opData)
|
elif opType == 3:
|
__Chuangong_GetAward(curPlayer)
|
return
|
|
def SendGameServer_FamilyChuangong(curPlayer, msgType, msgData):
|
playerID = curPlayer.GetPlayerID()
|
GameWorld.DebugLog("´«¹¦Í¬²½GameServer: msgType=%s,%s" % (msgType, msgData), playerID)
|
msgInfo = str([msgType, msgData])
|
GameWorld.GetPlayerManager().GameServer_QueryPlayerResult(playerID, 0, 0, "FamilyChuangong", msgInfo, len(msgInfo))
|
return
|
|
def __CheckCanChuangong(curPlayer):
|
playerID = curPlayer.GetPlayerID()
|
remainCnt = PlayerActivity.GetDailyActionrRemainCnt(curPlayer, ShareDefine.DailyActionID_FamilyChuanGong)
|
if remainCnt <= 0:
|
GameWorld.DebugLog("ûÓд«¹¦´ÎÊýÁË", playerID)
|
return
|
openServerDayLimit = IpyGameDataPY.GetFuncCfg("FamilyChuangong", 1)
|
if openServerDayLimit:
|
openServerDay = GameWorld.GetGameWorld().GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_ServerDay) + 1
|
if openServerDay > openServerDayLimit:
|
GameWorld.DebugLog("µ±Ç°¿ª·þÌì²»ÄÜ´«¹¦: openServerDay=%s > %s" % (openServerDay, openServerDayLimit), playerID)
|
return
|
return True
|
|
def __Chuangong_Invite(curPlayer, tagPlayerID):
|
## ´«¹¦ÑûÇë
|
if not __CheckCanChuangong(curPlayer):
|
return
|
SendGameServer_FamilyChuangong(curPlayer, "Invite", [tagPlayerID])
|
return
|
|
def __Chuangong_Response(curPlayer, tagPlayerID, isOK):
|
## ´«¹¦»ØÓ¦
|
SendGameServer_FamilyChuangong(curPlayer, "Response", [tagPlayerID, isOK])
|
return
|
|
def __Chuangong_GetAward(curPlayer):
|
## ´«¹¦Áì½±
|
if not __CheckCanChuangong(curPlayer):
|
return
|
PlayerActivity.AddDailyActionFinishCnt(curPlayer, ShareDefine.DailyActionID_FamilyChuanGong, 1)
|
|
playerID = curPlayer.GetPlayerID()
|
fromLV = curPlayer.GetLV()
|
|
# ¸ø¾Ñé
|
totalExp = 0
|
giveRound = IpyGameDataPY.GetFuncCfg("FamilyChuangong", 3)
|
worldlv = GameWorld.GetGameWorld().GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_WorldAverageLv)
|
playerControl = PlayerControl.PlayerControl(curPlayer)
|
for index in range(giveRound):
|
reLV = curPlayer.GetLV()
|
reExp = PlayerControl.GetPlayerReExp(curPlayer)
|
giveExp = eval(IpyGameDataPY.GetFuncCompileCfg("FamilyChuangong", 2))
|
finalAddExp = playerControl.AddExp(giveExp, ShareDefine.Def_ViewExpType_Chuangong)
|
totalExp += finalAddExp
|
GameWorld.DebugLog("´«¹¦¾Ñé: ÂÖ´Î=%s,reLV=%s,reExp=%s,finalAddExp=%s, %s" % (index, reLV, reExp, finalAddExp, totalExp), playerID)
|
|
PlayerWeekParty.AddWeekPartyActionCnt(curPlayer, ChConfig.Def_WPAct_FamilyChuanGong, 1)
|
PlayerTongTianLing.AddTongTianTaskValue(curPlayer, ChConfig.TTLTaskType_ChuanGong, 1)
|
|
# ¸øÎïÆ·
|
giveItemList = IpyGameDataPY.GetFuncEvalCfg("FamilyChuangong", 4)
|
ItemControler.GivePlayerItemOrMail(curPlayer, giveItemList)
|
|
# ͬ²½½á¹û
|
syncItemList = []
|
for itemID, itemCount, _ in giveItemList:
|
syncItem = ChPyNetSendPack.tagMCChuangongItem()
|
syncItem.Clear()
|
syncItem.ItemID = itemID
|
syncItem.ItemCount = itemCount
|
syncItemList.append(syncItem)
|
# ÓÐÐÖú¸ÐлÀñºÐ
|
if IpyGameDataPY.GetIpyGameDataNotLog("AssistThanksGift", itemID):
|
SendGameServer_FamilyChuangong(curPlayer, "ThanksGift", [itemID])
|
clientPack = ChPyNetSendPack.tagMCChuangongResult()
|
clientPack.Clear()
|
clientPack.FromLV = fromLV
|
clientPack.ToLV = curPlayer.GetLV()
|
clientPack.Exp = totalExp % ChConfig.Def_PerPointValue
|
clientPack.ExpPoint = totalExp / ChConfig.Def_PerPointValue
|
clientPack.AwardItemList = syncItemList
|
clientPack.ItemCount = len(clientPack.AwardItemList)
|
NetPackCommon.SendFakePack(curPlayer, clientPack)
|
return
|
|
##--------------------------------------------------------------------------------------------------
|
##----------------------------------------- Õ䱦¸ó --------------------------------------------------
|
#// A6 16 Õ䱦¸ó²Ù×÷ #tagCMZhenbaogeOP
|
#
|
#struct tagCMZhenbaogeOP
|
#{
|
# tagHead Head;
|
# BYTE OpType; // ²Ù×÷£º0-¿³¼Û£»1-¹ºÂò
|
#};
|
def OnZhenbaogeOP(index, clientData, tick):
|
curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
|
opType = clientData.OpType
|
playerID = curPlayer.GetPlayerID()
|
if not curPlayer.GetFamilyID():
|
GameWorld.DebugLog("ûÓÐÏÉÃËÎÞ·¨²Ù×÷Õ䱦¸ó!", playerID)
|
return
|
|
# ¿³¼Û
|
if opType == 0:
|
leaveTimeEx = PlayerControl.GetLeaveFamilyTimeEx(curPlayer)
|
cutState = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_FamilyZhenbaogeCut)
|
if cutState and leaveTimeEx:
|
cutCDTimes = IpyGameDataPY.GetFuncCfg("Zhenbaoge", 3) * 60
|
passTimes = int(time.time()) - leaveTimeEx
|
if passTimes < cutCDTimes:
|
GameWorld.DebugLog("½ñÈÕÒÑ¿³¼Û±ä¸üÏÉÃË¿³¼ÛCDÖÐ! passTimes=%s < %s" % (passTimes, cutCDTimes), playerID)
|
return
|
SendGameServer_FamilyZhenbaoge(curPlayer, "Cut", [])
|
|
# ¹ºÂò
|
elif opType == 1:
|
buyState = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_FamilyZhenbaogeBuy)
|
if buyState:
|
GameWorld.DebugLog("Õ䱦¸ó½ñÈÕÒѹºÂò!", playerID)
|
return
|
moneyType = IpyGameDataPY.GetFuncCfg("Zhenbaoge", 1)
|
playerMoneyValue = PlayerControl.GetMoney(curPlayer, moneyType)
|
SendGameServer_FamilyZhenbaoge(curPlayer, "Buy", [playerMoneyValue])
|
|
return
|
|
def SendGameServer_FamilyZhenbaoge(curPlayer, msgType, msgData):
|
playerID = curPlayer.GetPlayerID()
|
tick = GameWorld.GetGameWorld().GetTick()
|
if not GameWorld.SetPlayerTickTime(curPlayer, ChConfig.TYPE_Player_Tick_FamilyZhenbaoge, tick):
|
GameWorld.DebugLog("ÇëÇóCDÖÐ...", playerID)
|
return
|
GameWorld.DebugLog("Õ䱦¸óͬ²½GameServer: msgType=%s,%s" % (msgType, msgData), playerID)
|
msgInfo = str([msgType, msgData])
|
GameWorld.GetPlayerManager().GameServer_QueryPlayerResult(playerID, 0, 0, "FamilyZhenbaoge", msgInfo, len(msgInfo))
|
return
|
|
def GameServer_FamilyZhenbaogeRet(curPlayer, resultList):
|
curPlayer.SetTickByType(ChConfig.TYPE_Player_Tick_FamilyZhenbaoge, 0)
|
playerID = curPlayer.GetPlayerID()
|
msgType, _ = resultList[:2]
|
retData = resultList[2:]
|
GameWorld.Log("ÏÉÃËÕ䱦¸óGameServer·µ»Ø: %s" % str(resultList), playerID)
|
if msgType == "Cut":
|
cutPrice = retData[0]
|
if not cutPrice:
|
# ¿³¼Ûʧ°Ü²»´¦ÀíºóÐø
|
return
|
PlayerControl.NotifyCode(curPlayer, "ZhenbaogeCut", [cutPrice])
|
if not curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_FamilyZhenbaogeCut):
|
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_FamilyZhenbaogeCut, 1)
|
Sync_ZhenbaogeInfo(curPlayer)
|
|
elif msgType == "Buy":
|
isOK = retData[0]
|
if not isOK:
|
return
|
buyState = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_FamilyZhenbaogeBuy)
|
if buyState:
|
#Ò»ÌìÖ»ÄÜÂòÒ»´Î£¬·ÀÖ¹±ä¸üÏÉÃËË¢
|
return
|
nowPrice, giveItemList = retData[1:]
|
|
moneyType = IpyGameDataPY.GetFuncCfg("Zhenbaoge", 1)
|
if nowPrice > 0:
|
if not PlayerControl.PayMoney(curPlayer, moneyType, nowPrice, "Zhenbaoge"):
|
GameWorld.ErrLog("Õ䱦¸ó¹ºÂò»õ±Ò²»×ã! nowPrice=%s" % nowPrice, playerID)
|
return
|
elif nowPrice < 0:
|
PlayerControl.GiveMoney(curPlayer, moneyType, -nowPrice, "Zhenbaoge")
|
else: # 0²»´¦Àí
|
pass
|
|
if giveItemList:
|
ItemControler.GivePlayerItemOrMail(curPlayer, giveItemList, event=["Zhenbaoge", False, {}])
|
|
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_FamilyZhenbaogeBuy, 1)
|
Sync_ZhenbaogeInfo(curPlayer)
|
|
return
|
|
def Sync_ZhenbaogeInfo(curPlayer):
|
clientPack = ChPyNetSendPack.tagMCFamilyZhenbaogeInfo()
|
clientPack.CutState = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_FamilyZhenbaogeCut)
|
clientPack.BuyState = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_FamilyZhenbaogeBuy)
|
NetPackCommon.SendFakePack(curPlayer, clientPack)
|
return
|
|
##--------------------------------------------------------------------------------------------------
|