| | |
| | | heroIpyData = IpyGameDataPY.GetIpyGameData("Hero", heroID)
|
| | | if not heroIpyData:
|
| | | return
|
| | | heroIndex = heroIpyData.GetHeroIndex()
|
| | | heroActState = GameWorld.GetDictValueByBit(curPlayer, ChConfig.Def_PDict_HeroActState, heroIndex)
|
| | | if not heroActState:
|
| | | GameWorld.SetDictValueByBit(curPlayer, ChConfig.Def_PDict_HeroActState, heroIndex, 1)
|
| | | GameWorld.DebugLog("首次激活武将: heroID=%s,heroIndex=%s" % (heroID, heroIndex), curPlayer.GetPlayerID())
|
| | | |
| | | if not GetHeroActivite(curPlayer, heroID):
|
| | | SetHeroActivite(curPlayer, heroID, 1)
|
| | | GameWorld.DebugLog("首次激活武将: heroID=%s" % (heroID), curPlayer.GetPlayerID())
|
| | | #首次获得图鉴额外逻辑 ...
|
| | | Sync_HeroInfo(curPlayer, [heroID])
|
| | | |
| | | return
|
| | |
|
| | | def GetHeroActivite(curPlayer, heroID):
|
| | | ## 武将状态
|
| | | # @return: 0-未激活;1-武将已获得,可激活;2-图鉴已激活
|
| | | actState = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_HeroBook % heroID) % 10
|
| | | return actState
|
| | |
|
| | | def SetHeroActivite(curPlayer, heroID, isAct=1):
|
| | | ## 设置武将已获得,可激活状态
|
| | | bookState = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_HeroBook % heroID)
|
| | | actState = bookState % 10
|
| | | if isAct:
|
| | | if actState:
|
| | | return
|
| | | actState = 1
|
| | | else:
|
| | | actState = 0
|
| | | updBookState = GameWorld.SetValue(bookState, 1, 1, actState)
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_HeroBook % heroID, updBookState)
|
| | | GameWorld.DebugLog("设置武将激活状态:%s,bookState=%s,updBookState=%s" % (isAct, bookState, updBookState), curPlayer.GetPlayerID())
|
| | | return
|
| | |
|
| | | def GetHeroBookInitState(curPlayer, heroID):
|
| | | ## 武将图鉴激活状态
|
| | | initState = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_HeroBook % heroID) % 10
|
| | | return initState > 1
|
| | | def SetHeroBookInitState(curPlayer, heroID, isAct=1):
|
| | | ## 设置武将图鉴激活状态
|
| | | bookState = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_HeroBook % heroID)
|
| | | actState = bookState % 10
|
| | | if isAct:
|
| | | actState = 2
|
| | | else:
|
| | | actState = 1 if actState else 0
|
| | | updBookState = GameWorld.SetValue(bookState, 1, 1, actState)
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_HeroBook % heroID, updBookState)
|
| | | GameWorld.DebugLog("设置武将图鉴激活状态:%s,bookState=%s,updBookState=%s" % (isAct, bookState, updBookState), curPlayer.GetPlayerID())
|
| | | return
|
| | |
|
| | | def GetHeroBookStarLV(curPlayer, heroID):
|
| | | ## 武将图鉴星级等级
|
| | | bookState = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_HeroBook % heroID)
|
| | | return GameWorld.GetValue(bookState, 4, 3)
|
| | | def SetHeroBookStarLV(curPlayer, heroID, starLV):
|
| | | ## 设置武将图鉴星级等级,支持三位数 0~999 级
|
| | | bookState = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_HeroBook % heroID)
|
| | | updBookState = GameWorld.SetValue(bookState, 4, 3, starLV)
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_HeroBook % heroID, updBookState)
|
| | | GameWorld.DebugLog("设置武将图鉴星级等级:%s,bookState=%s,updBookState=%s" % (starLV, bookState, updBookState), curPlayer.GetPlayerID())
|
| | | return
|
| | |
|
| | | def GetHeroBookBreakLV(curPlayer, heroID):
|
| | | ## 武将图鉴突破等级
|
| | | bookState = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_HeroBook % heroID)
|
| | | return GameWorld.GetValue(bookState, 7, 3)
|
| | | def SetHeroBookBreakLV(curPlayer, heroID, breakLV):
|
| | | ## 设置武将图鉴突破等级,支持三位数 0~999 级
|
| | | bookState = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_HeroBook % heroID)
|
| | | updBookState = GameWorld.SetValue(bookState, 7, 3, breakLV)
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_HeroBook % heroID, updBookState)
|
| | | GameWorld.DebugLog("设置武将图鉴突破等级:%s,bookState=%s,updBookState=%s" % (breakLV, bookState, updBookState), curPlayer.GetPlayerID())
|
| | | return
|
| | |
|
| | | def GetHeroItem(curPlayer, itemIndex):
|
| | |
| | | Sync_HeroInfo(curPlayer, [heroID])
|
| | | return
|
| | |
|
| | | #// B2 37 武将图鉴激活升级 #tagCSHeroBookUP
|
| | | #
|
| | | #struct tagCSHeroBookUP
|
| | | #{
|
| | | # tagHead Head;
|
| | | # DWORD HeroID; //武将ID
|
| | | # WORD ItemIndex; //关联武将物品所在武将背包索引,激活时可不用发
|
| | | # BYTE BookType; //图鉴激活类型: 0-初始激活;1-星级升级;2-突破等级升级
|
| | | #};
|
| | | def OnHeroBookUP(index, clientData, tick):
|
| | | curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
|
| | | heroID = clientData.HeroID
|
| | | itemIndex = clientData.ItemIndex
|
| | | bookType = clientData.BookType
|
| | | |
| | | if bookType == 1:
|
| | | __doHeroBookStarLVUP(curPlayer, heroID, itemIndex)
|
| | | elif bookType == 2:
|
| | | __doHeroBookBreakLVUP(curPlayer, heroID, itemIndex)
|
| | | else:
|
| | | __doHeroBookAct(curPlayer, heroID)
|
| | | return
|
| | |
|
| | | def __doHeroBookAct(curPlayer, heroID):
|
| | | ## 图鉴激活
|
| | | playerID = curPlayer.GetPlayerID()
|
| | | if GetHeroBookInitState(curPlayer, heroID):
|
| | | GameWorld.DebugLog("该武将图鉴已激活! heroID=%s" % heroID, playerID)
|
| | | return
|
| | | GameWorld.DebugLog("武将图鉴激活! heroID=%s" % heroID, playerID)
|
| | | heroIpyData = IpyGameDataPY.GetIpyGameData("Hero", heroID)
|
| | | if not heroIpyData:
|
| | | return
|
| | | quality = heroIpyData.GetQuality()
|
| | | qualityIpyData = IpyGameDataPY.GetIpyGameData("HeroQuality", quality)
|
| | | if not qualityIpyData:
|
| | | return
|
| | | if GetHeroActivite(curPlayer, heroID) != 1:
|
| | | GameWorld.DebugLog("武将未获得过,不可激活图鉴! heroID=%s" % (heroID), playerID)
|
| | | return
|
| | | SetHeroBookInitState(curPlayer, heroID, 1)
|
| | | |
| | | awardMoneyInfo = qualityIpyData.GetBookActAwardMoney()
|
| | | if awardMoneyInfo and len(awardMoneyInfo) == 2:
|
| | | moneyType, moneyValue = awardMoneyInfo
|
| | | if moneyType and moneyValue:
|
| | | PlayerControl.GiveMoney(curPlayer, moneyType, moneyValue, "HeroBookAct")
|
| | | |
| | | Sync_HeroInfo(curPlayer, [heroID])
|
| | | return
|
| | |
|
| | | def __doHeroBookStarLVUP(curPlayer, heroID, itemIndex):
|
| | | ## 图鉴星级升级
|
| | | playerID = curPlayer.GetPlayerID()
|
| | | heroItem = GetHeroItem(curPlayer, itemIndex)
|
| | | if not heroItem:
|
| | | return
|
| | | if heroItem.GetItemTypeID() != heroID:
|
| | | GameWorld.DebugLog("非该武将图鉴关联物品! heroID=%s,itemID=%s" % (heroID, heroItem.GetItemTypeID()), playerID)
|
| | | return
|
| | | heroStar = heroItem.GetUserAttr(ShareDefine.Def_IudetHeroStar)
|
| | | bookStar = GetHeroBookStarLV(curPlayer, heroID)
|
| | | if bookStar >= heroStar:
|
| | | GameWorld.DebugLog("该武将图鉴星级已达当前英雄星级! heroID=%s,bookStar=%s,heroStar=%s" % (heroID, bookStar, heroStar), playerID)
|
| | | return
|
| | | GameWorld.DebugLog("武将图鉴星级升级! heroID=%s,bookStar=%s,heroStar=%s" % (heroID, bookStar, heroStar), playerID)
|
| | | SetHeroBookStarLV(curPlayer, heroID, bookStar + 1)
|
| | | Sync_HeroInfo(curPlayer, [heroID])
|
| | | |
| | | # 刷属性
|
| | | |
| | | return
|
| | |
|
| | | def __doHeroBookBreakLVUP(curPlayer, heroID, itemIndex):
|
| | | ## 图鉴突破升级
|
| | | playerID = curPlayer.GetPlayerID()
|
| | | heroItem = GetHeroItem(curPlayer, itemIndex)
|
| | | if not heroItem:
|
| | | return
|
| | | if heroItem.GetItemTypeID() != heroID:
|
| | | GameWorld.DebugLog("非该武将图鉴关联物品! heroID=%s,itemID=%s" % (heroID, heroItem.GetItemTypeID()), playerID)
|
| | | return
|
| | | heroBreakLV = heroItem.GetUserAttr(ShareDefine.Def_IudetHeroBreakLV)
|
| | | bookBreakLV = GetHeroBookBreakLV(curPlayer, heroID)
|
| | | if bookBreakLV >= heroBreakLV:
|
| | | GameWorld.DebugLog("该武将图鉴突破等级已达当前英雄突破等级! heroID=%s,bookBreakLV=%s,heroBreakLV=%s" % (heroID, bookBreakLV, heroBreakLV), playerID)
|
| | | return
|
| | | GameWorld.DebugLog("武将图鉴突破升级! heroID=%s,bookBreakLV=%s,heroBreakLV=%s" % (heroID, bookBreakLV, heroBreakLV), playerID)
|
| | | SetHeroBookBreakLV(curPlayer, heroID, bookBreakLV + 1)
|
| | | Sync_HeroInfo(curPlayer, [heroID])
|
| | | |
| | | # 刷属性
|
| | | |
| | | return
|
| | |
|
| | | #// B4 12 战斗阵型保存 #tagCSHeroBattlePosSave
|
| | | #
|
| | | #struct tagCSHeroBattlePos
|
| | |
| | | posNum = posInfo.PosNum
|
| | | itemIndex = posInfo.ItemIndex
|
| | | if itemIndex in indexList:
|
| | | # 单英雄只能一个位置,一个位置只能对应唯一英雄单位
|
| | | # 单武将只能一个位置,一个位置只能对应唯一武将单位
|
| | | continue
|
| | | indexList.append(itemIndex)
|
| | | heroPosDict[posNum] = itemIndex
|
| | |
| | | heroIpyData = IpyGameDataPY.GetIpyGameData("Hero", heroID)
|
| | | if not heroIpyData:
|
| | | continue
|
| | | heroIndex = heroIpyData.GetHeroIndex()
|
| | | heroActState = GameWorld.GetDictValueByBit(curPlayer, ChConfig.Def_PDict_HeroActState, heroIndex)
|
| | | if not heroActState and heroIDList == None:
|
| | | if heroIDList == None and not curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_HeroBook % heroID):
|
| | | continue
|
| | |
|
| | | hero = ChPyNetSendPack.tagSCHero()
|
| | | hero.HeroID = heroID
|
| | | hero.IsActive = heroActState
|
| | | hero.SkinState = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_HeroSkin % heroID)
|
| | | hero.BookInitState = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_HeroBook % heroID) % 10
|
| | | hero.BookStarLV = GetHeroBookStarLV(curPlayer, heroID)
|
| | | hero.BookBreakLV = GetHeroBookBreakLV(curPlayer, heroID)
|
| | | syncInfoList.append(hero)
|
| | |
|
| | | if not syncInfoList:
|