hxp
7 天以前 388823edfe6308cba6f76ca6dc4f20022c5cb2be
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
#!/usr/bin/python
# -*- coding: GBK -*-
#---------------------------------------------------------------------
#
#------------------------------------------------------------------------------ 
##@package Item_GiveMoney
# @todo: ¸øÈËÎï½ðÇ®
#
# @author: adaws
# @date 2010-08-11 16:00
# @version 1.9
#
# @change: "2011-02-23 17:30" panwei É¾³ýÍâ²ãͳһÁ÷Ïò¼Ç¼, µ¥¸öÎïÆ·µ÷ÓÃͳһÁ÷Ïò¼Ç¼
# @change: "2011-04-27 11:00" Alee Íæ¼ÒÊý¾ÝÁ÷Ïò¼Ç¼
# @change: "2012-04-09 14:30" jiang Á÷Ïò¼Ç¼
# @change: "2012-06-18 18:00" jiang ÐÞ¸ÄItemCommon.DelItemº¯ÊýµÄ²ÎÊýÓÃÓÚOssʼþ¼Ç¼
# @change: "2013-12-26 20:20" Alee ¼õÉÙÁ÷Ïò¼Ç¼
# @change: "2015-01-14 00:30" hxp Ôö¼Óʼþ»ã±¨
# @change: "2015-05-20 16:00" hxp Ôö¼ÓÅúÁ¿Ê¹ÓÃÂß¼­
# @change: "2016-07-20 14:30" hxp Í³Ò»º¯Êý
#------------------------------------------------------------------------------ 
#"""Version = 2016-07-20 14:30"""
#------------------------------------------------------------------------------
#µ¼Èë
import GameWorld
import ChConfig
import PlayerControl
import IPY_GameWorld
import ItemCommon
import ShareDefine
import PlayerFamily
#------------------------------------------------------------------------------ 
 
 
#------------------------------------------------------------------------------ 
 
##ÅúÁ¿Ê¹ÓÃÎïÆ·
# @param curPlayer: Íæ¼ÒʵÀý
# @param curRoleItem: ÎïÆ·ÊµÀý
# @param tick: Ê±¼ä´Á
# @param useCnt: Ê¹ÓøöÊý
# @return: 
def BatchUseItem(curPlayer, curRoleItem, tick, useCnt, exData):
    itemID = curRoleItem.GetItemTypeID()
    #itemName = curRoleItem.GetName()
    GameWorld.DebugLog("Item_GiveMoney.BatchUseItem itemID=%s,useCnt=%s" % (itemID, useCnt))
    
    effectCount = curRoleItem.GetEffectCount()
    playerLv = curPlayer.GetLV()
    reMoney = GameWorld.GetReMoney(playerLv)
    itemID = curRoleItem.GetItemTypeID()
    
    # »ã×ܸÃÎïÆ·¿É¸øµÄ»õ±ÒÀàÐÍ
    giveMoneyDict = {}
    for i in range(effectCount):
        curEff = curRoleItem.GetEffectByIndex(i)
        moneyType = GetAddMoneyType(curEff)
        if moneyType == -1:
            continue
        
        #multiValue = curEff.GetEffectValue(0)
        #addValue = curEff.GetEffectValue(1)
        giveMoney = curEff.GetEffectValue(0)#reMoney*multiValue + addValue
        if giveMoney <= 0:
            continue
        
        giveMoneyDict[moneyType] = giveMoney
        
    GameWorld.DebugLog("    giveMoneyDict=%s" % giveMoneyDict)
    if not giveMoneyDict:
        return
        
    # Ô¤¼ì²é¿É³É¹¦Ê¹ÓõÄ×ܸöÊý
    successCnt = 0
    isBreak = False
    for i in range(useCnt):
        
        if isBreak:
            break
        
        for moneyType, giveMoney in giveMoneyDict.items():
            curTypeTotalMoney = giveMoney * (successCnt + 1)
            # Ö»ÒªÓÐÆäÖÐÒ»ÖÖ»õ±ÒÀàÐͲ»ÄܸøÔòÍ£Ö¹ÅúÁ¿Ê¹ÓÃÎïÆ·
            if not PlayerControl.CanGiveMoney(curPlayer, moneyType, curTypeTotalMoney):
                isBreak = True
                break
            
            successCnt += 1
            
    GameWorld.DebugLog("    successCnt=%s" % successCnt)
    if successCnt <= 0:
        return
    
    #ÎïÆ·¼õÉÙ
    ItemCommon.DelItem(curPlayer, curRoleItem, successCnt, True, ChConfig.ItemDel_GiveMoney)
            
    # ¸ø»õ±Ò
    for moneyType, giveMoney in giveMoneyDict.items():
        
        giveTotalMoney = giveMoney * successCnt
        if moneyType == ShareDefine.TYPE_Price_Family_Contribution:
            PlayerFamily.AddPlayerFamilyActiveValue(curPlayer, giveTotalMoney, True, ShareDefine.Def_AddFAVReason_UseItem, True)
        else:
            addDataDict = {"UseCount":successCnt, ChConfig.Def_Give_Reason_SonKey:itemID}
            PlayerControl.GiveMoney(curPlayer, moneyType, giveTotalMoney, ChConfig.Def_GiveMoney_UseItem, addDataDict)
            
    return True, successCnt
 
 
##ʹÓÃÎïÆ·,´¥·¢ÎïÆ·¸½¼ÓЧ¹û ¸øÈËÎï½ðÇ®
# @param curPlayer: Íæ¼ÒʵÀý
# @param curRoleItem: ÎïÆ·ÊµÀý
# @param tick: Ê±¼ä´Á
# @return: ÊÇ·ñʹÓÃÎïÆ·³É¹¦
# @remarks: giveMoney = reMoney * curEff.GetEffectValue(1) + curEff.GetEffectValue(2)
# AֵΪ½ðÇ®¹«Ê½ÀïµÄÊýÁ¿(³Ë·¨Òò×Ó) BֵΪ½ðÇ®¹«Ê½Àï¶îÍâ¹Ì¶¨ÊýÁ¿(¼Ó·¨Òò×Ó) 
def UseItem(curPlayer, curRoleItem, tick):
    return BatchUseItem(curPlayer, curRoleItem, tick, 1, 0)
 
 
## ¸ù¾ÝµÀ¾ßµÄЧ¹ûID»ñµÃÐèÒª¸øµÄ½ðÇ®µÄÀàÐÍ
#  @param curEffID: µÀ¾ßµÄЧ¹ûID
#  @return: ½ðÇ®µÄÀàÐÍ Èç¹û¸ù¾ÝЧ¹ûIDÕÒ²»µ½µÄ»°·µ»Ø-1
#  @remarks: ¸ù¾ÝµÀ¾ßµÄЧ¹ûID»ñµÃÐèÒª¸øµÄ½ðÇ®µÄÀàÐÍ DÕÒ²»µ½µÄ»°·µ»Ø-1
def GetAddMoneyType(curEff):
    curEffID = curEff.GetEffectID()
    if curEffID == ChConfig.Def_Effect_GivePlayerMoneySilver:
        return IPY_GameWorld.TYPE_Price_Silver_Money
    elif curEffID == ChConfig.Def_Effect_GivePlayerMoneyGift:
        return IPY_GameWorld.TYPE_Price_Gold_Paper
    elif curEffID == ChConfig.Def_Effect_GivePlayerMoneyGold:
        return IPY_GameWorld.TYPE_Price_Gold_Money
    elif curEffID == ChConfig.Def_Effect_GivePlayerSilverPaper:
        return IPY_GameWorld.TYPE_Price_Silver_Paper
    elif curEffID == ChConfig.Def_Effect_ItemGiveHonor:
        return ShareDefine.TYPE_Price_Honor
    elif curEffID == ChConfig.Def_Effect_ItemGiveRuneJH:
        return ShareDefine.TYPE_Price_Rune
    elif curEffID == ChConfig.Def_Effect_ItemGiveRuneSplinters:
        return ShareDefine.TYPE_Price_RuneSplinters
    elif curEffID == ChConfig.Def_Effect_ItemGiveFamilyActivity:
        return ShareDefine.TYPE_Price_FamilyActivity
    elif curEffID == ChConfig.Def_Effect_ItemGiveFamilyContribution:
        return ShareDefine.TYPE_Price_Family_Contribution
    elif curEffID == ChConfig.Def_Effect_ItemGiveRealmPoint:
        return ShareDefine.TYPE_Price_RealmPoint
    elif curEffID == ChConfig.Def_Effect_ItemGiveSoulDust:
        return ShareDefine.TYPE_Price_SoulDust
    elif curEffID == ChConfig.Def_Effect_ItemGiveSoulSplinters:
        return ShareDefine.TYPE_Price_SoulSplinters
    elif curEffID == ChConfig.Def_Effect_ItemGiveSoulCore:
        return ShareDefine.TYPE_Price_SoulCore
    elif curEffID == ChConfig.Def_Effect_ItemGiveTreasureScore:
        return ShareDefine.TYPE_Price_TreasureScore
    elif curEffID == ChConfig.Def_Effect_ItemGiveMoney:
        return curEff.GetEffectValue(1)
    return -1