public override void BuildPacket() { PushIntoStack(_pageCount); PushIntoStack(ContextUser.GameCoin); PushIntoStack(ContextUser.GoldNum); PushIntoStack(_mallItemsInfoArray.Count); foreach (MallItemsInfo mallItems in _mallItemsInfoArray) { ItemBaseInfo itemInfo = new ConfigCacheSet <ItemBaseInfo>().FindKey(mallItems.ItemID); int mallPrice = 0; int specilPrice = 0; if (itemInfo != null) { mallPrice = mallItems.Price; if (mallItems.MallType == ShopType.Props || mallItems.MallType == ShopType.PresendBox) { mallPrice = (FestivalHelper.StoreDiscount() * mallPrice).ToInt(); } specilPrice = mallItems.SpecialPrice; } DataStruct dsItem = new DataStruct(); dsItem.PushIntoStack(mallItems.ItemID); dsItem.PushIntoStack(itemInfo == null ? string.Empty : itemInfo.ItemName.ToNotNullString()); dsItem.PushIntoStack(itemInfo == null ? string.Empty : itemInfo.HeadID.ToNotNullString()); dsItem.PushIntoStack(itemInfo == null ? string.Empty : itemInfo.MaxHeadID.ToNotNullString()); dsItem.PushIntoStack(itemInfo == null ? string.Empty : itemInfo.ItemDesc.ToNotNullString()); dsItem.PushIntoStack(itemInfo == null ? LanguageManager.GetLang().shortInt : (short)itemInfo.QualityType); dsItem.PushIntoStack(mallPrice); dsItem.PushIntoStack(specilPrice); dsItem.PushIntoStack(mallItems.SeqNO); dsItem.PushIntoStack((short)_commandType); PushIntoStack(dsItem); } PushIntoStack(ContextUser.ObtainNum); }
public override bool TakeAction() { ItemBaseInfo itemInfo = new ConfigCacheSet <ItemBaseInfo>().FindKey(_itemId); //UserItemHelper.AddUserItem(ContextUser.UserID, 1702, 1); //UserItemHelper.AddUserItem(ContextUser.UserID, 1701, 1); //UserItemHelper.AddUserItem(ContextUser.UserID, 1213, 1); if (itemInfo == null) { return(false); } //判断背包是否已满 string fullTitle = string.Empty; bool isFull = false; if (itemInfo.ItemType == ItemType.ZhuangBei) { isFull = UserPackHelper.PackIsFull(ContextUser, BackpackType.ZhuangBei, _num, out fullTitle); } else { isFull = UserPackHelper.PackIsFull(ContextUser, BackpackType.BeiBao, _num, out fullTitle); } if (isFull) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = fullTitle; //ErrorInfo = LanguageManager.GetLang().St7004_BeiBaoTimeOut; return(false); } //读取物品信息 MallItemsInfo mallItemInfo = new ConfigCacheSet <MallItemsInfo>().FindKey(_itemId, CityId, _commandType); if (mallItemInfo == null) { return(false); } //物品价格 int mallPrice = mallItemInfo.Price; if (mallItemInfo.MallType == ShopType.Props || mallItemInfo.MallType == ShopType.PresendBox) { mallPrice = (FestivalHelper.StoreDiscount() * mallPrice).ToInt(); } else if (mallItemInfo.SpecialPrice > 0) { mallPrice = mallItemInfo.SpecialPrice; } //根据物品类型进行扣钱 if (_commandType == ShopType.Props || _commandType == ShopType.PresendBox) { int useGold = mallPrice * _num; //if (mallItemInfo.MallType == ShopType.PresendBox) //{ if (ContextUser.GoldNum < useGold) { ErrorCode = 3; ErrorInfo = LanguageManager.GetLang().St_GoldNotEnough; return(false); } ContextUser.UseGold = MathUtils.Addition(ContextUser.UseGold, useGold); //增加道具日志统计 var mallItemLog = new MallItemLog { Amount = useGold, CreateDate = DateTime.Now, ItemID = _itemId, ItemName = itemInfo.ItemName, ItemNum = _num, MobileType = ContextUser.MobileType, Pid = ContextUser.Pid, PropType = itemInfo.PropType, RetailID = ContextUser.RetailID, Uid = ContextUser.UserID.ToInt() }; var sender = DataSyncManager.GetDataSender(); sender.Send(mallItemLog); UserItemHelper.AddUserItem(ContextUser.UserID, _itemId, _num); UserLogHelper.AppenUseGoldLog(ContextUser.UserID, 8, 1, 1, useGold, ContextUser.GoldNum, MathUtils.Addition(ContextUser.GoldNum, useGold, int.MaxValue)); //} //预留判断消耗的是金币还是晶石 //else //{ // if (ContextUser.GameCoin <useGold) // { // ErrorCode = LanguageManager.GetLang().ErrorCode; // ErrorInfo = LanguageManager.GetLang().St_GameCoinNotEnough; // return false; // } // ContextUser.GameCoin = MathUtils.Subtraction(ContextUser.GameCoin, useGold); // UserItemHelper.AddUserItem(ContextUser.UserID, _itemId, _num); //} } return(true); }