Overwrite

Complete Overwrite of the Folder with the free shard. ServUO 57.3 has been added.
This commit is contained in:
Unstable Kitsune
2023-11-28 23:20:26 -05:00
parent 3cd54811de
commit b918192e4e
11608 changed files with 2644205 additions and 47 deletions

View File

@@ -0,0 +1,233 @@
using System;
using Server;
using Server.Items;
using Server.Mobiles;
using System.Collections.Generic;
namespace Server.Engines.NewMagincia
{
public class CommodityBrokerEntry
{
private Type m_CommodityType;
private CommodityBroker m_Broker;
private int m_ItemID;
private int m_Label;
private int m_SellPricePer;
private int m_BuyPricePer;
private int m_BuyLimit;
private int m_SellLimit;
private int m_Stock;
public Type CommodityType { get { return m_CommodityType; } }
public CommodityBroker Broker { get { return m_Broker; } }
public int ItemID { get { return m_ItemID; } }
public int Label { get { return m_Label; } }
public int SellPricePer { get { return m_SellPricePer; } set { m_SellPricePer = value; } }
public int BuyPricePer { get { return m_BuyPricePer; } set { m_BuyPricePer = value; } }
public int BuyLimit { get { return m_BuyLimit; } set { m_BuyLimit = value; } }
public int SellLimit { get { return m_SellLimit; } set { m_SellLimit = value; } }
public int Stock { get { return m_Stock; } set { m_Stock = value; } }
public int ActualSellLimit
{
get
{
if (m_Stock < m_SellLimit)
return m_Stock;
return m_SellLimit;
}
}
public int ActualBuyLimit
{
get
{
if (m_Broker != null && m_Broker.BankBalance < m_BuyLimit * m_BuyPricePer && m_BuyPricePer > 0)
return m_Broker.BankBalance / m_BuyPricePer;
int limit = m_BuyLimit - m_Stock;
if (limit <= 0)
return 0;
return limit;
}
}
/* SellPricePer - price per unit the broker is selling to players for
* BuyPricePer - price per unit the borker is buying from players for
* BuyAtLimit - Limit a commodity must go below before it will buy that particular commodity
*
* SellAtLimit - Limit a commodty must go above before it will sell that particular commodity
* BuyLimit - Limit (in units) it will buy from players
* SellLimit - Limit (in units) it will sell to players
*/
public CommodityBrokerEntry (Item item, CommodityBroker broker, int amount)
{
m_CommodityType = item.GetType();
m_ItemID = item.ItemID;
m_Broker = broker;
m_Stock = amount;
if(item is ICommodity)
m_Label = ((ICommodity)item).Description;
else
m_Label = item.LabelNumber;
}
/// <summary>
/// Player buys, the vendor is selling
/// </summary>
/// <param name="amount"></param>
/// <returns></returns>
public bool PlayerCanBuy(int amount)
{
//return (m_SellAtLimit == 0 || m_Stock >= m_SellAtLimit) && m_Stock > 0 && m_SellPricePer > 0 && m_SellLimit < amount;
return (m_SellLimit == 0 || amount <= ActualSellLimit) && m_SellPricePer > 0;
}
/// <summary>
/// Player sells, the vendor is buying
/// </summary>
/// <param name="amount"></param>
/// <returns></returns>
public bool PlayerCanSell(int amount)
{
//(m_BuyAtLimit == 0 || m_Stock <= entry.BuyAtLimit) && m_Stock > 0 && m_BuyPricePer * amount <= m_Broker.BankBalance && m_BuyPricePer > 0 && m_BuyLimit < amount;
return (m_BuyLimit == 0 || amount <= ActualBuyLimit) && m_Stock > 0 && m_BuyPricePer > 0 && m_BuyPricePer <= m_Broker.BankBalance;
}
public CommodityBrokerEntry(GenericReader reader)
{
int version = reader.ReadInt();
m_CommodityType = ScriptCompiler.FindTypeByName(reader.ReadString());
m_Label = reader.ReadInt();
m_Broker = reader.ReadMobile() as CommodityBroker;
m_ItemID = reader.ReadInt();
m_SellPricePer = reader.ReadInt();
m_BuyPricePer = reader.ReadInt();
m_BuyLimit = reader.ReadInt();
m_SellLimit = reader.ReadInt();
m_Stock = reader.ReadInt();
}
public void Serialize(GenericWriter writer)
{
writer.Write((int)0);
writer.Write(m_CommodityType.Name);
writer.Write(m_Label);
writer.Write(m_Broker);
writer.Write(m_ItemID);
writer.Write(m_SellPricePer);
writer.Write(m_BuyPricePer);
writer.Write(m_BuyLimit);
writer.Write(m_SellLimit);
writer.Write(m_Stock);
}
}
public class PetBrokerEntry
{
private BaseCreature m_Pet;
private int m_SalePrice;
private string m_TypeName;
public BaseCreature Pet { get { return m_Pet; } }
public int SalePrice { get { return m_SalePrice; } set { m_SalePrice = value; } }
public string TypeName { get { return m_TypeName; } set { m_TypeName = value; } }
private static Dictionary<Type, string> m_NameBuffer = new Dictionary<Type, string>();
public static Dictionary<Type, string> NameBuffer { get { return m_NameBuffer; } }
public static readonly int DefaultPrice = 1000;
public PetBrokerEntry(BaseCreature pet) : this(pet, DefaultPrice)
{
}
public PetBrokerEntry(BaseCreature pet, int price)
{
m_Pet = pet;
m_SalePrice = price;
m_TypeName = GetOriginalName(pet);
}
public static string GetOriginalName(BaseCreature bc)
{
if(bc == null)
return null;
Type t = bc.GetType();
if(m_NameBuffer.ContainsKey(t))
return m_NameBuffer[t];
BaseCreature c = Activator.CreateInstance(t) as BaseCreature;
if(c != null)
{
c.Delete();
AddToBuffer(t, c.Name);
return c.Name;
}
return t.Name;
}
public static void AddToBuffer(Type type, string s)
{
if(s != null && s.Length > 0 && !m_NameBuffer.ContainsKey(type))
m_NameBuffer[type] = s;
}
public void Internalize()
{
if (m_Pet.Map == Map.Internal)
return;
m_Pet.ControlTarget = null;
m_Pet.ControlOrder = OrderType.Stay;
m_Pet.Internalize();
m_Pet.SetControlMaster(null);
m_Pet.SummonMaster = null;
m_Pet.IsStabled = true;
m_Pet.Loyalty = BaseCreature.MaxLoyalty;
m_Pet.Home = Point3D.Zero;
m_Pet.RangeHome = 10;
m_Pet.Blessed = false;
}
public PetBrokerEntry(GenericReader reader)
{
int version = reader.ReadInt();
m_Pet = reader.ReadMobile() as BaseCreature;
m_SalePrice = reader.ReadInt();
m_TypeName = reader.ReadString();
if (m_Pet != null)
{
AddToBuffer(m_Pet.GetType(), m_TypeName);
m_Pet.IsStabled = true;
Timer.DelayCall(TimeSpan.FromSeconds(10), new TimerCallback(Internalize));
}
}
public void Serialize(GenericWriter writer)
{
writer.Write((int)0);
writer.Write(m_Pet);
writer.Write(m_SalePrice);
writer.Write(m_TypeName);
}
}
}

View File

@@ -0,0 +1,899 @@
using Server;
using System;
using System.Collections.Generic;
using Server.Mobiles;
using Server.Items;
using Server.Accounting;
namespace Server.Engines.NewMagincia
{
public class MaginciaBazaar : Item
{
public static readonly int DefaultComissionFee = 5;
public static TimeSpan GetShortAuctionTime { get { return TimeSpan.FromMinutes(Utility.RandomMinMax(690, 750)); } }
public static TimeSpan GetLongAuctionTime { get { return TimeSpan.FromHours(Utility.RandomMinMax(168, 180)); } }
private static MaginciaBazaar m_Instance;
public static MaginciaBazaar Instance { get { return m_Instance; } set { m_Instance = value; } }
private Timer m_Timer;
private static List<MaginciaBazaarPlot> m_Plots = new List<MaginciaBazaarPlot>();
public static List<MaginciaBazaarPlot> Plots { get { return m_Plots; } }
private static Dictionary<Mobile, BidEntry> m_NextAvailable = new Dictionary<Mobile, BidEntry>();
public static Dictionary<Mobile, BidEntry> NextAvailable { get { return m_NextAvailable; } }
private static Dictionary<Mobile, int> m_Reserve = new Dictionary<Mobile, int>();
public static Dictionary<Mobile, int> Reserve { get { return m_Reserve; } }
private bool m_Enabled;
[CommandProperty(AccessLevel.GameMaster)]
public bool Enabled
{
get { return m_Enabled; }
set
{
if(m_Enabled != value)
{
if(value)
StartTimer();
else
EndTimer();
}
m_Enabled = value;
}
}
/*
* Phase 1 - Stalls A - D (0 - 19)
* Phase 2 - Stalls E - G (20 - 34)
* Phase 3 - Stalls H - J (35 - 49)
*/
public enum Phase
{
Phase1 = 1,
Phase2 = 2,
Phase3 = 3
}
private Phase m_Phase;
[CommandProperty(AccessLevel.GameMaster)]
public Phase PlotPhase
{
get { return m_Phase; }
set
{
if (value > m_Phase)
{
m_Phase = value;
ActivatePlots();
}
}
}
public MaginciaBazaar() : base(3240)
{
Movable = false;
m_Enabled = true;
WarehouseSuperintendent mob = new WarehouseSuperintendent();
mob.MoveToWorld(new Point3D(3795, 2259, 20), Map.Trammel);
mob.Home = mob.Location;
mob.RangeHome = 12;
mob = new WarehouseSuperintendent();
mob.MoveToWorld(new Point3D(3795, 2259, 20), Map.Felucca);
mob.Home = mob.Location;
mob.RangeHome = 12;
LoadPlots();
AddPlotSigns();
if (m_Enabled)
StartTimer();
m_Phase = Phase.Phase1;
ActivatePlots();
}
public static bool IsActivePlot(MaginciaBazaarPlot plot)
{
if (m_Instance != null)
{
int index = m_Plots.IndexOf(plot);
if (index == -1)
return false;
switch ((int)m_Instance.m_Phase)
{
case 1: return index < 40;
case 2: return index < 70;
case 3: return index < 100;
}
}
return false;
}
public void ActivatePlots()
{
for (int i = 0; i < m_Plots.Count; i++)
{
MaginciaBazaarPlot plot = m_Plots[i];
switch ((int)m_Phase)
{
case 1:
if (i < 40 && plot.Auction == null)
{
plot.NewAuction(GetShortAuctionTime);
}
break;
case 2:
if (i < 70 && plot.Auction == null)
{
plot.NewAuction(GetShortAuctionTime);
}
break;
case 3:
if (i < 100 && plot.Auction == null)
{
plot.NewAuction(GetShortAuctionTime);
}
break;
}
if (plot.Sign != null)
plot.Sign.InvalidateProperties();
}
}
public void StartTimer()
{
if (m_Timer != null)
m_Timer.Stop();
m_Timer = Timer.DelayCall(TimeSpan.FromMinutes(1), TimeSpan.FromMinutes(1), new TimerCallback(OnTick));
m_Timer.Priority = TimerPriority.OneMinute;
m_Timer.Start();
}
public void EndTimer()
{
if(m_Timer != null)
m_Timer.Stop();
m_Timer = null;
}
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);
}
public void AddPlotSigns()
{
foreach (MaginciaBazaarPlot plot in m_Plots)
{
Point3D loc = new Point3D(plot.PlotDef.SignLoc.X - 1, plot.PlotDef.SignLoc.Y, plot.PlotDef.SignLoc.Z);
Static pole = new Static(2592);
pole.MoveToWorld(loc, plot.PlotDef.Map);
pole = new Static(2969);
pole.MoveToWorld(plot.PlotDef.SignLoc, plot.PlotDef.Map);
plot.AddPlotSign();
}
}
public override void Delete()
{
// Note: This cannot be deleted. That could potentially piss alot of people off who have items and gold invested in a plot.
}
public static MaginciaBazaarPlot GetPlot(Mobile from)
{
foreach(MaginciaBazaarPlot plot in m_Plots)
{
if(plot.IsOwner(from))
return plot;
}
return null;
}
public static bool HasPlot(Mobile from)
{
foreach(MaginciaBazaarPlot plot in m_Plots)
{
if(plot.IsOwner(from))
return true;
}
return false;
}
public static MaginciaBazaarPlot GetBiddingPlot(Mobile from)
{
Account acct = from.Account as Account;
if(acct == null)
return null;
for (int i = 0; i < acct.Length; i++)
{
Mobile m = acct[i];
if (m == null)
continue;
MaginciaBazaarPlot plot = GetBiddingPlotForAccount(m);
if (plot != null)
return plot;
}
return null;
}
public static MaginciaBazaarPlot GetBiddingPlotForAccount(Mobile from)
{
foreach(MaginciaBazaarPlot plot in m_Plots)
{
if(plot.Auction != null && plot.Auction.Auctioners.ContainsKey(from))
return plot;
}
return null;
}
public bool HasActiveBid(Mobile from)
{
return GetBiddingPlot(from) != null || m_NextAvailable.ContainsKey(from);
}
public static bool TryRetractBid(Mobile from)
{
MaginciaBazaarPlot plot = GetBiddingPlot(from);
if(plot != null)
return plot.Auction.RetractBid(from);
return RetractBid(from);
}
public static bool RetractBid(Mobile from)
{
Account acct = from.Account as Account;
for (int i = 0; i < acct.Length; i++)
{
Mobile m = acct[i];
if (m == null)
continue;
if (m_NextAvailable.ContainsKey(m))
{
BidEntry entry = m_NextAvailable[m];
if (entry != null && Banker.Deposit(m, entry.Amount))
{
m_NextAvailable.Remove(m);
return true;
}
}
}
return false;
}
public static bool IsBiddingNextAvailable(Mobile from)
{
return m_NextAvailable.ContainsKey(from);
}
public static int GetNextAvailableBid(Mobile from)
{
if(m_NextAvailable.ContainsKey(from))
return m_NextAvailable[from].Amount;
return 0;
}
public static void MakeBidNextAvailable(Mobile from, int amount)
{
m_NextAvailable[from] = new BidEntry(from, amount, BidType.NextAvailable);
}
public static void RemoveBidNextAvailable(Mobile from)
{
if (m_NextAvailable.ContainsKey(from))
m_NextAvailable.Remove(from);
}
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 static void RegisterPlot(PlotDef plotDef)
{
m_Plots.Add(new MaginciaBazaarPlot(plotDef));
}
public static bool IsSameAccount(Mobile check, Mobile checkAgainst)
{
return IsSameAccount(check, checkAgainst, false);
}
public static bool IsSameAccount(Mobile check, Mobile checkAgainst, bool checkLink)
{
if(check == null || checkAgainst == null)
return false;
Account acct1 = checkAgainst.Account as Account;
Account acct2 = check.Account as Account;
if(acct1 != null && acct1 == acct2)
return true;
return false;
}
#region Bizaar Authority Storage
private static Dictionary<Mobile, StorageEntry> m_WarehouseStorage = new Dictionary<Mobile, StorageEntry>();
public void AddInventoryToWarehouse(Mobile owner, BaseBazaarBroker broker)
{
StorageEntry entry = GetStorageEntry(owner);
if (entry == null)
{
if (broker.HasValidEntry(owner))
{
entry = new StorageEntry(owner, broker);
}
}
else if (broker.HasValidEntry(owner))
{
entry.AddInventory(owner, broker);
}
if (entry != null)
{
m_WarehouseStorage[owner] = entry;
/*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 static StorageEntry GetStorageEntry(Mobile from)
{
if (m_WarehouseStorage.ContainsKey(from))
return m_WarehouseStorage[from];
return null;
}
public static void RemoveFromStorage(Mobile from)
{
if (m_WarehouseStorage.ContainsKey(from))
{
m_WarehouseStorage.Remove(from);
}
}
public static void AddToReserve(Mobile from, int amount)
{
foreach(Mobile m in m_Reserve.Keys)
{
if(from == m || IsSameAccount(from, m))
{
m_Reserve[m] += amount;
return;
}
}
m_Reserve[from] = amount;
}
public static void DeductReserve(Mobile from, int amount)
{
foreach(Mobile m in m_Reserve.Keys)
{
if(from == m || IsSameAccount(from, m))
{
m_Reserve[m] -= amount;
if(m_Reserve[m] <= 0)
m_Reserve.Remove(m);
return;
}
}
}
public static int GetBidMatching(Mobile from)
{
foreach(Mobile m in m_Reserve.Keys)
{
if(from == m || IsSameAccount(m, from))
return m_Reserve[m];
}
return 0;
}
#endregion
public MaginciaBazaar(Serial serial) : base(serial)
{
}
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.Write((int)0);
writer.Write(m_Enabled);
writer.Write((int)m_Phase);
writer.Write(m_Plots.Count);
for(int i = 0; i < m_Plots.Count; i++)
{
m_Plots[i].Serialize(writer);
}
writer.Write(m_NextAvailable.Count);
foreach(KeyValuePair<Mobile, BidEntry> kvp in m_NextAvailable)
{
writer.Write(kvp.Key);
kvp.Value.Serialize(writer);
}
writer.Write(m_WarehouseStorage.Count);
foreach (KeyValuePair<Mobile, StorageEntry> kvp in m_WarehouseStorage)
{
writer.Write(kvp.Key);
kvp.Value.Serialize(writer);
}
writer.Write(m_Reserve.Count);
foreach (KeyValuePair<Mobile, int> kvp in m_Reserve)
{
writer.Write(kvp.Key);
writer.Write(kvp.Value);
}
}
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
int version = reader.ReadInt();
m_Enabled = reader.ReadBool();
m_Phase = (Phase)reader.ReadInt();
int count = reader.ReadInt();
for(int i = 0; i < count; i++)
{
m_Plots.Add(new MaginciaBazaarPlot(reader));
}
count = reader.ReadInt();
for(int i = 0; i < count; i++)
{
Mobile m = reader.ReadMobile();
BidEntry entry = new BidEntry(reader);
if(m != null)
m_NextAvailable[m] = entry;
}
count = reader.ReadInt();
for (int i = 0; i < count; i++)
{
Mobile m = reader.ReadMobile();
StorageEntry entry = new StorageEntry(reader);
if (m != null)
m_WarehouseStorage[m] = entry;
}
count = reader.ReadInt();
for (int i = 0; i < count; i++)
{
Mobile m = reader.ReadMobile();
int amt = reader.ReadInt();
if (m != null && amt > 0)
m_Reserve[m] = amt;
}
m_Instance = this;
if (m_Enabled)
StartTimer();
}
public static void LoadPlots()
{
int idx = 0;
RegisterPlot(new PlotDef("A-1", m_StallLocs[idx], 0));
RegisterPlot(new PlotDef("A-1", m_StallLocs[idx], 1));
idx++;
RegisterPlot(new PlotDef("A-2", m_StallLocs[idx], 0));
RegisterPlot(new PlotDef("A-2", m_StallLocs[idx], 1));
idx++;
RegisterPlot(new PlotDef("A-3", m_StallLocs[idx], 0));
RegisterPlot(new PlotDef("A-3", m_StallLocs[idx], 1));
idx++;
RegisterPlot(new PlotDef("A-4", m_StallLocs[idx], 0));
RegisterPlot(new PlotDef("A-4", m_StallLocs[idx], 1));
idx++;
RegisterPlot(new PlotDef("B-1", m_StallLocs[idx], 0));
RegisterPlot(new PlotDef("B-1", m_StallLocs[idx], 1));
idx++;
RegisterPlot(new PlotDef("B-2", m_StallLocs[idx], 0));
RegisterPlot(new PlotDef("B-2", m_StallLocs[idx], 1));
idx++;
RegisterPlot(new PlotDef("B-3", m_StallLocs[idx], 0));
RegisterPlot(new PlotDef("B-3", m_StallLocs[idx], 1));
idx++;
RegisterPlot(new PlotDef("B-4", m_StallLocs[idx], 0));
RegisterPlot(new PlotDef("B-4", m_StallLocs[idx], 1));
idx++;
RegisterPlot(new PlotDef("B-5", m_StallLocs[idx], 0));
RegisterPlot(new PlotDef("B-5", m_StallLocs[idx], 1));
idx++;
RegisterPlot(new PlotDef("B-6", m_StallLocs[idx], 1));
RegisterPlot(new PlotDef("B-6", m_StallLocs[idx], 0));
idx++;
RegisterPlot(new PlotDef("C-1", m_StallLocs[idx], 1));
RegisterPlot(new PlotDef("C-1", m_StallLocs[idx], 0));
idx++;
RegisterPlot(new PlotDef("C-2", m_StallLocs[idx], 1));
RegisterPlot(new PlotDef("C-2", m_StallLocs[idx], 0));
idx++;
RegisterPlot(new PlotDef("C-3", m_StallLocs[idx], 1));
RegisterPlot(new PlotDef("C-3", m_StallLocs[idx], 0));
idx++;
RegisterPlot(new PlotDef("C-4", m_StallLocs[idx], 1));
RegisterPlot(new PlotDef("C-4", m_StallLocs[idx], 0));
idx++;
RegisterPlot(new PlotDef("C-5", m_StallLocs[idx], 1));
RegisterPlot(new PlotDef("C-5", m_StallLocs[idx], 0));
idx++;
RegisterPlot(new PlotDef("D-1", m_StallLocs[idx], 1));
RegisterPlot(new PlotDef("D-1", m_StallLocs[idx], 0));
idx++;
RegisterPlot(new PlotDef("D-2", m_StallLocs[idx], 1));
RegisterPlot(new PlotDef("D-2", m_StallLocs[idx], 0));
idx++;
RegisterPlot(new PlotDef("D-3", m_StallLocs[idx], 1));
RegisterPlot(new PlotDef("D-3", m_StallLocs[idx], 0));
idx++;
RegisterPlot(new PlotDef("D-4", m_StallLocs[idx], 1));
RegisterPlot(new PlotDef("D-4", m_StallLocs[idx], 0));
idx++;
RegisterPlot(new PlotDef("D-5", m_StallLocs[idx], 1));
RegisterPlot(new PlotDef("D-5", m_StallLocs[idx], 0));
idx++;
RegisterPlot(new PlotDef("E-1", m_StallLocs[idx], 1));
RegisterPlot(new PlotDef("E-1", m_StallLocs[idx], 0));
idx++;
RegisterPlot(new PlotDef("E-2", m_StallLocs[idx], 1));
RegisterPlot(new PlotDef("E-2", m_StallLocs[idx], 0));
idx++;
RegisterPlot(new PlotDef("E-3", m_StallLocs[idx], 1));
RegisterPlot(new PlotDef("E-3", m_StallLocs[idx], 0));
idx++;
RegisterPlot(new PlotDef("E-4", m_StallLocs[idx], 1));
RegisterPlot(new PlotDef("E-4", m_StallLocs[idx], 0));
idx++;
RegisterPlot(new PlotDef("E-5", m_StallLocs[idx], 1));
RegisterPlot(new PlotDef("E-5", m_StallLocs[idx], 0));
idx++;
RegisterPlot(new PlotDef("F-1", m_StallLocs[idx], 1));
RegisterPlot(new PlotDef("F-1", m_StallLocs[idx], 0));
idx++;
RegisterPlot(new PlotDef("F-2", m_StallLocs[idx], 1));
RegisterPlot(new PlotDef("F-2", m_StallLocs[idx], 0));
idx++;
RegisterPlot(new PlotDef("F-3", m_StallLocs[idx], 1));
RegisterPlot(new PlotDef("F-3", m_StallLocs[idx], 0));
idx++;
RegisterPlot(new PlotDef("F-4", m_StallLocs[idx], 1));
RegisterPlot(new PlotDef("F-4", m_StallLocs[idx], 0));
idx++;
RegisterPlot(new PlotDef("F-5", m_StallLocs[idx], 1));
RegisterPlot(new PlotDef("F-5", m_StallLocs[idx], 0));
idx++;
RegisterPlot(new PlotDef("G-1", m_StallLocs[idx], 1));
RegisterPlot(new PlotDef("G-1", m_StallLocs[idx], 0));
idx++;
RegisterPlot(new PlotDef("G-2", m_StallLocs[idx], 1));
RegisterPlot(new PlotDef("G-2", m_StallLocs[idx], 0));
idx++;
RegisterPlot(new PlotDef("G-3", m_StallLocs[idx], 1));
RegisterPlot(new PlotDef("G-3", m_StallLocs[idx], 0));
idx++;
RegisterPlot(new PlotDef("G-4", m_StallLocs[idx], 1));
RegisterPlot(new PlotDef("G-4", m_StallLocs[idx], 0));
idx++;
RegisterPlot(new PlotDef("G-5", m_StallLocs[idx], 1));
RegisterPlot(new PlotDef("G-5", m_StallLocs[idx], 0));
idx++;
RegisterPlot(new PlotDef("H-1", m_StallLocs[idx], 1));
RegisterPlot(new PlotDef("H-1", m_StallLocs[idx], 0));
idx++;
RegisterPlot(new PlotDef("H-2", m_StallLocs[idx], 1));
RegisterPlot(new PlotDef("H-2", m_StallLocs[idx], 0));
idx++;
RegisterPlot(new PlotDef("H-3", m_StallLocs[idx], 1));
RegisterPlot(new PlotDef("H-3", m_StallLocs[idx], 0));
idx++;
RegisterPlot(new PlotDef("H-4", m_StallLocs[idx], 1));
RegisterPlot(new PlotDef("H-4", m_StallLocs[idx], 0));
idx++;
RegisterPlot(new PlotDef("H-5", m_StallLocs[idx], 1));
RegisterPlot(new PlotDef("H-5", m_StallLocs[idx], 0));
idx++;
RegisterPlot(new PlotDef("H-6", m_StallLocs[idx], 1));
RegisterPlot(new PlotDef("H-6", m_StallLocs[idx], 0));
idx++;
RegisterPlot(new PlotDef("I-1", m_StallLocs[idx], 1));
RegisterPlot(new PlotDef("I-1", m_StallLocs[idx], 0));
idx++;
RegisterPlot(new PlotDef("I-2", m_StallLocs[idx], 1));
RegisterPlot(new PlotDef("I-2", m_StallLocs[idx], 0));
idx++;
RegisterPlot(new PlotDef("I-3", m_StallLocs[idx], 1));
RegisterPlot(new PlotDef("I-3", m_StallLocs[idx], 0));
idx++;
RegisterPlot(new PlotDef("I-4", m_StallLocs[idx], 1));
RegisterPlot(new PlotDef("I-4", m_StallLocs[idx], 0));
idx++;
RegisterPlot(new PlotDef("I-5", m_StallLocs[idx], 1));
RegisterPlot(new PlotDef("I-5", m_StallLocs[idx], 0));
idx++;
RegisterPlot(new PlotDef("J-1", m_StallLocs[idx], 1));
RegisterPlot(new PlotDef("J-1", m_StallLocs[idx], 0));
idx++;
RegisterPlot(new PlotDef("J-2", m_StallLocs[idx], 1));
RegisterPlot(new PlotDef("J-2", m_StallLocs[idx], 0));
idx++;
RegisterPlot(new PlotDef("J-3", m_StallLocs[idx], 1));
RegisterPlot(new PlotDef("J-3", m_StallLocs[idx], 0));
idx++;
RegisterPlot(new PlotDef("J-4", m_StallLocs[idx], 1));
RegisterPlot(new PlotDef("J-4", m_StallLocs[idx], 0));
}
private static Point3D[] m_StallLocs = new Point3D[]
{
//A
new Point3D(3716, 2198, 20),
new Point3D(3709, 2198, 20),
new Point3D(3700, 2192, 20),
new Point3D(3693, 2192, 20),
//B
new Point3D(3686, 2192, 20),
new Point3D(3686, 2198, 20),
new Point3D(3686, 2204, 20),
new Point3D(3686, 2210, 20),
new Point3D(3686, 2216, 20),
new Point3D(3686, 2222, 20),
//C
new Point3D(3686, 2228, 20),
new Point3D(3692, 2228, 20),
new Point3D(3698, 2228, 20),
new Point3D(3704, 2228, 20),
new Point3D(3710, 2228, 20),
//D
new Point3D(3716, 2228, 20),
new Point3D(3716, 2222, 20),
new Point3D(3716, 2216, 20),
new Point3D(3716, 2210, 20),
new Point3D(3716, 2204, 20),
//E
new Point3D(3686, 2178, 20),
new Point3D(3686, 2171, 20),
new Point3D(3686, 2164, 20),
new Point3D(3686, 2157, 20),
new Point3D(3686, 2150, 20),
//F
new Point3D(3693, 2178, 20),
new Point3D(3693, 2171, 20),
new Point3D(3693, 2164, 20),
new Point3D(3693, 2157, 20),
new Point3D(3693, 2150, 20),
//G
new Point3D(3700, 2178, 20),
new Point3D(3700, 2171, 20),
new Point3D(3700, 2164, 20),
new Point3D(3700, 2157, 20),
new Point3D(3700, 2150, 20),
//H
new Point3D(3672, 2238, 20),
new Point3D(3665, 2238, 20),
new Point3D(3658, 2238, 20),
new Point3D(3672, 2245, 20),
new Point3D(3665, 2245, 20),
new Point3D(3658, 2245, 20),
//I
new Point3D(3730, 2249, 20),
new Point3D(3730, 2242, 20),
new Point3D(3737, 2242, 20),
new Point3D(3737, 2249, 20),
new Point3D(3737, 2256, 20),
//J
new Point3D(3730, 2220, 20),
new Point3D(3737, 2220, 20),
new Point3D(3730, 2228, 20),
new Point3D(3737, 2228, 20),
};
}
}

View File

@@ -0,0 +1,441 @@
using Server;
using System;
using Server.Items;
using Server.Mobiles;
using Server.Accounting;
namespace Server.Engines.NewMagincia
{
[PropertyObject]
public class MaginciaBazaarPlot
{
private PlotDef m_Definition;
private Mobile m_Owner;
private string m_ShopName;
private BaseBazaarMulti m_PlotMulti;
private BaseBazaarBroker m_Merchant;
private PlotSign m_Sign;
private MaginciaPlotAuction m_Auction;
[CommandProperty(AccessLevel.GameMaster)]
public PlotDef PlotDef { get { return m_Definition; } set { } }
[CommandProperty(AccessLevel.GameMaster)]
public Mobile Owner { get { return m_Owner; } set { m_Owner = value; } }
[CommandProperty(AccessLevel.GameMaster)]
public string ShopName { get { return m_ShopName; } set { m_ShopName = value; } }
[CommandProperty(AccessLevel.GameMaster)]
public BaseBazaarMulti PlotMulti
{
get { return m_PlotMulti; }
set
{
if (m_PlotMulti != null && m_PlotMulti != value && value != null)
{
m_PlotMulti.Delete();
m_PlotMulti = null;
}
m_PlotMulti = value;
if(m_PlotMulti != null)
m_PlotMulti.MoveToWorld(m_Definition.MultiLocation, m_Definition.Map);
}
}
[CommandProperty(AccessLevel.GameMaster)]
public BaseBazaarBroker Merchant
{
get { return m_Merchant; }
set
{
m_Merchant = value;
if(m_Merchant != null)
{
m_Merchant.Plot = this;
Point3D p = m_Definition.Location;
p.X++;
p.Y++;
p.Z = 27;
if (m_PlotMulti != null && m_PlotMulti.Fillers.Count > 0)
{
p = m_PlotMulti.Fillers[0].Location;
p.Z = m_PlotMulti.Fillers[0].Z + TileData.ItemTable[m_PlotMulti.Fillers[0].ItemID & TileData.MaxItemValue].CalcHeight;
}
m_Merchant.MoveToWorld(p, m_Definition.Map);
}
}
}
[CommandProperty(AccessLevel.GameMaster)]
public PlotSign Sign { get { return m_Sign; } set { m_Sign = value; } }
[CommandProperty(AccessLevel.GameMaster)]
public MaginciaPlotAuction Auction
{
get
{
/*if(m_Auction == null)
{
TimeSpan ts;
if(m_Owner == null)
ts = MaginciaBazaar.GetLongAuctionTime;
else
ts = MaginciaBazaar.GetShortAuctionTime;
m_Auction = new MaginciaPlotAuction(this, ts);
}*/
return m_Auction;
}
set { m_Auction = value; }
}
[CommandProperty(AccessLevel.GameMaster)]
public bool Active { get { return MaginciaBazaar.IsActivePlot(this); } }
[CommandProperty(AccessLevel.GameMaster)]
public DateTime AuctionEnds
{
get
{
if (Auction == null)
return DateTime.MinValue;
return Auction.AuctionEnd;
}
}
public MaginciaBazaarPlot(PlotDef definition)
{
m_Definition = definition;
m_Owner = null;
m_PlotMulti = null;
m_Merchant = null;
m_ShopName = null;
}
public bool IsOwner(Mobile from)
{
if(from == null || m_Owner == null)
return false;
if(from == m_Owner)
return true;
Account acct1 = from.Account as Account;
Account acct2 = m_Owner.Account as Account;
return acct1 != null && acct2 != null && acct1 == acct2;
}
public void AddPlotSign()
{
m_Sign = new PlotSign(this);
m_Sign.MoveToWorld(m_Definition.SignLoc, m_Definition.Map);
}
public void Reset()
{
if(m_PlotMulti != null)
Timer.DelayCall(TimeSpan.FromMinutes(2), new TimerCallback(DeleteMulti_Callback));
EndTempMultiTimer();
if(m_Merchant != null)
m_Merchant.Dismiss();
m_Owner = null;
m_ShopName = null;
m_Merchant = null;
m_ShopName = null;
}
public void NewAuction(TimeSpan time)
{
m_Auction = new MaginciaPlotAuction(this, time);
if (m_Sign != null)
m_Sign.InvalidateProperties();
}
private void DeleteMulti_Callback()
{
if (m_PlotMulti != null)
m_PlotMulti.Delete();
m_PlotMulti = null;
}
public void OnTick()
{
if (m_Auction != null)
m_Auction.OnTick();
if(m_Merchant != null)
m_Merchant.OnTick();
if (m_Sign != null)
m_Sign.InvalidateProperties();
}
#region Stall Style Multis
private Timer m_Timer;
public void AddTempMulti(int idx1, int idx2)
{
if (m_PlotMulti != null)
{
m_PlotMulti.Delete();
m_PlotMulti = null;
}
BaseBazaarMulti multi = null;
if (idx1 == 0)
{
switch (idx2)
{
case 0: multi = new CommodityStyle1(); break;
case 1: multi = new CommodityStyle2(); break;
case 2: multi = new CommodityStyle3(); break;
}
}
else
{
switch (idx2)
{
case 0: multi = new PetStyle1(); break;
case 1: multi = new PetStyle2(); break;
case 2: multi = new PetStyle3(); break;
}
}
if (multi != null)
{
PlotMulti = multi;
BeginTempMultiTimer();
}
}
public void ConfirmMulti(bool commodity)
{
EndTempMultiTimer();
if(commodity)
Merchant = new CommodityBroker(this);
else
Merchant = new PetBroker(this);
}
public void RemoveTempPlot()
{
EndTempMultiTimer();
if (m_PlotMulti != null)
{
m_PlotMulti.Delete();
m_PlotMulti = null;
}
}
public void BeginTempMultiTimer()
{
if(m_Timer != null)
{
m_Timer.Stop();
m_Timer = null;
}
m_Timer = new InternalTimer(this);
m_Timer.Start();
}
public void EndTempMultiTimer()
{
if(m_Timer != null)
{
m_Timer.Stop();
m_Timer = null;
}
}
public bool HasTempMulti()
{
return m_Timer != null;
}
private class InternalTimer : Timer
{
private MaginciaBazaarPlot m_Plot;
public InternalTimer(MaginciaBazaarPlot plot) : base(TimeSpan.FromMinutes(1), TimeSpan.FromMinutes(1))
{
m_Plot = plot;
}
protected override void OnTick()
{
if(m_Plot != null)
m_Plot.RemoveTempPlot();
}
}
#endregion
public override string ToString()
{
return "...";
}
public bool TrySetShopName(Mobile from, string text)
{
if (text == null || !Server.Guilds.BaseGuildGump.CheckProfanity(text) || text.Length == 0 || text.Length > 40)
return false;
m_ShopName = text;
if(m_Merchant != null)
m_Merchant.InvalidateProperties();
if(m_Sign != null)
m_Sign.InvalidateProperties();
from.SendLocalizedMessage(1150333); // Your shop has been renamed.
return true;
}
public void FireBroker()
{
if(m_Merchant != null)
{
m_Merchant.Delete();
m_Merchant = null;
if (m_PlotMulti != null)
{
m_PlotMulti.Delete();
m_PlotMulti = null;
}
}
}
public void Abandon()
{
Reset();
if (m_Auction != null)
m_Auction.ChangeAuctionTime(MaginciaBazaar.GetShortAuctionTime);
}
public int GetBid(Mobile from)
{
if (m_Auction != null && m_Auction.Auctioners.ContainsKey(from))
return m_Auction.Auctioners[from].Amount;
return 0;
}
public void Serialize(GenericWriter writer)
{
writer.Write((int)0);
m_Definition.Serialize(writer);
writer.Write(m_Owner);
writer.Write(m_ShopName);
writer.Write(m_Merchant);
writer.Write(m_Sign);
writer.Write(m_PlotMulti);
if(m_Auction != null)
{
writer.Write((bool)true);
m_Auction.Serialize(writer);
}
else
writer.Write((bool)false);
}
public MaginciaBazaarPlot(GenericReader reader)
{
int version = reader.ReadInt();
m_Definition = new PlotDef(reader);
m_Owner = reader.ReadMobile();
m_ShopName = reader.ReadString();
m_Merchant = reader.ReadMobile() as BaseBazaarBroker;
m_Sign = reader.ReadItem() as PlotSign;
m_PlotMulti = reader.ReadItem() as BaseBazaarMulti;
if(reader.ReadBool())
m_Auction = new MaginciaPlotAuction(reader, this);
if(m_Merchant != null)
m_Merchant.Plot = this;
if (m_Sign != null)
m_Sign.Plot = this;
}
}
[PropertyObject]
public class PlotDef
{
private string m_ID;
private Point3D m_Location;
private Map m_Map;
[CommandProperty(AccessLevel.GameMaster)]
public string ID { get { return m_ID; } set { m_ID = value; } }
[CommandProperty(AccessLevel.GameMaster)]
public Point3D Location { get { return m_Location; } set { m_Location = value; } }
[CommandProperty(AccessLevel.GameMaster)]
public Map Map { get { return m_Map; } }
[CommandProperty(AccessLevel.GameMaster)]
public Point3D SignLoc { get { return new Point3D(m_Location.X + 1, m_Location.Y - 2, m_Location.Z); } }
[CommandProperty(AccessLevel.GameMaster)]
public Point3D MultiLocation { get { return new Point3D(m_Location.X, m_Location.Y, m_Location.Z + 2); } }
public PlotDef(string id, Point3D pnt, int mapID)
{
m_ID = id;
m_Location = pnt;
m_Map = Server.Map.Maps[mapID];
}
public override string ToString()
{
return "...";
}
public PlotDef(GenericReader reader)
{
int version = reader.ReadInt();
m_ID = reader.ReadString();
m_Location = reader.ReadPoint3D();
m_Map = reader.ReadMap();
}
public void Serialize(GenericWriter writer)
{
writer.Write((int)0);
writer.Write(m_ID);
writer.Write(m_Location);
writer.Write(m_Map);
}
}
}

View File

@@ -0,0 +1,347 @@
using Server;
using System;
using System.Collections.Generic;
using Server.Items;
using Server.Mobiles;
using Server.Accounting;
namespace Server.Engines.NewMagincia
{
[PropertyObject]
public class MaginciaPlotAuction
{
private Dictionary<Mobile, BidEntry> m_Auctioners = new Dictionary<Mobile, BidEntry>();
public Dictionary<Mobile, BidEntry> Auctioners { get { return m_Auctioners; } }
private MaginciaBazaarPlot m_Plot;
private DateTime m_AuctionEnd;
[CommandProperty(AccessLevel.GameMaster)]
public MaginciaBazaarPlot Plot { get { return m_Plot; } }
[CommandProperty(AccessLevel.GameMaster)]
public DateTime AuctionEnd { get { return m_AuctionEnd; } }
[CommandProperty(AccessLevel.GameMaster)]
public bool EndCurrentAuction
{
get { return false; }
set
{
EndAuction();
}
}
public MaginciaPlotAuction(MaginciaBazaarPlot plot) : this(plot, MaginciaBazaar.GetShortAuctionTime)
{
}
public MaginciaPlotAuction(MaginciaBazaarPlot plot, TimeSpan auctionDuration)
{
m_Plot = plot;
m_AuctionEnd = DateTime.UtcNow + auctionDuration;
}
public override string ToString()
{
return "...";
}
public void MakeBid(Mobile bidder, int amount)
{
m_Auctioners[bidder] = new BidEntry(bidder, amount, BidType.Specific);
}
public bool RetractBid(Mobile from)
{
Account acct = from.Account as Account;
for (int i = 0; i < acct.Length; i++)
{
Mobile m = acct[i];
if (m == null)
continue;
if (m_Auctioners.ContainsKey(m))
{
BidEntry entry = m_Auctioners[m];
if (entry != null && Banker.Deposit(m, entry.Amount))
{
m_Auctioners.Remove(m);
return true;
}
}
}
return false;
}
public void RemoveBid(Mobile from)
{
if (m_Auctioners.ContainsKey(from))
m_Auctioners.Remove(from);
}
public int GetHighestBid()
{
int highest = -1;
foreach(BidEntry entry in m_Auctioners.Values)
{
if(entry.Amount >= highest)
highest = entry.Amount;
}
return highest;
}
public void OnTick()
{
if(m_AuctionEnd < DateTime.UtcNow)
EndAuction();
}
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 int GetBidAmount(Mobile from)
{
if(!m_Auctioners.ContainsKey(from))
return 0;
return m_Auctioners[from].Amount;
}
public void ChangeAuctionTime(TimeSpan ts)
{
m_AuctionEnd = DateTime.UtcNow + ts;
if (m_Plot != null && m_Plot.Sign != null)
m_Plot.Sign.InvalidateProperties();
}
public MaginciaPlotAuction(GenericReader reader, MaginciaBazaarPlot plot)
{
int version = reader.ReadInt();
m_Plot = plot;
m_AuctionEnd = reader.ReadDateTime();
int c = reader.ReadInt();
for(int i = 0; i < c; i++)
{
Mobile m = reader.ReadMobile();
BidEntry entry = new BidEntry(reader);
if(m != null)
m_Auctioners[m] = entry;
}
}
public void Serialize(GenericWriter writer)
{
writer.Write((int)0);
writer.Write(m_AuctionEnd);
writer.Write(m_Auctioners.Count);
foreach(KeyValuePair<Mobile, BidEntry> kvp in m_Auctioners)
{
writer.Write(kvp.Key);
kvp.Value.Serialize(writer);
}
}
}
public enum BidType
{
Specific,
NextAvailable
}
public class BidEntry : IComparable
{
private Mobile m_Bidder;
private int m_Amount;
private BidType m_BidType;
private DateTime m_DatePlaced;
public Mobile Bidder { get { return m_Bidder; } }
public int Amount { get { return m_Amount; } }
public BidType BidType { get { return m_BidType; } }
public DateTime DatePlaced { get { return m_DatePlaced; } }
public BidEntry(Mobile bidder, int amount, BidType type)
{
m_Bidder = bidder;
m_Amount = amount;
m_BidType = type;
m_DatePlaced = DateTime.UtcNow;
}
public int CompareTo( object obj )
{
return ((BidEntry)obj).m_Amount - m_Amount;
}
public BidEntry(GenericReader reader)
{
int version = reader.ReadInt();
m_Bidder = reader.ReadMobile();
m_Amount = reader.ReadInt();
m_BidType = (BidType)reader.ReadInt();
m_DatePlaced = reader.ReadDateTime();
}
public void Serialize(GenericWriter writer)
{
writer.Write((int)0);
writer.Write(m_Bidder);
writer.Write(m_Amount);
writer.Write((int)m_BidType);
writer.Write(m_DatePlaced);
}
}
}

View File

@@ -0,0 +1,162 @@
using System;
using Server;
using Server.Items;
using Server.Mobiles;
using System.Collections.Generic;
namespace Server.Engines.NewMagincia
{
public class StorageEntry
{
private int m_Funds;
private DateTime m_Expires;
private Dictionary<Type, int> m_CommodityTypes = new Dictionary<Type, int>();
private List<BaseCreature> m_Creatures = new List<BaseCreature>();
public int Funds { get { return m_Funds; } set { m_Funds = value; } }
public DateTime Expires { get { return m_Expires; } }
public Dictionary<Type, int> CommodityTypes { get { return m_CommodityTypes; } }
public List<BaseCreature> Creatures { get { return m_Creatures; } }
public StorageEntry(Mobile m, BaseBazaarBroker broker)
{
AddInventory(m, broker);
}
public void AddInventory(Mobile m, BaseBazaarBroker broker)
{
m_Funds += broker.BankBalance;
m_Expires = DateTime.UtcNow + TimeSpan.FromDays(7);
if (broker is CommodityBroker)
{
foreach (CommodityBrokerEntry entry in ((CommodityBroker)broker).CommodityEntries)
{
if (entry.Stock > 0)
{
m_CommodityTypes[entry.CommodityType] = entry.Stock;
}
}
}
else if (broker is PetBroker)
{
foreach (PetBrokerEntry entry in ((PetBroker)broker).BrokerEntries)
{
if (entry.Pet.Map != Map.Internal || !entry.Pet.IsStabled)
{
entry.Internalize();
}
m_Creatures.Add(entry.Pet);
}
}
}
public void RemoveCommodity(Type type, int amount)
{
if (m_CommodityTypes.ContainsKey(type))
{
m_CommodityTypes[type] -= amount;
if(m_CommodityTypes[type] <= 0)
m_CommodityTypes.Remove(type);
}
}
public void RemovePet(BaseCreature pet)
{
if (m_Creatures.Contains(pet))
m_Creatures.Remove(pet);
}
public StorageEntry(GenericReader reader)
{
int version = reader.ReadInt();
switch (version)
{
case 1:
m_Funds = reader.ReadInt();
m_Expires = reader.ReadDateTime();
int count = reader.ReadInt();
for (int i = 0; i < count; i++)
{
Type cType = ScriptCompiler.FindTypeByName(reader.ReadString());
int amount = reader.ReadInt();
if (cType != null)
m_CommodityTypes[cType] = amount;
}
count = reader.ReadInt();
for (int i = 0; i < count; i++)
{
BaseCreature bc = reader.ReadMobile() as BaseCreature;
if (bc != null)
m_Creatures.Add(bc);
}
break;
case 0:
int type = reader.ReadInt();
m_Funds = reader.ReadInt();
m_Expires = reader.ReadDateTime();
switch (type)
{
case 0: break;
case 1:
{
int c1 = reader.ReadInt();
for (int i = 0; i < c1; i++)
{
Type cType = ScriptCompiler.FindTypeByName(reader.ReadString());
int amount = reader.ReadInt();
if (cType != null)
m_CommodityTypes[cType] = amount;
}
break;
}
case 2:
{
int c2 = reader.ReadInt();
for (int i = 0; i < c2; i++)
{
BaseCreature bc = reader.ReadMobile() as BaseCreature;
if (bc != null)
{
m_Creatures.Add(bc);
}
}
break;
}
}
break;
}
}
public void Serialize(GenericWriter writer)
{
writer.Write((int)1);
writer.Write(m_Funds);
writer.Write(m_Expires);
writer.Write(m_CommodityTypes.Count);
foreach (KeyValuePair<Type, int> kvp in m_CommodityTypes)
{
writer.Write(kvp.Key.Name);
writer.Write(kvp.Value);
}
writer.Write(m_Creatures.Count);
foreach (BaseCreature bc in m_Creatures)
{
writer.Write(bc);
}
}
}
}

View File

@@ -0,0 +1,76 @@
using System;
using Server;
using Server.Gumps;
using Server.Mobiles;
using Server.Network;
namespace Server.Engines.NewMagincia
{
public class BaseBazaarGump : Gump
{
public const int RedColor = 0xB22222;
public const int BlueColor = 0x000080;
public const int OrangeColor = 0x804000;
public const int GreenColor = 0x008040;
public const int DarkGreenColor = 0x008000;
public const int YellowColor = 0xFFFF00;
public const int GrayColor = 0x808080;
public const int RedColor16 = 0x4000;
public const int BlueColor16 = 0x10;
public const int OrangeColor16 = 0x4100;
public const int GreenColor16 = 0x208;
public const int DarkGreenColor16 = 0x200;
public const int YellowColor16 = 0xFFE0;
public const int GrayColor16 = 0xC618;
public const int LabelHueBlue = 0xCC;
public BaseBazaarGump() : this(520, 700)
{
}
public BaseBazaarGump(int width, int height) : base(100, 100)
{
AddBackground(0, 0, width, height, 9300);
if (!(this is CommodityTargetGump))
{
AddButton(width - 40, height - 30, 4020, 4022, 0, GumpButtonType.Reply, 0);
AddHtmlLocalized(width - 150, height - 30, 100, 20, 1114514, "#1060675", 0x0, false, false); // CLOSE
}
}
protected string Color(string str, int color)
{
return String.Format("<BASEFONT COLOR=#{0:X6}>{1}</BASEFONT>", color, str);
}
protected string FormatAmt(int amount)
{
if (amount == 0)
return "0";
return amount.ToString("###,###,###");
}
protected string FormatStallName(string str)
{
return String.Format("<DIV ALIGN=CENTER><i>{0}</i></DIV>", str);
}
protected string FormatBrokerName(string str)
{
return String.Format("<DIV ALIGN=CENTER>{0}</DIV>", str);
}
protected string AlignRight(string str)
{
return String.Format("<DIV ALIGN=RIGHT>{0}</DIV>", str);
}
protected string AlignLeft(string str)
{
return String.Format("<DIV ALIGN=LEFT>{0}</DIV>", str);
}
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,723 @@
using System;
using Server;
using Server.Items;
using Server.Mobiles;
using Server.Gumps;
using Server.Network;
using System.Collections.Generic;
namespace Server.Engines.NewMagincia
{
public class PetBrokerGump : BaseBazaarGump
{
private PetBroker m_Broker;
public PetBrokerGump(PetBroker broker, Mobile from)
{
m_Broker = broker;
AddHtmlLocalized(215, 10, 200, 18, 1150311, RedColor16, false, false); // Animal Broker
if(m_Broker.Plot.ShopName != null && m_Broker.Plot.ShopName.Length > 0)
AddHtml(173, 40, 173, 18, Color(FormatStallName(m_Broker.Plot.ShopName), BlueColor), false, false);
else
AddHtmlLocalized(180, 40, 200, 18, 1150314, BlueColor16, false, false); // This Shop Has No Name
AddHtml(173, 65, 173, 18, Color(FormatBrokerName(String.Format("Proprietor: {0}", broker.Name)), BlueColor), false, false);
AddHtmlLocalized(215, 100, 200, 18, 1150328, GreenColor16, false, false); // Owner Menu
AddButton(150, 150, 4005, 4007, 1, GumpButtonType.Reply, 0);
AddHtmlLocalized(190, 150, 200, 18, 1150392, OrangeColor16, false, false); // INFORMATION
AddHtmlLocalized(39, 180, 200, 18, 1150199, RedColor16, false, false); // Broker Account Balance
AddHtml(190, 180, 300, 18, FormatAmt(broker.BankBalance), false, false);
int balance = Banker.GetBalance(from);
AddHtmlLocalized(68, 200, 200, 18, 1150149, GreenColor16, false, false); // Your Bank Balance:
AddHtml(190, 200, 200, 18, FormatAmt(balance), false, false);
AddHtmlLocalized(32, 230, 200, 18, 1150329, OrangeColor16, false, false); // Broker Sales Comission
AddHtmlLocalized(190, 230, 100, 18, 1150330, false, false); // 5%
AddHtmlLocalized(110, 250, 200, 18, 1150331, OrangeColor16, false, false); // Weekly Fee:
AddHtml(190, 250, 250, 18, FormatAmt(broker.GetWeeklyFee()), false, false);
AddHtmlLocalized(113, 280, 200, 18, 1150332, OrangeColor16, false, false); // Shop Name:
AddBackground(190, 280, 285, 22, 9350);
AddTextEntry(191, 280, 285, 20, LabelHueBlue, 0, m_Broker.Plot.ShopName == null ? "" : m_Broker.Plot.ShopName);
AddButton(480, 280, 4014, 4016, 2, GumpButtonType.Reply, 0);
AddHtmlLocalized(83, 305, 150, 18, 1150195, OrangeColor16, false, false); // Withdraw Funds
AddBackground(190, 305, 285, 22, 9350);
AddTextEntry(191, 305, 285, 20, LabelHueBlue, 1, "");
AddButton(480, 305, 4014, 4016, 3, GumpButtonType.Reply, 0);
AddHtmlLocalized(95, 330, 150, 18, 1150196, OrangeColor16, false, false); // Deposit Funds
AddBackground(190, 330, 285, 22, 9350);
AddTextEntry(191, 330, 285, 20, LabelHueBlue, 2, "");
AddButton(480, 330, 4014, 4016, 4, GumpButtonType.Reply, 0);
AddButton(150, 365, 4005, 4007, 5, GumpButtonType.Reply, 0);
AddHtmlLocalized(190, 365, 350, 18, 1150276, OrangeColor16, false, false); // TRANSFER STABLED PETS TO MERCHANT
AddButton(150, 390, 4005, 4007, 6, GumpButtonType.Reply, 0);
AddHtmlLocalized(190, 390, 350, 18, 1150277, OrangeColor16, false, false); // TRANSFER MERCHANT INVENTORY TO STABLE
AddButton(150, 415, 4005, 4007, 7, GumpButtonType.Reply, 0);
AddHtmlLocalized(190, 415, 350, 18, 1150334, OrangeColor16, false, false); // VIEW INVENTORY / EDIT PRICES
}
public override void OnResponse(NetState state, RelayInfo info)
{
Mobile from = state.Mobile;
if(m_Broker == null || m_Broker.Plot == null)
return;
switch(info.ButtonID)
{
default:
case 0: return;
case 1:
from.SendGump(new PetBrokerGump(m_Broker, from));
from.SendGump(new BazaarInformationGump(1150311, 1150614));
return;
case 2: // Set Shop Name
TextRelay tr = info.TextEntries[0];
string text = tr.Text;
if(!m_Broker.Plot.TrySetShopName(from, text))
from.SendLocalizedMessage(1150775); // Shop names are limited to 40 characters in length. Shop names must pass an obscenity filter check. The text you have entered is not valid.
break;
case 3: // Withdraw Funds
TextRelay tr1 = info.TextEntries[1];
string text1 = tr1.Text;
int amount = 0;
try
{
amount = Convert.ToInt32(text1);
}
catch
{}
if(amount > 0)
{
m_Broker.TryWithdrawFunds(from, amount);
}
break;
case 4: // Deposit Funds
TextRelay tr2 = info.TextEntries[2];
string text2 = tr2.Text;
int amount1 = 0;
try
{
amount1 = Convert.ToInt32(text2);
}
catch{}
if(amount1 > 0)
{
m_Broker.TryDepositFunds(from, amount1);
}
break;
case 5: // TRANSFER STABLED PET TO MERCHANT
if(from.Stabled.Count > 0)
from.SendGump(new SelectPetsGump(m_Broker, from));
else
from.SendLocalizedMessage(1150335); // You currently have no pets in your stables that can be traded via an animal broker.
return;
case 6: // TRANSFER MERCHANT INVENTORY TO STABLE
m_Broker.CheckInventory();
if(m_Broker.BrokerEntries.Count > 0)
{
if(m_Broker.BankBalance < 0)
{
from.SendGump(new BazaarInformationGump(1150623, 1150615));
return;
}
from.SendGump(new RemovePetsGump(m_Broker, from));
}
else
from.SendLocalizedMessage(1150336); // The animal broker has no pets in its inventory.
return;
case 7: // VIEW INVENTORY / EDIT PRICES
m_Broker.CheckInventory();
if(m_Broker.BrokerEntries.Count > 0)
{
if(m_Broker.BankBalance < 0)
{
from.SendGump(new BazaarInformationGump(1150623, 1150615));
return;
}
else
from.SendGump(new SetPetPricesGump(m_Broker));
}
else
from.SendLocalizedMessage(1150336); // The animal broker has no pets in its inventory.
return;
}
from.SendGump(new PetBrokerGump(m_Broker, from));
}
}
public class SelectPetsGump : BaseBazaarGump
{
private PetBroker m_Broker;
private int m_Index;
private List<BaseCreature> m_List;
public SelectPetsGump(PetBroker broker, Mobile from) : this(broker, from, -1)
{
}
public SelectPetsGump(PetBroker broker, Mobile from, int index)
{
m_Broker = broker;
m_Index = index;
AddHtmlLocalized(215, 10, 200, 18, 1150311, RedColor16, false, false); // Animal Broker
AddHtmlLocalized(145, 50, 250, 18, 1150337, RedColor16, false, false); // ADD PET TO BROKER INVENTORY
AddHtmlLocalized(10, 100, 500, 40, 1150338, GreenColor16, false, false); // Click the button next to a pet to select it. Enter the price you wish to charge into the box below the pet list, then click the "ADD PET" button.
m_List = GetList(from);
int y = 150;
for(int i = 0; i < m_List.Count; i++)
{
int col = index == i ? YellowColor16 : OrangeColor16;
BaseCreature bc = m_List[i];
if (bc == null)
continue;
AddButton(10, y, 4005, 4007, i + 1, GumpButtonType.Reply, 0);
AddHtmlLocalized(60, y, 200, 18, 1150340, String.Format("{0}\t{1}", bc.Name, PetBrokerEntry.GetOriginalName(bc)), col, false, false); // ~1_NAME~ (~2_type~)
y += 22;
}
AddHtmlLocalized(215, 380, 100, 18, 1150339, OrangeColor16, false, false); // ADD PET
AddButton(175, 405, 4005, 4007, 501, GumpButtonType.Reply, 0);
AddBackground(215, 405, 295, 22, 9350);
AddTextEntry(216, 405, 294, 20, 0, 0, "");
AddButton(10, 490, 4014, 4016, 500, GumpButtonType.Reply, 0);
AddHtmlLocalized(50, 490, 100, 18, 1149777, BlueColor16, false, false); // MAIN MENU
}
public override void OnResponse(NetState state, RelayInfo info)
{
Mobile from = state.Mobile;
if(info.ButtonID == 0)
return;
if(info.ButtonID == 500) // MAIN MENU
{
from.SendGump( new PetBrokerGump(m_Broker, from));
return;
}
else if(info.ButtonID == 501) // ADD PET
{
if(m_Index >= 0 && m_Index < m_List.Count)
{
if(m_Broker.BankBalance < 0)
{
from.SendGump(new BazaarInformationGump(1150623, 1150615));
return;
}
TextRelay relay = info.TextEntries[0];
int cost = PetBrokerEntry.DefaultPrice;
try
{
cost = Convert.ToInt32(relay.Text);
}
catch { }
if(cost > 0)
{
BaseCreature bc = m_List[m_Index];
if(m_Broker.TryAddEntry(bc, from, cost))
{
from.Stabled.Remove(bc);
from.SendGump(new SetPetPricesGump(m_Broker));
from.SendLocalizedMessage(1150345, String.Format("{0}\t{1}\t{2}\t{3}", PetBrokerEntry.GetOriginalName(bc), bc.Name, m_Broker.Name, cost)); // Your pet ~1_TYPE~ named ~2_NAME~ has been transferred to the inventory of your animal broker named ~3_SHOP~ with an asking price of ~4_PRICE~.
}
}
else
from.SendLocalizedMessage(1150343); // You have entered an invalid price.
}
else
from.SendLocalizedMessage(1150341); // You did not select a pet.
}
else
from.SendGump(new SelectPetsGump(m_Broker, from, info.ButtonID - 1));
}
public List<BaseCreature> GetList(Mobile from)
{
List<BaseCreature> list = new List<BaseCreature>();
for ( int i = 0; i < from.Stabled.Count; ++i )
{
BaseCreature pet = from.Stabled[i] as BaseCreature;
if ( pet == null || pet.Deleted )
{
if(pet != null)
pet.IsStabled = false;
from.Stabled.RemoveAt( i );
--i;
continue;
}
list.Add( pet );
}
return list;
}
}
public class RemovePetsGump : BaseBazaarGump
{
private PetBroker m_Broker;
private int m_Index;
public RemovePetsGump(PetBroker broker, Mobile from) : this(broker, from, -1)
{
}
public RemovePetsGump(PetBroker broker, Mobile from, int index)
{
m_Broker = broker;
m_Index = index;
AddHtmlLocalized(215, 10, 200, 18, 1150311, RedColor16, false, false); // Animal Broker
AddHtmlLocalized(145, 50, 250, 18, 1150337, RedColor16, false, false); // ADD PET TO BROKER INVENTORY
AddHtmlLocalized(10, 80, 500, 40, 1150633, GreenColor16, false, false); // Click the button next to a pet to select it, then click the REMOVE PET button below to transfer that pet to your stables.
m_Broker.CheckInventory();
int y = 130;
for(int i = 0; i < broker.BrokerEntries.Count; i++)
{
BaseCreature bc = broker.BrokerEntries[i].Pet;
int col = index == i ? YellowColor16 : OrangeColor16;
AddButton(10, y, 4005, 4007, i + 1, GumpButtonType.Reply, 0);
AddHtmlLocalized(50, y, 200, 18, 1150340, String.Format("{0}\t{1}", bc.Name, PetBrokerEntry.GetOriginalName(bc)), col, false, false); // ~1_NAME~ (~2_type~)
y += 20;
}
AddHtmlLocalized(215, 405, 150, 18, 1150632, OrangeColor16, false, false); // REMOVE PET
AddButton(175, 405, 4014, 4016, 501, GumpButtonType.Reply, 0);
AddButton(10, 490, 4014, 4016, 500, GumpButtonType.Reply, 0);
AddHtmlLocalized(50, 490, 100, 18, 1149777, BlueColor16, false, false); // MAIN MENU
}
public override void OnResponse(NetState state, RelayInfo info)
{
Mobile from = state.Mobile;
if(info.ButtonID == 0)
return;
if(info.ButtonID == 500) // MAIN MENU
{
from.SendGump( new PetBrokerGump(m_Broker, from));
return;
}
else if (info.ButtonID == 501) // REMOVE PET
{
if (m_Index >= 0 && m_Index < m_Broker.BrokerEntries.Count)
{
PetBrokerEntry entry = m_Broker.BrokerEntries[m_Index];
if (from.Stabled.Count >= AnimalTrainer.GetMaxStabled(from) || entry.Pet == null)
from.SendLocalizedMessage(1150634); // Failed to transfer the selected pet to your stables. Either the pet is no longer in the broker's inventory, or you do not have any available stable slots.
else
{
BaseCreature bc = entry.Pet;
m_Broker.RemoveEntry(entry);
PetBroker.SendToStables(from, bc);
from.SendLocalizedMessage(1150635, String.Format("{0}\t{1}", entry.TypeName, bc.Name)); // Your pet ~1_TYPE~ named ~2_NAME~ has been transferred to the stables.
from.SendGump(new PetBrokerGump(m_Broker, from));
return;
}
}
else
from.SendLocalizedMessage(1150341); // You did not select a pet.
from.SendGump(new RemovePetsGump(m_Broker, from, m_Index));
}
else
from.SendGump(new RemovePetsGump(m_Broker, from, info.ButtonID - 1));
}
}
public class SetPetPricesGump : BaseBazaarGump
{
private PetBroker m_Broker;
private int m_Index;
public SetPetPricesGump(PetBroker broker) : this(broker, -1)
{
}
public SetPetPricesGump(PetBroker broker, int index)
{
m_Broker = broker;
m_Index = index;
AddHtmlLocalized(215, 10, 200, 18, 1150311, RedColor16, false, false); // Animal Broker
AddHtmlLocalized(60, 90, 100, 18, 1150347, OrangeColor16, false, false); // NAME
AddHtmlLocalized(220, 90, 100, 18, 1150348, OrangeColor16, false, false); // TYPE
AddHtmlLocalized(400, 90, 100, 18, 1150349, OrangeColor16, false, false); // PRICE
m_Broker.CheckInventory();
int y = 130;
for(int i = 0; i < broker.BrokerEntries.Count; i++)
{
int col = index == i ? YellowColor : OrangeColor;
PetBrokerEntry entry = broker.BrokerEntries[i];
AddHtml(60, y, 200, 18, Color(entry.Pet.Name != null ? entry.Pet.Name : "Unknown", col), false, false);
AddHtml(220, y, 200, 18, Color(entry.TypeName, col), false, false);
AddHtml(400, y, 200, 18, Color(FormatAmt(entry.SalePrice), col), false, false);
AddButton(10, y, 4005, 4007, i + 3, GumpButtonType.Reply, 0);
y += 22;
}
int price = index >= 0 && index < broker.BrokerEntries.Count ? broker.BrokerEntries[index].SalePrice : 0;
AddHtmlLocalized(215, 380, 150, 18, 1150627, BlueColor16, false, false); // SET PRICE
AddBackground(215, 405, 295, 22, 9350);
AddTextEntry(216, 405, 294, 20, 0, 0, FormatAmt(price));
AddButton(175, 405, 4005, 4007, 500, GumpButtonType.Reply, 0);
AddButton(10, 490, 4014, 4016, 1, GumpButtonType.Reply, 0);
AddHtmlLocalized(50, 490, 100, 18, 1149777, BlueColor16, false, false); // MAIN MENU
}
public override void OnResponse(NetState state, RelayInfo info)
{
Mobile from = state.Mobile;
switch(info.ButtonID)
{
case 0: break;
case 1: // MAIN MENU
from.SendGump( new PetBrokerGump(m_Broker, from));
break;
case 500: // SET PRICE
{
if(m_Index >= 0 && m_Index < m_Broker.BrokerEntries.Count)
{
PetBrokerEntry entry = m_Broker.BrokerEntries[m_Index];
int amount = 0;
TextRelay relay = info.TextEntries[0];
try
{
amount = Convert.ToInt32(relay.Text);
}
catch {}
if(amount > 0)
entry.SalePrice = amount;
else
from.SendLocalizedMessage(1150343); // You have entered an invalid price.
}
else
from.SendLocalizedMessage(1150341); // You did not select a pet.
}
from.SendGump(new SetPetPricesGump(m_Broker, -1));
break;
default:
int idx = info.ButtonID - 3;
if (idx >= 0 && idx < m_Broker.BrokerEntries.Count)
m_Index = idx;
from.SendGump(new SetPetPricesGump(m_Broker, m_Index));
break;
}
}
}
public class PetInventoryGump : BaseBazaarGump
{
private PetBroker m_Broker;
private List<PetBrokerEntry> m_Entries;
public PetInventoryGump(PetBroker broker, Mobile from)
{
m_Broker = broker;
m_Entries = broker.BrokerEntries;
AddHtmlLocalized( 10, 10, 500, 18, 1114513, "#1150311", RedColor16, false, false ); // Animal Broker
if (m_Broker.Plot.ShopName != null && m_Broker.Plot.ShopName.Length > 0)
AddHtml(10, 37, 500, 18, Color(FormatStallName(m_Broker.Plot.ShopName), BlueColor), false, false);
else
{
AddHtmlLocalized(10, 37, 500, 18, 1114513, "#1150314", BlueColor16, false, false); // This Shop Has No Name
}
AddHtmlLocalized(10, 55, 240, 18, 1114514, "#1150313", BlueColor16, false, false); // Proprietor:
AddHtml(260, 55, 250, 18, Color(String.Format("{0}", broker.Name), BlueColor), false, false);
if (m_Entries.Count != 0)
{
AddHtmlLocalized(10, 91, 500, 18, 1114513, "#1150346", GreenColor16, false, false); // PETS FOR SALE
AddHtmlLocalized(10, 118, 500, 72, 1114513, "#1150352", GreenColor16, false, false); // LORE: See the animal's
AddHtmlLocalized(10, 199, 52, 18, 1150351, OrangeColor16, false, false); // LORE
AddHtmlLocalized(68, 199, 52, 18, 1150353, OrangeColor16, false, false); // VIEW
AddHtmlLocalized(126, 199, 104, 18, 1150347, OrangeColor16, false, false); // NAME
AddHtmlLocalized(236, 199, 104, 18, 1150348, OrangeColor16, false, false); // TYPE
AddHtmlLocalized(346, 199, 104, 18, 1114514, "#1150349", OrangeColor16, false, false); // PRICE
AddHtmlLocalized(456, 199, 52, 18, 1150350, OrangeColor16, false, false); // BUY
int y = 219;
for (int i = 0; i < m_Entries.Count; i++)
{
PetBrokerEntry entry = m_Entries[i];
if (entry == null || entry.Pet == null)
{
continue;
}
AddButton(10, y + (i * 20), 4011, 4013, 100 + i, GumpButtonType.Reply, 0);
AddButton(68, y + (i * 20), 4008, 4010, 200 + i, GumpButtonType.Reply, 0);
AddHtml(126, y + (i * 20), 104, 14, Color(entry.Pet.Name, BlueColor), false, false);
AddHtml(236, y + (i * 20), 104, 20, Color(entry.TypeName, BlueColor), false, false);
AddHtml(346, y + (i * 20), 104, 20, Color(AlignRight(FormatAmt(entry.SalePrice)), GreenColor), false, false);
AddButton(456, y + (i * 20), 4014, 4016, 300 + i, GumpButtonType.Reply, 0);
}
}
else
{
AddHtmlLocalized(10, 127, 500, 534, 1114513, "#1150336", OrangeColor16, false, false); // The animal broker has no pets in its inventory.
AddButton(10, 490, 0xFAE, 0xFAF, 1, GumpButtonType.Reply, 0);
AddHtmlLocalized(50, 490, 210, 20, 1149777, BlueColor16, false, false); // MAIN MENU
}
}
public override void OnResponse(NetState state, RelayInfo info)
{
Mobile from = state.Mobile;
if (info.ButtonID == 1) // Main Menu
{
from.SendGump(new PetInventoryGump(m_Broker, from));
}
else if (info.ButtonID < 200) // LORE
{
int id = info.ButtonID - 100;
if(id >= 0 && id < m_Entries.Count)
{
PetBrokerEntry entry = m_Entries[id];
if (entry != null && entry.Pet != null && m_Broker.BrokerEntries.Contains(entry))
{
from.SendGump(new PetInventoryGump(m_Broker, from));
if (PetTrainingHelper.Enabled && from is PlayerMobile)
{
Timer.DelayCall(TimeSpan.FromSeconds(1), () =>
{
BaseGump.SendGump(new NewAnimalLoreGump((PlayerMobile)from, entry.Pet));
});
}
else
{
from.CloseGump(typeof(Server.SkillHandlers.AnimalLoreGump));
from.SendGump(new Server.SkillHandlers.AnimalLoreGump(entry.Pet));
}
}
else
{
from.SendLocalizedMessage(1150368); // The selected animal is not available.
}
}
}
else if (info.ButtonID < 300) // VIEW
{
int id = info.ButtonID - 200;
if(id >= 0 && id < m_Entries.Count)
{
PetBrokerEntry entry = m_Entries[id];
if(entry != null && entry.Pet != null && m_Broker.BrokerEntries.Contains(entry) && entry.Pet.IsStabled)
{
BaseCreature pet = entry.Pet;
pet.Blessed = true;
pet.SetControlMaster(m_Broker);
pet.ControlTarget = m_Broker;
pet.ControlOrder = OrderType.None;
pet.MoveToWorld(m_Broker.Location, m_Broker.Map);
pet.IsStabled = false;
pet.Home = pet.Location;
pet.RangeHome = 2;
pet.Loyalty = BaseCreature.MaxLoyalty;
PetBroker.AddToViewTimer(pet);
from.SendLocalizedMessage(1150369, String.Format("{0}\t{1}", entry.TypeName, pet.Name)); // The ~1_TYPE~ named "~2_NAME~" is now in the animal broker's pen for inspection.
}
else
from.SendLocalizedMessage(1150368); // The selected animal is not available.
}
from.SendGump(new PetInventoryGump(m_Broker, from));
}
else // BUY
{
int id = info.ButtonID - 300;
if(id >= 0 && id < m_Entries.Count)
{
PetBrokerEntry entry = m_Entries[id];
if(entry != null && entry.Pet != null && m_Broker.BrokerEntries.Contains(entry))
from.SendGump(new ConfirmBuyPetGump(m_Broker, entry));
}
}
}
}
public class ConfirmBuyPetGump : BaseBazaarGump
{
private PetBroker m_Broker;
private PetBrokerEntry m_Entry;
public ConfirmBuyPetGump(PetBroker broker, PetBrokerEntry entry)
{
m_Broker = broker;
m_Entry = entry;
AddHtmlLocalized(10, 10, 500, 18, 1114513, "#1150311", RedColor16, false, false); // Animal Broker
if (m_Broker.Plot.ShopName != null && m_Broker.Plot.ShopName.Length > 0)
AddHtml(10, 37, 500, 18, Color(FormatStallName(m_Broker.Plot.ShopName), BlueColor), false, false);
else
{
AddHtmlLocalized(10, 37, 500, 18, 1114513, "#1150314", BlueColor16, false, false); // This Shop Has No Name
}
AddHtmlLocalized(10, 55, 240, 18, 1114514, "#1150313", BlueColor16, false, false); // Proprietor:
AddHtml(260, 55, 250, 18, Color(String.Format("{0}", broker.Name), BlueColor), false, false);
AddHtmlLocalized(10, 91, 500, 18, 1114513, "#1150375", GreenColor16, false, false); // PURCHASE PET
AddHtmlLocalized(10, 118, 500, 72, 1114513, "#1150370", GreenColor16, false, false); // Please confirm your purchase order below, and click "ACCEPT" if you wish to purchase this animal.
AddHtmlLocalized(10, 235, 245, 18, 1114514, "#1150372", OrangeColor16, false, false); // Animal Name:
AddHtmlLocalized(10, 255, 245, 18, 1114514, "#1150371", OrangeColor16, false, false); // Animal Type:
AddHtmlLocalized(10, 275, 245, 18, 1114514, "#1150373", OrangeColor16, false, false); // Sale Price:
AddHtml(265, 235, 245, 18, Color(entry.Pet.Name, BlueColor), false, false);
AddHtml(265, 255, 245, 18, Color(entry.TypeName, BlueColor), false, false);
AddHtml(265, 275, 245, 18, Color(FormatAmt(entry.SalePrice), BlueColor), false, false);
/*int itemID = ShrinkTable.Lookup(entry.Pet);
//if (entry.Pet is WildTiger)
// itemID = 0x9844;
AddItem(240, 250, itemID);*/
AddHtmlLocalized(265, 295, 245, 22, 1150374, OrangeColor16, false, false); // ACCEPT
AddButton(225, 295, 4005, 4007, 1, GumpButtonType.Reply, 0);
AddButton(10, 490, 0xFAE, 0xFAF, 2, GumpButtonType.Reply, 0);
AddHtmlLocalized(50, 490, 210, 20, 1149777, BlueColor16, false, false); // MAIN MENU
}
public override void OnResponse(NetState state, RelayInfo info)
{
Mobile from = state.Mobile;
switch(info.ButtonID)
{
default:
case 0: break;
case 1: //BUY
{
int cliloc = m_Broker.TryBuyPet(from, m_Entry);
if (cliloc != 0)
{
from.SendGump(new PurchasePetGump(m_Broker, cliloc));
}
break;
}
case 2: //MAIN MENU
from.SendGump(new PetInventoryGump(m_Broker, from));
break;
}
}
}
public class PurchasePetGump : BaseBazaarGump
{
private PetBroker m_Broker;
public PurchasePetGump(PetBroker broker, int cliloc)
{
m_Broker = broker;
AddHtmlLocalized(10, 10, 500, 18, 1114513, "#1150311", RedColor16, false, false); // Animal Broker
if (m_Broker.Plot.ShopName != null && m_Broker.Plot.ShopName.Length > 0)
{
AddHtml(10, 37, 500, 18, Color(FormatStallName(m_Broker.Plot.ShopName), BlueColor), false, false);
}
else
{
AddHtmlLocalized(10, 37, 500, 18, 1114513, "#1150314", BlueColor16, false, false); // This Shop Has No Name
}
AddHtmlLocalized(10, 55, 240, 18, 1114514, "#1150313", BlueColor16, false, false); // Proprietor:
AddHtml(260, 55, 250, 18, Color(String.Format("{0}", broker.Name), BlueColor), false, false);
AddHtmlLocalized(10, 127, 500, 534, 1114513, String.Format("#{0}", cliloc), OrangeColor16, false, false);
AddButton(10, 490, 0xFAE, 0xFAF, 1, GumpButtonType.Reply, 0);
AddHtmlLocalized(50, 490, 210, 20, 1149777, BlueColor16, false, false); // MAIN MENU
}
public override void OnResponse(NetState state, RelayInfo info)
{
Mobile from = state.Mobile;
switch (info.ButtonID)
{
default:
case 0: break;
case 1: //MAIN MENU
from.SendGump(new PetInventoryGump(m_Broker, from));
break;
}
}
}
}

View File

@@ -0,0 +1,64 @@
using System;
using Server;
using Server.Items;
namespace Server.Engines.NewMagincia
{
public class WarehouseContainer : MediumCrate
{
private Mobile m_Owner;
[CommandProperty(AccessLevel.GameMaster)]
public Mobile Owner { get { return m_Owner; } }
public WarehouseContainer(Mobile owner)
{
m_Owner = owner;
}
public WarehouseContainer(Serial serial) : base(serial)
{
}
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.Write((int)0);
writer.Write(m_Owner);
}
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
int version = reader.ReadInt();
m_Owner = reader.ReadMobile();
}
}
public class Warehouse : LargeCrate
{
public Warehouse(Mobile owner)
{
Movable = false;
Visible = false;
}
public Warehouse(Serial serial) : base(serial)
{
}
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.Write((int)0);
}
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
int version = reader.ReadInt();
}
}
}

View File

@@ -0,0 +1,127 @@
using Server;
using System;
using Server.Mobiles;
using Server.Items;
using Server.ContextMenus;
using System.Collections.Generic;
namespace Server.Engines.NewMagincia
{
public class PlotSign : Item
{
public static readonly int RuneCost = 100;
private MaginciaBazaarPlot m_Plot;
[CommandProperty(AccessLevel.GameMaster)]
public MaginciaBazaarPlot Plot
{
get { return m_Plot; }
set { m_Plot = value; InvalidateProperties(); }
}
public override bool DisplayWeight { get { return false; } }
public PlotSign(MaginciaBazaarPlot plot)
: base(3025)
{
Movable = false;
m_Plot = plot;
}
public override void OnDoubleClick(Mobile from)
{
if (m_Plot == null || !m_Plot.Active)
{
from.SendMessage("New Magincia Bazaar Plot {0} is inactive at this time.", m_Plot.PlotDef.ID);
}
else if (from.InRange(this.Location, 3))
{
from.CloseGump(typeof(BaseBazaarGump));
from.SendGump(new StallLeasingGump(from, m_Plot));
}
}
public override void GetProperties(ObjectPropertyList list)
{
base.GetProperties(list);
if (m_Plot == null)
return;
if (m_Plot.ShopName != null)
list.Add(1062449, m_Plot.ShopName); // Shop Name: ~1_NAME~
if (m_Plot.Merchant != null)
list.Add(1150529, m_Plot.Merchant.Name); // Proprietor: ~1_NAME~
if (m_Plot.Auction != null)
{
int left = 1;
if (m_Plot.Auction.AuctionEnd > DateTime.UtcNow)
{
TimeSpan ts = m_Plot.Auction.AuctionEnd - DateTime.UtcNow;
left = (int)(ts.TotalHours + 1);
}
list.Add(1150533, left.ToString()); // Auction for Lease Ends Within ~1_HOURS~ Hours
}
if (!m_Plot.Active)
list.Add(1153036); // Inactive
}
public override void AddNameProperty(ObjectPropertyList list)
{
if (m_Plot == null)
list.Add(1150530, "unknown"); // Stall ~1_NAME~
else
list.Add(1150530, m_Plot.PlotDef != null ? m_Plot.PlotDef.ID : "unknown"); // Stall ~1_NAME~
}
public override void GetContextMenuEntries(Mobile from, List<ContextMenuEntry> list)
{
base.GetContextMenuEntries(from, list);
if(m_Plot != null && m_Plot.Active)
list.Add(new RecallRuneEntry(from, this));
}
private class RecallRuneEntry : ContextMenuEntry
{
private PlotSign m_Sign;
private Mobile m_From;
public RecallRuneEntry(Mobile from, PlotSign sign)
: base(1151508, -1)
{
m_Sign = sign;
m_From = from;
Enabled = from.InRange(sign.Location, 2);
}
public override void OnClick()
{
m_From.SendGump(new ShopRecallRuneGump(m_From, m_Sign));
}
}
public PlotSign(Serial serial)
: base(serial)
{
}
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.Write((int)0); // version
}
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
int version = reader.ReadInt();
}
}
}

View File

@@ -0,0 +1,265 @@
using Server;
using System;
using Server.Multis;
using Server.Items;
using System.Collections.Generic;
namespace Server.Engines.NewMagincia
{
public class BaseBazaarMulti : BaseMulti
{
private List<Item> m_Fillers;
public List<Item> Fillers
{
get { return m_Fillers; }
}
public BaseBazaarMulti(int id) : base(id)
{
m_Fillers = new List<Item>();
}
public void AddComponent(Item item)
{
if (item != null)
m_Fillers.Add(item);
}
public override void OnLocationChange(Point3D old)
{
foreach (Item item in m_Fillers)
{
if(item != null && !item.Deleted)
item.Location = new Point3D(X + (item.X - old.X), Y + (item.Y - old.Y), Z + (item.Z - old.Z));
}
}
public override void OnMapChange()
{
foreach (Item item in m_Fillers)
{
if (item != null && !item.Deleted)
item.Map = this.Map; ;
}
}
public override void OnAfterDelete()
{
foreach (Item item in m_Fillers)
{
if (item != null && !item.Deleted)
item.Delete();
}
base.OnAfterDelete();
}
/*public override int GetMaxUpdateRange()
{
return 18;
}
public override int GetUpdateRange(Mobile m)
{
return 18;
}*/
public BaseBazaarMulti(Serial serial) : base(serial)
{
}
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.Write((int)0);
writer.Write(m_Fillers.Count);
foreach (Item item in m_Fillers)
writer.Write(item);
}
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
int version = reader.ReadInt();
m_Fillers = new List<Item>();
int c = reader.ReadInt();
for (int i = 0; i < c; i++)
{
Item item = reader.ReadItem();
if (item != null)
AddComponent(item);
}
}
}
public class CommodityStyle1 : BaseBazaarMulti
{
[Constructable]
public CommodityStyle1 () : base(0x1772)
{
Item comp = new Static(1801);
comp.MoveToWorld(new Point3D(this.X + 1, this.Y + 1, this.Z), this.Map);
AddComponent(comp);
}
public CommodityStyle1(Serial serial) : base(serial)
{
}
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.Write((int)0);
}
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
int version = reader.ReadInt();
}
}
public class CommodityStyle2 : BaseBazaarMulti
{
[Constructable]
public CommodityStyle2() : base(0x1773)
{
Item comp = new Static(9272);
comp.MoveToWorld(new Point3D(this.X + 1, this.Y, this.Z), this.Map);
AddComponent(comp);
}
public CommodityStyle2(Serial serial) : base(serial)
{
}
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.Write((int)0);
}
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
int version = reader.ReadInt();
}
}
public class CommodityStyle3 : BaseBazaarMulti
{
[Constructable]
public CommodityStyle3() : base(0x1774)
{
Item comp = new Static(16527);
comp.MoveToWorld(new Point3D(this.X, this.Y, this.Z), this.Map);
AddComponent(comp);
}
public CommodityStyle3(Serial serial) : base(serial)
{
}
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.Write((int)0);
}
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
int version = reader.ReadInt();
}
}
public class PetStyle1 : BaseBazaarMulti
{
[Constructable]
public PetStyle1() : base(0x1775)
{
Item comp = new Static(1036);
comp.MoveToWorld(new Point3D(this.X - 1, this.Y, this.Z), this.Map);
AddComponent(comp);
}
public PetStyle1(Serial serial) : base(serial)
{
}
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.Write((int)0);
}
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
int version = reader.ReadInt();
}
}
public class PetStyle2 : BaseBazaarMulti
{
[Constructable]
public PetStyle2() : base(0x1777)
{
Item comp = new Static(6013);
comp.MoveToWorld(new Point3D(this.X, this.Y - 1, this.Z), this.Map);
AddComponent(comp);
comp = new Static(6013);
comp.MoveToWorld(new Point3D(this.X, this.Y + 1, this.Z), this.Map);
AddComponent(comp);
}
public PetStyle2(Serial serial) : base(serial)
{
}
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.Write((int)0);
}
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
int version = reader.ReadInt();
}
}
public class PetStyle3 : BaseBazaarMulti
{
[Constructable]
public PetStyle3() : base(0x177B)
{
Item comp = new Static(2324);
comp.MoveToWorld(new Point3D(this.X - 1, this.Y, this.Z), this.Map);
AddComponent(comp);
}
public PetStyle3(Serial serial) : base(serial)
{
}
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.Write((int)0);
}
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
int version = reader.ReadInt();
}
}
}

View File

@@ -0,0 +1,212 @@
using System;
using Server;
using Server.Items;
using Server.Mobiles;
namespace Server.Engines.NewMagincia
{
public abstract class BaseBazaarBroker : BaseCreature
{
private MaginciaBazaarPlot m_Plot;
private int m_BankBalance;
private DateTime m_NextFee;
[CommandProperty(AccessLevel.GameMaster)]
public MaginciaBazaarPlot Plot { get { return m_Plot; } set { m_Plot = value; } }
[CommandProperty(AccessLevel.GameMaster)]
public int BankBalance { get { return m_BankBalance; } set { m_BankBalance = value; } }
[CommandProperty(AccessLevel.GameMaster)]
public bool SendToWarehouse
{
get { return false; }
set
{
Delete();
}
}
public virtual int ComissionFee { get { return MaginciaBazaar.DefaultComissionFee; } }
public override bool IsInvulnerable { get { return true; } }
public BaseBazaarBroker(MaginciaBazaarPlot plot) : base(AIType.AI_Vendor, FightMode.None, 2, 1, 0.5, 2)
{
m_Plot = plot;
m_BankBalance = 0;
m_NextFee = DateTime.UtcNow + TimeSpan.FromHours(23);
InitBody();
InitOutfit();
Blessed = true;
CantWalk = true;
Direction = Direction.East;
}
public virtual void InitOutfit()
{
switch (Utility.Random(3))
{
case 0: EquipItem(new FancyShirt(GetRandomHue())); break;
case 1: EquipItem(new Doublet(GetRandomHue())); break;
case 2: EquipItem(new Shirt(GetRandomHue())); break;
}
switch (Utility.Random(4))
{
case 0: EquipItem(new Shoes()); break;
case 1: EquipItem(new Boots()); break;
case 2: EquipItem(new Sandals()); break;
case 3: EquipItem(new ThighBoots()); break;
}
if (Female)
{
switch (Utility.Random(6))
{
case 0: EquipItem(new ShortPants(GetRandomHue())); break;
case 1:
case 2: EquipItem(new Kilt(GetRandomHue())); break;
case 3:
case 4:
case 5: EquipItem(new Skirt(GetRandomHue())); break;
}
}
else
{
switch (Utility.Random(2))
{
case 0: EquipItem(new LongPants(GetRandomHue())); break;
case 1: EquipItem(new ShortPants(GetRandomHue())); break;
}
}
}
public virtual void InitBody()
{
InitStats( 100, 100, 25 );
SpeechHue = Utility.RandomDyedHue();
Hue = Utility.RandomSkinHue();
if ( IsInvulnerable && !Core.AOS )
NameHue = 0x35;
if ( Female = Utility.RandomBool() )
{
Body = 0x191;
Name = NameList.RandomName( "female" );
}
else
{
Body = 0x190;
Name = NameList.RandomName( "male" );
}
Hue = Race.RandomSkinHue();
HairItemID = Race.RandomHair(Female);
HairHue = Race.RandomHairHue();
FacialHairItemID = Race.RandomFacialHair(Female);
if (FacialHairItemID != 0)
FacialHairHue = Race.RandomHairHue();
else
FacialHairHue = 0;
}
public virtual int GetRandomHue()
{
switch ( Utility.Random( 5 ) )
{
default:
case 0: return Utility.RandomBlueHue();
case 1: return Utility.RandomGreenHue();
case 2: return Utility.RandomRedHue();
case 3: return Utility.RandomYellowHue();
case 4: return Utility.RandomNeutralHue();
}
}
public void Dismiss()
{
Delete();
}
public abstract bool HasValidEntry(Mobile m);
public override void Delete()
{
if(m_Plot != null && MaginciaBazaar.Instance != null)
MaginciaBazaar.Instance.AddInventoryToWarehouse(m_Plot.Owner, this);
m_Plot.Merchant = null;
base.Delete();
}
public virtual void OnTick()
{
if(m_NextFee < DateTime.UtcNow)
{
m_BankBalance -= GetWeeklyFee() / 7;
m_NextFee = DateTime.UtcNow + TimeSpan.FromHours(23);
}
}
public virtual int GetWeeklyFee()
{
return 0;
}
public void TryWithdrawFunds(Mobile from, int amount)
{
if(m_BankBalance < amount || !Banker.Deposit(from, amount))
from.SendLocalizedMessage(1150214); // Transfer of funds from the broker to your bank box failed. Please check the amount to transfer is available in the broker's account, and make sure your bank box is able to hold the new funds without becoming overloaded.
else
{
m_BankBalance -= amount;
from.SendMessage("You withdraw {0}gp to your broker.", amount);
from.PlaySound(0x37);
}
}
public void TryDepositFunds(Mobile from, int amount)
{
if(Banker.Withdraw(from, amount))
{
m_BankBalance += amount;
from.SendMessage("You deposit {0}gp to your brokers account.", amount);
from.PlaySound(0x37);
}
else
{
from.SendLocalizedMessage(1150215); // You have entered an invalid value, or a non-numeric value. Please try again.ase deposit the necessary funds into your bank box and try again.
}
}
public BaseBazaarBroker(Serial serial) : base(serial)
{
}
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.Write((int)0);
writer.Write(m_BankBalance);
writer.Write(m_NextFee);
}
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
int version = reader.ReadInt();
m_BankBalance = reader.ReadInt();
m_NextFee = reader.ReadDateTime();
}
}
}

View File

@@ -0,0 +1,392 @@
using System;
using Server;
using Server.Items;
using Server.Mobiles;
using System.Collections.Generic;
namespace Server.Engines.NewMagincia
{
public class CommodityBroker : BaseBazaarBroker
{
private List<CommodityBrokerEntry> m_CommodityEntries = new List<CommodityBrokerEntry>();
public List<CommodityBrokerEntry> CommodityEntries { get { return m_CommodityEntries; } }
public static readonly int MaxEntries = 50;
public CommodityBroker(MaginciaBazaarPlot plot) : base(plot)
{
}
public override void OnDoubleClick(Mobile from)
{
if(from.InRange(this.Location, 4) && Plot != null)
{
if(Plot.Owner == from)
{
from.CloseGump(typeof(CommodityBrokerGump));
from.SendGump(new CommodityBrokerGump(this, from));
}
else
{
from.CloseGump(typeof(CommodityInventoryGump));
from.SendGump(new CommodityInventoryGump(this));
}
}
else
base.OnDoubleClick(from);
}
public override int GetWeeklyFee()
{
int total = 0;
foreach(CommodityBrokerEntry entry in m_CommodityEntries)
{
if(entry.SellPricePer > 0)
total += entry.Stock * entry.SellPricePer;
}
double perc = (double)total * .05;
return (int)perc;
}
public bool TryAddBrokerEntry(Item item, Mobile from)
{
Item realItem = item;
if (item is CommodityDeed)
realItem = ((CommodityDeed)item).Commodity;
Type type = realItem.GetType();
int amount = realItem.Amount;
if(HasType(type))
return false;
CommodityBrokerEntry entry = new CommodityBrokerEntry(realItem, this, amount);
m_CommodityEntries.Add(entry);
if(amount > 0)
from.SendLocalizedMessage(1150220, String.Format("{0}\t#{1}\t{2}", amount.ToString(), entry.Label, Plot.ShopName == null ? "an unnamed shop" : Plot.ShopName)); // You have added ~1_QUANTITY~ units of ~2_ITEMNAME~ to the inventory of "~3_SHOPNAME~"
item.Delete();
return true;
}
public void RemoveEntry(Mobile from, CommodityBrokerEntry entry)
{
if(m_CommodityEntries.Contains(entry))
{
if(entry.Stock > 0)
WithdrawInventory(from, GetStock(entry), entry);
m_CommodityEntries.Remove(entry);
}
}
public override bool HasValidEntry(Mobile m)
{
foreach (CommodityBrokerEntry entry in m_CommodityEntries)
{
if (entry.Stock > 0)
return true;
}
return false;
}
public void AddInventory(Mobile from, Item item)
{
Type type = item.GetType();
int amountToAdd = item.Amount;
if(item is CommodityDeed)
{
type = ((CommodityDeed)item).Commodity.GetType();
amountToAdd = ((CommodityDeed)item).Commodity.Amount;
}
foreach(CommodityBrokerEntry entry in m_CommodityEntries)
{
if(entry.CommodityType == type)
{
entry.Stock += amountToAdd;
item.Delete();
if(from != null && Plot.Owner == from)
from.SendLocalizedMessage(1150220, String.Format("{0}\t#{1}\t{2}", amountToAdd.ToString(), entry.Label, Plot.ShopName == null ? "an unnamed shop" : Plot.ShopName)); // You have added ~1_QUANTITY~ units of ~2_ITEMNAME~ to the inventory of "~3_SHOPNAME~"
break;
}
}
}
private bool HasType(Type type)
{
foreach(CommodityBrokerEntry entry in m_CommodityEntries)
{
if(entry.CommodityType == type)
return true;
}
return false;
}
public int GetStock(CommodityBrokerEntry entry)
{
return entry.Stock;
}
public void WithdrawInventory(Mobile from, int amount, CommodityBrokerEntry entry)
{
if(from == null || Plot == null || entry == null || !m_CommodityEntries.Contains(entry))
return;
Container pack = from.Backpack;
if(pack != null)
{
while(amount > 60000)
{
CommodityDeed deed = new CommodityDeed();
Item item = Loot.Construct(entry.CommodityType);
item.Amount = 60000;
deed.SetCommodity(item);
pack.DropItem(deed);
amount -= 60000;
entry.Stock -= 60000;
}
CommodityDeed deed2 = new CommodityDeed();
Item newitem = Loot.Construct(entry.CommodityType);
newitem.Amount = amount;
deed2.SetCommodity(newitem);
pack.DropItem(deed2);
entry.Stock -= amount;
}
if(Plot != null && from == Plot.Owner)
from.SendLocalizedMessage(1150221, String.Format("{0}\t#{1}\t{2}", amount.ToString(), entry.Label, Plot.ShopName != null ? Plot.ShopName : "a shop with no name")); // You have removed ~1_QUANTITY~ units of ~2_ITEMNAME~ from the inventory of "~3_SHOPNAME~"
}
public int GetBuyCost(Mobile from, CommodityBrokerEntry entry, int amount)
{
int totalCost = entry.SellPricePer * amount;
int toDeduct = totalCost + (int)((double)totalCost * ((double)ComissionFee / 100.0));
return toDeduct;
}
// Called when a player BUYS the commodity from teh broker...this is fucking confusing
public void TryBuyCommodity(Mobile from, CommodityBrokerEntry entry, int amount)
{
int totalCost = entry.SellPricePer * amount;
int toAdd = totalCost + (int)((double)totalCost * ((double)ComissionFee / 100.0));
if (Banker.Withdraw(from, totalCost, true))
{
from.SendLocalizedMessage(1150643, String.Format("{0}\t#{1}", amount.ToString("###,###,###"), entry.Label)); // A commodity deed worth ~1_AMOUNT~ ~2_ITEM~ has been placed in your backpack.
WithdrawInventory(from, amount, entry);
BankBalance += toAdd;
}
else
{
from.SendLocalizedMessage(1150252); // You do not have the funds needed to make this trade available in your bank box. Brokers are only able to transfer funds from your bank box. Please deposit the necessary funds into your bank box and try again.
}
}
public bool SellCommodityControl(Mobile from, CommodityBrokerEntry entry, int amount)
{
int totalCost = entry.BuyPricePer * amount;
Type type = entry.CommodityType;
if (from.Backpack != null)
{
int total = amount;
int typeAmount = from.Backpack.GetAmount(type);
int commodityAmount = GetCommodityType(from.Backpack, type);
if (typeAmount + commodityAmount >= total)
return true;
}
return false;
}
// Called when a player SELLs the commodity from teh broker...this is fucking confusing
public void TrySellCommodity(Mobile from, CommodityBrokerEntry entry, int amount)
{
int totalCost = entry.BuyPricePer * amount;
Type type = entry.CommodityType;
if(BankBalance < totalCost)
{
//No message, this should have already been handled elsewhere
}
else if(from.Backpack != null)
{
int total = amount;
int typeAmount = from.Backpack.GetAmount(type);
int commodityAmount = GetCommodityType(from.Backpack, type);
if(typeAmount + commodityAmount < total)
from.SendLocalizedMessage(1150667); // You do not have the requested amount of that commodity (either in item or deed form) in your backpack to trade. Note that commodities cannot be traded from your bank box.
else if(Banker.Deposit(from, totalCost))
{
TakeItems(from.Backpack, type, ref total);
if(total > 0)
TakeCommodities(from.Backpack, type, ref total);
BankBalance -= totalCost + (int)((double)totalCost * ((double)ComissionFee / 100.0));
from.SendLocalizedMessage(1150668, String.Format("{0}\t#{1}", amount.ToString(), entry.Label)); // You have sold ~1_QUANTITY~ units of ~2_COMMODITY~ to the broker. These have been transferred from deeds and/or items in your backpack.
}
else
from.SendLocalizedMessage(1150265); // Your bank box cannot hold the proceeds from this transaction.
}
}
private void TakeCommodities(Container c, Type type, ref int amount)
{
if (c == null)
return;
Item[] items = c.FindItemsByType(typeof(CommodityDeed));
List<Item> toSell = new List<Item>();
foreach(Item item in items)
{
CommodityDeed commodityDeed = item as CommodityDeed;
if (commodityDeed != null && commodityDeed.Commodity != null && commodityDeed.Commodity.GetType() == type)
{
Item commodity = commodityDeed.Commodity;
if (commodity.Amount <= amount)
{
toSell.Add(item);
amount -= commodity.Amount;
}
else
{
CommodityDeed newDeed = new CommodityDeed();
Item newItem = Loot.Construct(type);
newItem.Amount = amount;
newDeed.SetCommodity(newItem);
commodity.Amount -= amount;
commodityDeed.InvalidateProperties();
toSell.Add(newDeed);
amount = 0;
}
}
}
foreach(Item item in toSell)
{
AddInventory(null, item);
}
}
private void TakeItems(Container c, Type type, ref int amount)
{
if (c == null)
return;
Item[] items = c.FindItemsByType(type);
List<Item> toSell = new List<Item>();
foreach(Item item in items)
{
if(amount <= 0)
break;
if(item.Amount <= amount)
{
toSell.Add(item);
amount -= item.Amount;
}
else
{
Item newItem = Loot.Construct(type);
newItem.Amount = amount;
item.Amount -= amount;
toSell.Add(newItem);
amount = 0;
}
}
foreach(Item item in toSell)
{
AddInventory(null, item);
}
}
public int GetCommodityType(Container c, Type type)
{
if (c == null)
return 0;
Item[] items = c.FindItemsByType(typeof(CommodityDeed));
int amt = 0;
foreach (Item item in items)
{
if (item is CommodityDeed && ((CommodityDeed)item).Commodity != null && ((CommodityDeed)item).Commodity.GetType() == type)
amt += ((CommodityDeed)item).Commodity.Amount;
}
return amt;
}
public int GetLabelID(CommodityBrokerEntry entry)
{
/*Item[] items = BuyPack.FindItemsByType(typeof(CommodityDeed));
foreach(Item item in items)
{
if(item is CommodityDeed)
{
CommodityDeed deed = (CommodityDeed)item;
if(deed.Commodity != null && deed.Commodity.GetType() == entry.CommodityType)
return deed.Commodity.ItemID;
}
}
Item item = Loot.Construct(entry.CommodityType);
int id = 0;
if(item != null)
{
id = item.ItemID;
item.Delete();
}*/
return entry != null ? entry.Label : 1;
}
public CommodityBroker(Serial serial) : base(serial)
{
}
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.Write((int)0);
writer.Write(m_CommodityEntries.Count);
foreach(CommodityBrokerEntry entry in m_CommodityEntries)
entry.Serialize(writer);
}
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
int version = reader.ReadInt();
int count = reader.ReadInt();
for(int i = 0; i < count; i++)
m_CommodityEntries.Add(new CommodityBrokerEntry(reader));
}
}
}

View File

@@ -0,0 +1,276 @@
using System;
using Server;
using Server.Items;
using Server.Mobiles;
using System.Collections.Generic;
namespace Server.Engines.NewMagincia
{
public class PetBroker : BaseBazaarBroker
{
private List<PetBrokerEntry> m_BrokerEntries = new List<PetBrokerEntry>();
public List<PetBrokerEntry> BrokerEntries { get { return m_BrokerEntries; } }
public static readonly int MaxEntries = 10;
public PetBroker(MaginciaBazaarPlot plot) : base(plot)
{
FollowersMax = 500;
}
public override void OnDoubleClick(Mobile from)
{
if(from.InRange(this.Location, 4) && Plot != null)
{
if(Plot.Owner == from)
{
from.CloseGump(typeof(PetBrokerGump));
from.SendGump(new PetBrokerGump(this, from));
}
else
{
from.CloseGump(typeof(PetInventoryGump));
from.SendGump(new PetInventoryGump(this, from));
}
}
else
base.OnDoubleClick(from);
}
public bool TryAddEntry(BaseCreature bc, Mobile from, int cost)
{
if(bc == null || HasEntry(bc) || !bc.Alive || !bc.IsStabled)
from.SendLocalizedMessage(1150342); // That pet is not in the stables. The pet must remain in the stables in order to be transferred to the broker's inventory.
else if(m_BrokerEntries.Count >= MaxEntries)
from.SendLocalizedMessage(1150631); // You cannot add more pets to this animal broker's inventory at this time, because the shop inventory is full.
else if (!from.Stabled.Contains(bc))
from.SendLocalizedMessage(1150344); // Transferring the pet from the stables to the animal broker's inventory failed for an unknown reason.
else
{
m_BrokerEntries.Add(new PetBrokerEntry(bc, cost));
return true;
}
return false;
}
public void RemoveEntry(PetBrokerEntry entry)
{
if (m_BrokerEntries.Contains(entry))
{
m_BrokerEntries.Remove(entry);
}
}
public override bool HasValidEntry(Mobile m)
{
var hasValid = false;
foreach (PetBrokerEntry entry in m_BrokerEntries)
{
if (entry.Pet != null)
{
if (m.Stabled.Count < AnimalTrainer.GetMaxStabled(m))
{
SendToStables(m, entry.Pet);
}
else
{
hasValid = true;
}
}
}
return hasValid;
}
public bool HasEntry(BaseCreature bc)
{
foreach(PetBrokerEntry entry in m_BrokerEntries)
{
if(entry.Pet == bc)
return true;
}
return false;
}
public void CheckInventory()
{
List<PetBrokerEntry> entries = new List<PetBrokerEntry>(m_BrokerEntries);
foreach(PetBrokerEntry entry in entries)
{
if (entry.Pet == null || entry.Pet.Deleted)
m_BrokerEntries.Remove(entry);
}
}
public override int GetWeeklyFee()
{
int total = 0;
foreach(PetBrokerEntry entry in m_BrokerEntries)
{
if(entry.SalePrice > 0)
total += entry.SalePrice;
}
double perc = (double)total * .05;
return (int)perc;
}
public int TryBuyPet(Mobile from, PetBrokerEntry entry)
{
if (from == null || entry == null || entry.Pet == null)
{
return 1150377; // Unable to complete the desired transaction at this time.
}
int cost = entry.SalePrice;
int toAdd = cost - (int)((double)cost * ((double)ComissionFee / 100.0));
BaseCreature pet = entry.Pet;
if (!m_BrokerEntries.Contains(entry) || entry.Pet == null || entry.Pet.Deleted)
{
return 1150377; // Unable to complete the desired transaction at this time.
}
else if (pet.GetControlChance(from) <= 0.0)
{
return 1150379; // Unable to transfer that pet to you because you have no chance at all of controlling it.
}
else if (from.Stabled.Count >= AnimalTrainer.GetMaxStabled(from))
{
return 1150376; // You do not have any available stable slots. The Animal Broker can only transfer pets to your stables. Please make a stables slot available and try again.
}
else if (!Banker.Withdraw(from, cost, true))
{
return 1150252; // You do not have the funds needed to make this trade available in your bank box. Brokers are only able to transfer funds from your bank box. Please deposit the necessary funds into your bank box and try again.
}
else
{
BankBalance += toAdd;
pet.IsBonded = false;
SendToStables(from, pet);
from.SendLocalizedMessage(1150380, String.Format("{0}\t{1}", entry.TypeName, pet.Name)); // You have purchased ~1_TYPE~ named "~2_NAME~". The animal is now in the stables and you may retrieve it there.
m_BrokerEntries.Remove(entry);
return 0;
}
}
public static void SendToStables(Mobile to, BaseCreature pet)
{
EndViewTimer(pet);
pet.Blessed = false;
pet.ControlTarget = null;
pet.ControlOrder = OrderType.Stay;
pet.Internalize();
pet.SetControlMaster(null);
pet.SummonMaster = null;
pet.IsStabled = true;
pet.Loyalty = BaseCreature.MaxLoyalty;
to.Stabled.Add(pet);
}
public static void SendToBrokerStables(BaseCreature pet)
{
if (pet is BaseMount)
((BaseMount)pet).Rider = null;
pet.ControlTarget = null;
pet.ControlOrder = OrderType.Stay;
pet.Internalize();
pet.SetControlMaster(null);
pet.SummonMaster = null;
pet.IsStabled = true;
pet.Loyalty = BaseCreature.MaxLoyalty;
pet.Home = Point3D.Zero;
pet.RangeHome = 10;
pet.Blessed = false;
EndViewTimer(pet);
}
private static Dictionary<BaseCreature, Timer> m_ViewTimer = new Dictionary<BaseCreature, Timer>();
public static void AddToViewTimer(BaseCreature bc)
{
if(m_ViewTimer.ContainsKey(bc))
{
if(m_ViewTimer[bc] != null)
m_ViewTimer[bc].Stop();
}
m_ViewTimer[bc] = new InternalTimer(bc);
m_ViewTimer[bc].Start();
}
public static void EndViewTimer(BaseCreature bc)
{
if(m_ViewTimer.ContainsKey(bc))
{
if(m_ViewTimer[bc] != null)
m_ViewTimer[bc].Stop();
m_ViewTimer.Remove(bc);
}
}
private class InternalTimer : Timer
{
BaseCreature m_Creature;
public InternalTimer(BaseCreature bc) : base(TimeSpan.FromMinutes(2), TimeSpan.FromMinutes(2))
{
m_Creature = bc;
Priority = TimerPriority.OneMinute;
}
protected override void OnTick()
{
PetBroker.SendToBrokerStables(m_Creature);
}
}
public PetBroker(Serial serial) : base(serial)
{
}
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.Write((int)0);
writer.Write(m_BrokerEntries.Count);
foreach(PetBrokerEntry entry in m_BrokerEntries)
entry.Serialize(writer);
}
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
int version = reader.ReadInt();
int count = reader.ReadInt();
for(int i = 0; i < count; i++)
m_BrokerEntries.Add(new PetBrokerEntry(reader));
Timer.DelayCall(TimeSpan.FromSeconds(10), () =>
{
foreach (var entry in m_BrokerEntries)
{
if (entry.Pet != null && !entry.Pet.IsStabled)
{
AddToViewTimer(entry.Pet);
}
}
});
}
}
}

View File

@@ -0,0 +1,316 @@
using System;
using Server;
using Server.Items;
using Server.Mobiles;
using Server.Gumps;
using Server.Network;
using System.Collections.Generic;
using Server.ContextMenus;
using Server.Prompts;
namespace Server.Engines.NewMagincia
{
public class WarehouseSuperintendent : BaseCreature
{
public override bool IsInvulnerable { get { return true; } }
[Constructable]
public WarehouseSuperintendent() : base(AIType.AI_Vendor, FightMode.None, 2, 1, 0.5, 2)
{
Race = Race.Human;
Blessed = true;
Title = "The Warehouse Superintendent";
if(Utility.RandomBool())
{
Female = true;
Body = 0x191;
Name = NameList.RandomName( "female" );
AddItem(new Skirt(Utility.RandomPinkHue()));
}
else
{
Female = false;
Body = 0x190;
Name = NameList.RandomName( "male" );
AddItem(new ShortPants(Utility.RandomBlueHue()));
}
AddItem(new Tunic(Utility.RandomBlueHue()));
AddItem(new Boots());
Utility.AssignRandomHair(this, Utility.RandomHairHue());
Utility.AssignRandomFacialHair(this, Utility.RandomHairHue());
Hue = Race.RandomSkinHue();
}
/*public override void OnDoubleClick(Mobile from)
{
if(from.InRange(this.Location, 3) && from.Backpack != null)
{
WarehouseContainer container = MaginciaBazaar.ClaimContainer(from);
if(container != null)
TryTransferItems(from, container);
}
}*/
public void TryTransfer(Mobile from, StorageEntry entry)
{
if (entry == null)
return;
int fees = entry.Funds;
if (fees < 0)
{
int owed = fees * -1;
SayTo(from, String.Format("It looks like you owe {0}gp as back fees. How much would you like to pay now?", owed.ToString("###,###,###")));
from.Prompt = new BackfeePrompt(this, entry);
return;
}
if (!TryPayFunds(from, entry))
{
from.SendGump(new BazaarInformationGump(1150681, 1150678)); // Some personal possessions that were equipped on the broker still remain in storage, because your backpack cannot hold them. Please free up space in your backpack and return to claim these items.
return;
}
if (entry.Creatures.Count > 0)
{
List<BaseCreature> list = new List<BaseCreature>(entry.Creatures);
foreach (BaseCreature bc in list)
{
if (from.Stabled.Count < AnimalTrainer.GetMaxStabled(from))
{
bc.Blessed = false;
bc.ControlOrder = OrderType.Stay;
bc.Internalize();
bc.IsStabled = true;
bc.Loyalty = BaseCreature.MaxLoyalty; // Wonderfully happy
from.Stabled.Add(bc);
bc.SetControlMaster(null);
bc.SummonMaster = null;
entry.RemovePet(bc);
}
else
{
from.SendGump(new BazaarInformationGump(1150681, 1150678)); // Some personal possessions that were equipped on the broker still remain in storage, because your backpack cannot hold them. Please free up space in your backpack and return to claim these items.
return;
}
}
ColUtility.Free(list);
}
if (entry.CommodityTypes.Count > 0)
{
Dictionary<Type, int> copy = new Dictionary<Type, int>(entry.CommodityTypes);
foreach (KeyValuePair<Type, int> commodities in copy)
{
Type type = commodities.Key;
int amt = commodities.Value;
if (!GiveItems(from, type, amt, entry))
{
from.SendGump(new BazaarInformationGump(1150681, 1150678)); // Some personal possessions that were equipped on the broker still remain in storage, because your backpack cannot hold them. Please free up space in your backpack and return to claim these items.
return;
}
}
copy.Clear();
}
entry.CommodityTypes.Clear();
ColUtility.Free(entry.Creatures);
from.SendGump(new BazaarInformationGump(1150681, 1150677)); // There are no longer any items or funds in storage for your former bazaar stall. Thank you for your diligence in recovering your possessions.
MaginciaBazaar.RemoveFromStorage(from);
}
private bool GiveItems(Mobile from, Type type, int amt, StorageEntry entry)
{
int amount = amt;
while (amount > 60000)
{
CommodityDeed deed = new CommodityDeed();
Item item = Loot.Construct(type);
item.Amount = 60000;
deed.SetCommodity(item);
amount -= 60000;
if (from.Backpack == null || !from.Backpack.TryDropItem(from, deed, false))
{
deed.Delete();
return false;
}
else
entry.RemoveCommodity(type, 60000);
}
CommodityDeed deed2 = new CommodityDeed();
Item item2 = Loot.Construct(type);
item2.Amount = amount;
deed2.SetCommodity(item2);
if (from.Backpack == null || !from.Backpack.TryDropItem(from, deed2, false))
{
deed2.Delete();
return false;
}
else
entry.RemoveCommodity(type, amount);
return true;
}
private bool TryPayFunds(Mobile from, StorageEntry entry)
{
int amount = entry.Funds;
if (Banker.Withdraw(from, amount, true))
{
entry.Funds = 0;
return true;
}
return false;
}
public void TryPayBackfee(Mobile from, string text, StorageEntry entry)
{
int amount = Utility.ToInt32(text);
int owed = entry.Funds * -1;
if (amount > 0)
{
int toDeduct = Math.Min(owed, amount);
if (Banker.Withdraw(from, toDeduct))
{
entry.Funds += toDeduct;
int newAmount = entry.Funds;
if (newAmount >= 0)
{
TryTransfer(from, entry);
}
else
{
SayTo(from, String.Format("Thank you! You have a remaining balance of {0}gp as backfees!", newAmount * -1));
}
}
else
{
SayTo(from, "You don't have enough funds in your bankbox to support that amount.");
}
}
}
private class BackfeePrompt : Prompt
{
private WarehouseSuperintendent m_Mobile;
private StorageEntry m_Entry;
public BackfeePrompt(WarehouseSuperintendent mobile, StorageEntry entry)
{
m_Mobile = mobile;
m_Entry = entry; ;
}
public override void OnResponse( Mobile from, string text )
{
m_Mobile.TryPayBackfee(from, text, m_Entry);
}
}
/*private bool TransferItems(Mobile from, WarehouseContainer c)
{
List<Item> items = new List<Item>(c.Items);
foreach(Item item in items)
{
from.Backpack.TryDropItem(from, item, false);
}
return c.Items.Count == 0;
}*/
public override void GetContextMenuEntries( Mobile from, List<ContextMenuEntry> list )
{
base.GetContextMenuEntries(from, list);
list.Add(new ClaimStorageEntry(from, this));
list.Add(new ChangeMatchBidEntry(from));
}
private class ClaimStorageEntry : ContextMenuEntry
{
private WarehouseSuperintendent m_Mobile;
private StorageEntry m_Entry;
public ClaimStorageEntry(Mobile from, WarehouseSuperintendent mobile) : base(1150681, 3)
{
m_Mobile = mobile;
m_Entry = MaginciaBazaar.GetStorageEntry(from);
if(m_Entry == null)
Flags |= CMEFlags.Disabled;
}
public override void OnClick()
{
Mobile from = Owner.From;
if (from == null || m_Entry == null)
return;
m_Mobile.TryTransfer(from, m_Entry);
}
}
private class ChangeMatchBidEntry : ContextMenuEntry
{
public ChangeMatchBidEntry(Mobile from) : base(1150587, 3)
{
}
public override void OnClick()
{
Mobile from = Owner.From;
if(from != null)
from.SendGump(new MatchBidGump(from, null));
}
}
public WarehouseSuperintendent(Serial serial) : base(serial)
{
}
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.Write((int)1);
}
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
int version = reader.ReadInt();
if(version == 0)
{
Hue = Race.RandomSkinHue();
}
}
}
}