hxp
2026-01-09 09e416b2e9e97f4ac902bba159d9670ad066a8d5
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
#!/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 ItemCommon
#------------------------------------------------------------------------------ 
 
 
#------------------------------------------------------------------------------ 
 
##ÅúÁ¿Ê¹ÓÃÎïÆ·
# @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
        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_ItemGiveMoney:
        return curEff.GetEffectValue(1)
    return -1