private static bool PayWithVoucher(GameSession session, BeautyShop shop) { string voucherTag = ""; // using an Item's tag to search for any applicable voucher switch (shop.BeautyType) { case BeautyShopType.Hair: if (shop.BeautyCategory == BeautyCategory.Special) { voucherTag = "beauty_hair_special"; break; } voucherTag = "beauty_hair"; break; case BeautyShopType.Face: voucherTag = "beauty_face"; break; case BeautyShopType.Makeup: voucherTag = "beauty_makeup"; break; case BeautyShopType.Skin: voucherTag = "beauty_skin"; break; case BeautyShopType.Dye: voucherTag = "beauty_itemcolor"; break; default: Logger.Warning($"Unknown Beauty Shop: {shop.BeautyType}"); session.Send(NoticePacket.Notice("Unknown Beauty Shop", NoticeType.FastText)); return(false); } Item voucher = session.Player.Inventory.GetAllByTag(voucherTag).FirstOrDefault(); if (voucher == null) { session.Send(NoticePacket.Notice(SystemNotice.ErrorItemNotFound, NoticeType.FastText)); return(false); } session.Send(BeautyPacket.UseVoucher(voucher.Id, 1)); session.Player.Inventory.ConsumeItem(session, voucher.Uid, 1); return(true); }
private static bool PayWithVoucher(GameSession session, BeautyMetadata shop) { string voucherTag = ""; // using an Item's tag to search for any applicable voucher switch (shop.BeautyType) { case BeautyShopType.Hair: if (shop.BeautyCategory == BeautyCategory.Special) { voucherTag = "beauty_hair_special"; break; } voucherTag = "beauty_hair"; break; case BeautyShopType.Face: voucherTag = "beauty_face"; break; case BeautyShopType.Makeup: voucherTag = "beauty_makeup"; break; case BeautyShopType.Skin: voucherTag = "beauty_skin"; break; case BeautyShopType.Dye: voucherTag = "beauty_itemcolor"; break; default: session.Send(NoticePacket.Notice("Unknown Beauty Shop", NoticeType.FastText)); return(false); } Item voucher = session.Player.Inventory.Items.FirstOrDefault(x => x.Value.Tag == voucherTag).Value; if (voucher == null) { session.Send(NoticePacket.Notice(SystemNotice.ItemNotFound, NoticeType.FastText)); return(false); } session.Send(BeautyPacket.UseVoucher(voucher.Id, 1)); InventoryController.Consume(session, voucher.Uid, 1); return(true); }