Overwrite
Complete Overwrite of the Folder with the free shard. ServUO 57.3 has been added.
This commit is contained in:
@@ -0,0 +1,284 @@
|
||||
using Server;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Server.Accounting;
|
||||
|
||||
namespace Server.Engines.NewMagincia
|
||||
{
|
||||
[PropertyObject]
|
||||
public class MaginciaHousingPlot
|
||||
{
|
||||
private string m_Identifier;
|
||||
private WritOfLease m_Writ;
|
||||
private Rectangle2D m_Bounds;
|
||||
private MaginciaPlotStone m_Stone;
|
||||
private bool m_IsPrimeSpot;
|
||||
private bool m_Complete;
|
||||
private Mobile m_Winner;
|
||||
private Map m_Map;
|
||||
private DateTime m_Expires;
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public string Identifier { get { return m_Identifier; } }
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public WritOfLease Writ { get { return m_Writ; } set { m_Writ = value; } }
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public Rectangle2D Bounds { get { return m_Bounds; } }
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public MaginciaPlotStone Stone { get { return m_Stone; } set { m_Stone = value; } }
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public bool IsPrimeSpot { get { return m_IsPrimeSpot; } }
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public bool Complete { get { return m_Complete; } }
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public Mobile Winner { get { return m_Winner; } set { m_Winner = value; } }
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public Map Map { get { return m_Map; } }
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public DateTime Expires { get { return m_Expires; } set { m_Expires = value; } }
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public Point3D RecallLoc
|
||||
{
|
||||
get
|
||||
{
|
||||
return new Point3D(m_Bounds.X, m_Bounds.Y, m_Map.GetAverageZ(m_Bounds.X, m_Bounds.Y));
|
||||
}
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public bool IsAvailable { get { return !m_Complete; } }
|
||||
|
||||
#region Lotto Info
|
||||
private DateTime m_LottoEnds;
|
||||
private Dictionary<Mobile, int> m_Participants = new Dictionary<Mobile, int>();
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public DateTime LottoEnds { get { return m_LottoEnds; } set { m_LottoEnds = value; } }
|
||||
|
||||
public Dictionary<Mobile, int> Participants { get { return m_Participants; } }
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public int LottoPrice { get { return m_IsPrimeSpot ? 10000 : 2000; } }
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public bool LottoOngoing { get { return IsAvailable && m_LottoEnds > DateTime.UtcNow && m_LottoEnds != DateTime.MinValue; } }
|
||||
#endregion
|
||||
|
||||
public MaginciaHousingPlot(string identifier, Rectangle2D bounds, bool prime, Map map)
|
||||
{
|
||||
m_Identifier = identifier;
|
||||
m_Bounds = bounds;
|
||||
m_IsPrimeSpot = prime;
|
||||
m_Map = map;
|
||||
m_Writ = null;
|
||||
m_Complete = false;
|
||||
m_Expires = DateTime.MinValue;
|
||||
}
|
||||
|
||||
public void AddPlotStone()
|
||||
{
|
||||
AddPlotStone(MaginciaLottoSystem.GetPlotStoneLoc(this));
|
||||
}
|
||||
|
||||
public void AddPlotStone(Point3D p)
|
||||
{
|
||||
m_Stone = new MaginciaPlotStone();
|
||||
m_Stone.Plot = this;
|
||||
m_Stone.MoveToWorld(p, m_Map);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return "...";
|
||||
}
|
||||
|
||||
public bool CanPurchaseLottoTicket(Mobile from)
|
||||
{
|
||||
if (m_IsPrimeSpot)
|
||||
{
|
||||
Account acct = from.Account as Account;
|
||||
|
||||
if (acct == null)
|
||||
return false;
|
||||
|
||||
return CheckAccount(acct);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool CheckAccount(Account acct)
|
||||
{
|
||||
for (int i = 0; i < acct.Length; i++)
|
||||
{
|
||||
Mobile m = acct[i];
|
||||
|
||||
if (m == null)
|
||||
continue;
|
||||
|
||||
foreach (MaginciaHousingPlot plot in MaginciaLottoSystem.Plots)
|
||||
{
|
||||
if (plot.IsPrimeSpot && plot.Participants.ContainsKey(m))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void PurchaseLottoTicket(Mobile from, int toBuy)
|
||||
{
|
||||
if (m_Participants.ContainsKey(from))
|
||||
m_Participants[from] += toBuy;
|
||||
else
|
||||
m_Participants[from] = toBuy;
|
||||
}
|
||||
|
||||
public void EndLotto()
|
||||
{
|
||||
if (m_Participants.Count == 0)
|
||||
{
|
||||
ResetLotto();
|
||||
return;
|
||||
}
|
||||
|
||||
List<Mobile> raffle = new List<Mobile>();
|
||||
|
||||
foreach (KeyValuePair<Mobile, int> kvp in m_Participants)
|
||||
{
|
||||
if (kvp.Value == 0)
|
||||
continue;
|
||||
|
||||
for (int i = 0; i < kvp.Value; i++)
|
||||
raffle.Add(kvp.Key);
|
||||
}
|
||||
|
||||
Mobile winner = raffle[Utility.Random(raffle.Count)];
|
||||
|
||||
if(winner != null)
|
||||
OnLottoComplete(winner);
|
||||
else
|
||||
ResetLotto();
|
||||
|
||||
m_Participants.Clear();
|
||||
}
|
||||
|
||||
public void OnLottoComplete(Mobile winner)
|
||||
{
|
||||
m_Complete = true;
|
||||
m_Winner = winner;
|
||||
m_LottoEnds = DateTime.MinValue;
|
||||
m_Expires = DateTime.UtcNow + TimeSpan.FromDays(MaginciaLottoSystem.WritExpirePeriod);
|
||||
|
||||
if (winner.HasGump(typeof(PlotWinnerGump)))
|
||||
return;
|
||||
|
||||
Account acct = winner.Account as Account;
|
||||
|
||||
if (acct == null)
|
||||
return;
|
||||
|
||||
for (int i = 0; i < acct.Length; i++)
|
||||
{
|
||||
Mobile m = acct[i];
|
||||
|
||||
if (m == null)
|
||||
continue;
|
||||
|
||||
if (m.NetState != null)
|
||||
{
|
||||
winner.SendGump(new PlotWinnerGump(this));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void SendMessage_Callback(object o)
|
||||
{
|
||||
object[] obj = o as object[];
|
||||
|
||||
if (obj != null)
|
||||
{
|
||||
Mobile winner = obj[0] as Mobile;
|
||||
NewMaginciaMessage message = obj[1] as NewMaginciaMessage;
|
||||
|
||||
MaginciaLottoSystem.SendMessageTo(winner, message);
|
||||
}
|
||||
}
|
||||
|
||||
public void ResetLotto()
|
||||
{
|
||||
if (MaginciaLottoSystem.AutoResetLotto && MaginciaLottoSystem.Instance != null)
|
||||
m_LottoEnds = DateTime.UtcNow + MaginciaLottoSystem.Instance.LottoDuration;
|
||||
else
|
||||
m_LottoEnds = DateTime.MinValue;
|
||||
}
|
||||
|
||||
public MaginciaHousingPlot(GenericReader reader)
|
||||
{
|
||||
int version = reader.ReadInt();
|
||||
|
||||
m_Identifier = reader.ReadString();
|
||||
m_Writ = reader.ReadItem() as WritOfLease;
|
||||
m_Stone = reader.ReadItem() as MaginciaPlotStone;
|
||||
m_LottoEnds = reader.ReadDateTime();
|
||||
m_Bounds = reader.ReadRect2D();
|
||||
m_Map = reader.ReadMap();
|
||||
m_IsPrimeSpot = reader.ReadBool();
|
||||
m_Complete = reader.ReadBool();
|
||||
m_Winner = reader.ReadMobile();
|
||||
m_Expires = reader.ReadDateTime();
|
||||
|
||||
int c = reader.ReadInt();
|
||||
for (int i = 0; i < c; i++)
|
||||
{
|
||||
Mobile m = reader.ReadMobile();
|
||||
int amount = reader.ReadInt();
|
||||
|
||||
if (m != null)
|
||||
m_Participants[m] = amount;
|
||||
}
|
||||
|
||||
if ((m_Stone == null || m_Stone.Deleted) && LottoOngoing && MaginciaLottoSystem.IsRegisteredPlot(this))
|
||||
AddPlotStone();
|
||||
else if (m_Stone != null)
|
||||
m_Stone.Plot = this;
|
||||
|
||||
if (m_Writ != null)
|
||||
m_Writ.Plot = this;
|
||||
}
|
||||
|
||||
public void Serialize(GenericWriter writer)
|
||||
{
|
||||
writer.Write((int)0);
|
||||
|
||||
writer.Write(m_Identifier);
|
||||
writer.Write(m_Writ);
|
||||
writer.Write(m_Stone);
|
||||
writer.Write(m_LottoEnds);
|
||||
writer.Write(m_Bounds);
|
||||
writer.Write(m_Map);
|
||||
writer.Write(m_IsPrimeSpot);
|
||||
writer.Write(m_Complete);
|
||||
writer.Write(m_Winner);
|
||||
writer.Write(m_Expires);
|
||||
|
||||
writer.Write(m_Participants.Count);
|
||||
|
||||
foreach (KeyValuePair<Mobile, int> kvp in m_Participants)
|
||||
{
|
||||
writer.Write(kvp.Key);
|
||||
writer.Write(kvp.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,658 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
using Server;
|
||||
using Server.Items;
|
||||
using Server.Mobiles;
|
||||
using Server.Commands;
|
||||
using Server.Accounting;
|
||||
using Server.Multis;
|
||||
using Server.Gumps;
|
||||
|
||||
namespace Server.Engines.NewMagincia
|
||||
{
|
||||
public class MaginciaLottoSystem : Item
|
||||
{
|
||||
public static readonly TimeSpan DefaultLottoDuration = TimeSpan.FromDays(30);
|
||||
public static readonly int WritExpirePeriod = 30;
|
||||
public static readonly bool AutoResetLotto = false;
|
||||
|
||||
private static int m_GoldSink;
|
||||
private static MaginciaLottoSystem m_Instance;
|
||||
public static MaginciaLottoSystem Instance { get { return m_Instance; } set { m_Instance = value; } }
|
||||
|
||||
private static List<MaginciaHousingPlot> m_Plots = new List<MaginciaHousingPlot>();
|
||||
public static List<MaginciaHousingPlot> Plots { get { return m_Plots; } }
|
||||
|
||||
private static Dictionary<Map, List<Rectangle2D>> m_FreeHousingZones;
|
||||
public static Dictionary<Map, List<Rectangle2D>> FreeHousingZones { get { return m_FreeHousingZones; } }
|
||||
|
||||
private static Dictionary<Mobile, List<NewMaginciaMessage>> m_MessageQueue = new Dictionary<Mobile, List<NewMaginciaMessage>>();
|
||||
public static Dictionary<Mobile, List<NewMaginciaMessage>> MessageQueue { get { return m_MessageQueue; } }
|
||||
|
||||
private Timer m_Timer;
|
||||
private TimeSpan m_LottoDuration;
|
||||
private bool m_Enabled;
|
||||
|
||||
public static void Initialize()
|
||||
{
|
||||
EventSink.Login += new LoginEventHandler(OnLogin);
|
||||
|
||||
if (m_Instance != null)
|
||||
m_Instance.CheckMessages();
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public bool ResetAuctions
|
||||
{
|
||||
get { return false; }
|
||||
set
|
||||
{
|
||||
if (value == true)
|
||||
{
|
||||
foreach (MaginciaHousingPlot plot in m_Plots)
|
||||
{
|
||||
if(plot.IsAvailable)
|
||||
plot.LottoEnds = DateTime.UtcNow + m_LottoDuration;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public bool Enabled
|
||||
{
|
||||
get { return m_Enabled; }
|
||||
set
|
||||
{
|
||||
if (m_Enabled != value)
|
||||
{
|
||||
if (value)
|
||||
{
|
||||
StartTimer();
|
||||
}
|
||||
else
|
||||
{
|
||||
EndTimer();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public static int GoldSink { get { return m_GoldSink; } set { m_GoldSink = value; } }
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public TimeSpan LottoDuration { get { return m_LottoDuration; } set { m_LottoDuration = value; } }
|
||||
|
||||
public MaginciaLottoSystem() : base(3240)
|
||||
{
|
||||
Movable = false;
|
||||
m_Enabled = true;
|
||||
m_LottoDuration = DefaultLottoDuration;
|
||||
|
||||
m_FreeHousingZones = new Dictionary<Map, List<Rectangle2D>>();
|
||||
m_FreeHousingZones[Map.Trammel] = new List<Rectangle2D>();
|
||||
m_FreeHousingZones[Map.Felucca] = new List<Rectangle2D>();
|
||||
|
||||
if(m_Enabled)
|
||||
StartTimer();
|
||||
|
||||
LoadPlots();
|
||||
}
|
||||
|
||||
public override void OnDoubleClick(Mobile from)
|
||||
{
|
||||
if (from.AccessLevel > AccessLevel.Player)
|
||||
{
|
||||
from.CloseGump(typeof(LottoTrackingGump));
|
||||
from.CloseGump(typeof(PlotTrackingGump));
|
||||
from.SendGump(new LottoTrackingGump());
|
||||
}
|
||||
}
|
||||
|
||||
public void StartTimer()
|
||||
{
|
||||
if (m_Timer != null)
|
||||
m_Timer.Stop();
|
||||
|
||||
m_Timer = Timer.DelayCall(TimeSpan.FromMinutes(1), TimeSpan.FromMinutes(1), new TimerCallback(ProcessTick));
|
||||
m_Timer.Priority = TimerPriority.OneMinute;
|
||||
m_Timer.Start();
|
||||
}
|
||||
|
||||
public void EndTimer()
|
||||
{
|
||||
if (m_Timer != null)
|
||||
{
|
||||
m_Timer.Stop();
|
||||
m_Timer = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void ProcessTick()
|
||||
{
|
||||
List<MaginciaHousingPlot> plots = new List<MaginciaHousingPlot>(m_Plots);
|
||||
|
||||
foreach (MaginciaHousingPlot plot in plots)
|
||||
{
|
||||
if (plot.IsAvailable && plot.LottoEnds != DateTime.MinValue && DateTime.UtcNow > plot.LottoEnds)
|
||||
plot.EndLotto();
|
||||
|
||||
if (plot.Expires != DateTime.MinValue && plot.Expires < DateTime.UtcNow)
|
||||
{
|
||||
if (plot.Writ != null)
|
||||
plot.Writ.OnExpired();
|
||||
else
|
||||
UnregisterPlot(plot);
|
||||
}
|
||||
}
|
||||
|
||||
ColUtility.Free(plots);
|
||||
|
||||
if (m_Plots.Count == 0)
|
||||
EndTimer();
|
||||
}
|
||||
|
||||
public override void Delete()
|
||||
{
|
||||
}
|
||||
|
||||
public static void RegisterPlot(MaginciaHousingPlot plot)
|
||||
{
|
||||
m_Plots.Add(plot);
|
||||
}
|
||||
|
||||
public static void UnregisterPlot(MaginciaHousingPlot plot)
|
||||
{
|
||||
if (plot == null)
|
||||
return;
|
||||
|
||||
if (plot.Stone != null && !plot.Stone.Deleted)
|
||||
plot.Stone.Delete();
|
||||
|
||||
if (m_Plots.Contains(plot))
|
||||
m_Plots.Remove(plot);
|
||||
|
||||
if (plot.Map != null && m_FreeHousingZones.ContainsKey(plot.Map) && !m_FreeHousingZones[plot.Map].Contains(plot.Bounds))
|
||||
m_FreeHousingZones[plot.Map].Add(plot.Bounds);
|
||||
}
|
||||
|
||||
public static bool IsRegisteredPlot(MaginciaHousingPlot plot)
|
||||
{
|
||||
return m_Plots.Contains(plot);
|
||||
}
|
||||
|
||||
public static bool IsFreeHousingZone(Point3D p, Map map)
|
||||
{
|
||||
if (!m_FreeHousingZones.ContainsKey(map))
|
||||
return false;
|
||||
|
||||
foreach (Rectangle2D rec in m_FreeHousingZones[map])
|
||||
{
|
||||
if (rec.Contains(p))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void CheckHousePlacement(Mobile from, Point3D center)
|
||||
{
|
||||
MaginciaLottoSystem system = MaginciaLottoSystem.Instance;
|
||||
|
||||
if (system != null && system.Enabled && from.Backpack != null && IsInMagincia(center.X, center.Y, from.Map))
|
||||
{
|
||||
List<Item> items = new List<Item>();
|
||||
|
||||
Item[] packItems = from.Backpack.FindItemsByType(typeof(WritOfLease));
|
||||
Item[] bankItems = from.BankBox.FindItemsByType(typeof(WritOfLease));
|
||||
|
||||
if (packItems != null && packItems.Length > 0)
|
||||
items.AddRange(packItems);
|
||||
|
||||
if (bankItems != null && bankItems.Length > 0)
|
||||
items.AddRange(bankItems);
|
||||
|
||||
foreach (Item item in items)
|
||||
{
|
||||
WritOfLease lease = item as WritOfLease;
|
||||
|
||||
if (lease != null && !lease.Expired && lease.Plot != null && lease.Plot.Bounds.Contains(center) && from.Map == lease.Plot.Map)
|
||||
{
|
||||
lease.OnExpired();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static bool IsInMagincia(int x, int y, Map map)
|
||||
{
|
||||
return x > 3614 && x < 3817 && y > 2031 && y < 2274 && (map == Map.Trammel || map == Map.Felucca);
|
||||
}
|
||||
|
||||
private void LoadPlots()
|
||||
{
|
||||
for (int i = 0; i < m_MagHousingZones.Length; i++)
|
||||
{
|
||||
bool prime = (i > 0 && i < 6) || i > 14;
|
||||
|
||||
MaginciaHousingPlot tramplot = new MaginciaHousingPlot(m_Identifiers[i], m_MagHousingZones[i], prime, Map.Trammel);
|
||||
MaginciaHousingPlot felplot = new MaginciaHousingPlot(m_Identifiers[i], m_MagHousingZones[i], prime, Map.Felucca);
|
||||
|
||||
RegisterPlot(tramplot);
|
||||
RegisterPlot(felplot);
|
||||
|
||||
tramplot.AddPlotStone(m_StoneLocs[i]);
|
||||
tramplot.LottoEnds = DateTime.UtcNow + m_LottoDuration;
|
||||
|
||||
felplot.AddPlotStone(m_StoneLocs[i]);
|
||||
felplot.LottoEnds = DateTime.UtcNow + m_LottoDuration;
|
||||
}
|
||||
}
|
||||
|
||||
public static Rectangle2D[] MagHousingZones { get { return m_MagHousingZones; } }
|
||||
private static Rectangle2D[] m_MagHousingZones = new Rectangle2D[]
|
||||
{
|
||||
new Rectangle2D(3686, 2125, 18, 18), // C1
|
||||
new Rectangle2D(3686, 2086, 18, 18), // C2 / Prime
|
||||
new Rectangle2D(3686, 2063, 18, 18), // C3 / Prime
|
||||
|
||||
new Rectangle2D(3657, 2036, 18, 18), // N1 / Prime
|
||||
new Rectangle2D(3648, 2058, 18, 18), // N2 / Prime
|
||||
new Rectangle2D(3636, 2081, 18, 18), // N3 / Prime
|
||||
|
||||
new Rectangle2D(3712, 2123, 16, 16), // SE3
|
||||
new Rectangle2D(3712, 2151, 18, 16), // SE2
|
||||
new Rectangle2D(3712, 2172, 18, 16), // SE1
|
||||
new Rectangle2D(3729, 2135, 16, 16), // SE4
|
||||
|
||||
new Rectangle2D(3655, 2213, 18, 18), // SW1
|
||||
new Rectangle2D(3656, 2191, 18, 16), // SW2
|
||||
new Rectangle2D(3628, 2197, 20, 20), // SW3
|
||||
new Rectangle2D(3628, 2175, 18, 18), // SW4
|
||||
new Rectangle2D(3657, 2165, 18, 18), // SW5
|
||||
|
||||
new Rectangle2D(3745, 2122, 16, 18), // E1 / Prime
|
||||
new Rectangle2D(3765, 2122, 18, 18), // E2 / Prime
|
||||
new Rectangle2D(3787, 2130, 18, 18), // E3 / Prime
|
||||
new Rectangle2D(3784, 2108, 18, 17), // E4 / Prime
|
||||
new Rectangle2D(3765, 2086, 18, 18), // E5 / Prime
|
||||
new Rectangle2D(3749, 2065, 18, 18), // E6 / Prime
|
||||
new Rectangle2D(3715, 2090, 18, 18), // E7 / Prime
|
||||
};
|
||||
|
||||
private static Point3D[] m_StoneLocs = new Point3D[]
|
||||
{
|
||||
new Point3D(3683, 2134, 20),
|
||||
new Point3D(3704, 2092, 5),
|
||||
new Point3D(3704, 2069, 5),
|
||||
|
||||
new Point3D(3677, 2045, 20),
|
||||
new Point3D(3667, 2065, 20),
|
||||
new Point3D(3644, 2099, 20),
|
||||
|
||||
new Point3D(3711, 2131, 20),
|
||||
new Point3D(3711, 2160, 20),
|
||||
new Point3D(3711, 2180, 20),
|
||||
new Point3D(3735, 2133, 20),
|
||||
|
||||
new Point3D(3676, 2220, 20),
|
||||
new Point3D(3675, 2198, 20),
|
||||
new Point3D(3647, 2205, 22),
|
||||
new Point3D(3647, 2184, 21),
|
||||
new Point3D(3665, 2183, 22),
|
||||
|
||||
new Point3D(3753, 2119, 21),
|
||||
new Point3D(3772, 2119, 21),
|
||||
new Point3D(3785, 2127, 25),
|
||||
new Point3D(3790, 2106, 30),
|
||||
new Point3D(3761, 2090, 20),
|
||||
new Point3D(3746, 2064, 23),
|
||||
new Point3D(3711, 2087, 5)
|
||||
};
|
||||
|
||||
private static string[] m_Identifiers = new string[]
|
||||
{
|
||||
"C-1",
|
||||
"C-2",
|
||||
"C-3",
|
||||
|
||||
"N-1",
|
||||
"N-2",
|
||||
"N-3",
|
||||
|
||||
"SE-1",
|
||||
"SE-2",
|
||||
"SE-3",
|
||||
"SE-4",
|
||||
|
||||
"SW-1",
|
||||
"SW-2",
|
||||
"SW-3",
|
||||
"SW-4",
|
||||
"SW-5",
|
||||
|
||||
"E-1",
|
||||
"E-2",
|
||||
"E-3",
|
||||
"E-4",
|
||||
"E-5",
|
||||
"E-6",
|
||||
"E-7"
|
||||
};
|
||||
|
||||
public static Point3D GetPlotStoneLoc(MaginciaHousingPlot plot)
|
||||
{
|
||||
if (plot == null)
|
||||
return Point3D.Zero;
|
||||
|
||||
for (int i = 0; i < m_Identifiers.Length; i++)
|
||||
{
|
||||
if (m_Identifiers[i] == plot.Identifier)
|
||||
return m_StoneLocs[i];
|
||||
}
|
||||
|
||||
int z = plot.Map.GetAverageZ(plot.Bounds.X - 1, plot.Bounds.Y - 1);
|
||||
return new Point3D(plot.Bounds.X - 1, plot.Bounds.Y - 1, z);
|
||||
}
|
||||
|
||||
public static string FormatSextant(MaginciaHousingPlot plot)
|
||||
{
|
||||
int z = plot.Map.GetAverageZ(plot.Bounds.X, plot.Bounds.Y);
|
||||
Point3D p = new Point3D(plot.Bounds.X, plot.Bounds.Y, z);
|
||||
|
||||
return FormatSextant(p, plot.Map);
|
||||
}
|
||||
|
||||
public static string FormatSextant(Point3D p, Map map)
|
||||
{
|
||||
int xLong = 0, yLat = 0;
|
||||
int xMins = 0, yMins = 0;
|
||||
bool xEast = false, ySouth = false;
|
||||
|
||||
if (Sextant.Format(p, map, ref xLong, ref yLat, ref xMins, ref yMins, ref xEast, ref ySouth))
|
||||
{
|
||||
return String.Format("{0}° {1}'{2}, {3}° {4}'{5}", yLat, yMins, ySouth ? "S" : "N", xLong, xMins, xEast ? "E" : "W");
|
||||
}
|
||||
|
||||
return p.ToString();
|
||||
}
|
||||
|
||||
#region Messages
|
||||
public static void SendMessageTo(Mobile from, TextDefinition title, TextDefinition body, TimeSpan expires)
|
||||
{
|
||||
SendMessageTo(from, new NewMaginciaMessage(title, body, expires));
|
||||
}
|
||||
|
||||
public static void SendMessageTo(Mobile from, NewMaginciaMessage message)
|
||||
{
|
||||
if (from == null || message == null)
|
||||
return;
|
||||
|
||||
AddMessageToQueue(from, message);
|
||||
|
||||
if (from is PlayerMobile && from.NetState != null)
|
||||
{
|
||||
if (from.HasGump(typeof(NewMaginciaMessageGump)))
|
||||
from.CloseGump(typeof(NewMaginciaMessageGump));
|
||||
|
||||
if (from.HasGump(typeof(NewMaginciaMessageListGump)))
|
||||
from.CloseGump(typeof(NewMaginciaMessageListGump));
|
||||
|
||||
if (from.HasGump(typeof(NewMaginciaMessageDetailGump)))
|
||||
from.CloseGump(typeof(NewMaginciaMessageDetailGump));
|
||||
|
||||
if (HasMessageInQueue(from))
|
||||
{
|
||||
BaseGump.SendGump(new NewMaginciaMessageGump((PlayerMobile)from));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void AddMessageToQueue(Mobile from, NewMaginciaMessage message)
|
||||
{
|
||||
if (!MessageQueue.ContainsKey(from) || m_MessageQueue[from] == null)
|
||||
m_MessageQueue[from] = new List<NewMaginciaMessage>();
|
||||
|
||||
m_MessageQueue[from].Add(message);
|
||||
}
|
||||
|
||||
public static void RemoveMessageFromQueue(Mobile from, NewMaginciaMessage message)
|
||||
{
|
||||
if (from == null || message == null)
|
||||
return;
|
||||
|
||||
if (m_MessageQueue.ContainsKey(from) && m_MessageQueue[from].Contains(message))
|
||||
{
|
||||
m_MessageQueue[from].Remove(message);
|
||||
|
||||
if (m_MessageQueue[from].Count == 0)
|
||||
m_MessageQueue.Remove(from);
|
||||
}
|
||||
}
|
||||
|
||||
public static bool HasMessageInQueue(Mobile from)
|
||||
{
|
||||
return from != null && m_MessageQueue.ContainsKey(from) && m_MessageQueue[from] != null && m_MessageQueue[from].Count > 0;
|
||||
}
|
||||
|
||||
public static void OnLogin(LoginEventArgs e)
|
||||
{
|
||||
Mobile from = e.Mobile;
|
||||
Account acct = from.Account as Account;
|
||||
CheckMessages(from);
|
||||
|
||||
//TODO: Support for account wide messages?
|
||||
|
||||
if (m_MessageQueue.ContainsKey(from))
|
||||
{
|
||||
if (m_MessageQueue[from] == null || m_MessageQueue[from].Count == 0)
|
||||
{
|
||||
m_MessageQueue.Remove(from);
|
||||
}
|
||||
else if (from is PlayerMobile)
|
||||
{
|
||||
from.CloseGump(typeof(NewMaginciaMessageGump));
|
||||
BaseGump.SendGump(new NewMaginciaMessageGump((PlayerMobile)from));
|
||||
}
|
||||
}
|
||||
|
||||
GetWinnerGump(from);
|
||||
}
|
||||
|
||||
public void CheckMessages()
|
||||
{
|
||||
List<Mobile> mobiles = new List<Mobile>(m_MessageQueue.Keys);
|
||||
|
||||
foreach (Mobile m in mobiles)
|
||||
{
|
||||
List<NewMaginciaMessage> messages = new List<NewMaginciaMessage>(m_MessageQueue[m]);
|
||||
|
||||
foreach (NewMaginciaMessage message in messages)
|
||||
{
|
||||
if (m_MessageQueue.ContainsKey(m) && m_MessageQueue[m].Contains(message) && message.Expired)
|
||||
m_MessageQueue[m].Remove(message);
|
||||
}
|
||||
|
||||
ColUtility.Free(messages);
|
||||
}
|
||||
|
||||
ColUtility.Free(mobiles);
|
||||
}
|
||||
|
||||
public static List<NewMaginciaMessage> GetMessages(Mobile m)
|
||||
{
|
||||
if (m_MessageQueue.ContainsKey(m))
|
||||
{
|
||||
return m_MessageQueue[m];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void CheckMessages(Mobile from)
|
||||
{
|
||||
if (!m_MessageQueue.ContainsKey(from) || m_MessageQueue[from] == null || m_MessageQueue[from].Count == 0)
|
||||
return;
|
||||
|
||||
List<NewMaginciaMessage> list = new List<NewMaginciaMessage>(m_MessageQueue[from]);
|
||||
|
||||
for (int i = 0; i < list.Count; i++)
|
||||
{
|
||||
if (list[i].Expired)
|
||||
m_MessageQueue[from].Remove(list[i]);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
public static void GetWinnerGump(Mobile from)
|
||||
{
|
||||
Account acct = from.Account as Account;
|
||||
|
||||
if (acct == null)
|
||||
return;
|
||||
|
||||
for (int i = 0; i < acct.Length; i++)
|
||||
{
|
||||
Mobile m = acct[i];
|
||||
|
||||
if (m == null)
|
||||
continue;
|
||||
|
||||
foreach (MaginciaHousingPlot plot in m_Plots)
|
||||
{
|
||||
if (plot.Expires != DateTime.MinValue && plot.Winner == m)
|
||||
{
|
||||
from.SendGump(new PlotWinnerGump(plot));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public MaginciaLottoSystem(Serial serial)
|
||||
: base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write((int)0); // version
|
||||
|
||||
writer.Write(m_GoldSink);
|
||||
writer.Write(m_Enabled);
|
||||
writer.Write(m_LottoDuration);
|
||||
|
||||
writer.Write(m_Plots.Count);
|
||||
for (int i = 0; i < m_Plots.Count; i++)
|
||||
m_Plots[i].Serialize(writer);
|
||||
|
||||
writer.Write(m_FreeHousingZones[Map.Trammel].Count);
|
||||
foreach(Rectangle2D rec in m_FreeHousingZones[Map.Trammel])
|
||||
writer.Write(rec);
|
||||
|
||||
writer.Write(m_FreeHousingZones[Map.Felucca].Count);
|
||||
foreach (Rectangle2D rec in m_FreeHousingZones[Map.Felucca])
|
||||
writer.Write(rec);
|
||||
|
||||
writer.Write(m_MessageQueue.Count);
|
||||
foreach(KeyValuePair<Mobile, List<NewMaginciaMessage>> kvp in m_MessageQueue)
|
||||
{
|
||||
writer.Write(kvp.Key);
|
||||
|
||||
writer.Write(kvp.Value.Count);
|
||||
foreach(NewMaginciaMessage message in kvp.Value)
|
||||
message.Serialize(writer);
|
||||
}
|
||||
|
||||
Timer.DelayCall(TimeSpan.FromSeconds(30), new TimerCallback(CheckMessages));
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
int version = reader.ReadInt();
|
||||
|
||||
m_FreeHousingZones = new Dictionary<Map, List<Rectangle2D>>();
|
||||
m_FreeHousingZones[Map.Trammel] = new List<Rectangle2D>();
|
||||
m_FreeHousingZones[Map.Felucca] = new List<Rectangle2D>();
|
||||
|
||||
m_GoldSink = reader.ReadInt();
|
||||
m_Enabled = reader.ReadBool();
|
||||
m_LottoDuration = reader.ReadTimeSpan();
|
||||
|
||||
int c = reader.ReadInt();
|
||||
for (int i = 0; i < c; i++)
|
||||
RegisterPlot(new MaginciaHousingPlot(reader));
|
||||
|
||||
c = reader.ReadInt();
|
||||
for (int i = 0; i < c; i++)
|
||||
m_FreeHousingZones[Map.Trammel].Add(reader.ReadRect2D());
|
||||
|
||||
c = reader.ReadInt();
|
||||
for (int i = 0; i < c; i++)
|
||||
m_FreeHousingZones[Map.Felucca].Add(reader.ReadRect2D());
|
||||
|
||||
c = reader.ReadInt();
|
||||
for (int i = 0; i < c; i++)
|
||||
{
|
||||
Mobile m = reader.ReadMobile();
|
||||
List<NewMaginciaMessage> messages = new List<NewMaginciaMessage>();
|
||||
|
||||
int count = reader.ReadInt();
|
||||
for(int j = 0; j < count; j++)
|
||||
messages.Add(new NewMaginciaMessage(reader));
|
||||
|
||||
if (m != null && messages.Count > 0)
|
||||
m_MessageQueue[m] = messages;
|
||||
}
|
||||
|
||||
if (m_Enabled)
|
||||
StartTimer();
|
||||
|
||||
m_Instance = this;
|
||||
|
||||
Timer.DelayCall(ValidatePlots);
|
||||
}
|
||||
|
||||
public void ValidatePlots()
|
||||
{
|
||||
for(int i = 0; i < m_Identifiers.Length; i++)
|
||||
{
|
||||
var rec = m_MagHousingZones[i];
|
||||
var id = m_Identifiers[i];
|
||||
|
||||
var plotTram = m_Plots.FirstOrDefault(p => p.Identifier == id && p.Map == Map.Trammel);
|
||||
var plotFel = m_Plots.FirstOrDefault(p => p.Identifier == id && p.Map == Map.Felucca);
|
||||
|
||||
if (plotTram == null && !m_FreeHousingZones[Map.Trammel].Contains(rec))
|
||||
{
|
||||
Console.WriteLine("Adding {0} to Magincia Free Housing Zone.[{1}]", rec, "Plot non-existent");
|
||||
m_FreeHousingZones[Map.Trammel].Add(rec);
|
||||
}
|
||||
else if (plotTram != null && plotTram.Stone == null && (plotTram.Writ == null || plotTram.Writ.Expired))
|
||||
{
|
||||
Console.WriteLine("Adding {0} to Magincia Free Housing Zone.[{1}]", rec, "Plot existed, writ expired");
|
||||
UnregisterPlot(plotTram);
|
||||
}
|
||||
|
||||
if (plotFel == null && !m_FreeHousingZones[Map.Felucca].Contains(rec))
|
||||
{
|
||||
Console.WriteLine("Adding {0} to Magincia Free Housing Zone.[{1}]", rec, "Plot non-existent");
|
||||
m_FreeHousingZones[Map.Felucca].Add(rec);
|
||||
}
|
||||
else if (plotFel != null && plotFel.Stone == null && (plotFel.Writ == null || plotFel.Writ.Expired))
|
||||
{
|
||||
Console.WriteLine("Adding {0} to Magincia Free Housing Zone.[{1}]", rec, "Plot existed, writ expired");
|
||||
UnregisterPlot(plotFel);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
using Server;
|
||||
using System;
|
||||
|
||||
namespace Server.Engines.NewMagincia
|
||||
{
|
||||
public class NewMaginciaMessage
|
||||
{
|
||||
public static readonly TimeSpan DefaultExpirePeriod = TimeSpan.FromDays(7);
|
||||
|
||||
private TextDefinition m_Title;
|
||||
private TextDefinition m_Body;
|
||||
private string m_Args;
|
||||
private DateTime m_Expires;
|
||||
|
||||
public TextDefinition Title { get { return m_Title; } }
|
||||
public TextDefinition Body { get { return m_Body; } }
|
||||
public string Args { get { return m_Args; } }
|
||||
public DateTime Expires { get { return m_Expires; } }
|
||||
|
||||
public bool Expired { get { return m_Expires < DateTime.UtcNow; } }
|
||||
|
||||
public NewMaginciaMessage(TextDefinition title, TextDefinition body)
|
||||
: this(title, body, DefaultExpirePeriod, null)
|
||||
{
|
||||
}
|
||||
|
||||
public NewMaginciaMessage(TextDefinition title, TextDefinition body, string args)
|
||||
: this(title, body, DefaultExpirePeriod, args)
|
||||
{
|
||||
}
|
||||
|
||||
public NewMaginciaMessage(TextDefinition title, TextDefinition body, TimeSpan expires)
|
||||
: this(title, body, expires, null)
|
||||
{
|
||||
}
|
||||
|
||||
public NewMaginciaMessage(TextDefinition title, TextDefinition body, TimeSpan expires, string args)
|
||||
{
|
||||
m_Title = title;
|
||||
m_Body = body;
|
||||
m_Args = args;
|
||||
m_Expires = DateTime.UtcNow + expires;
|
||||
}
|
||||
|
||||
public void Serialize(GenericWriter writer)
|
||||
{
|
||||
writer.Write((int)0);
|
||||
|
||||
TextDefinition.Serialize(writer, m_Title);
|
||||
TextDefinition.Serialize(writer, m_Body);
|
||||
writer.Write(m_Expires);
|
||||
writer.Write(m_Args);
|
||||
}
|
||||
|
||||
public NewMaginciaMessage(GenericReader reader)
|
||||
{
|
||||
int v = reader.ReadInt();
|
||||
|
||||
m_Title = TextDefinition.Deserialize(reader);
|
||||
m_Body = TextDefinition.Deserialize(reader);
|
||||
m_Expires = reader.ReadDateTime();
|
||||
m_Args = reader.ReadString();
|
||||
}
|
||||
}
|
||||
}
|
||||
45
Scripts/Services/New Magincia/Housing Lotto/Core/Region.cs
Normal file
45
Scripts/Services/New Magincia/Housing Lotto/Core/Region.cs
Normal file
@@ -0,0 +1,45 @@
|
||||
using System;
|
||||
using Server;
|
||||
using Server.Mobiles;
|
||||
using Server.Regions;
|
||||
using System.Xml;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Server.Engines.NewMagincia
|
||||
{
|
||||
public class NewMaginciaRegion : TownRegion
|
||||
{
|
||||
public NewMaginciaRegion(XmlElement xml, Map map, Region parent) : base(xml, map, parent)
|
||||
{
|
||||
}
|
||||
|
||||
public override bool AllowHousing(Mobile from, Point3D p)
|
||||
{
|
||||
MaginciaLottoSystem system = MaginciaLottoSystem.Instance;
|
||||
|
||||
if (system != null && system.Enabled && from.Backpack != null)
|
||||
{
|
||||
List<Item> items = new List<Item>();
|
||||
|
||||
Item[] packItems = from.Backpack.FindItemsByType(typeof(WritOfLease));
|
||||
Item[] bankItems = from.BankBox.FindItemsByType(typeof(WritOfLease));
|
||||
|
||||
if (packItems != null && packItems.Length > 0)
|
||||
items.AddRange(packItems);
|
||||
|
||||
if (bankItems != null && bankItems.Length > 0)
|
||||
items.AddRange(bankItems);
|
||||
|
||||
foreach (Item item in items)
|
||||
{
|
||||
WritOfLease lease = item as WritOfLease;
|
||||
|
||||
if (lease != null && !lease.Expired && lease.Plot != null && lease.Plot.Bounds.Contains(p) && from.Map == lease.Plot.Map)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return MaginciaLottoSystem.IsFreeHousingZone(p, this.Map);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,173 @@
|
||||
using System;
|
||||
using Server;
|
||||
using Server.Items;
|
||||
using Server.Mobiles;
|
||||
using Server.Gumps;
|
||||
using System.Collections.Generic;
|
||||
using Server.Network;
|
||||
|
||||
namespace Server.Engines.NewMagincia
|
||||
{
|
||||
public class LottoTrackingGump : Gump
|
||||
{
|
||||
private readonly int LabelColor = 0xFFFFFF;
|
||||
private List<MaginciaHousingPlot> m_List;
|
||||
|
||||
public LottoTrackingGump() : base(50, 50)
|
||||
{
|
||||
AddBackground(0, 0, 410, 564, 9500);
|
||||
|
||||
AddHtml(205, 10, 205, 20, "<DIV ALIGN=RIGHT><Basefont Color=#FFFFFF>New Magincia Lotto Tracking</DIV>", false, false);
|
||||
AddHtml(10, 10, 205, 20, Color(String.Format("Gold Sink: {0}", MaginciaLottoSystem.GoldSink.ToString("###,###,###")), 0xFFFFFF), false, false);
|
||||
|
||||
AddHtml(45, 40, 40, 20, Color("ID", LabelColor), false, false);
|
||||
AddHtml(85, 40, 60, 20, Color("Facet", LabelColor), false, false);
|
||||
AddHtml(145, 40, 40, 20, Color("#bids", LabelColor), false, false);
|
||||
|
||||
m_List = new List<MaginciaHousingPlot>(MaginciaLottoSystem.Plots);
|
||||
|
||||
int y = 60;
|
||||
int x = 0;
|
||||
for (int i = 0; i < m_List.Count; i++)
|
||||
{
|
||||
MaginciaHousingPlot plot = m_List[i];
|
||||
|
||||
if(plot == null)
|
||||
continue;
|
||||
|
||||
int bids = 0;
|
||||
foreach(int bid in plot.Participants.Values)
|
||||
bids += bid;
|
||||
|
||||
AddButton(10 + x, y, 4005, 4007, i + 5, GumpButtonType.Reply, 0);
|
||||
AddHtml(45 + x, y, 40, 22, Color(plot.Identifier, LabelColor), false, false);
|
||||
AddHtml(85 + x, y, 60, 22, Color(plot.Map.ToString(), LabelColor), false, false);
|
||||
|
||||
if(plot.LottoOngoing)
|
||||
AddHtml(145 + x, y, 40, 22, Color(bids.ToString(), LabelColor), false, false);
|
||||
else if (plot.Complete)
|
||||
AddHtml(145 + x, y, 40, 22, Color("Owned", "red"), false, false);
|
||||
else
|
||||
AddHtml(145 + x, y, 40, 22, Color("Expired", "red"), false, false);
|
||||
|
||||
if (i == 21)
|
||||
{
|
||||
y = 60;
|
||||
x = 200;
|
||||
|
||||
AddHtml(45 + x, 40, 40, 20, Color("ID", LabelColor), false, false);
|
||||
AddHtml(85 + x, 40, 60, 20, Color("Facet", LabelColor), false, false);
|
||||
AddHtml(145 + x, 40, 40, 20, Color("#bids", LabelColor), false, false);
|
||||
}
|
||||
else
|
||||
y += 22;
|
||||
}
|
||||
}
|
||||
|
||||
private string Color(string str, int color)
|
||||
{
|
||||
return String.Format("<BASEFONT COLOR=#{0:X6}>{1}</BASEFONT>", color, str);
|
||||
}
|
||||
|
||||
private string Color(string str, string color)
|
||||
{
|
||||
return String.Format("<BASEFONT COLOR={0}>{1}</BASEFONT>", color, str);
|
||||
}
|
||||
|
||||
public override void OnResponse(NetState state, RelayInfo info)
|
||||
{
|
||||
Mobile from = state.Mobile;
|
||||
|
||||
if (info.ButtonID >= 5 && from.AccessLevel > AccessLevel.Player)
|
||||
{
|
||||
int index = info.ButtonID - 5;
|
||||
|
||||
if (index >= 0 && index < m_List.Count)
|
||||
{
|
||||
MaginciaHousingPlot plot = m_List[index];
|
||||
|
||||
if (plot != null)
|
||||
{
|
||||
from.SendGump(new PlotTrackingGump(plot));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class PlotTrackingGump : Gump
|
||||
{
|
||||
public PlotTrackingGump(MaginciaHousingPlot plot) : base(50, 50)
|
||||
{
|
||||
int partCount = plot.Participants.Count;
|
||||
int y = 544;
|
||||
int x = 600;
|
||||
|
||||
AddBackground(0, 0, x, y, 9500);
|
||||
|
||||
AddHtml(10, 10, 580, 20, String.Format("<Center><Basefont Color=#FFFFFF>Plot {0}</Center>", plot.Identifier), false, false);
|
||||
|
||||
AddHtml(10, 40, 80, 20, Color("Player", 0xFFFFFF), false, false);
|
||||
AddHtml(92, 40, 60, 20, Color("Tickets", 0xFFFFFF), false, false);
|
||||
AddHtml(154, 40, 60, 20, Color("Total Gold", 0xFFFFFF), false, false);
|
||||
|
||||
x = 0;
|
||||
y = 60;
|
||||
int goldSink = 0;
|
||||
|
||||
List<Mobile> mobiles = new List<Mobile>(plot.Participants.Keys);
|
||||
List<int> amounts = new List<int>(plot.Participants.Values);
|
||||
|
||||
for (int i = 0; i < mobiles.Count; i++)
|
||||
{
|
||||
Mobile m = mobiles[i];
|
||||
int amt = amounts[i];
|
||||
int total = amt * plot.LottoPrice;
|
||||
goldSink += total;
|
||||
|
||||
AddHtml(10 + x, y, 80, 22, Color(m.Name, 0xFFFFFF), false, false);
|
||||
AddHtml(92 + x, y, 60, 22, Color(amt.ToString(), 0xFFFFFF), false, false);
|
||||
AddHtml(154 + x, y, 60, 22, Color(total.ToString(), 0xFFFFFF), false, false);
|
||||
|
||||
if (i == 21)
|
||||
{
|
||||
x = 200;
|
||||
y = 60;
|
||||
|
||||
AddHtml(10 + x, 40, 80, 20, Color("Player", 0xFFFFFF), false, false);
|
||||
AddHtml(92 + x, 40, 60, 20, Color("Tickets", 0xFFFFFF), false, false);
|
||||
AddHtml(154 + x, 40, 60, 20, Color("Total Gold", 0xFFFFFF), false, false);
|
||||
}
|
||||
else if (i == 43)
|
||||
{
|
||||
x = 400;
|
||||
y = 60;
|
||||
|
||||
AddHtml(10 + x, 40, 80, 20, Color("Player", 0xFFFFFF), false, false);
|
||||
AddHtml(92 + x, 40, 60, 20, Color("Tickets", 0xFFFFFF), false, false);
|
||||
AddHtml(154 + x, 40, 60, 20, Color("Total Gold", 0xFFFFFF), false, false);
|
||||
}
|
||||
else
|
||||
y += 22;
|
||||
}
|
||||
|
||||
AddHtml(10, 10, 150, 20, Color(String.Format("Gold Sink: {0}", goldSink.ToString()), 0xFFFFFF), false, false);
|
||||
|
||||
AddButton(10, 544 - 32, 4014, 4016, 1, GumpButtonType.Reply, 0);
|
||||
AddHtml(45, 544 - 32, 150, 20, Color("Back", 0xFFFFFF), false, false);
|
||||
}
|
||||
|
||||
private string Color(string str, int color)
|
||||
{
|
||||
return String.Format("<BASEFONT COLOR=#{0:X6}>{1}</BASEFONT>", color, str);
|
||||
}
|
||||
|
||||
public override void OnResponse(NetState state, RelayInfo info)
|
||||
{
|
||||
Mobile from = state.Mobile;
|
||||
|
||||
if (info.ButtonID == 1)
|
||||
from.SendGump(new LottoTrackingGump());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,140 @@
|
||||
using System;
|
||||
using Server;
|
||||
using Server.Items;
|
||||
using Server.Mobiles;
|
||||
using Server.Gumps;
|
||||
using Server.Network;
|
||||
|
||||
namespace Server.Engines.NewMagincia
|
||||
{
|
||||
public class MaginciaLottoGump : Gump
|
||||
{
|
||||
private MaginciaHousingPlot m_Plot;
|
||||
private Mobile m_From;
|
||||
|
||||
private readonly int BlueColor = 0x00BFFF;
|
||||
private readonly int LabelColor = 0xFFFFFF;
|
||||
private readonly int EntryColor = 0xE9967A;
|
||||
|
||||
public MaginciaLottoGump(Mobile from, MaginciaHousingPlot plot) : base(75, 75)
|
||||
{
|
||||
m_Plot = plot;
|
||||
m_From = from;
|
||||
|
||||
bool prime = plot.IsPrimeSpot;
|
||||
|
||||
int ticketsBought = 0;
|
||||
if (plot.Participants.ContainsKey(from))
|
||||
ticketsBought = plot.Participants[from];
|
||||
|
||||
int totalTicketsSold = 0;
|
||||
foreach (int i in plot.Participants.Values)
|
||||
totalTicketsSold += i;
|
||||
|
||||
AddBackground(0, 0, 350, 380, 9500);
|
||||
|
||||
AddHtmlLocalized(10, 10, 200, 20, 1150460, BlueColor, false, false); // New Magincia Housing Lottery
|
||||
|
||||
AddHtmlLocalized(10, 50, 75, 20, 1150461, BlueColor, false, false); // This Facet:
|
||||
AddHtml(170, 50, 100, 16, String.Format("<BASEFONT COLOR=#{0:X6}>{1}</BASEFONT>", LabelColor, plot.Map.ToString()), false, false);
|
||||
|
||||
AddHtmlLocalized(10, 70, 75, 20, 1150462, BlueColor, false, false); // This Plot:
|
||||
AddHtml(170, 70, 100, 16, String.Format("<BASEFONT COLOR=#{0:X6}>{1}</BASEFONT>", EntryColor, plot.Identifier), false, false);
|
||||
|
||||
AddHtmlLocalized(10, 95, 130, 20, 1150463, BlueColor, false, false); // Total Tickets Sold:
|
||||
AddHtml(170, 95, 100, 16, String.Format("<BASEFONT COLOR=#{0:X6}>{1}</BASEFONT>", EntryColor, totalTicketsSold.ToString()), false, false);
|
||||
|
||||
AddHtmlLocalized(10, 110, 320, 40, prime ? 1150464 : 1150465, LabelColor, false, false);
|
||||
|
||||
AddHtmlLocalized(10, 160, 90, 20, 1150466, BlueColor, false, false); // Your Tickets:
|
||||
AddHtml(170, 160, 100, 20, String.Format("<BASEFONT COLOR=#{0:X6}>{1}</BASEFONT>", EntryColor, ticketsBought.ToString()), false, false);
|
||||
|
||||
if (ticketsBought == 0)
|
||||
AddHtmlLocalized(10, 175, 320, 40, 1150467, LabelColor, false, false); // You have not bought a ticket, so you have no chance of winning this plot.
|
||||
else
|
||||
{
|
||||
int odds = totalTicketsSold / ticketsBought;
|
||||
|
||||
AddHtmlLocalized(10, 175, 320, 40, 1150468, odds.ToString(), LabelColor, false, false); // Your chances of winning this plot are currently about 1 in ~1_ODDS~
|
||||
}
|
||||
|
||||
AddHtmlLocalized(10, 225, 115, 20, 1150472, BlueColor, false, false); // Price Per Ticket:
|
||||
AddHtml(170, 225, 100, 20, String.Format("<BASEFONT COLOR=#{0:X6}>{1}</BASEFONT>", EntryColor, plot.LottoPrice.ToString("###,###,###")), false, false);
|
||||
|
||||
if (plot.LottoOngoing)
|
||||
{
|
||||
if (!prime)
|
||||
{
|
||||
AddButton(310, 245, 4005, 4007, 1, GumpButtonType.Reply, 0);
|
||||
AddImageTiled(170, 245, 130, 20, 3004);
|
||||
AddTextEntry(172, 245, 126, 16, 0, 0, "");
|
||||
AddHtmlLocalized(10, 245, 100, 20, 1150477, BlueColor, false, false); // Buy Tickets
|
||||
}
|
||||
else
|
||||
{
|
||||
if (plot.CanPurchaseLottoTicket(from))
|
||||
{
|
||||
AddButton(125, 245, 4014, 4007, 2, GumpButtonType.Reply, 0);
|
||||
AddHtmlLocalized(165, 242, 100, 20, 1150469, BlueColor, false, false); // Buy Ticket
|
||||
}
|
||||
else
|
||||
AddHtmlLocalized(10, 240, 320, 40, 1150475, LabelColor, false, false); // You may not purchase another ticket for this plot's lottery.
|
||||
}
|
||||
}
|
||||
else
|
||||
AddHtml(10, 240, 320, 40, "<BASEFONT COLOR=#{0:X6}>The lottery on this plot is currently disabled.</BASEFONT>", false, false);
|
||||
|
||||
TimeSpan ts = plot.LottoEnds - DateTime.UtcNow;
|
||||
|
||||
AddHtmlLocalized(10, 300, 320, 40, 1150476, LabelColor, false, false); // Ticket purchases are NONREFUNDABLE. Odds of winning may vary.
|
||||
|
||||
if(ts.Days > 0)
|
||||
AddHtmlLocalized(10, 340, 320, 20, 1150504, ts.Days.ToString(), LabelColor, false, false); // There are ~1_DAYS~ days left before the drawing.
|
||||
else
|
||||
AddHtmlLocalized(10, 340, 320, 20, 1150503, LabelColor, false, false); // The lottery drawing will happen in less than 1 day.
|
||||
}
|
||||
|
||||
public override void OnResponse(NetState state, RelayInfo info)
|
||||
{
|
||||
bool prime = m_Plot.IsPrimeSpot;
|
||||
|
||||
if (info.ButtonID == 0)
|
||||
return;
|
||||
|
||||
if ((prime && !m_Plot.CanPurchaseLottoTicket(m_From)) || !m_Plot.LottoOngoing)
|
||||
return;
|
||||
|
||||
int pricePer = m_Plot.LottoPrice;
|
||||
int total = pricePer;
|
||||
int toBuy = 1;
|
||||
|
||||
if (!prime && info.ButtonID == 1)
|
||||
{
|
||||
toBuy = 0;
|
||||
TextRelay relay = info.GetTextEntry(0);
|
||||
string text = relay.Text;
|
||||
|
||||
try
|
||||
{
|
||||
toBuy = Convert.ToInt32(text);
|
||||
}
|
||||
catch { }
|
||||
|
||||
if (toBuy <= 0)
|
||||
return;
|
||||
}
|
||||
|
||||
if(toBuy > 1)
|
||||
total = toBuy * pricePer;
|
||||
|
||||
if (Banker.Withdraw(m_From, total))
|
||||
{
|
||||
MaginciaLottoSystem.GoldSink += total;
|
||||
m_From.SendLocalizedMessage(1150480, String.Format("{0}\t{1}\t{2}", toBuy.ToString(), pricePer.ToString(), total.ToString())); // Purchase of ~1_COUNT~ ticket(s) at ~2_PRICE~gp each costs a total of ~3_TOTAL~. The funds have been withdrawn from your bank box and your ticket purchase has been recorded.
|
||||
m_Plot.PurchaseLottoTicket(m_From, toBuy);
|
||||
}
|
||||
else
|
||||
m_From.SendLocalizedMessage(1150479, String.Format("{0}\t{1}\t{2}", toBuy.ToString(), pricePer.ToString(), total.ToString())); // Purchase of ~1_COUNT~ ticket(s) at ~2_PRICE~gp each costs a total of ~3_TOTAL~. You do not have the required funds in your bank box to make the purchase.
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,259 @@
|
||||
using System;
|
||||
using Server;
|
||||
using Server.Gumps;
|
||||
using Server.Mobiles;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Server.Engines.NewMagincia
|
||||
{
|
||||
public class NewMaginciaMessageGump : BaseGump
|
||||
{
|
||||
public List<NewMaginciaMessage> Messages;
|
||||
|
||||
public readonly int LightBlueColor = 0x4AFD;
|
||||
public readonly int GreenColor = 0x4BB7;
|
||||
|
||||
public NewMaginciaMessageGump(PlayerMobile from)
|
||||
: base(from, 490, 30)
|
||||
{
|
||||
Messages = MaginciaLottoSystem.GetMessages(from);
|
||||
}
|
||||
|
||||
public override void AddGumpLayout()
|
||||
{
|
||||
AddPage(0);
|
||||
|
||||
AddBackground(0, 0, 164, 32, 0x24B8);
|
||||
AddButton(7, 7, 0x1523, 0x1523, 1, GumpButtonType.Reply, 0);
|
||||
AddHtmlLocalized(37, 7, 120, 18, 1150425, String.Format("{0}", Messages.Count), GreenColor, false, false); // ~1_COUNT~ Messages
|
||||
}
|
||||
|
||||
public override void OnResponse(RelayInfo info)
|
||||
{
|
||||
switch (info.ButtonID)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
if (Messages.Count != 0)
|
||||
{
|
||||
SendGump(new NewMaginciaMessageGump(User));
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
SendGump(new NewMaginciaMessageListGump(User));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class NewMaginciaMessageListGump : BaseGump
|
||||
{
|
||||
public readonly int GreenColor = 0x4BB7;
|
||||
public readonly int LightBlueColor = 0x4AFD;
|
||||
|
||||
public bool Widescreen;
|
||||
public List<NewMaginciaMessage> Messages;
|
||||
|
||||
public NewMaginciaMessageListGump(PlayerMobile from, bool widescreen = false)
|
||||
: base(from, 490, 30)
|
||||
{
|
||||
Widescreen = widescreen;
|
||||
Messages = MaginciaLottoSystem.GetMessages(from);
|
||||
}
|
||||
|
||||
public override void AddGumpLayout()
|
||||
{
|
||||
if (Messages == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
AddPage(0);
|
||||
|
||||
int width = (Widescreen ? 200 : 0);
|
||||
int buttonid = (Widescreen ? 0x1519 : 0x151A);
|
||||
|
||||
AddBackground(0, 0, 314 + width, 241 + width, 0x24B8);
|
||||
AddButton(7, 7, 0x1523, 0x1523, 0, GumpButtonType.Reply, 0);
|
||||
AddButton(290 + width, 7, buttonid, buttonid, 1, GumpButtonType.Reply, 0);
|
||||
AddHtmlLocalized(47, 7, Widescreen ? 460 : 194, 18, 1150425, String.Format("{0}", Messages.Count), GreenColor, false, false); // ~1_COUNT~ Messages
|
||||
|
||||
int page = 1;
|
||||
int y = 0;
|
||||
|
||||
AddPage(page);
|
||||
|
||||
for (int i = 0; i < Messages.Count; i++)
|
||||
{
|
||||
if (page > 1)
|
||||
AddButton(Widescreen ? 446 : 246, 7, 0x1458, 0x1458, 0, GumpButtonType.Page, page - 1);
|
||||
|
||||
var message = Messages[i];
|
||||
|
||||
if (message == null)
|
||||
continue;
|
||||
|
||||
if (message.Body.Number > 0)
|
||||
{
|
||||
if (message.Args == null)
|
||||
{
|
||||
AddHtmlLocalized(47, 34 + (y * 32), 260 + width, 16, message.Body, LightBlueColor, false, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
AddHtmlLocalized(47, 34 + (y * 32), 260 + width, 16, message.Body, message.Args, LightBlueColor, false, false);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
AddHtml(40, 34 + (y * 32), 260 + width, 16, Color("#94BDEF", message.Body.String), false, false);
|
||||
}
|
||||
|
||||
AddButton(7, 34 + (y * 32), 4029, 4031, i + 1000, GumpButtonType.Reply, 0);
|
||||
|
||||
y++;
|
||||
|
||||
bool pages = Widescreen && (i + 1) % 12 == 0 || !Widescreen && (i + 1) % 6 == 0;
|
||||
|
||||
if (pages && Messages.Count - 1 != i)
|
||||
{
|
||||
AddButton(Widescreen ? 468 : 268, 7, 0x1459, 0x1459, 0, GumpButtonType.Page, page + 1);
|
||||
page++;
|
||||
y = 0;
|
||||
|
||||
AddPage(page);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnResponse(RelayInfo info)
|
||||
{
|
||||
switch (info.ButtonID)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
SendGump(new NewMaginciaMessageGump(User));
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
SendGump(new NewMaginciaMessageListGump(User, Widescreen ? false : true));
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
int id = info.ButtonID - 1000;
|
||||
|
||||
if (id >= 0 && id < Messages.Count)
|
||||
{
|
||||
SendGump(new NewMaginciaMessageDetailGump(User, Messages, id));
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class NewMaginciaMessageDetailGump : BaseGump
|
||||
{
|
||||
public NewMaginciaMessage Message;
|
||||
public List<NewMaginciaMessage> Messages;
|
||||
|
||||
public readonly int GreenColor = 0x4BB7;
|
||||
public readonly int BlueColor = 0x110;
|
||||
public readonly int EntryColor = 0x76F2;
|
||||
|
||||
public NewMaginciaMessageDetailGump(PlayerMobile from, List<NewMaginciaMessage> messages, int messageid)
|
||||
: base(from, 490, 30)
|
||||
{
|
||||
Messages = messages;
|
||||
Message = messages[messageid];
|
||||
|
||||
|
||||
}
|
||||
|
||||
public override void AddGumpLayout()
|
||||
{
|
||||
if (Message != null)
|
||||
{
|
||||
AddPage(0);
|
||||
|
||||
AddBackground(0, 0, 414, 341, 0x24B8);
|
||||
AddButton(7, 7, 0x1523, 0x1523, 0, GumpButtonType.Reply, 0);
|
||||
AddButton(390, 7, 0x1519, 0x151A, 1, GumpButtonType.Reply, 0);
|
||||
AddHtmlLocalized(47, 7, 360, 18, 1150425, String.Format("{0}", Messages.Count), GreenColor, false, false); // ~1_COUNT~ Messages
|
||||
|
||||
if (Message.Body != null)
|
||||
{
|
||||
if (Message.Body.Number != 0)
|
||||
{
|
||||
if (Message.Args == null)
|
||||
{
|
||||
AddHtmlLocalized(7, 34, 404, 150, Message.Body.Number, BlueColor, true, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
AddHtmlLocalized(7, 34, 404, 150, Message.Body.Number, Message.Args, BlueColor, true, true);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
AddHtml(7, 34, 404, 150, Color("#004284", Message.Body.String), true, true);
|
||||
}
|
||||
}
|
||||
|
||||
TimeSpan ts = Message.Expires - DateTime.UtcNow;
|
||||
|
||||
AddHtmlLocalized(7, 194, 400, 18, 1150432, String.Format("@{0}@{1}@{2}", ts.Days, ts.Hours, ts.Minutes), GreenColor, false, false); // This message will expire in ~1_DAYS~ days, ~2_HOURS~ hours, and ~3_MIN~ minutes.
|
||||
|
||||
AddHtmlLocalized(47, 212, 360, 22, 1150433, EntryColor, false, false); // DELETE NOW
|
||||
AddButton(7, 212, 4005, 4007, 2, GumpButtonType.Reply, 0);
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnResponse(RelayInfo info)
|
||||
{
|
||||
switch (info.ButtonID)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
SendGump(new NewMaginciaMessageGump(User));
|
||||
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
SendGump(new NewMaginciaMessageListGump(User));
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
{
|
||||
if (Message != null)
|
||||
{
|
||||
List<NewMaginciaMessage> messages = MaginciaLottoSystem.MessageQueue[User];
|
||||
|
||||
if (messages == null)
|
||||
{
|
||||
MaginciaLottoSystem.MessageQueue.Remove(User);
|
||||
}
|
||||
else
|
||||
{
|
||||
MaginciaLottoSystem.RemoveMessageFromQueue(User, Message);
|
||||
|
||||
if (MaginciaLottoSystem.HasMessageInQueue(User))
|
||||
{
|
||||
SendGump(new NewMaginciaMessageListGump(User));
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
using System;
|
||||
using Server;
|
||||
using Server.Items;
|
||||
using Server.Mobiles;
|
||||
using Server.Gumps;
|
||||
using System.Collections.Generic;
|
||||
using Server.Network;
|
||||
|
||||
namespace Server.Engines.NewMagincia
|
||||
{
|
||||
public class PlotWinnerGump : Gump
|
||||
{
|
||||
private MaginciaHousingPlot m_Plot;
|
||||
|
||||
private readonly int BlueColor = 0x1E90FF;
|
||||
private readonly int GreenColor = 0x7FFFD4;
|
||||
private readonly int EntryColor = 0xFF7F50;
|
||||
|
||||
public PlotWinnerGump(MaginciaHousingPlot plot) : base(75, 75)
|
||||
{
|
||||
m_Plot = plot;
|
||||
|
||||
AddBackground(0, 0, 424, 351, 9500);
|
||||
AddImage(5, 10, 5411);
|
||||
|
||||
AddHtmlLocalized(170, 13, 150, 16, 1150484, GreenColor, false, false); // WRIT OF LEASE
|
||||
|
||||
string args = String.Format("{0}\t{1}\t{2}", plot.Identifier, plot.Map, String.Format("{0} {1}", plot.Bounds.X, plot.Bounds.Y));
|
||||
AddHtmlLocalized(10, 40, 404, 180, 1150499, args, BlueColor, true, true);
|
||||
|
||||
AddButton(5, 235, 4005, 4007, 1, GumpButtonType.Reply, 0);
|
||||
AddHtmlLocalized(50, 235, 150, 16, 1150498, EntryColor, false, false); // CLAIM DEED
|
||||
}
|
||||
|
||||
public override void OnResponse(NetState state, RelayInfo info)
|
||||
{
|
||||
Mobile winner = state.Mobile;
|
||||
|
||||
if (info.ButtonID == 1)
|
||||
{
|
||||
WritOfLease writ = new WritOfLease(m_Plot);
|
||||
m_Plot.Writ = writ;
|
||||
m_Plot.Winner = null;
|
||||
|
||||
if (winner.Backpack == null || !winner.Backpack.TryDropItem(winner, writ, false))
|
||||
{
|
||||
winner.SendLocalizedMessage(1150501); // Your backpack is full, so the deed has been placed in your bank box.
|
||||
winner.BankBox.DropItem(writ);
|
||||
}
|
||||
else
|
||||
winner.SendLocalizedMessage(1150500); // The deed has been placed in your backpack.
|
||||
|
||||
MaginciaLottoSystem.GetWinnerGump(winner);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
using System;
|
||||
using Server;
|
||||
using Server.Gumps;
|
||||
using Server.Mobiles;
|
||||
using Server.Items;
|
||||
|
||||
namespace Server.Engines.NewMagincia
|
||||
{
|
||||
public class MaginciaPlotStone : Item
|
||||
{
|
||||
public override bool ForceShowProperties { get { return true; } }
|
||||
|
||||
private MaginciaHousingPlot m_Plot;
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public MaginciaHousingPlot Plot
|
||||
{
|
||||
get { return m_Plot; }
|
||||
set { m_Plot = value; }
|
||||
}
|
||||
|
||||
[Constructable]
|
||||
public MaginciaPlotStone() : base(3805)
|
||||
{
|
||||
Movable = false;
|
||||
}
|
||||
|
||||
public override void AddNameProperty(ObjectPropertyList list)
|
||||
{
|
||||
list.Add(1150494, m_Plot != null ? m_Plot.Identifier : "Unknown"); // lot ~1_PLOTID~
|
||||
}
|
||||
|
||||
public override void OnDoubleClick(Mobile from)
|
||||
{
|
||||
MaginciaLottoSystem system = MaginciaLottoSystem.Instance;
|
||||
|
||||
if (system == null || !system.Enabled || m_Plot == null)
|
||||
return;
|
||||
|
||||
if (from.InRange(this.Location, 4))
|
||||
{
|
||||
if (m_Plot.LottoOngoing)
|
||||
{
|
||||
from.CloseGump(typeof(MaginciaLottoGump));
|
||||
from.SendGump(new MaginciaLottoGump(from, m_Plot));
|
||||
}
|
||||
else if (!m_Plot.IsAvailable)
|
||||
from.SendMessage("The lottory for this lot has ended.");
|
||||
else
|
||||
from.SendMessage("The lottory for this lot has expired. Check back soon!");
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnAfterDelete()
|
||||
{
|
||||
if (m_Plot != null)
|
||||
MaginciaLottoSystem.UnregisterPlot(m_Plot);
|
||||
|
||||
base.OnAfterDelete();
|
||||
}
|
||||
|
||||
public MaginciaPlotStone(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();
|
||||
}
|
||||
}
|
||||
}
|
||||
162
Scripts/Services/New Magincia/Housing Lotto/Items/WritOfLease.cs
Normal file
162
Scripts/Services/New Magincia/Housing Lotto/Items/WritOfLease.cs
Normal file
@@ -0,0 +1,162 @@
|
||||
using System;
|
||||
using Server;
|
||||
using Server.Items;
|
||||
using Server.Gumps;
|
||||
|
||||
namespace Server.Engines.NewMagincia
|
||||
{
|
||||
public class WritOfLease : Item
|
||||
{
|
||||
public override int LabelNumber { get { return 1150489; } } // a writ of lease
|
||||
|
||||
private MaginciaHousingPlot m_Plot;
|
||||
private DateTime m_Expires;
|
||||
private bool m_Expired;
|
||||
private Map m_Facet;
|
||||
private string m_Identifier;
|
||||
private Point3D m_RecallLoc;
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public MaginciaHousingPlot Plot { get { return m_Plot; } set { m_Plot = value; } }
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public DateTime Expires { get { return m_Expires; } }
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public bool Expired { get { return m_Expired; } }
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public Map Facet { get { return m_Facet; } }
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public string Identifier { get { return m_Identifier; } }
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public Point3D RecallLoc { get { return m_RecallLoc; } }
|
||||
|
||||
public WritOfLease(MaginciaHousingPlot plot)
|
||||
: base(5358)
|
||||
{
|
||||
Hue = 0x9A;
|
||||
m_Plot = plot;
|
||||
m_Expires = plot.Expires;
|
||||
m_Expired = false;
|
||||
|
||||
if (plot != null)
|
||||
{
|
||||
m_Facet = plot.Map;
|
||||
m_Identifier = plot.Identifier;
|
||||
m_RecallLoc = plot.RecallLoc;
|
||||
}
|
||||
}
|
||||
|
||||
public override void GetProperties(ObjectPropertyList list)
|
||||
{
|
||||
base.GetProperties(list);
|
||||
|
||||
list.Add(1150547, m_Identifier != null ? m_Identifier : "Unkonwn"); // Lot: ~1_LOTNAME~
|
||||
|
||||
list.Add(m_Facet == Map.Trammel ? 1150549 : 1150548); // Facet: Felucca
|
||||
|
||||
list.Add(1150546, Server.Misc.ServerList.ServerName); // Shard: ~1_SHARDNAME~
|
||||
|
||||
if (m_Expired)
|
||||
list.Add(1150487); // [Expired]
|
||||
}
|
||||
|
||||
public override void OnDoubleClick(Mobile from)
|
||||
{
|
||||
if (from.InRange(this.GetWorldLocation(), 2))
|
||||
{
|
||||
from.CloseGump(typeof(WritNoteGump));
|
||||
from.SendGump(new WritNoteGump(this));
|
||||
}
|
||||
}
|
||||
|
||||
public void CheckExpired()
|
||||
{
|
||||
if (DateTime.UtcNow > m_Expires)
|
||||
OnExpired();
|
||||
}
|
||||
|
||||
public void OnExpired()
|
||||
{
|
||||
MaginciaLottoSystem.UnregisterPlot(m_Plot);
|
||||
m_Plot = null;
|
||||
m_Expired = true;
|
||||
m_Expires = DateTime.MinValue;
|
||||
InvalidateProperties();
|
||||
}
|
||||
|
||||
public override void Delete()
|
||||
{
|
||||
if (!m_Expired)
|
||||
OnExpired();
|
||||
|
||||
base.Delete();
|
||||
}
|
||||
|
||||
public WritOfLease(Serial serial)
|
||||
: base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
writer.Write((int)0); // version
|
||||
|
||||
writer.Write(m_Expired);
|
||||
writer.Write(m_Expires);
|
||||
writer.Write(m_Facet);
|
||||
writer.Write(m_Identifier);
|
||||
writer.Write(m_RecallLoc);
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
int version = reader.ReadInt();
|
||||
m_Expired = reader.ReadBool();
|
||||
m_Expires = reader.ReadDateTime();
|
||||
m_Facet = reader.ReadMap();
|
||||
m_Identifier = reader.ReadString();
|
||||
m_RecallLoc = reader.ReadPoint3D();
|
||||
}
|
||||
|
||||
private class WritNoteGump : Gump
|
||||
{
|
||||
private WritOfLease m_Lease;
|
||||
|
||||
public WritNoteGump(WritOfLease lease)
|
||||
: base(100, 100)
|
||||
{
|
||||
m_Lease = lease;
|
||||
|
||||
AddImage(0, 0, 9380);
|
||||
AddImage(114, 0, 9381);
|
||||
AddImage(171, 0, 9382);
|
||||
AddImage(0, 140, 9386);
|
||||
AddImage(114, 140, 9387);
|
||||
AddImage(171, 140, 9388);
|
||||
|
||||
AddHtmlLocalized(90, 5, 200, 16, 1150484, 1, false, false); // WRIT OF LEASE
|
||||
|
||||
string args;
|
||||
|
||||
if (lease.Expired)
|
||||
{
|
||||
args = String.Format("{0}\t{1}\t{2}\t{3}\t{4}", lease.Identifier, lease.Facet.ToString(), Server.Misc.ServerList.ServerName, "", String.Format("{0} {1}", lease.RecallLoc.X, lease.RecallLoc.Y));
|
||||
AddHtmlLocalized(38, 55, 215, 178, 1150488, args, 1, false, true);
|
||||
//This deed once entitled the bearer to build a house on the plot of land designated "~1_PLOT~" (located at ~5_SEXTANT~) in the City of New Magincia on the ~2_FACET~ facet of the ~3_SHARD~ shard.<br><br>The deed has expired, and now the indicated plot of land is subject to normal house construction rules.<br><br>This deed was won by lottery, and while it is no longer valid for land ownership it does serve to commemorate the winning of land during the Rebuilding of Magincia.<br><br>This deed functions as a recall rune marked for the location of the plot it represents.
|
||||
}
|
||||
else
|
||||
{
|
||||
args = String.Format("{0}\t{1}\t{2}\t{3}\t{4}", lease.Identifier, lease.Facet.ToString(), Server.Misc.ServerList.ServerName, MaginciaLottoSystem.WritExpirePeriod.ToString(), String.Format("{0} {1}", lease.RecallLoc.X, lease.RecallLoc.Y));
|
||||
AddHtmlLocalized(38, 55, 215, 178, 1150483, args, 1, false, true);
|
||||
//This deed entitles the bearer to build a house on the plot of land designated "~1_PLOT~" (located at ~5_SEXTANT~) in the City of New Magincia on the ~2_FACET~ facet of the ~3_SHARD~ shard.<br><br>The deed will expire once it is used to construct a house, and thereafter the indicated plot of land will be subject to normal house construction rules. The deed will expire after ~4_DAYS~ more days have passed, and at that time the right to place a house reverts to normal house construction rules.<br><br>This deed functions as a recall rune marked for the location of the plot it represents.<br><br>To place a house on the deeded plot, you must simply have this deed in your backpack or bank box when using a House Placement Tool there.
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user