From 8bfa5768bc81e3d8a3838527b22170b3fe95460e Mon Sep 17 00:00:00 2001
From: hch <305670599@qq.com>
Date: 星期五, 26 七月 2019 21:16:57 +0800
Subject: [PATCH] Merge branch 'master' of http://192.168.0.87:10010/r/SnxxServerCode

---
 ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerFamilyParty.py |   51 +++++++++++++++++++++++++++++++++------------------
 1 files changed, 33 insertions(+), 18 deletions(-)

diff --git a/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerFamilyParty.py b/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerFamilyParty.py
index 2c4c5dd..39e15f0 100644
--- a/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerFamilyParty.py
+++ b/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerFamilyParty.py
@@ -31,9 +31,10 @@
 import random
 
 FamilyPartyFB_QuestionID = 'FamilyPartyFB_QuestionID%s' #当前题ID
+FamilyPartyFB_QuestionTick = 'FamilyPartyFB_QuestionTick%s' #当前题出题时间
 FamilyPartyFB_AnswerTick = 'FamilyPartyFB_AnswerTick%s' #答对时间
 
-
+AnswerState = 2 #开始答题活动状态
 ## 玩家登录
 #  @param None
 #  @return None
@@ -54,7 +55,7 @@
     #刚登录的或刚进仙盟的补发最近的题目
     gameWorld = GameWorld.GetGameWorld()
     state = gameWorld.GetDictByKey(ShareDefine.Def_Notify_WorldKey_FBFuncState % ChConfig.Def_FBMapID_FamilyParty)
-    if state != 1:
+    if state != AnswerState:
         return
     curFamilyid = curPlayer.GetFamilyID()
     if not curFamilyid:
@@ -65,7 +66,7 @@
     PlayerControl.NotifyCode(curPlayer, 'Party_Topic', [questionID])
     return
 
-def FamilyPartyStateChange(state):
+def FamilyPartyStateChange(state, beforeState=0):
     #活动状态变更
 
     if state == 1:
@@ -80,8 +81,8 @@
             familyID = family.GetID()
             gameWorld.SetDict(FamilyPartyFB_QuestionID % familyID, 0)
             gameWorld.SetDict(FamilyPartyFB_AnswerTick % familyID, 0)
-            
-    
+        GameWorld.SendMapServerMsgEx(ShareDefine.Def_Notify_WorldKey_FamilyPartyInfo, [])
+        
     if state == 0:
         #活动结算 前3名仙盟、答题王
         GameWorld.Log(" 仙盟宴会结算 g_familyAnswerDict=%s, g_familyPartyTopInfo=%s"%(PyGameData.g_familyAnswerDict, PyGameData.g_familyPartyTopInfo))
@@ -100,7 +101,9 @@
                 if not family:
                     continue
                 PlayerFamilyRedPacket.CreatNewFamilyRedPacket(family, family.GetLeaderID(), redPackID)
-        PlayerControl.WorldNotify(0, 'Party_TopThree', topfamilyNameList)
+                
+        if beforeState == AnswerState:
+            PlayerControl.WorldNotify(0, 'Party_TopThree', topfamilyNameList)
         
 
         if PyGameData.g_familyPartyTopInfo:
@@ -148,7 +151,7 @@
     #开始出题
     gameWorld = GameWorld.GetGameWorld()
     state = gameWorld.GetDictByKey(ShareDefine.Def_Notify_WorldKey_FBFuncState % ChConfig.Def_FBMapID_FamilyParty)
-    if state != 1:
+    if state != AnswerState:
         return
     allQuestionIDList = IpyGameDataPY.GetConfigEx('AllQuestionID')
     ipyMgr = IpyGameDataPY.IPY_Data()
@@ -166,12 +169,21 @@
     for i in range(0, familyManager.GetCount()):
         family = familyManager.GetAt(i)
         familyID = family.GetID()
-    
-        if gameWorld.GetDictByKey(FamilyPartyFB_QuestionID % familyID):
+        lastQuestionID = gameWorld.GetDictByKey(FamilyPartyFB_QuestionID % familyID)
+        if lastQuestionID:
             #还有题未答
-            continue
+            maxSecond = IpyGameDataPY.GetFuncCfg('FairyCorrectAnswer')
+            if tick - gameWorld.GetDictByKey(FamilyPartyFB_QuestionTick % familyID) > maxSecond*1000:
+                ipyData = IpyGameDataPY.GetIpyGameData('QuestionBank', lastQuestionID)
+                if ipyData:
+                    answer = ipyData.GetAnswer()
+                    answer = answer.replace('[', '')
+                    answer = answer.replace(']', '')
+                    PlayerControl.FamilyNotify(familyID, 'Party_Correct', [maxSecond, GameWorld.GbkToCode(answer)])
+            else:
+                continue
         answerTick = gameWorld.GetDictByKey(FamilyPartyFB_AnswerTick % familyID)
-        if tick - answerTick < 5000:
+        if not lastQuestionID and tick - answerTick < 5000:
             continue
         
         #随机题目
@@ -186,6 +198,8 @@
                 break
         
         gameWorld.SetDict(FamilyPartyFB_QuestionID % familyID, questionID)
+        gameWorld.SetDict(FamilyPartyFB_QuestionTick % familyID, tick)
+        
         PlayerControl.FamilyNotify(familyID, 'Party_Topic', [questionID])
     return
 
@@ -194,7 +208,7 @@
 
     gameWorld = GameWorld.GetGameWorld()
     state = gameWorld.GetDictByKey(ShareDefine.Def_Notify_WorldKey_FBFuncState % ChConfig.Def_FBMapID_FamilyParty)
-    if state != 1:
+    if state != AnswerState:
         return
     
     curFamilyid = curPlayer.GetFamilyID()
@@ -207,6 +221,7 @@
     if not ipyData:
         GameWorld.ErrLog('仙盟宴会答题 该题不存在,异常 questionID=%s, 重新出题'%questionID)
         gameWorld.SetDict(FamilyPartyFB_QuestionID % curFamilyid, 0)
+        gameWorld.SetDict(FamilyPartyFB_QuestionTick % curFamilyid, 0)
         return
     
     answerList = eval(ipyData.GetAnswer())
@@ -214,11 +229,11 @@
     ChContent = GameWorld.CodeToGBK(ChContent)
     ChContent = ChContent.strip()
     isRight = ChContent in answerList
-#    if curPlayer.GetMapID() != ChConfig.Def_FBMapID_FamilyParty:
-#        if isRight:
-#            PlayerControl.FamilyNotify(curFamilyid, 'FamilyPleaseIntoParty')
-#            PlayerControl.NotifyCode(curPlayer, 'FamilyNoIntoParty')
-#        return
+    if curPlayer.GetMapID() != ChConfig.Def_FBMapID_FamilyParty:
+        if isRight:
+            PlayerControl.FamilyNotify(curFamilyid, 'FamilyPleaseIntoParty')
+            PlayerControl.NotifyCode(curPlayer, 'FamilyNoIntoParty')
+        return
     
     playerID = curPlayer.GetID()
     GameWorld.DebugLog("    answer=%s  ChContent=%s"%(answerList, ChContent), playerID)
@@ -228,7 +243,7 @@
         playerName = curPlayer.GetName()
         gameWorld.SetDict(FamilyPartyFB_QuestionID%curFamilyid, 0)
         gameWorld.SetDict(FamilyPartyFB_AnswerTick%curFamilyid, tick)
-        PlayerControl.FamilyNotify(curFamilyid, 'Party_Answer', [playerName])
+
         if curFamilyid in PyGameData.g_familyAnswerDict:
             PyGameData.g_familyAnswerDict[curFamilyid][0] +=1
             PyGameData.g_familyAnswerDict[curFamilyid][1] = tick

--
Gitblit v1.8.0