public async Task OfferList(SocketReaction reaction, IUserMessage msg) { //{page}.{x}.{JsonConvert.SerializeObject(guids)} string[] args = data.Split('.'); int page = int.Parse(args[0]); int length = int.Parse(args[1]); ItemOffer.OfferQuery q = (ItemOffer.OfferQuery)Enum.Parse(typeof(ItemOffer.OfferQuery), args[2]); Guid[] guids = JsonConvert.DeserializeObject <Guid[]>(args[3]); switch (reaction.Emote.ToString()) { case next: await ItemOffer.GetOffers(player, page + 1, q, reaction.Channel); break; case prev: await ItemOffer.GetOffers(player, page - 1, q, reaction.Channel); break; default: { int i = GetNum(reaction.Emote.ToString()) - 1; if (i > -1 && i < guids.Length) { var v = ItemOffer.IdLoad(guids[i]); await v.InspectOffer(player, reaction.Channel); } } break; } await TryMSGDel(msg); }
public async Task ConfirmOffer(SocketReaction reaction, IUserMessage msg) { if (reaction.Emote.ToString() == ok) { //{o.i.index, o.i.amount, o.i.cost, t.id, o.note} string[] args = JsonConvert.DeserializeObject <string[]>(data); Player target = Player.Load(ulong.Parse(args[3]), Player.IgnoreException.All); int amount = int.Parse(args[1]); int index = int.Parse(args[0]); ItemOffer offer = new ItemOffer(reaction.UserId, target.userid, new StackedItems(player.inventory.GetItem(index), amount), long.Parse(args[2]), args[4]); //Place the offer out of the inventory player.inventory.Remove(index, amount); player.SaveFileMongo(); IMessageChannel chan = reaction.Channel is IGuildChannel gChan && (await gChan.Guild.GetUserAsync(target.userid)) != null ? reaction.Channel : (IMessageChannel)(await DiscordBotHandler.Client.GetUser(target.userid).GetOrCreateDMChannelAsync()); await chan.SendMessageAsync($"<@{target.userid}>, You've received a new offer. View all offers using " + $"`Received Offers`"); await offer.InspectOffer(target, chan); } await TryMSGDel(msg); }
public POSItemDetail(CustomerProfile customerProfile, ItemProfile itemProfile, ItemOffer itemOffer, List <BalanceBarcodeAc> ListOfBalanceBarcodeConfiguration) { _customerProfile = customerProfile; _itemProfile = itemProfile; _itemOffer = itemOffer; _listOfBalanceBarcodeConfiguration = ListOfBalanceBarcodeConfiguration; _isOfferItem = itemOffer != null; _itemPrice = GetItemPrice(_customerProfile, _itemProfile, _itemOffer, _listOfBalanceBarcodeConfiguration); }
public ActionResult AddOfrItem(int Itemid) { HG_Items objitem = new HG_Items().GetOne(Itemid); ItemOffer itemOffers = new ItemOffer(); itemOffers.ItemId = objitem.ItemID; itemOffers.ItemName = objitem.Items; itemOffers.TotalItemPrice = objitem.Price; return(View("OfferItm", itemOffers)); }
public bool AddOffer(ItemOffer itemOffer) { if (itemOffer is null) { throw new ArgumentNullException(); } else { itemOffers.Add(itemOffer); } return(true); }
public decimal CalculateDiscount(List <Item> items, ItemOffer offer) { if (items == null || items.Count == 0) { return(0.0m); } var itemQuantity = items.Count(); var totalPrice = items.Sum(p => p.Price); var unitPrice = items.FirstOrDefault().Price; var totalDiscount = 0.0m; var modulas = itemQuantity % offer.Quantity; itemQuantity = modulas != 0 ? itemQuantity - modulas : itemQuantity; totalDiscount = (itemQuantity / offer.Quantity) * offer.OfferPrice; return((totalPrice - totalDiscount) - (modulas * unitPrice)); }
/// <summary> /// To Get Item Price According to Customer/WalkIn Customer or Offer /// </summary> /// <param name="customer"></param> /// <param name="item"></param> /// <returns></returns> private decimal GetItemPrice(CustomerProfile customer, ItemProfile item, ItemOffer itemOffer, List <BalanceBarcodeAc> listOfBalanceBarcodeConfiguration) { if (listOfBalanceBarcodeConfiguration != null && listOfBalanceBarcodeConfiguration.Any()) { foreach (var balancebarcode in listOfBalanceBarcodeConfiguration) { int totalLengthforBalanceBarcode = GetTotalLengthOfBalanceBarcode(balancebarcode); if (item.Barcode.Length == totalLengthforBalanceBarcode) { decimal amount = 0M; if (balancebarcode.AmountStartPosition != null) { amount = Convert.ToInt32(item.Barcode.Substring(Convert.ToInt32(balancebarcode.AmountStartPosition) - 1, Convert.ToInt32(balancebarcode.AmountLength) + 1)); } if (balancebarcode.AmountDecimalStartPosition != null) { amount = Convert.ToDecimal(amount.ToString() + "." + item.Barcode.Substring(Convert.ToInt32(balancebarcode.AmountDecimalStartPosition) - 1, Convert.ToInt32(balancebarcode.AmountDecimalLength) + 1)); } return(amount); } } } var priceWithOffer = 0M; if (customer != null && !customer.IsWalkIn) { var priceWithoutOffer = GetPriceByCategory(customer.PriceCategory, item); if (itemOffer != null) { priceWithOffer = GetPriceByCategory(customer.PriceCategory, itemOffer); } IfCustomerPriceLessThanOfferPrice = priceWithoutOffer < priceWithOffer; //return minimum of customer and offer price return(priceWithOffer > 0 ? Math.Min(priceWithoutOffer, priceWithOffer) : priceWithoutOffer); } IfCustomerPriceLessThanOfferPrice = false; return(itemOffer != null ? itemOffer.SellPrice : item.SellPrice); }
public async Task SentOffers(int page = 1) { Player player = Context.Player; await ItemOffer.GetOffers(player, page - 1, ItemOffer.OfferQuery.Sender, Context.Channel); }
public async Task Offer(string indexXamount, long cost, string user, [Remainder] string notes = null) { Player player = Context.Player; string prefix = Context.Prefix; //string[] splitArg = arg.Split('x', 'X', '*'); int index = -1; int amount = 0; try { var ia = Verify.IndexXAmount(indexXamount); index = ia.index - 1; amount = ia.amount; } catch (Exception) { await ReplyAsync("The offer was unsuccessful, make sure you are using the correct format: " + Environment.NewLine + "{ItemIndex}x{AmountOffered} cost @user" + Environment.NewLine + $"Example: ``{prefix}offer 13*6 60 @Friend`` will offer 6 of the index 13 item for 60 each to Friend"); } if (!ulong.TryParse(Regex.Replace(user, "[<|@|!|>]", ""), out ulong utId)) { throw NeitsilliaError.ReplyError("User is not valid. Please @user or enter user id."); } IUser utarget = Context.Client.GetUser(utId) ?? throw NeitsilliaError.ReplyError("User not found."); if (utarget.Id == player.userid) { await ReplyAsync("You may not offer yourself an item."); } else if (index > -1 && index < player.inventory.Count) { ItemOffer[] offers = await ItemOffer.SentOffers(player.userid); if (offers.Length >= 15) { await ReplyAsync("You may not create more offers, cancel older offers to continue." + $" Use ``{prefix}Sent Offers`` to view all sent offers, inspect one using the reaction and cancel the offer"); } else { amount = Verify.Max(amount, player.inventory.GetCount(index)); EmbedBuilder offer = new EmbedBuilder() { Title = $"Confirm Offer to {utarget.Username}" }; offer.WithFooter($"Offer will be sent to the character {utarget.Username} will have loaded after the confirmation"); Item item = player.inventory.GetItem(index); offer.WithDescription($"Offering {amount} {item} (R:{item.tier}) for {cost}Kuts." + Environment.NewLine + $"Total: {cost}Kuts"); // await player.NewUI(await ReplyAsync($"{Context.User.Mention}", embed: offer.Build()), MsgType.ConfirmOffer, JsonConvert.SerializeObject(new string[] { index.ToString(), amount.ToString(), cost.ToString(), utarget.Id.ToString(), notes })); } } else { await ReplyAsync("Selection invalid"); } }
public async Task InspectOffer(SocketReaction reaction, IUserMessage msg) { ItemOffer offer = ItemOffer.IdLoad(JsonConvert.DeserializeObject <Guid>(data)); switch (reaction.Emote.ToString()) { case ok: { if (offer.receiver == reaction.UserId) { if (player.KCoins < offer.pricePer) { await EditMessage($"{player.name} does not have enough Kutsyei Coins"); } else { Player offerer = Player.Load(offer.sender, Player.IgnoreException.None); if (!player.CollectItem(offer.offer, true)) { await EditMessage($"{player.name} does not have inventory storage"); } else { player.KCoins -= offer.pricePer; offerer.KCoins += offer.pricePer; player.SaveFileMongo(); offerer.SaveFileMongo(); await offer.DeleteAsync(); await reaction.Channel.SendMessageAsync("Trade completed!"); await ItemOffer.GetOffers(player, 0, ItemOffer.OfferQuery.Receiver, reaction.Channel); } } } else { await TryMSGDel(msg); } } break; case cancel: { if (offer.receiver == reaction.UserId) { EmbedBuilder em = new EmbedBuilder(); em.WithTitle($"{player.name} denied the following trade."); em.WithDescription(offer.ToInfo(false)); // Player sender = Player.Load(offer.sender, Player.IgnoreException.All); sender.inventory.Add(offer.offer, -1); sender.SaveFileMongo(); await sender.SendMessageToDM("Offer Items returned to inventory.", em, reaction.Channel); await offer.DeleteAsync(); await reaction.Channel.SendMessageAsync("Trade Denied!"); await NeitsilliaCommands.Social.ItemOffer.GetOffers(player, 0, ItemOffer.OfferQuery.Receiver, reaction.Channel); } else if (offer.sender == reaction.UserId) { EmbedBuilder em = new EmbedBuilder(); em.WithTitle($"<@{player.userid}> canceled the following trade."); em.WithDescription(offer.ToInfo(false)); // Player receiver = Player.Load(offer.receiver, Player.IgnoreException.All); player.inventory.Add(offer.offer, -1); player.SaveFileMongo(); await receiver.SendMessageToDM(null, em, reaction.Channel); await offer.DeleteAsync(); await reaction.Channel.SendMessageAsync("Trade Canceled, Items retrieved!"); await ItemOffer.GetOffers(player, 0, ItemOffer.OfferQuery.Sender, reaction.Channel); } } break; } }
private static void ResolveColumnValue(Object sender, ColumnValueResolveEventArg e) { if (e.Type == typeof(Resistance[])) { String[] array = e.Value.Split(s_Seperator, StringSplitOptions.RemoveEmptyEntries); List <Resistance> list = new List <Resistance>(array.Length / 2); for (Int32 i = 1; i < array.Length; i += 2) { Resistance item; item.Type = (EDamageType)Enum.Parse(typeof(EDamageType), array[i - 1], true); item.Value = Int32.Parse(array[i], CultureInfo.InvariantCulture); list.Add(item); } e.Output = list.ToArray(); } else if (e.Type == typeof(DamageData[])) { String[] array2 = e.Value.Split(s_Seperator, StringSplitOptions.RemoveEmptyEntries); List <DamageData> list2 = new List <DamageData>(array2.Length / 3); for (Int32 j = 2; j < array2.Length; j += 3) { EDamageType p_type = (EDamageType)Enum.Parse(typeof(EDamageType), array2[j - 2], true); Int32 p_minimum = Int32.Parse(array2[j - 1]); Int32 p_maximum = Int32.Parse(array2[j]); DamageData item2 = new DamageData(p_type, p_minimum, p_maximum); list2.Add(item2); } e.Output = list2.ToArray(); } else if (e.Type == typeof(NpcEffect[])) { String[] array3 = e.Value.Split(s_Seperator, StringSplitOptions.RemoveEmptyEntries); List <NpcEffect> list3 = new List <NpcEffect>(array3.Length / 4); for (Int32 k = 3; k < array3.Length; k += 4) { ETargetCondition p_targetEffect = (ETargetCondition)Enum.Parse(typeof(ETargetCondition), array3[k - 3], true); EEffectPeriodicity p_effectType = (EEffectPeriodicity)Enum.Parse(typeof(EEffectPeriodicity), array3[k - 2], true); Single p_effectValue = Single.Parse(array3[k - 1]); Int32 p_effectPrice = Int32.Parse(array3[k]); NpcEffect item3 = new NpcEffect(p_targetEffect, p_effectType, p_effectValue, p_effectPrice); list3.Add(item3); } e.Output = list3.ToArray(); } else if (e.Type == typeof(IntRange)) { String[] array4 = e.Value.Split(s_Seperator, StringSplitOptions.RemoveEmptyEntries); IntRange zero = IntRange.Zero; if (array4.Length == 1) { zero.Min = (zero.Max = Int32.Parse(array4[0])); } else if (array4.Length > 1) { zero.Min = Int32.Parse(array4[0]); zero.Max = Int32.Parse(array4[1]); } e.Output = zero; } else if (e.Type == typeof(FloatRange)) { String[] array5 = e.Value.Split(s_Seperator, StringSplitOptions.RemoveEmptyEntries); FloatRange zero2 = FloatRange.Zero; if (array5.Length == 1) { zero2.Min = (zero2.Max = Single.Parse(array5[0])); } else if (array5.Length > 1) { zero2.Min = Single.Parse(array5[0]); zero2.Max = Single.Parse(array5[1]); } e.Output = zero2; } else if (e.Type == typeof(MonsterStaticData.SpellData[])) { String[] array6 = e.Value.Split(s_Seperator, StringSplitOptions.RemoveEmptyEntries); List <MonsterStaticData.SpellData> list4 = new List <MonsterStaticData.SpellData>(array6.Length / 4); for (Int32 l = 2; l < array6.Length; l += 4) { String p_animationClipName = array6[l - 2]; Int32 p_spellID = Int32.Parse(array6[l - 1]); Int32 p_spellProbability = Int32.Parse(array6[l]); Int32 p_level = Int32.Parse(array6[l + 1]); list4.Add(new MonsterStaticData.SpellData(p_animationClipName, p_spellID, p_spellProbability, p_level)); } e.Output = list4.ToArray(); } else if (e.Type == typeof(MonsterStaticData.ExtraDamage)) { String[] array7 = e.Value.Split(s_Seperator, StringSplitOptions.RemoveEmptyEntries); if (array7.Length > 0) { MonsterStaticData.ExtraDamage extraDamage = new MonsterStaticData.ExtraDamage((EDamageType)Enum.Parse(typeof(EDamageType), array7[0], true), Int32.Parse(array7[1])); e.Output = extraDamage; } } else if (e.Type == typeof(ItemOffer[])) { String[] array8 = e.Value.Split(s_Seperator, StringSplitOptions.RemoveEmptyEntries); ItemOffer[] array9 = new ItemOffer[array8.Length / 3]; for (Int32 m = 0; m < array9.Length; m++) { EDataType p_itemType = (EDataType)Enum.Parse(typeof(EDataType), array8[m * 3], true); Int32 p_itemID = Int32.Parse(array8[m * 3 + 1]); Int32 p_itemQuantity = Int32.Parse(array8[m * 3 + 2]); array9[m] = new ItemOffer(p_itemType, p_itemID, p_itemQuantity); } e.Output = array9; } else if (e.Type == typeof(Position)) { String[] array10 = e.Value.Split(s_Seperator, StringSplitOptions.RemoveEmptyEntries); Position position = default(Position); if (array10.Length == 2) { position.X = Int32.Parse(array10[0]); position.Y = Int32.Parse(array10[1]); } e.Output = position; } else if (e.Type == typeof(EquipmentData[])) { String[] array11 = e.Value.Split(s_Seperator, StringSplitOptions.RemoveEmptyEntries); EquipmentData[] array12 = new EquipmentData[array11.Length / 2]; for (Int32 n = 0; n < array12.Length; n++) { EDataType p_type2 = (EDataType)Enum.Parse(typeof(EDataType), array11[n * 2], true); Int32 p_staticId = Int32.Parse(array11[n * 2 + 1]); array12[n] = new EquipmentData(p_type2, p_staticId); } e.Output = array12; } else if (e.Type == typeof(SteadyLoot[])) { String[] array13 = e.Value.Split(s_Seperator, StringSplitOptions.RemoveEmptyEntries); SteadyLoot[] array14 = new SteadyLoot[array13.Length / 5]; for (Int32 num = 0; num < array14.Length; num++) { EDataType p_itemClass = (EDataType)Enum.Parse(typeof(EDataType), array13[num * 5], true); Int32 p_itemID2 = Int32.Parse(array13[num * 5 + 1]); Int32 p_min = Int32.Parse(array13[num * 5 + 2]); Int32 p_max = Int32.Parse(array13[num * 5 + 3]); Single p_dropChance = Single.Parse(array13[num * 5 + 4]); array14[num] = new SteadyLoot(p_itemClass, p_itemID2, p_min, p_max, p_dropChance); } e.Output = array14; } else if (e.Type == typeof(ModelProbability[])) { String[] array15 = e.Value.Split(s_Seperator, StringSplitOptions.RemoveEmptyEntries); ModelProbability[] array16 = new ModelProbability[array15.Length / 2]; for (Int32 num2 = 0; num2 < array16.Length; num2++) { String text = array15[num2 * 2]; Int32 p_modelLevel = Int32.Parse(text.Substring(0, 1)); ESubModel p_subModel = (ESubModel)Enum.Parse(typeof(ESubModel), text.Substring(1, 1), true); Single p_weight = Single.Parse(array15[num2 * 2 + 1]); array16[num2] = new ModelProbability(p_modelLevel, p_subModel, p_weight); } e.Output = array16; } else if (e.Type == typeof(EnchantmentProbability[])) { String[] array17 = e.Value.Split(s_Seperator, StringSplitOptions.RemoveEmptyEntries); EnchantmentProbability[] array18 = new EnchantmentProbability[array17.Length / 2]; for (Int32 num3 = 0; num3 < array18.Length; num3++) { Int32 p_modelLevel2 = Int32.Parse(array17[num3 * 2]); Single p_weight2 = Single.Parse(array17[num3 * 2 + 1]); array18[num3] = new EnchantmentProbability(p_modelLevel2, p_weight2); } e.Output = array18; } else if (e.Type == typeof(StepsOnTerrainData)) { StepsOnTerrainData empty = StepsOnTerrainData.Empty; String[] array19 = e.Value.Split(s_Seperator, StringSplitOptions.RemoveEmptyEntries); if (array19.Length == 2) { Int32 p_numberOfSteps = Int32.Parse(array19[0]); ETerrainType p_type3 = (ETerrainType)Enum.Parse(typeof(ETerrainType), array19[1], true); empty = new StepsOnTerrainData(p_numberOfSteps, p_type3); } e.Output = empty; } else if (e.Type == typeof(MonsterAbilityID[])) { String[] array20 = e.Value.Split(s_Seperator, StringSplitOptions.RemoveEmptyEntries); MonsterAbilityID[] array21 = new MonsterAbilityID[array20.Length / 2]; for (Int32 num4 = 0; num4 < array21.Length; num4++) { MonsterAbilityID monsterAbilityID; monsterAbilityID.AbilityType = (EMonsterAbilityType)Enum.Parse(typeof(EMonsterAbilityType), array20[num4 * 2]); monsterAbilityID.Level = Int32.Parse(array20[num4 * 2 + 1]); array21[num4] = monsterAbilityID; } e.Output = array21; } }