#!/usr/bin/python # -*- coding: GBK -*- #--------------------------------------------------------------------- # #--------------------------------------------------------------------- ##@package Item_AddExp # @todo: ÎïÆ·¸ø¾­Ñé # # @author: panwei # @date 2010-07-28 # @version 1.0 # #------------------------------------------------------------------------------ """Version = 2015-12-11 18:30""" #--------------------------------------------------------------------- #µ¼Èë import GameWorld import ChConfig import PlayerControl import ItemCommon import math #--------------------------------------------------------------------- #È«¾Ö±äÁ¿ #--------------------------------------------------------------------- #--------------------------------------------------------------------- ##ÅúÁ¿Ê¹ÓÃÎïÆ· # @param curPlayer: Íæ¼ÒʵÀý # @param curRoleItem: ÎïÆ·ÊµÀý # @param tick: ʱ¼ä´Á # @param useCnt: ʹÓøöÊý # @return: def BatchUseItem(curPlayer, curRoleItem, tick, useCnt, exData): itemTypeID = curRoleItem.GetItemTypeID() curLV = curPlayer.GetLV() GameWorld.DebugLog("Item_AddExp.BatchUseItem itemID=%s,useCnt=%s" % (itemTypeID, useCnt)) giveExp = 0 curEff = curRoleItem.GetEffectByIndex(0) curEffID = curEff.GetEffectID() # °´¹Ì¶¨¾­Ñ鏸¾­Ñé if curEffID == ChConfig.Def_Effect_ItemAddExp: giveExp = curEff.GetEffectValue(0) elif curEffID == ChConfig.Def_Effect_ItemAddExpByLV: expPer = curEff.GetEffectValue(0)#ËùÌáÉý¾­ÑéµÄЧÂÊÖµ confLV = curEff.GetEffectValue(1) #µÈ¼¶ÏÞÖÆµ±=0Ϊ²»ÏÞÖÆµÈ¼¶ reLV = min(confLV, curLV) if confLV else curLV lvIpyData = PlayerControl.GetPlayerLVIpyData(reLV) if not lvIpyData: return giveExp = int(lvIpyData.GetReExp() * expPer) if giveExp <= 0: GameWorld.ErrLog('²ß»®Ìî±í´íÎó£¬ÎïÆ· = %s,¸ø¾­ÑéÒì³£giveExp=%s!'%(itemTypeID, giveExp)) return False beforeLV = curPlayer.GetLV() beforeTotalExp = PlayerControl.GetPlayerTotalExp(curPlayer) playerControl = PlayerControl.PlayerControl(curPlayer) addExpTotal = useCnt * giveExp actualAddExp = playerControl.AddExp(addExpTotal) GameWorld.DebugLog(" beforeTotalExp=%s,addExpTotal=%s(%s*%s),actualAddExp=%s" % (beforeTotalExp, addExpTotal, giveExp, useCnt, actualAddExp)) #¸øÍæ¼Ò¾­Ñé if actualAddExp <= 0: return False actualUseCnt = int(math.ceil(actualAddExp / float(giveExp))) afterLV = curPlayer.GetLV() afterTotalExp = PlayerControl.GetPlayerTotalExp(curPlayer) #ÎïÆ·¼õÉÙ saveDataDict = {"BeforeLV":beforeLV, "BeforeTotalExp":beforeTotalExp, "AfterLV":afterLV, "AfterTotalExp":afterTotalExp, "AddExp":actualAddExp} GameWorld.DebugLog("Item_AddExp saveDataDict=%s" % saveDataDict, curPlayer.GetPlayerID()) ItemCommon.DelItem(curPlayer, curRoleItem, actualUseCnt, True, ChConfig.ItemDel_AddExp, saveDataDict) PlayerControl.NotifyCode(curPlayer, 'UseElixirHint', [itemTypeID, actualAddExp]) return True, actualUseCnt ##ʹÓÃÎïÆ·,´¥·¢ÎïÆ·¸½¼Ó¼¼ÄÜ # @param curPlayer Íæ¼ÒʵÀý # @param curRoleItem ÎïÆ·ÊµÀý # @param tick ʱ¼ä´Á # @return ÊÇ·ñʹÓÃÎïÆ·³É¹¦ # @remarks giveExp = reExp * curEff.GetEffectValue(0) + curEff.GetEffectValue(1) def UseItem(curPlayer, curRoleItem, tick): return BatchUseItem(curPlayer, curRoleItem, tick, 1, 0)