| #!/usr/bin/python  | 
| # -*- coding: GBK -*-  | 
| #-------------------------------------------------------------------------------  | 
| #  | 
| #-------------------------------------------------------------------------------  | 
| #  | 
| ##@package SetMoney  | 
| #  | 
| # @todo:ÉèÖÃÍæ¼ÒµÄÇ®  | 
| # @author hxp  | 
| # @date 2013-12-10 14:00  | 
| # @version 1.1  | 
| #  | 
| # @change: "2016-07-20 14:30" hxp Í³Ò»º¯Êý  | 
| #  | 
| # ÏêϸÃèÊö: ÉèÖÃÍæ¼ÒµÄÇ®  | 
| #  | 
| #---------------------------------------------------------------------  | 
| #"""Version = 2016-07-20 14:30"""  | 
| #---------------------------------------------------------------------  | 
|   | 
| import PlayerControl  | 
| import Lang  | 
| import ChConfig  | 
| import ShareDefine  | 
| import GameWorld  | 
|   | 
| moneyNameDict = ShareDefine.MoneyNameDict  | 
|   | 
| ## GMÃüÁîÖ´ÐÐÈë¿Ú  | 
| #  @param curPlayer µ±Ç°Íæ¼Ò  | 
| #  @param list ²ÎÊýÁбí [ <Ç®±ÒÀàÐÍ><ÊýÁ¿>]  | 
| #  @return None  | 
| #  @remarks º¯ÊýÏêϸ˵Ã÷.  | 
| def OnExec(curPlayer, List):  | 
|       | 
|     if len(List) == 1:  | 
|         moneyType = List[0]  | 
|         if moneyType == 0:  | 
|             moneyList = moneyNameDict.keys()  | 
|             moneyList.sort()  | 
|         else:  | 
|             moneyList = [moneyType]  | 
|         for moneyType in moneyList:  | 
|             GameWorld.DebugAnswer(curPlayer, "(%s) %s: %s" % (moneyType, moneyNameDict.get(moneyType, moneyType), PlayerControl.GetMoneyReal(curPlayer, moneyType)))  | 
|         return  | 
|       | 
|     if len(List) != 2:  | 
|         #²ÎÊý²»ÕýÈ·  | 
|         GameWorld.DebugAnswer(curPlayer, Lang.GBText("²ÎÊý²»ÕýÈ·"))  | 
|         GameWorld.DebugAnswer(curPlayer, "ÉèÖûõ±Ò: SetMoney »õ±ÒÀàÐÍ ÊýÖµ")  | 
|         GameWorld.DebugAnswer(curPlayer, "ÏÔʾ»õ±Ò: SetMoney »õ±ÒÀàÐÍ")  | 
|         helpStr = ""  | 
|         moneyTypeList = moneyNameDict.keys()  | 
|         for moneyType in moneyTypeList:  | 
|             helpStr += "%s-%s;" % (moneyType, moneyNameDict[moneyType])  | 
|         GameWorld.DebugAnswer(curPlayer, helpStr)  | 
|         return  | 
|     #Ç®±ÒÀàÐÍ  | 
|     moneyType = List[0]  | 
|     #Ç®±ÒÊýÁ¿  | 
|     moneyCount = List[1]  | 
|     #ÊäÈëÀàÐͲ»¶ÔÌáʾǮ±ÒÀàÐÍ´í  | 
|     if type(moneyType) != int or type(moneyCount) not in [int, long]:  | 
|         GameWorld.DebugAnswer(curPlayer, Lang.GBText("²ÎÊý²»ÕýÈ·"))  | 
|         return  | 
|     #Ç®±ÒÀàÐÍ·¶Î§  | 
|     if moneyType not in [1, 2, 3, 4] and moneyType not in ShareDefine.MoneyNameDict:  | 
|         GameWorld.DebugAnswer(curPlayer, Lang.GBText("Ç®±ÒÀàÐͲ»ÕýÈ·"))  | 
|         return  | 
|     #0ÎIJ»´¦Àí  | 
|     if moneyType not in ShareDefine.MoneyMinusRefreshDict and moneyCount < 0:  | 
|         return  | 
|     isOK = False  | 
|     playerMoney = PlayerControl.GetMoneyReal(curPlayer, moneyType)  | 
|     if moneyType == ShareDefine.TYPE_Price_PayCoin:  | 
|         playerMoney = PlayerControl.GetPayCoinTotal(curPlayer)  | 
|     if playerMoney > moneyCount:  | 
|         isOK = PlayerControl.PayMoney(curPlayer, moneyType, playerMoney - moneyCount, ChConfig.Def_Cost_GM, {ChConfig.Def_Cost_Reason_SonKey:"SetMoney"}, isMinus=True)  | 
|     elif playerMoney < moneyCount:  | 
|         isOK = PlayerControl.GiveMoney(curPlayer, moneyType, moneyCount - playerMoney, ChConfig.Def_GiveMoney_GM, {ChConfig.Def_Give_Reason_SonKey:"SetMoney"})  | 
|     else:  | 
|         isOK = True  | 
|     if not isOK:  | 
|         GameWorld.DebugAnswer(curPlayer, "ÉèÖÃÍæ¼Ò»õ±Òʧ°Ü£¬Ïê¼ûÈÕÖ¾»òÁ÷Ïò")  | 
|     else:  | 
|         GameWorld.DebugAnswer(curPlayer, "ÉèÖÃ%s%s=%s" % (moneyType, moneyNameDict.get(moneyType, moneyType), PlayerControl.GetMoneyReal(curPlayer, moneyType)))  | 
|           | 
|     return  | 
|           | 
|           |