public override void Deserialize(GenericReader reader) { base.Deserialize(reader); int version = reader.ReadInt(); m_FreeHousingZones = new Dictionary <Map, List <Rectangle2D> >(); m_FreeHousingZones[Map.Trammel] = new List <Rectangle2D>(); m_FreeHousingZones[Map.Felucca] = new List <Rectangle2D>(); m_GoldSink = reader.ReadInt(); m_Enabled = reader.ReadBool(); m_LottoDuration = reader.ReadTimeSpan(); int c = reader.ReadInt(); for (int i = 0; i < c; i++) { RegisterPlot(new MaginciaHousingPlot(reader)); } c = reader.ReadInt(); for (int i = 0; i < c; i++) { m_FreeHousingZones[Map.Trammel].Add(reader.ReadRect2D()); } c = reader.ReadInt(); for (int i = 0; i < c; i++) { m_FreeHousingZones[Map.Felucca].Add(reader.ReadRect2D()); } c = reader.ReadInt(); for (int i = 0; i < c; i++) { Mobile m = reader.ReadMobile(); List <NewMaginciaMessage> messages = new List <NewMaginciaMessage>(); int count = reader.ReadInt(); for (int j = 0; j < count; j++) { messages.Add(new NewMaginciaMessage(reader)); } if (m != null && messages.Count > 0) { m_MessageQueue[m] = messages; } } if (m_Enabled) { StartTimer(); } m_Instance = this; Timer.DelayCall(ValidatePlots); }
public static void CheckHousePlacement(Mobile from, Point3D center) { MaginciaLottoSystem system = MaginciaLottoSystem.Instance; if (system != null && system.Enabled && from.Backpack != null && IsInMagincia(center.X, center.Y, from.Map)) { List <Item> items = new List <Item>(); Item[] packItems = from.Backpack.FindItemsByType(typeof(WritOfLease)); Item[] bankItems = from.BankBox.FindItemsByType(typeof(WritOfLease)); if (packItems != null && packItems.Length > 0) { items.AddRange(packItems); } if (bankItems != null && bankItems.Length > 0) { items.AddRange(bankItems); } foreach (Item item in items) { WritOfLease lease = item as WritOfLease; if (lease != null && !lease.Expired && lease.Plot != null && lease.Plot.Bounds.Contains(center) && from.Map == lease.Plot.Map) { lease.OnExpired(); return; } } } }
public override void OnResponse(RelayInfo info) { switch (info.ButtonID) { case 0: { SendGump(new NewMaginciaMessageGump(User, Messages)); break; } case 1: { SendGump(new NewMaginciaMessageListGump(User, Messages)); } break; case 2: { if (Message != null) { MaginciaLottoSystem.RemoveMessageFromQueue(User, Message); } var messages = MaginciaLottoSystem.GetMessages(User); if (messages != null) { SendGump(new NewMaginciaMessageListGump(User, messages)); } break; } } }
public override bool AllowHousing(Mobile from, Point3D p) { MaginciaLottoSystem system = MaginciaLottoSystem.Instance; if (system != null && system.Enabled && from.Backpack != null) { List <Item> items = new List <Item>(); Item[] packItems = from.Backpack.FindItemsByType(typeof(WritOfLease)); Item[] bankItems = from.BankBox.FindItemsByType(typeof(WritOfLease)); if (packItems != null && packItems.Length > 0) { items.AddRange(packItems); } if (bankItems != null && bankItems.Length > 0) { items.AddRange(bankItems); } foreach (Item item in items) { WritOfLease lease = item as WritOfLease; if (lease != null && !lease.Expired && lease.Plot != null && lease.Plot.Bounds.Contains(p) && from.Map == lease.Plot.Map) { return(true); } } } return(MaginciaLottoSystem.IsFreeHousingZone(p, Map)); }
public override void OnDoubleClick(Mobile from) { MaginciaLottoSystem system = MaginciaLottoSystem.Instance; if (system == null || !system.Enabled || m_Plot == null) { return; } if (from.InRange(Location, 4)) { if (m_Plot.LottoOngoing) { from.CloseGump(typeof(MaginciaLottoGump)); from.SendGump(new MaginciaLottoGump(from, m_Plot)); } else if (!m_Plot.IsAvailable) { from.SendMessage("The lottory for this lot has ended."); } else { from.SendMessage("The lottory for this lot has expired. Check back soon!"); } } }
public void AddInventoryToWarehouse(Mobile owner, BaseBazaarBroker broker) { StorageEntry newEntry = null; if (broker is CommodityBroker && ((CommodityBroker)broker).HasValidEntry()) { newEntry = new StorageEntry(((CommodityBroker)broker).CommodityEntries, broker.BankBalance); } else if (broker is PetBroker && ((PetBroker)broker).HasValidEntry()) { newEntry = new StorageEntry(((PetBroker)broker).BrokerEntries, broker.BankBalance); } if (newEntry != null) { m_WarehouseStorage[owner] = newEntry; /*Your hired broker has transferred any remaining inventory and funds from * your stall at the New Magincia Bazaar into storage at the New Magincia * Warehouse. You must reclaim these items or they will be destroyed! To reclaim * these items, see the Warehouse Superintendent in New Magincia.<br><br>This * service is provided free of charge. If you owed your broker any back fees, * those fees must be paid before you can reclaim your belongings. The storage * period lasts 7 days starting with the expiration of your lease at the New * Magincia Bazaar, and this storage period cannot be extended. Claim your * possessions and gold without delay!<br><br>The expiration time of this * message coincides with the expiration time of your Warehouse storage.*/ MaginciaLottoSystem.SendMessageTo(owner, new NewMaginciaMessage(1150676, new TextDefinition(1150674), null)); } }
public void OnExpired() { MaginciaLottoSystem.UnregisterPlot(m_Plot); m_Plot = null; m_Expired = true; m_Expires = DateTime.MinValue; InvalidateProperties(); }
public override void OnAfterDelete() { if (m_Plot != null) { MaginciaLottoSystem.UnregisterPlot(m_Plot); } base.OnAfterDelete(); }
public override void OnResponse(RelayInfo info) { switch (info.ButtonID) { case 0: break; case 1: if (m_Message != null) { List <NewMaginciaMessage> messages = MaginciaLottoSystem.MessageQueue[User]; if (messages == null) { MaginciaLottoSystem.MessageQueue.Remove(User); } else { MaginciaLottoSystem.RemoveMessageFromQueue(User, m_Message); if (MaginciaLottoSystem.HasMessageInQueue(User)) { m_Message = m_Messages[0]; Refresh(); } } } break; case 2: if (m_Message != null) { m_Message = null; Refresh(); } else if (MaginciaLottoSystem.HasMessageInQueue(User)) { if (m_Messages != null && m_Messages.Count > 0) { m_Message = m_Messages[0]; } Refresh(); } break; default: int id = info.ButtonID - 1000; if (id >= 0 && id < m_Messages.Count) { m_Message = m_Messages[id]; } Refresh(); break; } }
public void SendMessage_Callback(object o) { object[] obj = o as object[]; if (obj != null) { Mobile winner = obj[0] as Mobile; NewMaginciaMessage message = obj[1] as NewMaginciaMessage; MaginciaLottoSystem.SendMessageTo(winner, message); } }
public MaginciaHousingPlot(GenericReader reader) { int version = reader.ReadInt(); m_Identifier = reader.ReadString(); m_Writ = reader.ReadItem() as WritOfLease; m_Stone = reader.ReadItem() as MaginciaPlotStone; m_LottoEnds = reader.ReadDateTime(); m_Bounds = reader.ReadRect2D(); m_Map = reader.ReadMap(); m_IsPrimeSpot = reader.ReadBool(); m_Complete = reader.ReadBool(); m_Winner = reader.ReadMobile(); m_Expires = reader.ReadDateTime(); int c = reader.ReadInt(); for (int i = 0; i < c; i++) { Mobile m = reader.ReadMobile(); int amount = reader.ReadInt(); if (m != null) { m_Participants[m] = amount; } } if ((m_Stone == null || m_Stone.Deleted) && LottoOngoing && MaginciaLottoSystem.IsRegisteredPlot(this)) { AddPlotStone(); } else if (m_Stone != null) { m_Stone.Plot = this; } if (m_Writ != null) { m_Writ.Plot = this; } }
public override void OnResponse(RelayInfo info) { switch (info.ButtonID) { case 0: { SendGump(new NewMaginciaMessageGump(User)); break; } case 1: { SendGump(new NewMaginciaMessageListGump(User)); } break; case 2: { if (Message != null) { List <NewMaginciaMessage> messages = MaginciaLottoSystem.MessageQueue[User]; if (messages == null) { MaginciaLottoSystem.MessageQueue.Remove(User); } else { MaginciaLottoSystem.RemoveMessageFromQueue(User, Message); if (MaginciaLottoSystem.HasMessageInQueue(User)) { SendGump(new NewMaginciaMessageListGump(User)); } } } break; } } }
public override void OnResponse(NetState state, RelayInfo info) { Mobile winner = state.Mobile; if (info.ButtonID == 1) { WritOfLease writ = new WritOfLease(m_Plot); m_Plot.Writ = writ; m_Plot.Winner = null; if (winner.Backpack == null || !winner.Backpack.TryDropItem(winner, writ, false)) { winner.SendLocalizedMessage(1150501); // Your backpack is full, so the deed has been placed in your bank box. winner.BankBox.DropItem(writ); } else { winner.SendLocalizedMessage(1150500); // The deed has been placed in your backpack. } MaginciaLottoSystem.GetWinnerGump(winner); } }
public override void OnResponse(NetState state, RelayInfo info) { if (info.ButtonID == 1) { if (MaginciaLottoSystem.MessageQueue.ContainsKey(m_From)) { List <NewMaginciaMessage> messages = MaginciaLottoSystem.MessageQueue[m_From]; if (messages == null) { MaginciaLottoSystem.MessageQueue.Remove(m_From); } else { MaginciaLottoSystem.RemoveMessageFromQueue(m_From, m_Message); if (MaginciaLottoSystem.HasMessageInQueue(m_From)) { m_From.SendGump(new NewMaginciaMessageGump(m_From, messages[0])); } } } } }
public NewMaginciaMessageGump(PlayerMobile from, NewMaginciaMessage message = null) : base(from, 75, 75) { m_Message = message; m_Messages = MaginciaLottoSystem.GetMessages(from); }
public NewMaginciaMessageGump(PlayerMobile from) : base(from, 490, 30) { Messages = MaginciaLottoSystem.GetMessages(from); }
public void EndAuction() { if (m_Plot == null) { return; } if (m_Plot.HasTempMulti()) { m_Plot.RemoveTempPlot(); } Mobile winner = null; int highest = 0; Dictionary <Mobile, BidEntry> combined = new Dictionary <Mobile, BidEntry>(m_Auctioners); //Combine auction bids with the bids for next available plot foreach (KeyValuePair <Mobile, BidEntry> kvp in MaginciaBazaar.NextAvailable) { combined.Add(kvp.Key, kvp.Value); } //Get highest bid foreach (BidEntry entry in combined.Values) { if (entry.Amount > highest) { highest = entry.Amount; } } // Check for owner, and if the owner has a match bad AND hasn't bidded on another plot! if (m_Plot.Owner != null && MaginciaBazaar.Reserve.ContainsKey(m_Plot.Owner) && MaginciaBazaar.Instance != null && !MaginciaBazaar.Instance.HasActiveBid(m_Plot.Owner)) { int matching = MaginciaBazaar.GetBidMatching(m_Plot.Owner); if (matching >= highest) { MaginciaBazaar.DeductReserve(m_Plot.Owner, highest); int newreserve = MaginciaBazaar.GetBidMatching(m_Plot.Owner); winner = m_Plot.Owner; /*You extended your lease on Stall ~1_STALLNAME~ at the ~2_FACET~ New Magincia * Bazaar. You matched the top bid of ~3_BIDAMT~gp. That amount has been deducted * from your Match Bid of ~4_MATCHAMT~gp. Your Match Bid balance is now *~5_NEWMATCH~gp. You may reclaim any additional match bid funds or adjust * your match bid for next week at the bazaar.*/ MaginciaLottoSystem.SendMessageTo(m_Plot.Owner, new NewMaginciaMessage(null, new TextDefinition(1150427), string.Format("@{0}@{1}@{2}@{3}@{4}", m_Plot.PlotDef.ID, m_Plot.PlotDef.Map.ToString(), highest.ToString("N0"), matching.ToString("N0"), newreserve.ToString("N0")))); } else { /*You lost the bid to extend your lease on Stall ~1_STALLNAME~ at the ~2_FACET~ * New Magincia Bazaar. Your match bid amount of ~3_BIDAMT~gp is held in escrow * at the Bazaar. You may obtain a full refund there at any time. Your hired * merchant, if any, has deposited your proceeds and remaining inventory at the * Warehouse in New Magincia. You must retrieve these within one week or they * will be destroyed.*/ MaginciaLottoSystem.SendMessageTo(m_Plot.Owner, new NewMaginciaMessage(null, new TextDefinition(1150528), string.Format("@{0}@{1}@{2}", m_Plot.PlotDef.ID, m_Plot.PlotDef.Map.ToString(), matching.ToString("N0")))); } } else if (m_Plot.Owner != null) { /*Your lease has expired on Stall ~1_STALLNAME~ at the ~2_FACET~ New Magincia Bazaar.*/ MaginciaLottoSystem.SendMessageTo(m_Plot.Owner, new NewMaginciaMessage(null, new TextDefinition(1150430), string.Format("@{0}@{1}", m_Plot.PlotDef.ID, m_Plot.PlotDef.Map.ToString()))); } if (winner == null) { //Get list of winners List <BidEntry> winners = new List <BidEntry>(); foreach (KeyValuePair <Mobile, BidEntry> kvp in combined) { if (kvp.Value.Amount >= highest) { winners.Add(kvp.Value); } } // One winner! if (winners.Count == 1) { winner = winners[0].Bidder; } else { // get a list of specific type (as opposed to next available) List <BidEntry> specifics = new List <BidEntry>(); foreach (BidEntry bid in winners) { if (bid.BidType == BidType.Specific) { specifics.Add(bid); } } // one 1 specific! if (specifics.Count == 1) { winner = specifics[0].Bidder; } else if (specifics.Count > 1) { //gets oldest specific BidEntry oldest = null; foreach (BidEntry entry in specifics) { if (oldest == null || entry.DatePlaced < oldest.DatePlaced) { oldest = entry; } } winner = oldest.Bidder; } else { //no specifics! gets oldest of list of winners BidEntry oldest = null; foreach (BidEntry entry in winners) { if (oldest == null || entry.DatePlaced < oldest.DatePlaced) { oldest = entry; } } if (oldest != null) { winner = oldest.Bidder; } } } } //Give back gold foreach (KeyValuePair <Mobile, BidEntry> kvp in m_Auctioners) { Mobile m = kvp.Key; if (m != winner) { if (!Banker.Deposit(m, kvp.Value.Amount, true) && m.Backpack != null) { int total = kvp.Value.Amount; while (total > 60000) { m.Backpack.DropItem(new BankCheck(60000)); total -= 60000; } if (total > 0) { m.Backpack.DropItem(new BankCheck(total)); } } } } //Does actual changes to plots if (winner != null) { MaginciaBazaar.AwardPlot(this, winner, highest); } else { m_Plot.Reset(); // lease expires m_Plot.NewAuction(MaginciaBazaar.GetShortAuctionTime); } }
public void AddPlotStone() { AddPlotStone(MaginciaLottoSystem.GetPlotStoneLoc(this)); }
public NewMaginciaMessageListGump(PlayerMobile from, bool widescreen = false) : base(from, 490, 30) { Widescreen = widescreen; Messages = MaginciaLottoSystem.GetMessages(from); }
public override void Deserialize(GenericReader reader) { base.Deserialize(reader); int version = reader.ReadInt(); m_FreeHousingZones = new Dictionary<Map, List<Rectangle2D>>(); m_FreeHousingZones[Map.Trammel] = new List<Rectangle2D>(); m_FreeHousingZones[Map.Felucca] = new List<Rectangle2D>(); m_GoldSink = reader.ReadInt(); m_Enabled = reader.ReadBool(); m_LottoDuration = reader.ReadTimeSpan(); int c = reader.ReadInt(); for (int i = 0; i < c; i++) RegisterPlot(new MaginciaHousingPlot(reader)); c = reader.ReadInt(); for (int i = 0; i < c; i++) m_FreeHousingZones[Map.Trammel].Add(reader.ReadRect2D()); c = reader.ReadInt(); for (int i = 0; i < c; i++) m_FreeHousingZones[Map.Felucca].Add(reader.ReadRect2D()); c = reader.ReadInt(); for (int i = 0; i < c; i++) { Mobile m = reader.ReadMobile(); List<NewMaginciaMessage> messages = new List<NewMaginciaMessage>(); int count = reader.ReadInt(); for(int j = 0; j < count; j++) messages.Add(new NewMaginciaMessage(reader)); if (m != null && messages.Count > 0) m_MessageQueue[m] = messages; } if (m_Enabled) StartTimer(); m_Instance = this; }
public static void AwardPlot(MaginciaPlotAuction auction, Mobile winner, int highest) { MaginciaBazaarPlot plot = auction.Plot; if (m_NextAvailable.ContainsKey(winner)) { m_NextAvailable.Remove(winner); } if (plot != null && plot.Owner != winner) { MaginciaBazaarPlot current = GetPlot(winner); //new owner if (current == null && winner != plot.Owner) { /*You won a lease on Stall ~1_STALLNAME~ at the ~2_FACET~ New Magincia Bazaar. * Your bid amount of ~3_BIDAMT~gp won the auction and has been remitted. Your * lease begins immediately and will continue for 7 days.*/ MaginciaLottoSystem.SendMessageTo(winner, new NewMaginciaMessage(null, new TextDefinition(1150426), String.Format("{0}\t{1}\t{2}", plot.PlotDef.ID, plot.PlotDef.Map.ToString(), highest.ToString("###,###,###")))); } plot.Reset(); //Transfer to new plot if (current != null) { /*You won a lease and moved to Stall ~1_STALLNAME~ at the ~2_FACET~ New Magincia * Bazaar. The lease on your previous stall has been terminated. Your hired * merchant, if any, has relocated your stall and goods to the new lot. Your * bid amount of ~3_BIDAMT~gp has been remitted.*/ MaginciaLottoSystem.SendMessageTo(winner, new NewMaginciaMessage(null, new TextDefinition(1150428), String.Format("{0}\t{1}\t{2}", plot.PlotDef.ID, plot.PlotDef.Map, highest.ToString("###,###,###")))); plot.PlotMulti = current.PlotMulti; plot.Merchant = current.Merchant; plot.ShopName = current.ShopName; current.PlotMulti = null; current.Merchant = null; current.Owner = null; if (current.Auction != null) { current.Auction.EndAuction(); } } plot.Owner = winner; plot.NewAuction(GetLongAuctionTime); } else if (plot != null) { if (plot.Owner != null) { plot.NewAuction(GetLongAuctionTime); } else { plot.Reset(); plot.NewAuction(GetShortAuctionTime); } } }
public void OnTick() { foreach (MaginciaBazaarPlot plot in m_Plots) { if (plot.Active) { plot.OnTick(); } } List <Mobile> toRemove = new List <Mobile>(); foreach (KeyValuePair <Mobile, StorageEntry> kvp in m_WarehouseStorage) { Mobile m = kvp.Key; StorageEntry entry = kvp.Value; bool deleted = false; if (entry.Expires < DateTime.UtcNow) { switch (entry.StorageType) { case StorageType.None: break; case StorageType.Commodity: deleted = true; break; case StorageType.Pet: { foreach (BaseCreature bc in entry.Creatures) { if (!deleted) { deleted = true; } bc.Delete(); } } break; } } if (deleted) { toRemove.Add(m); /*Your broker inventory and/or funds in storage at the New Magincia Warehouse * have been donated to charity, because these items remained unclaimed for a * full week. These items may no longer be recovered, but the orphans will * appreciate a nice hot meal.*/ MaginciaLottoSystem.SendMessageTo(m, new NewMaginciaMessage(new TextDefinition(1150676), new TextDefinition(1150673), null)); } } foreach (Mobile m in toRemove) { if (m_WarehouseStorage.ContainsKey(m)) { m_WarehouseStorage.Remove(m); } } }
public void OnTick() { foreach (MaginciaBazaarPlot plot in m_Plots) { if (plot.Active) { plot.OnTick(); } } List <Mobile> toRemove = new List <Mobile>(); foreach (KeyValuePair <Mobile, StorageEntry> kvp in m_WarehouseStorage) { Mobile m = kvp.Key; StorageEntry entry = kvp.Value; if (entry.Expires < DateTime.UtcNow) { bool deleted = false; bool stabled = false; if (entry.CommodityTypes.Count > 0) { deleted = true; } foreach (BaseCreature bc in entry.Creatures) { if (m.Stabled.Count < AnimalTrainer.GetMaxStabled(m)) { PetBroker.SendToStables(m, bc); if (!stabled) { stabled = true; } } else { if (!deleted) { deleted = true; } bc.Delete(); } } if (stabled) { string message; if (deleted) { message = "Your broker inventory and/or funds in storage at the New Magincia Warehouse " + "have been donated to charity, because these items remained unclaimed for a " + "full week. These items may no longer be recovered, but the orphans will " + "appreciate a nice hot meal. One or all of your pets have been placed in your stables."; } else { message = "Because your pets remained in storage for more than a full week, one or all of them have been placed in your stables. " + "If you had insufficient room in your stables, any further pets will be lost and returned to the wild."; } MaginciaLottoSystem.SendMessageTo(m, new NewMaginciaMessage(new TextDefinition(1150676), message, null)); } else if (deleted) { toRemove.Add(m); /*Your broker inventory and/or funds in storage at the New Magincia Warehouse * have been donated to charity, because these items remained unclaimed for a * full week. These items may no longer be recovered, but the orphans will * appreciate a nice hot meal.*/ MaginciaLottoSystem.SendMessageTo(m, new NewMaginciaMessage(new TextDefinition(1150676), new TextDefinition(1150673), null)); } } } foreach (Mobile m in toRemove) { if (m_WarehouseStorage.ContainsKey(m)) { m_WarehouseStorage.Remove(m); } } ColUtility.Free(toRemove); }