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,62 @@
using Server;
using System;
using Server.Mobiles;
using Server.Items;
using Server.Gumps;
using Server.Commands;
using System.Collections.Generic;
namespace Server.Engines.NewMagincia
{
public static class NewMaginciaCommand
{
public static void Initialize()
{
CommandSystem.Register("ViewLottos", AccessLevel.GameMaster, new CommandEventHandler(ViewLottos_OnCommand));
CommandSystem.Register("GenNewMagincia", AccessLevel.GameMaster, new CommandEventHandler(GenNewMagincia_OnCommand));
CommandSystem.Register("DeleteNewMagincia", AccessLevel.Administrator, Delete);
}
private static void Delete(CommandEventArgs e)
{
}
public static void GenNewMagincia_OnCommand(CommandEventArgs e)
{
Mobile from = e.Mobile;
from.SendMessage("Generating New Magincia Bazaar System...");
if (MaginciaBazaar.Instance == null)
{
MaginciaBazaar.Instance = new MaginciaBazaar();
MaginciaBazaar.Instance.MoveToWorld(new Point3D(3729, 2058, 5), Map.Trammel);
Console.WriteLine("Generated {0} New Magincia Bazaar Stalls.", MaginciaBazaar.Plots.Count);
}
else
Console.WriteLine("Magincia Bazaar System already exists!");
Console.WriteLine("Generating New Magincia Housing Lotty System..");
if (MaginciaLottoSystem.Instance == null)
{
MaginciaLottoSystem.Instance = new MaginciaLottoSystem();
MaginciaLottoSystem.Instance.MoveToWorld(new Point3D(3718, 2049, 5), Map.Trammel);
Console.WriteLine("Generated {0} New Magincia Housing Plots.", MaginciaLottoSystem.Plots.Count);
}
else
Console.WriteLine("Magincia Housing Lotto System already exists!");
}
public static void ViewLottos_OnCommand(CommandEventArgs e)
{
if (e.Mobile.AccessLevel > AccessLevel.Player)
{
e.Mobile.CloseGump(typeof(LottoTrackingGump));
e.Mobile.SendGump(new LottoTrackingGump());
}
}
}
}

View File

@@ -0,0 +1,73 @@
using Server;
using System;
using Server.Items;
namespace Server.Engines.Distillation
{
public class CraftDefinition
{
private Group m_Group;
private Liquor m_Liquor;
private Type[] m_Ingredients;
private int[] m_Amounts;
private int[] m_Labels;
private TimeSpan m_MaturationDuration;
public Group Group { get { return m_Group; } }
public Liquor Liquor { get { return m_Liquor; } }
public Type[] Ingredients { get { return m_Ingredients; } }
public int[] Amounts { get { return m_Amounts; } }
public int[] Labels { get { return m_Labels; } }
public TimeSpan MaturationDuration { get { return m_MaturationDuration; } }
public CraftDefinition(Group group, Liquor liquor, Type[] ingredients, int[] amounts, TimeSpan matureperiod)
{
m_Group = group;
m_Liquor = liquor;
m_Ingredients = ingredients;
m_Amounts = amounts;
m_MaturationDuration = matureperiod;
m_Labels = new int[m_Ingredients.Length];
for(int i = 0; i < m_Ingredients.Length; i++)
{
Type type = m_Ingredients[i];
if(type == typeof(Yeast))
m_Labels[i] = 1150453;
else if (type == typeof(WheatWort))
m_Labels[i] = 1150275;
else if (type == typeof(PewterBowlOfCorn))
m_Labels[i] = 1025631;
else if (type == typeof(PewterBowlOfPotatos))
m_Labels[i] = 1025634;
else if (type == typeof(TribalBerry))
m_Labels[i] = 1040001;
else if (type == typeof(HoneydewMelon))
m_Labels[i] = 1023189;
else if (type == typeof(JarHoney))
m_Labels[i] = 1022540;
else if (type == typeof(Pitcher))
{
if(m_Liquor == Liquor.Brandy)
m_Labels[i] = 1028091; // pitcher of wine
else
m_Labels[i] = 1024088; // pitcher of water
}
else if (type == typeof(Dates))
m_Labels[i] = 1025927;
else
{
Item item = Loot.Construct(type);
if(item != null)
{
m_Labels[i] = item.LabelNumber;
item.Delete();
}
}
}
}
}
}

View File

@@ -0,0 +1,123 @@
using Server;
using System;
using Server.Items;
using System.Collections.Generic;
using System.IO;
namespace Server.Engines.Distillation
{
public class DistillationContext
{
private Group m_LastGroup;
private Liquor m_LastLiquor;
private Yeast[] m_SelectedYeast = new Yeast[4];
private bool m_MakeStrong;
private bool m_Mark;
private string m_Label;
public Group LastGroup { get { return m_LastGroup; } set { m_LastGroup = value; } }
public Liquor LastLiquor { get { return m_LastLiquor; } set { m_LastLiquor = value; } }
public Yeast[] SelectedYeast { get { return m_SelectedYeast; } }
public bool MakeStrong { get { return m_MakeStrong; } set { m_MakeStrong = value; } }
public bool Mark { get { return m_Mark; } set { m_Mark = value; } }
public string Label { get { return m_Label; } set { m_Label = value; } }
public DistillationContext()
{
m_LastGroup = Group.WheatBased;
m_LastLiquor = Liquor.None;
m_MakeStrong = false;
m_Mark = true;
m_Label = null;
}
public bool YeastInUse(Yeast yeast)
{
foreach(Yeast y in m_SelectedYeast)
{
if(y != null && y == yeast)
return true;
}
return false;
}
public void ClearYeasts()
{
for(int i = 0; i < m_SelectedYeast.Length; i++)
{
m_SelectedYeast[i] = null;
}
}
public DistillationContext(GenericReader reader)
{
int version = reader.ReadInt();
m_LastGroup = (Group)reader.ReadInt();
m_LastLiquor = (Liquor)reader.ReadInt();
m_MakeStrong = reader.ReadBool();
m_Mark = reader.ReadBool();
m_Label = reader.ReadString();
}
public void Serialize(GenericWriter writer)
{
writer.Write((int)0);
writer.Write((int)m_LastGroup);
writer.Write((int)m_LastLiquor);
writer.Write(m_MakeStrong);
writer.Write(m_Mark);
writer.Write(m_Label);
}
#region Serialize/Deserialize Persistence
private static string FilePath = Path.Combine("Saves", "CraftContext", "DistillationContexts.bin");
public static void Configure()
{
EventSink.WorldSave += OnSave;
EventSink.WorldLoad += OnLoad;
}
public static void OnSave(WorldSaveEventArgs e)
{
Persistence.Serialize(
FilePath,
writer =>
{
writer.Write(0); // version
writer.Write(DistillationSystem.Contexts.Count);
foreach (KeyValuePair<Mobile, DistillationContext> kvp in DistillationSystem.Contexts)
{
writer.Write(kvp.Key);
kvp.Value.Serialize(writer);
}
});
}
public static void OnLoad()
{
Persistence.Deserialize(
FilePath,
reader =>
{
int version = reader.ReadInt();
int count = reader.ReadInt();
for (int i = 0; i < count; i++)
{
Mobile m = reader.ReadMobile();
DistillationContext context = new DistillationContext(reader);
if (m != null)
DistillationSystem.Contexts[m] = context;
}
});
}
#endregion
}
}

View File

@@ -0,0 +1,497 @@
using Server;
using System;
using Server.Items;
using Server.Mobiles;
using Server.Gumps;
using Server.Prompts;
using Server.Targeting;
using Server.Network;
using System.Collections.Generic;
namespace Server.Engines.Distillation
{
public class DistillationGump : Gump
{
private const int LabelHue = 0x480;
private const int LabelColor = 0x7FFF;
private const int FontColor = 0xFFFFFF;
private DistillationContext m_Context;
private CraftDefinition m_Def;
public DistillationGump(Mobile from) : base(35, 35)
{
from.CloseGump(typeof(DistillationGump));
m_Context = DistillationSystem.GetContext(from);
Group group = m_Context.LastGroup;
Liquor liquor = m_Context.LastLiquor;
if (liquor == Liquor.None)
liquor = DistillationSystem.GetFirstLiquor(group);
m_Def = DistillationSystem.GetDefinition(liquor, group);
if (m_Def == null)
return;
if (m_Def.Liquor != liquor)
liquor = m_Def.Liquor;
AddBackground(0, 0, 500, 500, 5054);
AddImageTiled(10, 10, 480, 30, 2624);
AddImageTiled(10, 50, 230, 120, 2624);
AddImageTiled(10, 180, 230, 200, 2624);
AddImageTiled(250, 50, 240, 200, 2624);
AddImageTiled(250, 260, 240, 120, 2624);
AddImageTiled(10, 390, 480, 60, 2624);
AddImageTiled(10, 460, 480, 30, 2624);
AddAlphaRegion(10, 10, 480, 480);
AddHtmlLocalized(10, 16, 510, 20, 1150682, LabelColor, false, false); // <center>DISTILLERY MENU</center>
AddHtmlLocalized(10, 55, 230, 20, 1150683, LabelColor, false, false); // <center>Select the group</center>
AddButton(15, 80, 4005, 4007, 1, GumpButtonType.Reply, 0);
AddHtmlLocalized(55, 80, 200, 20, DistillationSystem.GetLabel(Group.WheatBased), LabelColor, false, false); // WHEAT BASED
AddButton(15, 106, 4005, 4007, 2, GumpButtonType.Reply, 0);
AddHtmlLocalized(55, 106, 200, 20, DistillationSystem.GetLabel(Group.WaterBased), LabelColor, false, false); // WATER BASED
AddButton(15, 132, 4005, 4007, 3, GumpButtonType.Reply, 0);
AddHtmlLocalized(55, 132, 200, 20, DistillationSystem.GetLabel(Group.Other), LabelColor, false, false); // OTHER
AddHtmlLocalized(10, 184, 230, 20, 1150684, LabelColor, false, false); // <center>Select the liquor type</center>
int y = 210;
for (int i = 0; i < DistillationSystem.CraftDefs.Count; i++)
{
CraftDefinition def = DistillationSystem.CraftDefs[i];
if (def.Group == group)
{
AddButton(15, y, 4005, 4007, 1000 + i, GumpButtonType.Reply, 0);
AddHtmlLocalized(55, y, 200, 20, DistillationSystem.GetLabel(def.Liquor, false), LabelColor, false, false);
y += 26;
}
}
AddHtmlLocalized(250, 54, 240, 20, 1150735, String.Format("#{0}", DistillationSystem.GetLabel(liquor, false)), LabelColor, false, false); // <center>Ingredients of ~1_NAME~</center>
y = 80;
for (int i = 0; i < m_Def.Ingredients.Length; i++)
{
Type type = m_Def.Ingredients[i];
int amt = m_Def.Amounts[i];
bool strong = m_Context.MakeStrong;
if (i == 0 && type == typeof(Yeast))
{
for (int j = 0; j < amt; j++)
{
Yeast yeast = m_Context.SelectedYeast[j];
AddHtmlLocalized(295, y, 200, 20, yeast == null ? 1150778 : 1150779, "#1150453", LabelColor, false, false); // Yeast: ~1_VAL~
AddButton(255, y, 4005, 4007, 2000 + j, GumpButtonType.Reply, 0);
y += 26;
}
continue;
}
else
{
int total = strong ? amt * 2 : amt;
int amount = DistillationTarget.GetAmount(from, type, liquor);
if (amount > total)
amount = total;
AddHtmlLocalized(295, y, 200, 20, 1150733, String.Format("#{0}\t{1}", m_Def.Labels[i], String.Format("{0}/{1}", amount.ToString(), total.ToString())), LabelColor, false, false); // ~1_NAME~ : ~2_NUMBER~
}
y += 26;
}
AddHtmlLocalized(250, 264, 240, 20, 1150770, LabelColor, false, false); // <center>Distillery Options</center>
AddButton(255, 290, 4005, 4007, 4, GumpButtonType.Reply, 0);
AddHtmlLocalized(295, 290, 200, 20, m_Context.MakeStrong ? 1150730 : 1150729, LabelColor, false, false); // Double Distillation - Standard Distillation
AddButton(255, 316, 4005, 4007, 5, GumpButtonType.Reply, 0);
AddHtmlLocalized(295, 320, 200, 20, m_Context.Mark ? 1150731 : 1150732, LabelColor, false, false); // Mark Distiller Name - Do Not Mark
AddButton(15, 395, 4005, 4007, 6, GumpButtonType.Reply, 0);
AddHtmlLocalized(55, 395, 200, 20, 1150733, String.Format("Label\t{0}", m_Context.Label == null ? "None" : m_Context.Label), LabelColor, false, false); // ~1_NAME~ : ~2_NUMBER~
AddButton(15, 465, 4005, 4007, 7, GumpButtonType.Reply, 0);
AddHtmlLocalized(55, 465, 200, 20, 1150771, LabelColor, false, false); // Execute Distillation
AddButton(455, 465, 4017, 4019, 0, GumpButtonType.Reply, 0);
AddHtmlLocalized(400, 465, 100, 20, 1060675, LabelColor, false, false); // CLOSE
}
public override void OnResponse(NetState state, RelayInfo info)
{
Mobile from = state.Mobile;
switch (info.ButtonID)
{
case 0: return;
case 1: // Select Wheat Based
m_Context.LastGroup = Group.WheatBased;
break;
case 2: // Select Water Based
m_Context.LastGroup = Group.WaterBased;
break;
case 3: // Select Other
m_Context.LastGroup = Group.Other;
break;
case 4: // Distillation Strength
if (m_Context.MakeStrong)
m_Context.MakeStrong = false;
else
m_Context.MakeStrong = true;
break;
case 5: // Mark Option
if (m_Context.Mark)
m_Context.Mark = false;
else
m_Context.Mark = true;
break;
case 6: // Label
from.Prompt = new LabelPrompt(m_Context);
from.SendLocalizedMessage(1150734); // Please enter the text with which you wish to label the liquor that you will distill. You many enter up to 15 characters. Leave the text area blank to remove any existing text.
return;
case 7: // Execute Distillation
from.Target = new DistillationTarget(from, m_Context, m_Def);
from.SendLocalizedMessage(1150810); // Target an empty liquor barrel in your backpack. If you don't have one already, you can use the Carpentry skill to make one.
return;
default:
{
if (info.ButtonID < 2000) // Select Liquor Type
{
int sel = info.ButtonID - 1000;
if (sel >= 0 && sel < DistillationSystem.CraftDefs.Count)
{
CraftDefinition def = DistillationSystem.CraftDefs[sel];
m_Context.LastLiquor = def.Liquor;
}
}
else // Select Yeast
{
int sel = info.ButtonID - 2000;
if(m_Def.Ingredients[0] == typeof(Yeast) && m_Def.Amounts.Length > 0)
{
int amt = m_Def.Amounts[0];
if (sel >= 0 && sel < amt)
{
from.Target = new YeastSelectionTarget(m_Context, sel);
from.SendLocalizedMessage(1150437); // Target the yeast in your backpack that you wish to toggle distillation item status on. Hit <ESC> to cancel.
return;
}
}
}
}
break;
}
from.SendGump(new DistillationGump(from));
}
private class LabelPrompt : Prompt
{
private DistillationContext m_Context;
public LabelPrompt(DistillationContext context)
{
m_Context = context;
}
public override void OnResponse(Mobile from, string text)
{
if (text == null || text.Length == 0)
m_Context.Label = null;
else if (text != null)
{
text = text.Trim();
if (text.Length > 15 || !Server.Guilds.BaseGuildGump.CheckProfanity(text))
from.SendMessage("That label is unacceptable. Please try again.");
else
m_Context.Label = text;
}
from.SendGump(new DistillationGump(from));
}
public override void OnCancel(Mobile from)
{
from.SendGump(new DistillationGump(from));
}
}
public class DistillationTarget : Target
{
private DistillationContext m_Context;
private CraftDefinition m_Def;
public DistillationTarget(Mobile from, DistillationContext context, CraftDefinition def)
: base(-1, false, TargetFlags.None)
{
m_Context = context;
m_Def = def;
BeginTimeout(from, TimeSpan.FromSeconds(30));
}
protected override void OnTarget(Mobile from, object targeted)
{
if (targeted is LiquorBarrel)
{
LiquorBarrel barrel = targeted as LiquorBarrel;
if (barrel.IsChildOf(from.Backpack))
{
if (barrel.IsMature)
from.SendLocalizedMessage(1150811); // This liquor barrel already contains liquor.
else if (!barrel.IsEmpty)
from.SendLocalizedMessage(1150802); // You realize that the liquor is on the process of maturation so you leave it alone.
else
{
double perc = m_Context.MakeStrong ? 2 : 1;
if (HasTotal(from, perc) && barrel != null)
{
double cooking = from.Skills[SkillName.Cooking].Value;
double alchemy = from.Skills[SkillName.Alchemy].Value / 2;
int resist = 0;
for (int i = 0; i < m_Context.SelectedYeast.Length; i++)
{
Yeast yeast = m_Context.SelectedYeast[i];
if (yeast != null)
resist += yeast.BacterialResistance;
}
int chance = (int)((cooking + alchemy + (resist * 12)) / 2.5);
if (chance > Utility.Random(100))
{
ConsumeTotal(from, perc);
m_Context.ClearYeasts();
from.SendLocalizedMessage(1150772); // You succeed at your distillation attempt.
Mobile marker = m_Context.Mark ? from : null;
from.PlaySound(0x2D6);
barrel.BeginDistillation(m_Def.Liquor, m_Def.MaturationDuration, m_Context.Label, m_Context.MakeStrong, marker);
}
else
{
from.PlaySound(0x2D6);
ConsumeTotal(from, perc / 2);
from.SendLocalizedMessage(1150745); // You have failed your distillation attempt and ingredients have been lost.
}
}
else
from.SendLocalizedMessage(1150747); // You don't have enough ingredients.
}
}
else
from.SendLocalizedMessage(1054107); // This item must be in your backpack.
}
else
from.SendMessage("That is not a liquor barrel.");
DistillationSystem.SendDelayedGump(from);
}
protected override void OnTargetCancel(Mobile from, TargetCancelType cancelType)
{
if (cancelType == TargetCancelType.Timeout)
from.SendLocalizedMessage(1150859); // You have waited too long to make your selection, your distillation attempt has timed out.
from.SendGump(new DistillationGump(from));
}
public static int GetAmount(Mobile from, Type type, Liquor liquor)
{
if (from == null || from.Backpack == null)
return 0;
Container pack = from.Backpack;
if (type == typeof(Pitcher))
{
int amount = 0;
BeverageType bType = liquor == Liquor.Brandy ? BeverageType.Wine : BeverageType.Water;
Item[] items = pack.FindItemsByType(type);
foreach (Item item in items)
{
Pitcher Pitcher = item as Pitcher;
if (Pitcher != null && Pitcher.Content == bType && Pitcher.Quantity >= Pitcher.MaxQuantity)
amount++;
}
return amount;
}
else if (type == typeof(PewterBowlOfCorn))
{
return pack.GetAmount(type) + pack.GetAmount(typeof(WoodenBowlOfCorn));
}
return pack.GetAmount(type);
}
private bool HasTotal(Mobile from, double percentage)
{
for (int i = 0; i < m_Def.Ingredients.Length; i++)
{
Type type = m_Def.Ingredients[i];
int toConsume = m_Def.Amounts[i];
if (i == 0 && type == typeof(Yeast))
{
for (int j = 0; j < toConsume; j++)
{
Yeast yeast = m_Context.SelectedYeast[j];
if (yeast == null || !yeast.IsChildOf(from.Backpack))
return false;
}
}
else
{
toConsume = (int)((double)toConsume * percentage);
if (GetAmount(from, type, m_Def.Liquor) < toConsume)
return false;
}
}
return true;
}
private void ConsumeTotal(Mobile from, double percentage)
{
if (from == null || from.Backpack == null)
return;
Container pack = from.Backpack;
for (int i = 0; i < m_Def.Ingredients.Length; i++)
{
Type type = m_Def.Ingredients[i];
int toConsume = m_Def.Amounts[i];
if (i == 0 && type == typeof(Yeast))
{
for (int j = 0; j < toConsume; j++)
{
Yeast yeast = m_Context.SelectedYeast[j];
if (yeast != null)
yeast.Consume();
}
}
else if (type == typeof(Pitcher))
{
toConsume = (int)((double)toConsume * percentage);
BeverageType bType = m_Def.Liquor == Liquor.Brandy ? BeverageType.Wine : BeverageType.Water;
Item[] items = pack.FindItemsByType(type);
foreach (Item item in items)
{
Pitcher Pitcher = item as Pitcher;
if (Pitcher != null && Pitcher.Content == bType && Pitcher.Quantity >= Pitcher.MaxQuantity)
{
Pitcher.Quantity = 0;
toConsume--;
}
if (toConsume <= 0)
break;
}
}
else if (type == typeof(PewterBowlOfCorn))
{
toConsume = (int)((double)toConsume * percentage);
int totalPewter = pack.GetAmount(type);
int totalWooden = pack.GetAmount(typeof(WoodenBowlOfCorn));
if (totalPewter >= toConsume)
pack.ConsumeTotal(type, toConsume);
else
{
pack.ConsumeTotal(type, totalPewter);
toConsume -= totalPewter;
pack.ConsumeTotal(typeof(WoodenBowlOfCorn), toConsume);
}
}
else
{
toConsume = (int)((double)toConsume * percentage);
pack.ConsumeTotal(type, toConsume);
}
}
}
}
private class YeastSelectionTarget : Target
{
private int m_Index;
private DistillationContext m_Context;
public YeastSelectionTarget(DistillationContext context, int index)
: base(-1, false, TargetFlags.None)
{
m_Index = index;
m_Context = context;
}
protected override void OnTarget(Mobile from, object targeted)
{
if (targeted is Yeast)
{
Yeast yeast = targeted as Yeast;
if (yeast.IsChildOf(from.Backpack))
{
if (!m_Context.YeastInUse(yeast))
{
m_Context.SelectedYeast[m_Index] = yeast;
from.SendLocalizedMessage(1150740); // You have chosen the yeast.
}
else
from.SendLocalizedMessage(1150742); // You have already chosen other yeast.
}
else
from.SendLocalizedMessage(1054107); // This item must be in your backpack.
}
else
from.SendLocalizedMessage(1150741); // That is not yeast.
from.SendGump(new DistillationGump(from));
}
protected override void OnTargetCancel(Mobile from, TargetCancelType cancelType)
{
if (m_Context.SelectedYeast[m_Index] != null)
{
m_Context.SelectedYeast[m_Index] = null;
from.SendLocalizedMessage(1150743); // You no longer choose this yeast.
}
from.SendGump(new DistillationGump(from));
}
}
}
}

View File

@@ -0,0 +1,138 @@
using Server;
using System;
using Server.Items;
using System.Collections.Generic;
namespace Server.Engines.Distillation
{
public enum Group
{
WheatBased,
WaterBased,
Other
}
public enum Liquor
{
None,
Whiskey,
Bourbon,
Spirytus,
Cassis,
MelonLiquor,
Mist,
Akvavit,
Arak,
CornWhiskey,
Brandy
}
public class DistillationSystem
{
public static readonly TimeSpan MaturationPeriod = TimeSpan.FromHours(48);
private static List<CraftDefinition> m_CraftDefs = new List<CraftDefinition>();
public static List<CraftDefinition> CraftDefs { get { return m_CraftDefs; } }
private static Dictionary<Mobile, DistillationContext> m_Contexts = new Dictionary<Mobile, DistillationContext>();
public static Dictionary<Mobile, DistillationContext> Contexts { get { return m_Contexts; } }
public static void Initialize()
{
// Wheat Based
m_CraftDefs.Add(new CraftDefinition(Group.WheatBased, Liquor.Whiskey, new Type[] { typeof(Yeast), typeof(WheatWort) }, new int[] { 3, 1 }, MaturationPeriod ) );
m_CraftDefs.Add(new CraftDefinition(Group.WheatBased, Liquor.Bourbon, new Type[] { typeof(Yeast), typeof(WheatWort), typeof(PewterBowlOfCorn) }, new int[] { 3, 3, 1 }, MaturationPeriod ) );
m_CraftDefs.Add(new CraftDefinition(Group.WheatBased, Liquor.Spirytus, new Type[] { typeof(Yeast), typeof(WheatWort), typeof(PewterBowlOfPotatos) }, new int[] { 3, 1, 1 }, TimeSpan.MinValue ) );
m_CraftDefs.Add(new CraftDefinition(Group.WheatBased, Liquor.Cassis, new Type[] { typeof(Yeast), typeof(WheatWort), typeof(PewterBowlOfPotatos), typeof(TribalBerry) }, new int[] { 3, 3, 3, 1 }, MaturationPeriod ) );
m_CraftDefs.Add(new CraftDefinition(Group.WheatBased, Liquor.MelonLiquor, new Type[] { typeof(Yeast), typeof(WheatWort), typeof(PewterBowlOfPotatos), typeof(HoneydewMelon) }, new int[] { 3, 3, 3, 1 }, MaturationPeriod ) );
m_CraftDefs.Add(new CraftDefinition(Group.WheatBased, Liquor.Mist, new Type[] { typeof(Yeast), typeof(WheatWort), typeof(JarHoney) }, new int[] { 3, 3, 1 }, MaturationPeriod ) );
// Water Based
m_CraftDefs.Add(new CraftDefinition(Group.WaterBased, Liquor.Akvavit, new Type[] { typeof(Yeast), typeof(Pitcher), typeof(PewterBowlOfPotatos) }, new int[] { 1, 3, 1 }, TimeSpan.MinValue ) );
m_CraftDefs.Add(new CraftDefinition(Group.WaterBased, Liquor.Arak, new Type[] { typeof(Yeast), typeof(Pitcher), typeof(Dates) }, new int[] { 1, 3, 1 }, MaturationPeriod ) );
m_CraftDefs.Add(new CraftDefinition(Group.WaterBased, Liquor.CornWhiskey, new Type[] { typeof(Yeast), typeof(Pitcher), typeof(PewterBowlOfCorn) }, new int[] { 1, 3, 1 }, MaturationPeriod ) );
// Other
m_CraftDefs.Add(new CraftDefinition(Group.Other, Liquor.Brandy, new Type[] { typeof(Pitcher) }, new int[] { 4 }, MaturationPeriod ) );
}
public static void AddContext(Mobile from, DistillationContext context)
{
if(from != null)
m_Contexts[from] = context;
}
public static DistillationContext GetContext(Mobile from)
{
if(from == null)
return null;
if(!m_Contexts.ContainsKey(from))
m_Contexts[from] = new DistillationContext();
return m_Contexts[from];
}
public static int GetLabel(Liquor liquor, bool strong)
{
if(strong)
return 1150718 + (int)liquor;
return 1150442 + (int)liquor;
}
public static int GetLabel(Group group)
{
if(group == Group.Other)
return 1077435;
return 1150736 + (int)group;
}
public static Liquor GetFirstLiquor(Group group)
{
foreach(CraftDefinition def in m_CraftDefs)
{
if(def.Group == group)
return def.Liquor;
}
return Liquor.Whiskey;
}
public static CraftDefinition GetFirstDefForGroup(Group group)
{
foreach (CraftDefinition def in m_CraftDefs)
{
if (def.Group == group)
return def;
}
return null;
}
public static CraftDefinition GetDefinition(Liquor liquor, Group group)
{
foreach(CraftDefinition def in m_CraftDefs)
{
if(def.Liquor == liquor && def.Group == group)
return def;
}
return GetFirstDefForGroup(group);
}
public static void SendDelayedGump(Mobile from)
{
Timer.DelayCall(TimeSpan.FromSeconds(1.5), new TimerStateCallback(SendGump), from);
}
public static void SendGump(object o)
{
Mobile from = o as Mobile;
if(from != null)
from.SendGump(new DistillationGump(from));
}
}
}

View File

@@ -0,0 +1,100 @@
using Server;
using System;
using Server.Items;
namespace Server.Engines.Distillation
{
public class BottleOfLiquor : BeverageBottle
{
private Liquor m_Liquor;
private string m_Label;
private bool m_IsStrong;
private Mobile m_Distiller;
[CommandProperty(AccessLevel.GameMaster)]
public Liquor Liquor { get { return m_Liquor; } set { m_Liquor = value; InvalidateProperties(); } }
[CommandProperty(AccessLevel.GameMaster)]
public string Label { get { return m_Label; } set { m_Label = value; InvalidateProperties(); } }
[CommandProperty(AccessLevel.GameMaster)]
public bool IsStrong { get { return m_IsStrong; } set { m_IsStrong = value; InvalidateProperties(); } }
[CommandProperty(AccessLevel.GameMaster)]
public Mobile Distiller { get { return m_Distiller; } set { m_Distiller = value; InvalidateProperties(); } }
public override bool ShowQuantity { get { return false; } }
[Constructable]
public BottleOfLiquor() : this(Liquor.Whiskey, null, false, null)
{
}
[Constructable]
public BottleOfLiquor(Liquor liquor, string label, bool isstrong, Mobile distiller) : base(BeverageType.Liquor)
{
Quantity = MaxQuantity;
m_Liquor = liquor;
m_Label = label;
m_IsStrong = isstrong;
m_Distiller = distiller;
}
public override void AddNameProperty(ObjectPropertyList list)
{
if(m_Label != null && m_Label.Length > 0)
list.Add(1049519, m_Label); // a bottle of ~1_DRINK_NAME~
else
list.Add(1049519, String.Format("#{0}", DistillationSystem.GetLabel(m_Liquor, m_IsStrong))); // a bottle of ~1_DRINK_NAME~
}
public override void GetProperties(ObjectPropertyList list)
{
base.GetProperties(list);
if(m_Liquor != Liquor.None)
list.Add(1150454, String.Format("#{0}", DistillationSystem.GetLabel(m_Liquor, m_IsStrong))); // Liquor Type: ~1_TYPE~
if (m_Distiller != null)
list.Add(1150679, m_Distiller.Name); // Distiller: ~1_NAME~
list.Add( GetQuantityDescription() );
}
public BottleOfLiquor(Serial serial) : base(serial)
{
}
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.Write((int)1);
writer.Write(m_IsStrong);
writer.Write((int)m_Liquor);
writer.Write(m_Label);
writer.Write(m_Distiller);
}
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
int version = reader.ReadInt();
switch (version)
{
case 1:
m_IsStrong = reader.ReadBool();
goto case 0;
case 0:
m_Liquor = (Liquor)reader.ReadInt();
m_Label = reader.ReadString();
m_Distiller = reader.ReadMobile();
m_IsStrong = true;
break;
}
}
}
}

View File

@@ -0,0 +1,214 @@
using Server;
using System;
using Server.Engines.Distillation;
using Server.Mobiles;
using Server.Engines.Craft;
namespace Server.Items
{
public class LiquorBarrel : Item, ICraftable
{
private Liquor m_Liquor;
private DateTime m_MaturationBegin;
private TimeSpan m_MaturationDuration;
private string m_Label;
private bool m_IsStrong;
private int m_UsesRemaining;
private bool m_Exceptional;
private Mobile m_Crafter;
private Mobile m_Distiller;
[CommandProperty(AccessLevel.GameMaster)]
public Liquor Liquor { get { return m_Liquor; } set { BeginDistillation(value); InvalidateProperties(); } }
[CommandProperty(AccessLevel.GameMaster)]
public DateTime MaturationBegin { get { return m_MaturationBegin; } set { m_MaturationBegin = value; InvalidateProperties(); } }
[CommandProperty(AccessLevel.GameMaster)]
public TimeSpan MutrationDuration { get { return m_MaturationDuration; } }
[CommandProperty(AccessLevel.GameMaster)]
public string Label { get { return m_Label; } set { m_Label = value; InvalidateProperties(); } }
[CommandProperty(AccessLevel.GameMaster)]
public bool IsStrong { get { return m_IsStrong; } set { m_IsStrong = value; InvalidateProperties(); } }
[CommandProperty(AccessLevel.GameMaster)]
public int UsesRemaining { get { return m_UsesRemaining; } set { m_UsesRemaining = value; InvalidateProperties(); } }
[CommandProperty(AccessLevel.GameMaster)]
public bool Exceptional { get { return m_Exceptional; } set { m_Exceptional = value; InvalidateProperties(); } }
[CommandProperty(AccessLevel.GameMaster)]
public Mobile Crafter { get { return m_Crafter; } set { m_Crafter = value; InvalidateProperties(); } }
[CommandProperty(AccessLevel.GameMaster)]
public Mobile Distiller { get { return m_Distiller; } set { m_Distiller = value; InvalidateProperties(); } }
[CommandProperty(AccessLevel.GameMaster)]
public virtual bool IsMature { get { return m_Liquor != Liquor.None && (m_MaturationDuration == TimeSpan.MinValue || m_MaturationBegin + m_MaturationDuration < DateTime.UtcNow); } }
[CommandProperty(AccessLevel.GameMaster)]
public bool IsEmpty { get { return m_Liquor == Liquor.None; } }
public override int LabelNumber { get { return m_UsesRemaining == 0 || m_Liquor == Liquor.None ? 1150816 : 1150807; } } // liquor barrel
public override double DefaultWeight { get { return 5.0; } }
[Constructable]
public LiquorBarrel()
: base(4014)
{
m_Liquor = Liquor.None;
m_UsesRemaining = 0;
}
public override void OnDoubleClick(Mobile from)
{
if (IsChildOf(from.Backpack) && m_UsesRemaining > 0)
{
if (IsMature)
{
BottleOfLiquor bottle = new BottleOfLiquor(m_Liquor, m_Label, m_IsStrong, m_Distiller);
if (from.Backpack == null || !from.Backpack.TryDropItem(from, bottle, false))
{
bottle.Delete();
from.SendLocalizedMessage(500720); // You don't have enough room in your backpack!
}
else
{
from.PlaySound(0x240);
from.SendMessage("You pour the liquior into a bottle and place it in your backpack.");
m_UsesRemaining--;
}
}
else
{
from.SendLocalizedMessage(1150806); // You need to wait until the liquor in the barrel has matured.
if (DateTime.UtcNow < m_MaturationBegin + m_MaturationDuration)
{
TimeSpan remaining = (m_MaturationBegin + m_MaturationDuration) - DateTime.UtcNow;
if (remaining.TotalDays > 0)
from.SendLocalizedMessage(1150814, String.Format("{0}\t{1}", remaining.Days.ToString(), remaining.Hours.ToString()));
else
from.SendLocalizedMessage(1150813, remaining.TotalHours.ToString());
}
}
}
}
public override void GetProperties(ObjectPropertyList list)
{
base.GetProperties(list);
if (m_Crafter != null)
list.Add(1050043, m_Crafter.Name); // Crafted By: ~1_Name~
if (m_Exceptional)
list.Add(1018303); // Exceptional
if (!IsEmpty)
{
if (IsMature)
list.Add(1060584, m_UsesRemaining.ToString()); // uses remaining: ~1_val~
list.Add(1150805, m_MaturationBegin.ToShortDateString()); // start date: ~1_NAME~
int cliloc = IsMature ? 1150804 : 1150812; // maturing: ~1_NAME~ / // matured: ~1_NAME~
if (m_Label == null)
list.Add(cliloc, String.Format("#{0}", DistillationSystem.GetLabel(m_Liquor, m_IsStrong)));
else
list.Add(cliloc, m_Label);
list.Add(1150454, String.Format("#{0}", DistillationSystem.GetLabel(m_Liquor, m_IsStrong))); // Liquor Type: ~1_TYPE~
if (m_Distiller != null)
list.Add(1150679, m_Distiller.Name); // Distiller: ~1_NAME~
}
}
public void BeginDistillation(Liquor liquor)
{
TimeSpan ts;
if (liquor == Liquor.Spirytus || liquor == Liquor.Akvavit)
ts = TimeSpan.MinValue;
else
ts = DistillationSystem.MaturationPeriod;
BeginDistillation(liquor, ts, m_Label, m_IsStrong, m_Distiller);
}
public void BeginDistillation(Liquor liquor, TimeSpan duration, string label, bool isStrong, Mobile distiller)
{
m_Liquor = liquor;
m_MaturationDuration = duration;
m_Label = label;
m_IsStrong = isStrong;
m_Distiller = distiller;
m_MaturationBegin = DateTime.UtcNow;
m_UsesRemaining = m_Exceptional ? 20 : 10;
InvalidateProperties();
}
public virtual int OnCraft(int quality, bool makersMark, Mobile from, CraftSystem craftSystem, Type typeRes, ITool tool, CraftItem craftItem, int resHue)
{
if (quality >= 2)
{
m_Exceptional = true;
if (makersMark)
m_Crafter = from;
}
if (typeRes == null)
typeRes = craftItem.Resources.GetAt(0).ItemType;
CraftResource resource = CraftResources.GetFromType(typeRes);
Hue = CraftResources.GetHue(resource);
return quality;
}
public LiquorBarrel(Serial serial)
: base(serial)
{
}
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.Write((int)0);
writer.Write((int)m_Liquor);
writer.Write(m_MaturationBegin);
writer.Write(m_MaturationDuration);
writer.Write(m_Label);
writer.Write(m_IsStrong);
writer.Write(m_UsesRemaining);
writer.Write(m_Exceptional);
writer.Write(m_Crafter);
writer.Write(m_Distiller);
}
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
int version = reader.ReadInt();
m_Liquor = (Liquor)reader.ReadInt();
m_MaturationBegin = reader.ReadDateTime();
m_MaturationDuration = reader.ReadTimeSpan();
m_Label = reader.ReadString();
m_IsStrong = reader.ReadBool();
m_UsesRemaining = reader.ReadInt();
m_Exceptional = reader.ReadBool();
m_Crafter = reader.ReadMobile();
m_Distiller = reader.ReadMobile();
}
}
}

View File

@@ -0,0 +1,33 @@
using System;
using Server;
namespace Server.Items
{
public class MetalKeg : Keg
{
public override int LabelNumber { get { return 1150675; } }
[Constructable]
public MetalKeg()
{
}
public MetalKeg( 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,44 @@
using Server;
using System;
using Server.Engines.Distillation;
namespace Server.Items
{
public class WheatWort : Item
{
public override int LabelNumber { get { return 1150275; } } // wheat wort
[Constructable]
public WheatWort() : this(1)
{
}
[Constructable]
public WheatWort(int num)
: base(0x1848)
{
Stackable = true;
Amount = num;
Hue = 1281;
}
public WheatWort(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)
ItemID = 0x1848;
}
}
}

View File

@@ -0,0 +1,92 @@
using Server;
using System;
using Server.Engines.Distillation;
namespace Server.Items
{
public class Yeast : Item
{
private int m_BacterialResistance;
[CommandProperty(AccessLevel.GameMaster)]
public int BacterialResistance
{
get { return m_BacterialResistance; }
set
{
m_BacterialResistance = value;
if(m_BacterialResistance < 1) m_BacterialResistance = 1;
if(m_BacterialResistance > 5) m_BacterialResistance = 5;
InvalidateProperties();
}
}
public override int LabelNumber { get { return 1150453; } } // yeast
[Constructable]
public Yeast() : base(3624)
{
Hue = 2418;
int ran = Utility.Random(100);
if(ran <= 5)
m_BacterialResistance = 5;
else if (ran <= 10)
m_BacterialResistance = 4;
else if (ran <= 20)
m_BacterialResistance = 3;
else if (ran <= 40)
m_BacterialResistance = 2;
else
m_BacterialResistance = 1;
}
[Constructable]
public Yeast(int resistance) : base(3624)
{
BacterialResistance = resistance;
}
public override void GetProperties(ObjectPropertyList list)
{
base.GetProperties(list);
list.Add(1150455, GetResistanceLabel()); // Bacterial Resistance: ~1_VAL~
}
private string GetResistanceLabel()
{
switch(m_BacterialResistance)
{
default:
case 5: return "++";
case 4: return "+";
case 3: return "+-";
case 2: return "-";
case 1: return "--";
}
}
public Yeast(Serial serial) : base(serial)
{
}
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.Write((int)0);
writer.Write(m_BacterialResistance);
}
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
int version = reader.ReadInt();
m_BacterialResistance = reader.ReadInt();
}
}
}

View File

@@ -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);
}
}
}
}

View File

@@ -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);
}
}
}
}
}

View File

@@ -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();
}
}
}

View 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);
}
}
}

View File

@@ -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());
}
}
}

View File

@@ -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.
}
}
}

View File

@@ -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;
}
}
}
}
}

View File

@@ -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);
}
}
}
}

View File

@@ -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();
}
}
}

View 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.
}
}
}
}
}

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();
}
}
}
}

View File

@@ -0,0 +1,88 @@
using System;
using Server.Targeting;
using Server.Engines.Plants;
namespace Server.Items
{
public class GardeningContract : Item
{
public override int LabelNumber { get { return 1155764; } } // Gardening Contract
[Constructable]
public GardeningContract()
: base(0x14F0)
{
Weight = 1.0;
}
public GardeningContract(Serial serial)
: base(serial)
{
}
public override void OnDoubleClick(Mobile from)
{
if (!IsChildOf(from.Backpack))
{
from.SendLocalizedMessage(1080058); // This must be in your backpack to use it.
}
else
{
from.SendLocalizedMessage(1155765); // Target the New Magincia plant you wish to have a gardener tend to...
from.Target = new InternalTarget(this);
}
}
private class InternalTarget : Target
{
private readonly Item m_Item;
public InternalTarget(Item item)
: base(2, true, TargetFlags.None)
{
m_Item = item;
}
protected override void OnTarget(Mobile from, object targeted)
{
if (targeted is MaginciaPlantItem)
{
MaginciaPlantItem plant = (MaginciaPlantItem)targeted;
if (!plant.IsContract)
{
if (plant.ContractTime.Month == DateTime.UtcNow.Month)
{
from.SendLocalizedMessage(1155760); // You may do this once every other month.
return;
}
plant.ContractTime = DateTime.UtcNow;
from.SendLocalizedMessage(1155762); // You have hired a gardener to tend to your plant. The gardener will no longer tend to your plant when server maintenance occurs after the expiration date of your gardening contract. While a gardener is tending to your plant you will not have to care for it.
m_Item.Delete();
}
else
{
from.SendLocalizedMessage(1155761); // A Gardener is already tending to this plant.
}
}
else
{
from.SendLocalizedMessage(1155759); // This item can only be used on New Magincia Gardening Plants.
}
}
}
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,143 @@
using System;
using Server;
using Server.Targeting;
using Server.Engines.Plants;
using Server.Network;
namespace Server.Items
{
public class Hoe : BaseAxe, IUsesRemaining
{
public override int LabelNumber { get { return 1150482; } } // hoe
[Constructable]
public Hoe()
: base(0xE86)
{
Hue = 2524;
Weight = 11.0;
UsesRemaining = 50;
ShowUsesRemaining = true;
}
public override WeaponAbility PrimaryAbility { get { return WeaponAbility.DoubleStrike; } }
public override WeaponAbility SecondaryAbility { get { return WeaponAbility.Disarm; } }
public override int AosStrengthReq { get { return 50; } }
public override int AosMinDamage { get { return 12; } }
public override int AosMaxDamage { get { return 16; } }
public override int AosSpeed { get { return 35; } }
public override float MlSpeed { get { return 3.00f; } }
public override int InitMinHits { get { return 31; } }
public override int InitMaxHits { get { return 60; } }
public override bool CanBeWornByGargoyles { get { return true; } }
public override WeaponAnimation DefAnimation { get { return WeaponAnimation.Slash1H; } }
public override void OnDoubleClick(Mobile from)
{
if (IsChildOf(from.Backpack))
{
from.Target = new InternalTarget(this);
}
}
private class InternalTarget : Target
{
private readonly Hoe m_Hoe;
public InternalTarget(Hoe hoe)
: base(2, true, TargetFlags.None)
{
m_Hoe = hoe;
}
protected override void OnTarget(Mobile from, object targeted)
{
if (!MaginciaPlantSystem.Enabled)
{
from.SendMessage("Magincia plant placement is currently disabled.");
return;
}
Map map = from.Map;
if (targeted is LandTarget && map != null)
{
LandTarget lt = (LandTarget)targeted;
Region r = Region.Find(lt.Location, map);
if (r != null && r.IsPartOf("Magincia") && (lt.Name == "dirt" || lt.Name == "grass"))
{
if (MaginciaPlantSystem.CanAddPlant(from, lt.Location))
{
if (!MaginciaPlantSystem.CheckDelay(from))
{
return;
}
else if (from.Mounted || from.Flying)
{
from.SendLocalizedMessage(501864); // You can't mine while riding.
}
else if (from.IsBodyMod && !from.Body.IsHuman)
{
from.SendLocalizedMessage(501865); // You can't mine while polymorphed.
}
else
{
m_Hoe.UsesRemaining--;
from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1150492); // You till a small area to plant.
from.Animate(AnimationType.Attack, 3);
MaginciaPlantItem dirt = new MaginciaPlantItem();
dirt.Owner = from;
dirt.StartTimer();
MaginciaPlantSystem.OnPlantPlanted(from, from.Map);
Timer.DelayCall(TimeSpan.FromSeconds(.7), new TimerStateCallback(MoveItem_Callback), new object[] { dirt, lt.Location, map });
}
}
}
else
{
from.SendLocalizedMessage(1150457); // The ground here is not good for gardening.
}
}
}
private void MoveItem_Callback(object o)
{
object[] objs = o as object[];
if (objs != null)
{
Item dirt = objs[0] as Item;
Point3D p = (Point3D)objs[1];
Map map = objs[2] as Map;
if (dirt != null)
dirt.MoveToWorld(p, map);
}
}
}
public Hoe(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,258 @@
using Server;
using System;
using Server.Network;
namespace Server.Engines.Plants
{
public class MaginciaPlantItem : PlantItem
{
public override bool MaginciaPlant { get { return true; } }
public override int BowlOfDirtID { get { return 2323; } }
public override int GreenBowlID
{
get
{
if (PlantStatus <= PlantStatus.Stage3)
return 0xC7E;
else
return 0xC62;
}
}
public override int ContainerLocalization { get { return 1150436; } } // mound of dirt
public override int OnPlantLocalization { get { return 1150442; } } // You plant the seed in the mound of dirt.
public override int CantUseLocalization { get { return 501648; } } // You cannot use this unless you are the owner.
public override int LabelNumber
{
get
{
int label = base.LabelNumber;
if (label == 1029913)
label = 1022321; // patch of dirt
return label;
}
}
private DateTime m_Planted;
private DateTime m_Contract;
private Timer m_Timer;
[CommandProperty(AccessLevel.GameMaster)]
public Mobile Owner { get; set; }
[CommandProperty(AccessLevel.GameMaster)]
public DateTime Planted { get { return m_Planted; } set { m_Planted = value; InvalidateProperties(); } }
[CommandProperty(AccessLevel.GameMaster)]
public DateTime ContractTime { get { return m_Contract; } set { m_Contract = value; InvalidateProperties(); } }
[CommandProperty(AccessLevel.GameMaster)]
public DateTime ContractEndTime => ContractTime + TimeSpan.FromDays(14);
[CommandProperty(AccessLevel.GameMaster)]
public bool IsContract => ContractEndTime > DateTime.UtcNow;
[CommandProperty(AccessLevel.GameMaster)]
public DateTime SetToDecorative { get; set; }
[CommandProperty(AccessLevel.GameMaster)]
public override bool ValidGrowthLocation
{
get
{
return RootParent == null && !Movable;
}
}
[Constructable]
public MaginciaPlantItem()
: this(false)
{
}
[Constructable]
public MaginciaPlantItem(bool fertile)
: base(2323, fertile)
{
Movable = false;
Planted = DateTime.UtcNow;
}
public override void OnDoubleClick(Mobile from)
{
if (PlantStatus >= PlantStatus.DecorativePlant)
return;
Point3D loc = GetWorldLocation();
if (!from.InLOS(loc) || !from.InRange(loc, 2))
{
from.LocalOverheadMessage(MessageType.Regular, 0x3E9, 1019045); // I can't reach that.
return;
}
if (!IsUsableBy(from))
{
LabelTo(from, CantUseLocalization);
return;
}
from.SendGump(new MainPlantGump(this));
}
public override bool IsUsableBy(Mobile from)
{
return RootParent == null && !Movable && Owner == from && IsAccessibleTo(from);
}
public override void Die()
{
base.Die();
Timer.DelayCall(TimeSpan.FromMinutes(Utility.RandomMinMax(2, 5)), new TimerCallback(Delete));
}
public override void Delete()
{
if (Owner != null && PlantStatus < PlantStatus.DecorativePlant)
MaginciaPlantSystem.OnPlantDelete(Owner, Map);
base.Delete();
}
public override void GetProperties(ObjectPropertyList list)
{
base.GetProperties(list);
if (Owner != null)
{
list.Add(1150474, string.Format("{0}\t{1}", "#1011345", Owner.Name)); // Planted in ~1_val~ by: ~2_val~
list.Add(1150478, m_Planted.ToShortDateString());
if (IsContract)
{
DateTime easternTime = TimeZoneInfo.ConvertTimeFromUtc(ContractEndTime, TimeZoneInfo.FindSystemTimeZoneById("Eastern Standard Time"));
list.Add(1155763, easternTime.ToString("MM-dd-yyyy HH:mm 'ET'")); // Gardening Contract Expires: ~1_TIME~
}
if (PlantStatus == PlantStatus.DecorativePlant)
list.Add(1150490, SetToDecorative.ToShortDateString()); // Date harvested: ~1_val~
}
}
public void StartTimer()
{
m_Timer = Timer.DelayCall(TimeSpan.FromMinutes(2), new TimerCallback(Delete));
}
public override bool PlantSeed(Mobile from, Seed seed)
{
if (!CheckLocation(from, seed) || !base.PlantSeed(from, seed))
return false;
if (m_Timer != null)
{
m_Timer.Stop();
m_Timer = null;
}
return true;
}
private bool CheckLocation(Mobile from, Seed seed)
{
if (!BlocksMovement(seed))
return true;
IPooledEnumerable eable = Map.GetItemsInRange(Location, 1);
foreach (Item item in eable)
{
if (item != this && item is MaginciaPlantItem)
{
if (((MaginciaPlantItem)item).BlocksMovement())
{
eable.Free();
from.SendLocalizedMessage(1150434); // Plants that block movement cannot be planted next to other plants that block movement.
return false;
}
}
}
eable.Free();
return true;
}
public bool BlocksMovement()
{
if (PlantStatus == PlantStatus.BowlOfDirt || PlantStatus == PlantStatus.DeadTwigs)
return false;
PlantTypeInfo info = PlantTypeInfo.GetInfo(PlantType);
ItemData data = TileData.ItemTable[info.ItemID & TileData.MaxItemValue];
TileFlag flags = data.Flags;
return (flags & TileFlag.Impassable) > 0;
}
public static bool BlocksMovement(Seed seed)
{
PlantTypeInfo info = PlantTypeInfo.GetInfo(seed.PlantType);
ItemData data = TileData.ItemTable[info.ItemID & TileData.MaxItemValue];
TileFlag flags = data.Flags;
return (flags & TileFlag.Impassable) > 0;
}
public MaginciaPlantItem(Serial serial)
: base(serial)
{
}
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.Write((int)1); // version
writer.Write(ContractTime);
writer.Write(Owner);
writer.Write(m_Planted);
writer.Write(SetToDecorative);
}
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
int version = reader.ReadInt();
switch (version)
{
case 1:
{
ContractTime = reader.ReadDateTime();
Owner = reader.ReadMobile();
m_Planted = reader.ReadDateTime();
SetToDecorative = reader.ReadDateTime();
break;
}
case 0:
{
Owner = reader.ReadMobile();
m_Planted = reader.ReadDateTime();
SetToDecorative = reader.ReadDateTime();
break;
}
}
if (PlantStatus == PlantStatus.BowlOfDirt)
Delete();
}
}
}

View File

@@ -0,0 +1,265 @@
using Server;
using System;
using System.Collections.Generic;
using Server.Engines.NewMagincia;
namespace Server.Engines.Plants
{
public class MaginciaPlantSystem : Item
{
public static readonly bool Enabled = true;
public static readonly int PlantDelay = 4;
public Dictionary<Mobile, DateTime> PlantDelayTable { get; } = new Dictionary<Mobile, DateTime>();
public static MaginciaPlantSystem FelInstance { get; private set; }
public static MaginciaPlantSystem TramInstance { get; private set; }
public static void Initialize()
{
if (Enabled)
{
if (FelInstance == null)
{
FelInstance = new MaginciaPlantSystem();
FelInstance.MoveToWorld(new Point3D(3715, 2049, 5), Map.Felucca);
}
if (TramInstance == null)
{
TramInstance = new MaginciaPlantSystem();
TramInstance.MoveToWorld(new Point3D(3715, 2049, 5), Map.Trammel);
}
}
}
public MaginciaPlantSystem()
: base(3240)
{
Movable = false;
}
public bool CheckPlantDelay(Mobile from)
{
if (PlantDelayTable.ContainsKey(from))
{
if (PlantDelayTable[from] > DateTime.UtcNow)
{
TimeSpan left = PlantDelayTable[from] - DateTime.UtcNow;
// Time remaining to plant on the Isle of Magincia again: ~1_val~ days ~2_val~ hours ~3_val~ minutes.
from.SendLocalizedMessage(1150459, string.Format("{0}\t{1}\t{2}", left.Days.ToString(), left.Hours.ToString(), left.Minutes.ToString()));
return false;
}
}
return true;
}
public void OnPlantDelete(Mobile from)
{
if (PlantDelayTable.ContainsKey(from))
PlantDelayTable.Remove(from);
}
public void OnPlantPlanted(Mobile from)
{
if (from.AccessLevel == AccessLevel.Player)
PlantDelayTable[from] = DateTime.UtcNow + TimeSpan.FromDays(PlantDelay);
else
from.SendMessage("As staff, you bypass the {0} day plant delay.", PlantDelay);
}
public override void Delete()
{
}
public static bool CanAddPlant(Mobile from, Point3D p)
{
if (!IsValidLocation(p))
{
from.SendLocalizedMessage(1150457); // The ground here is not good for gardening.
return false;
}
Map map = from.Map;
IPooledEnumerable eable = map.GetItemsInRange(p, 17);
int plantCount = 0;
foreach (Item item in eable)
{
if (item is MaginciaPlantItem)
{
if(item.Location != p)
plantCount++;
else
{
from.SendLocalizedMessage(1150367); // This plot already has a plant!
eable.Free();
return false;
}
}
else if (!item.Movable && item.Location == p)
{
from.SendLocalizedMessage(1150457); // The ground here is not good for gardening.
eable.Free();
return false;
}
}
eable.Free();
if (plantCount > 34)
{
from.SendLocalizedMessage(1150491); // There are too many objects in this area to plant (limit 34 per 17x17 area).
return false;
}
StaticTile[] staticTiles = map.Tiles.GetStaticTiles(p.X, p.Y, true);
if (staticTiles.Length > 0)
{
from.SendLocalizedMessage(1150457); // The ground here is not good for gardening.
return false;
}
return true;
}
public static bool CheckDelay(Mobile from)
{
MaginciaPlantSystem system = null;
Map map = from.Map;
if (map == Map.Trammel)
system = TramInstance;
else if (map == Map.Felucca)
system = FelInstance;
if (system == null)
{
from.SendLocalizedMessage(1150457); // The ground here is not good for gardening.
return false;
}
return system.CheckPlantDelay(from);
}
public static bool IsValidLocation(Point3D p)
{
/*foreach (Rectangle2D rec in m_MagGrowBounds)
{
if (rec.Contains(p))
return true;
}*/
foreach (Rectangle2D rec in m_NoGrowZones)
{
if (rec.Contains(p))
return false;
}
foreach (Rectangle2D rec in MaginciaLottoSystem.MagHousingZones)
{
Rectangle2D newRec = new Rectangle2D(rec.X - 2, rec.Y - 2, rec.Width + 4, rec.Height + 7);
if (newRec.Contains(p))
return false;
}
return true;
}
public static void OnPlantDelete(Mobile owner, Map map)
{
if (owner == null || map == null)
return;
if (map == Map.Trammel)
TramInstance.OnPlantDelete(owner);
else if (map == Map.Felucca)
FelInstance.OnPlantDelete(owner);
}
public static void OnPlantPlanted(Mobile from, Map map)
{
if (map == Map.Felucca)
FelInstance.OnPlantPlanted(from);
else if (map == Map.Trammel)
TramInstance.OnPlantPlanted(from);
}
public static Rectangle2D[] MagGrowBounds { get { return m_MagGrowBounds; } }
private static readonly Rectangle2D[] m_MagGrowBounds = new Rectangle2D[]
{
new Rectangle2D(3663, 2103, 19, 19),
new Rectangle2D(3731, 2199, 7, 7),
};
private static Rectangle2D[] m_NoGrowZones = new Rectangle2D[]
{
new Rectangle2D(3683, 2144, 21, 40),
new Rectangle2D(3682, 2189, 39, 44),
new Rectangle2D(3654, 2233, 23, 30),
new Rectangle2D(3727, 2217, 15, 45),
new Rectangle2D(3558, 2134, 8, 8),
new Rectangle2D(3679, 2018, 70, 28)
};
public void DefragPlantDelayTable()
{
List<Mobile> toRemove = new List<Mobile>();
foreach (KeyValuePair<Mobile, DateTime> kvp in PlantDelayTable)
{
if (kvp.Value < DateTime.UtcNow)
toRemove.Add(kvp.Key);
}
foreach (Mobile m in toRemove)
PlantDelayTable.Remove(m);
}
public MaginciaPlantSystem(Serial serial) : base(serial)
{
}
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.Write((int)0); // version
DefragPlantDelayTable();
writer.Write(PlantDelayTable.Count);
foreach (KeyValuePair<Mobile, DateTime> kvp in PlantDelayTable)
{
writer.Write(kvp.Key);
writer.Write(kvp.Value);
}
}
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
int version = reader.ReadInt();
int c = reader.ReadInt();
for (int i = 0; i < c; i++)
{
Mobile m = reader.ReadMobile();
DateTime dt = reader.ReadDateTime();
if (m != null && dt > DateTime.UtcNow)
PlantDelayTable[m] = dt;
}
if (Map == Map.Felucca)
FelInstance = this;
else if (Map == Map.Trammel)
TramInstance = this;
else
Delete();
}
}
}

View File

@@ -0,0 +1,7 @@
To generate these systems, say [GenNewMagincia
[DeleteNewMagincia will not work, not by default.
The login behind this, is deleting the control item for the plot lotto system or the bazzar system could potentially piss alot of players off who have time, gold and
items invested. As a shard owner, if you want to disable a system, simple disable from the props gump, and delete the items associated with each system, such as the
posts, etc.