예제 #1
0
        public override bool TakeAction()
        {
            ErrorCode = _ops;
            var sparePart = ContextUser.SparePartList.Find(m => m.UserSparepartID.Equals(_sparepartID));
            var sparePartInfo = new ShareCacheStruct<SparePartInfo>().FindKey(sparePart.SparePartId);

            var reset = sparePartInfo.GetSparePartReset(_partPropertys.Length);
            if (_ops == 1)
            {
                ErrorInfo = string.Format(LanguageManager.GetLang().St1214_ResetUseLingshi, reset.Lingshi, reset.Coin);
            }
            else if (_ops == 2)
            {
                if (reset.Lingshi > ContextUser.UserExtend.LingshiNum)
                {
                    ErrorCode = LanguageManager.GetLang().ErrorCode;
                    ErrorInfo = LanguageManager.GetLang().St_LingshiNumNotEnough;
                    return false;
                }
                if (reset.Coin > ContextUser.GameCoin)
                {
                    ErrorCode = LanguageManager.GetLang().ErrorCode;
                    ErrorInfo = LanguageManager.GetLang().St_GameCoinNotEnough;
                    return false;
                }
                if (reset.Lingshi <= ContextUser.UserExtend.LingshiNum)
                {
                    ResetProperty();
                    ContextUser.UserExtend.UpdateNotify(obj => 
                        {
                            ContextUser.UserExtend.LingshiNum = MathUtils.Subtraction(ContextUser.UserExtend.LingshiNum, reset.Lingshi, 0);
                            return true;
                        });
                    ContextUser.GameCoin = MathUtils.Subtraction(ContextUser.GameCoin, reset.Coin, 0);
                    //ContextUser.Update();
                }
                UserLogHelper.AppendSparePartLog(ContextUser.UserID, sparePart, 4);
            }
            else if (_ops == 3)
            {
                ErrorInfo = string.Format(LanguageManager.GetLang().St1214_ResetUseGold, reset.Gold, reset.Coin);
            }
            else if (_ops == 4)
            {
                if (reset.Gold > ContextUser.GoldNum)
                {
                    ErrorCode = LanguageManager.GetLang().ErrorCode;
                    ErrorInfo = LanguageManager.GetLang().St_GoldNotEnough;
                    return false;
                }
                if (reset.Coin > ContextUser.GameCoin)
                {
                    ErrorCode = LanguageManager.GetLang().ErrorCode;
                    ErrorInfo = LanguageManager.GetLang().St_GameCoinNotEnough;
                    return false;
                }
                if (reset.Gold <= ContextUser.GoldNum && reset.Coin <= ContextUser.GameCoin)
                {
                    ResetProperty();
                    ContextUser.UseGold = MathUtils.Addition(ContextUser.UseGold, reset.Gold);
                    ContextUser.GameCoin = MathUtils.Subtraction(ContextUser.GameCoin, reset.Coin);
                    //ContextUser.Update();
                }
                UserLogHelper.AppendSparePartLog(ContextUser.UserID, sparePart, 5);
            }
            return true;
        }
예제 #2
0
        public override bool TakeAction()
        {
            ErrorCode = _ops;
            var sparePart     = ContextUser.SparePartList.Find(m => m.UserSparepartID.Equals(_sparepartID));
            var sparePartInfo = new ShareCacheStruct <SparePartInfo>().FindKey(sparePart.SparePartId);

            var reset = sparePartInfo.GetSparePartReset(_partPropertys.Length);

            if (_ops == 1)
            {
                ErrorInfo = string.Format(LanguageManager.GetLang().St1214_ResetUseLingshi, reset.Lingshi, reset.Coin);
            }
            else if (_ops == 2)
            {
                if (reset.Lingshi > ContextUser.UserExtend.LingshiNum)
                {
                    ErrorCode = LanguageManager.GetLang().ErrorCode;
                    ErrorInfo = LanguageManager.GetLang().St_LingshiNumNotEnough;
                    return(false);
                }
                if (reset.Coin > ContextUser.GameCoin)
                {
                    ErrorCode = LanguageManager.GetLang().ErrorCode;
                    ErrorInfo = LanguageManager.GetLang().St_GameCoinNotEnough;
                    return(false);
                }
                if (reset.Lingshi <= ContextUser.UserExtend.LingshiNum)
                {
                    ResetProperty();
                    ContextUser.UserExtend.UpdateNotify(obj =>
                    {
                        ContextUser.UserExtend.LingshiNum = MathUtils.Subtraction(ContextUser.UserExtend.LingshiNum, reset.Lingshi, 0);
                        return(true);
                    });
                    ContextUser.GameCoin = MathUtils.Subtraction(ContextUser.GameCoin, reset.Coin, 0);
                    //ContextUser.Update();
                }
                UserLogHelper.AppendSparePartLog(ContextUser.UserID, sparePart, 4);
            }
            else if (_ops == 3)
            {
                ErrorInfo = string.Format(LanguageManager.GetLang().St1214_ResetUseGold, reset.Gold, reset.Coin);
            }
            else if (_ops == 4)
            {
                if (reset.Gold > ContextUser.GoldNum)
                {
                    ErrorCode = LanguageManager.GetLang().ErrorCode;
                    ErrorInfo = LanguageManager.GetLang().St_GoldNotEnough;
                    return(false);
                }
                if (reset.Coin > ContextUser.GameCoin)
                {
                    ErrorCode = LanguageManager.GetLang().ErrorCode;
                    ErrorInfo = LanguageManager.GetLang().St_GameCoinNotEnough;
                    return(false);
                }
                if (reset.Gold <= ContextUser.GoldNum && reset.Coin <= ContextUser.GameCoin)
                {
                    ResetProperty();
                    ContextUser.UseGold  = MathUtils.Addition(ContextUser.UseGold, reset.Gold);
                    ContextUser.GameCoin = MathUtils.Subtraction(ContextUser.GameCoin, reset.Coin);
                    //ContextUser.Update();
                }
                UserLogHelper.AppendSparePartLog(ContextUser.UserID, sparePart, 5);
            }
            return(true);
        }