Reorganizes Project (#41)
This commit is contained in:
parent
08bf44af9a
commit
3614a66aee
3499 changed files with 79 additions and 55 deletions
214
Projects/Scripts/Items/Special/House Raffle/HouseRaffleDeed.cs
Normal file
214
Projects/Scripts/Items/Special/House Raffle/HouseRaffleDeed.cs
Normal file
|
|
@ -0,0 +1,214 @@
|
|||
using System;
|
||||
using Server.Gumps;
|
||||
|
||||
namespace Server.Items
|
||||
{
|
||||
public class HouseRaffleDeed : Item
|
||||
{
|
||||
private Mobile m_AwardedTo;
|
||||
private Map m_Facet;
|
||||
private Point3D m_PlotLocation;
|
||||
private HouseRaffleStone m_Stone;
|
||||
|
||||
public HouseRaffleDeed(HouseRaffleStone stone = null, Mobile m = null) : base(0x2830)
|
||||
{
|
||||
m_Stone = stone;
|
||||
|
||||
if (stone != null)
|
||||
{
|
||||
m_PlotLocation = stone.GetPlotCenter();
|
||||
m_Facet = stone.PlotFacet;
|
||||
}
|
||||
|
||||
m_AwardedTo = m;
|
||||
|
||||
LootType = LootType.Blessed;
|
||||
Hue = 0x501;
|
||||
}
|
||||
|
||||
public HouseRaffleDeed(Serial serial)
|
||||
: base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster, AccessLevel.Seer)]
|
||||
public HouseRaffleStone Stone
|
||||
{
|
||||
get => m_Stone;
|
||||
set
|
||||
{
|
||||
m_Stone = value;
|
||||
InvalidateProperties();
|
||||
}
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster, AccessLevel.Seer)]
|
||||
public Point3D PlotLocation
|
||||
{
|
||||
get => m_PlotLocation;
|
||||
set
|
||||
{
|
||||
m_PlotLocation = value;
|
||||
InvalidateProperties();
|
||||
}
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster, AccessLevel.Seer)]
|
||||
public Map PlotFacet
|
||||
{
|
||||
get => m_Facet;
|
||||
set
|
||||
{
|
||||
m_Facet = value;
|
||||
InvalidateProperties();
|
||||
}
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster, AccessLevel.Seer)]
|
||||
public Mobile AwardedTo
|
||||
{
|
||||
get => m_AwardedTo;
|
||||
set
|
||||
{
|
||||
m_AwardedTo = value;
|
||||
InvalidateProperties();
|
||||
}
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster, AccessLevel.Seer)]
|
||||
public bool IsExpired => m_Stone?.Deleted != false || m_Stone.IsExpired;
|
||||
|
||||
public override string DefaultName => "a writ of lease";
|
||||
|
||||
public override double DefaultWeight => 1.0;
|
||||
|
||||
public bool ValidLocation()
|
||||
{
|
||||
return m_PlotLocation != Point3D.Zero && m_Facet != null && m_Facet != Map.Internal;
|
||||
}
|
||||
|
||||
public override void GetProperties(ObjectPropertyList list)
|
||||
{
|
||||
base.GetProperties(list);
|
||||
|
||||
if (ValidLocation())
|
||||
{
|
||||
list.Add(1060658, "location\t{0}",
|
||||
HouseRaffleStone.FormatLocation(m_PlotLocation, m_Facet, false)); // ~1_val~: ~2_val~
|
||||
list.Add(1060659, "facet\t{0}", m_Facet); // ~1_val~: ~2_val~
|
||||
list.Add(1150486); // [Marked Item]
|
||||
}
|
||||
|
||||
if (IsExpired)
|
||||
list.Add(1150487); // [Expired]
|
||||
|
||||
//list.Add( 1060660, "shard\t{0}", ServerList.ServerName ); // ~1_val~: ~2_val~
|
||||
}
|
||||
|
||||
public override void OnDoubleClick(Mobile from)
|
||||
{
|
||||
if (!ValidLocation())
|
||||
return;
|
||||
|
||||
if (IsChildOf(from.Backpack))
|
||||
{
|
||||
from.CloseGump<WritOfLeaseGump>();
|
||||
from.SendGump(new WritOfLeaseGump(this));
|
||||
}
|
||||
else
|
||||
{
|
||||
from.SendLocalizedMessage(1042001); // That must be in your pack for you to use it.
|
||||
}
|
||||
}
|
||||
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write(1); // version
|
||||
|
||||
writer.Write(m_Stone);
|
||||
writer.Write(m_PlotLocation);
|
||||
writer.Write(m_Facet);
|
||||
writer.Write(m_AwardedTo);
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
int version = reader.ReadInt();
|
||||
|
||||
switch (version)
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
m_Stone = reader.ReadItem<HouseRaffleStone>();
|
||||
|
||||
goto case 0;
|
||||
}
|
||||
case 0:
|
||||
{
|
||||
m_PlotLocation = reader.ReadPoint3D();
|
||||
m_Facet = reader.ReadMap();
|
||||
m_AwardedTo = reader.ReadMobile();
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class WritOfLeaseGump : Gump
|
||||
{
|
||||
public WritOfLeaseGump(HouseRaffleDeed deed) : base(150, 50)
|
||||
{
|
||||
AddPage(0);
|
||||
|
||||
AddImage(0, 0, 9380);
|
||||
AddImage(114, 0, 9381);
|
||||
AddImage(171, 0, 9382);
|
||||
AddImage(0, 140, 9383);
|
||||
AddImage(114, 140, 9384);
|
||||
AddImage(171, 140, 9385);
|
||||
AddImage(0, 182, 9383);
|
||||
AddImage(114, 182, 9384);
|
||||
AddImage(171, 182, 9385);
|
||||
AddImage(0, 224, 9383);
|
||||
AddImage(114, 224, 9384);
|
||||
AddImage(171, 224, 9385);
|
||||
AddImage(0, 266, 9386);
|
||||
AddImage(114, 266, 9387);
|
||||
AddImage(171, 266, 9388);
|
||||
|
||||
AddHtmlLocalized(30, 48, 229, 20, 1150484, 200); // WRIT OF LEASE
|
||||
AddHtml(28, 75, 231, 280, FormatDescription(deed), false, true);
|
||||
}
|
||||
|
||||
private static string FormatDescription(HouseRaffleDeed deed)
|
||||
{
|
||||
if (deed == null)
|
||||
return string.Empty;
|
||||
|
||||
if (deed.IsExpired)
|
||||
return "<bodytextblack>" +
|
||||
"This deed once entitled the bearer to build a house on the plot of land " +
|
||||
$"located at {HouseRaffleStone.FormatLocation(deed.PlotLocation, deed.PlotFacet, false)} on the {deed.PlotFacet} facet.<br><br>" +
|
||||
"The deed has expired, and now the indicated plot of land " +
|
||||
"is subject to normal house construction rules.<br><br>" +
|
||||
"This deed functions as a recall rune marked for the location of the plot it represents." +
|
||||
"</bodytextblack>";
|
||||
|
||||
int daysLeft = (int)Math.Ceiling((deed.Stone.Started + deed.Stone.Duration +
|
||||
HouseRaffleStone.ExpirationTime - DateTime.UtcNow).TotalDays);
|
||||
|
||||
return "<bodytextblack>" + "This deed entitles the bearer to build a house on the plot of land " +
|
||||
$"located at {HouseRaffleStone.FormatLocation(deed.PlotLocation, deed.PlotFacet, false)} on the {deed.PlotFacet} facet.<br><br>" +
|
||||
$"The deed will expire after {daysLeft} more day{(daysLeft == 1 ? "" : "s")} 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." + "</bodytextblack>";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue