438 【方案】方案预设-服务端(武将方案切换时如果为空方案则复制当前武将方案;)
| | |
| | | shapeType = 0#clientData.ShapeType
|
| | | heroPosList = clientData.HeroPosList
|
| | |
|
| | | heroPosDict = {}
|
| | | indexList = []
|
| | | itemIndexPosDict = {}
|
| | | for posInfo in heroPosList:
|
| | | posNum = posInfo.PosNum
|
| | | itemIndex = posInfo.ItemIndex
|
| | | itemIndexPosDict[itemIndex] = posNum
|
| | | |
| | | DoSaveHeroPreset(curPlayer, presetID, itemIndexPosDict, shapeType)
|
| | | return
|
| | |
|
| | | def DoSaveHeroPreset(curPlayer, presetID, itemIndexPosDict, shapeType=0):
|
| | | |
| | | if not PlayerPreset.GetFuncPresetIDState(curPlayer, presetID, ShareDefine.FuncPreset_Hero):
|
| | | GameWorld.DebugLog("该武将阵容预设不可用! presetID=%s" % presetID)
|
| | | return
|
| | | |
| | | heroPosDict = {}
|
| | | indexList = []
|
| | | for itemIndex, posNum in itemIndexPosDict.items():
|
| | | if itemIndex in indexList:
|
| | | # 单武将只能一个位置,一个位置只能对应唯一武将单位
|
| | | continue
|
| | | indexList.append(itemIndex)
|
| | | heroPosDict[posNum] = itemIndex
|
| | |
|
| | | if not PlayerPreset.GetFuncPresetIDState(curPlayer, presetID, ShareDefine.FuncPreset_Hero):
|
| | | GameWorld.DebugLog("该武将阵容预设不可用! presetID=%s" % presetID)
|
| | | return
|
| | | |
| | | GameWorld.DebugLog("保存武将预设阵容: presetID=%s, %s" % (presetID, heroPosDict), curPlayer.GetPlayerID())
|
| | | curPack = curPlayer.GetItemManager().GetPack(ShareDefine.rptHero)
|
| | | # 直接重置旧阵型
|
| | |
| | | reloadEffHeroCard(curPlayer, self) # 更新武将阵容强制重刷生效卡牌
|
| | | return
|
| | |
|
| | | def OnSwitch(self):
|
| | | self.isHeroChange = True
|
| | | return
|
| | | |
| | | def IsHeroItemIn(self, itemIndex): return itemIndex in self.heroItemDict
|
| | |
|
| | | def GetHeroEffectiveCard(self, heroID): return self._effectiveCardDict.get(heroID, [-1, -1, False])
|
| | |
| | | import IPY_GameWorld
|
| | | import NetPackCommon
|
| | | import PlayerOnline
|
| | | import PlayerHero
|
| | | import GameWorld
|
| | | import ChConfig
|
| | |
|
| | |
| | | curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
|
| | | batPresetID = clientData.BatPresetID
|
| | | funcPresetType = clientData.FuncPresetType
|
| | | funcPresetID = clientData.PresetID
|
| | | toPresetID = clientData.PresetID
|
| | |
|
| | | if funcPresetType == ShareDefine.FuncPreset_Battle:
|
| | | GameWorld.DebugLog("全局战斗预设不在此修改,请使用B263封包修改全局预设方案! funcPresetType=%s" % (funcPresetType))
|
| | |
| | | GameWorld.DebugLog("全局预设未解锁! batPresetID=%s" % batPresetID)
|
| | | return
|
| | |
|
| | | if not GetFuncPresetIDState(curPlayer, funcPresetID, funcPresetType):
|
| | | GameWorld.DebugLog("功能预设未解锁! funcPresetID=%s,funcPresetType=%s" % (funcPresetID, funcPresetType))
|
| | | if not GetFuncPresetIDState(curPlayer, toPresetID, funcPresetType):
|
| | | GameWorld.DebugLog("功能预设未解锁! toPresetID=%s,funcPresetType=%s" % (toPresetID, funcPresetType))
|
| | | return
|
| | |
|
| | | if GetFuncPresetID(curPlayer, batPresetID, funcPresetType) == funcPresetID:
|
| | | GameWorld.DebugLog("功能预设不变不处理! batPresetID=%s,funcPresetType=%s,funcPresetID=%s" % (batPresetID, funcPresetType, funcPresetID))
|
| | | nowPresetID = GetFuncPresetID(curPlayer, batPresetID, funcPresetType)
|
| | | if nowPresetID == toPresetID:
|
| | | GameWorld.DebugLog("功能预设不变不处理! batPresetID=%s,funcPresetType=%s,toPresetID=%s" % (batPresetID, funcPresetType, toPresetID))
|
| | | return
|
| | |
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_PresetFuncID % (batPresetID, funcPresetType), funcPresetID)
|
| | | GameWorld.DebugLog("功能预设方案切换: batPresetID=%s,funcPresetType=%s,funcPresetID=%s" % (batPresetID, funcPresetType, funcPresetID))
|
| | | GameWorld.DebugLog("功能预设方案切换: batPresetID=%s,funcPresetType=%s,nowPresetID=%s,toPresetID=%s" % (batPresetID, funcPresetType, nowPresetID, toPresetID))
|
| | | |
| | | # 武将方案检查是否空,空的话强制复制当前
|
| | | if funcPresetType == ShareDefine.FuncPreset_Hero:
|
| | | olPlayer = PlayerOnline.GetOnlinePlayer(curPlayer)
|
| | | heroPreset = olPlayer.GetHeroPreset(toPresetID)
|
| | | if not heroPreset.heroItemDict:
|
| | | nowHeroPreset = olPlayer.GetHeroPreset(nowPresetID)
|
| | | itemIndexPosDict = {}
|
| | | itemIndexPosDict.update(nowHeroPreset.heroItemDict)
|
| | | GameWorld.DebugLog("该武将方案为空直接先复制当前方案! nowPresetID=%s,itemIndexPosDict=%s" % (nowPresetID, itemIndexPosDict))
|
| | | PlayerHero.DoSaveHeroPreset(curPlayer, toPresetID, itemIndexPosDict)
|
| | | |
| | | heroPreset.OnSwitch()
|
| | | |
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_PresetFuncID % (batPresetID, funcPresetType), toPresetID)
|
| | |
|
| | | # 刷属性
|
| | | PlayerOnline.GetOnlinePlayer(curPlayer).RefreshBatPreset(batPresetID)
|