public byte[] SetItemVisibilityAndPrice(byte[] argument) // from guild master window { lock (this) { ushort GuildIDMaster = swap16(BitConverter.ToUInt16(argument, 0)); uint itemIDmaster = swap32(BitConverter.ToUInt32(argument, 2)); uint GeneralPriceMaster = swap32(BitConverter.ToUInt32(argument, 6)); uint MemberPriceMaster = swap32(BitConverter.ToUInt32(argument, 10)); Boolean isGeneralMaster = argument[14] == 0x01; Boolean isMemberMaster = argument[15] == 0x01; GuildItemShopModel guildItemShopModel = DBAccess.getInstance().GetSingleGuildItem(GuildIDMaster, itemIDmaster); guildItemShopModel.GeneralPrice = (int)GeneralPriceMaster; guildItemShopModel.MemberPrice = (int)MemberPriceMaster; guildItemShopModel.AvailableForGeneral = isGeneralMaster; guildItemShopModel.AvailableForMember = isMemberMaster; DBAccess.getInstance().UpdateSingleGuildItem(guildItemShopModel, false); Console.Write("GenePrice " + GeneralPriceMaster + "\nMemberPrice " + MemberPriceMaster + "\nisGeneral " + isGeneralMaster + "\nisMember " + isMemberMaster); return(new byte[] { 0x00, 0x00 }); } }
public byte[] BuyItemFromGuild(byte[] argument) { lock (this) { ushort guildIDBuying = swap16(BitConverter.ToUInt16(argument, 0)); uint itemIDBuying = swap32(BitConverter.ToUInt32(argument, 2)); ushort quantityOfBuying = swap16(BitConverter.ToUInt16(argument, 6)); uint priceOfEachPiece = swap32(BitConverter.ToUInt32(argument, 8)); Console.WriteLine("Guild ID " + guildIDBuying + "\nItem ID = " + itemIDBuying + "\nitem Quantity " + quantityOfBuying + "\nprice of each piece " + priceOfEachPiece); GuildItemShopModel guildItemShopModel = DBAccess.getInstance().GetSingleGuildItem(guildIDBuying, itemIDBuying); GuildRepositoryModel guildRepositoryModel = DBAccess.getInstance().GetGuildInfo(guildIDBuying); guildItemShopModel.Quantity -= quantityOfBuying; uint totalGPToAdd = priceOfEachPiece * quantityOfBuying; guildRepositoryModel.Gp += (int)totalGPToAdd; DBAccess.getInstance().UpdateSingleGuildItem(guildItemShopModel, false); DBAccess.getInstance().UpdateGuildInfo(guildRepositoryModel); MemoryStream m = new MemoryStream(); m.Write(BitConverter.GetBytes(swap16(quantityOfBuying))); return(m.ToArray()); } }
public byte[] GetPriceOfItemToBeDonated(ushort guildID, uint itemID) { lock (this) { GuildItemShopModel guildItemShopModel = DBAccess.getInstance().GetSingleGuildItem(guildID, itemID); if (guildItemShopModel == null || guildItemShopModel.ItemShopID == -1 || guildItemShopModel.ItemShopID == 0) { MemoryStream m = new MemoryStream(); m = new MemoryStream(); m.Write(BitConverter.GetBytes(swap32(0))); m.Write(BitConverter.GetBytes(swap32(0))); return(m.ToArray()); } else { MemoryStream m = new MemoryStream(); m = new MemoryStream(); m.Write(BitConverter.GetBytes(swap32((uint)guildItemShopModel.GeneralPrice))); m.Write(BitConverter.GetBytes(swap32((uint)guildItemShopModel.MemberPrice))); return(m.ToArray()); } } }
public byte[] TakeItemFromGuild(ushort guildID, uint itemID, ushort quantity) { GuildItemShopModel guildItemShopModel = DBAcess.getInstance().GetSingleGuildItem(guildID, itemID); guildItemShopModel.Quantity -= quantity; DBAcess.getInstance().UpdateSingleGuildItem(guildItemShopModel, false); MemoryStream m = new MemoryStream(); m.Write(BitConverter.GetBytes(swap16(quantity))); return(m.ToArray()); }
public GuildItemShopModel GetSingleGuildItem(ushort guildID, uint itemID) { using ISession session = _sessionFactory.OpenSession(); using ITransaction transaction = session.BeginTransaction(); GuildItemShopModel guildItemShopList = session.Query <GuildItemShopModel>().SingleOrDefault( x => x.GuildID == guildID && x.ItemID == itemID); transaction.Commit(); session.Close(); return(guildItemShopList); }
public void UpdateSingleGuildItem(GuildItemShopModel guildItemShopModel, bool isNewItem) { using ISession session = _sessionFactory.OpenSession(); using ITransaction transaction = session.BeginTransaction(); if (isNewItem) { session.Save(guildItemShopModel); } else { session.SaveOrUpdate(guildItemShopModel); } transaction.Commit(); session.Close(); }
public byte[] AddItemToGuildInventory(ushort guildID, uint itemID, ushort itemQuantity, uint generalPrice, uint memberPrice, bool isGeneral, bool isMember, bool isGuildMaster) { lock (this) { bool isNewItem = false; GuildItemShopModel guildItemShopModel = DBAccess.getInstance().GetSingleGuildItem(guildID, itemID); if (guildItemShopModel == null || guildItemShopModel.ItemShopID == -1 || guildItemShopModel.ItemShopID == 0) { guildItemShopModel = new GuildItemShopModel(); guildItemShopModel.ItemID = (int)itemID; guildItemShopModel.GuildID = guildID; guildItemShopModel.Quantity = 0; guildItemShopModel.GeneralPrice = 0; guildItemShopModel.MemberPrice = 0; guildItemShopModel.AvailableForGeneral = false; guildItemShopModel.AvailableForMember = false; isNewItem = true; } guildItemShopModel.Quantity += itemQuantity; if (isGuildMaster) { // edit price and publishing settings guildItemShopModel.GeneralPrice = (int)generalPrice; guildItemShopModel.MemberPrice = (int)memberPrice; guildItemShopModel.AvailableForGeneral = isGeneral; guildItemShopModel.AvailableForMember = isMember; } DBAccess.getInstance().UpdateSingleGuildItem(guildItemShopModel, isNewItem); MemoryStream m = new MemoryStream(); m.Write(BitConverter.GetBytes(swap16(itemQuantity))); return(m.ToArray()); } }