fix: Codegens guildstone and jewelery (#1061)

This commit is contained in:
Kamron Batman 2022-06-14 08:29:00 -07:00 • committed by GitHub
parent 3594e97109
commit c1cc1308a5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
45 changed files with 1239 additions and 1673 deletions

View file

@ -1,47 +1,71 @@
using ModernUO.Serialization;
using Server.Guilds;
using Server.Multis;
using Server.Prompts;
namespace Server.Items
namespace Server.Items;
[SerializationGenerator(0, false)]
public partial class GuildDeed : Item
{
public class GuildDeed : Item
[Constructible]
public GuildDeed() : base(0x14F0) => Weight = 1.0;
public override int LabelNumber => 1041055; // a guild deed
public override void OnDoubleClick(Mobile from)
{
[Constructible]
public GuildDeed() : base(0x14F0) => Weight = 1.0;
public GuildDeed(Serial serial) : base(serial)
if (Guild.NewGuildSystem)
{
return;
}
public override int LabelNumber => 1041055; // a guild deed
public override void Serialize(IGenericWriter writer)
if (!IsChildOf(from.Backpack))
{
base.Serialize(writer);
writer.Write(0); // version
from.SendLocalizedMessage(1042001); // That must be in your pack for you to use it.
}
public override void Deserialize(IGenericReader reader)
else if (from.Guild != null)
{
base.Deserialize(reader);
from.SendLocalizedMessage(501137); // You must resign from your current guild before founding another!
}
else
{
var house = BaseHouse.FindHouseAt(from);
var version = reader.ReadInt();
if (Weight == 0.0)
if (house == null)
{
Weight = 1.0;
from.SendLocalizedMessage(501138); // You can only place a guildstone in a house.
}
else if (house.FindGuildstone() != null)
{
from.SendLocalizedMessage(501142); // Only one guildstone may reside in a given house.
}
else if (!house.IsOwner(from))
{
from.SendLocalizedMessage(501141); // You can only place a guildstone in a house you own!
}
else
{
from.SendLocalizedMessage(1013060); // Enter new guild name (40 characters max):
from.Prompt = new InternalPrompt(this);
}
}
}
public override void OnDoubleClick(Mobile from)
private class InternalPrompt : Prompt
{
private readonly GuildDeed m_Deed;
public InternalPrompt(GuildDeed deed) => m_Deed = deed;
public override void OnResponse(Mobile from, string text)
{
if (Guild.NewGuildSystem)
if (m_Deed.Deleted)
{
return;
}
if (!IsChildOf(from.Backpack))
if (!m_Deed.IsChildOf(from.Backpack))
{
from.SendLocalizedMessage(1042001); // That must be in your pack for you to use it.
}
@ -67,76 +91,30 @@ namespace Server.Items
}
else
{
from.SendLocalizedMessage(1013060); // Enter new guild name (40 characters max):
from.Prompt = new InternalPrompt(this);
m_Deed.Delete();
if (text.Length > 40)
{
text = text[..40];
}
var guild = new Guild(from, text, "none");
from.Guild = guild;
from.GuildTitle = "Guildmaster";
var stone = new Guildstone(guild);
stone.MoveToWorld(from.Location, from.Map);
guild.Guildstone = stone;
}
}
}
private class InternalPrompt : Prompt
public override void OnCancel(Mobile from)
{
private readonly GuildDeed m_Deed;
public InternalPrompt(GuildDeed deed) => m_Deed = deed;
public override void OnResponse(Mobile from, string text)
{
if (m_Deed.Deleted)
{
return;
}
if (!m_Deed.IsChildOf(from.Backpack))
{
from.SendLocalizedMessage(1042001); // That must be in your pack for you to use it.
}
else if (from.Guild != null)
{
from.SendLocalizedMessage(501137); // You must resign from your current guild before founding another!
}
else
{
var house = BaseHouse.FindHouseAt(from);
if (house == null)
{
from.SendLocalizedMessage(501138); // You can only place a guildstone in a house.
}
else if (house.FindGuildstone() != null)
{
from.SendLocalizedMessage(501142); // Only one guildstone may reside in a given house.
}
else if (!house.IsOwner(from))
{
from.SendLocalizedMessage(501141); // You can only place a guildstone in a house you own!
}
else
{
m_Deed.Delete();
if (text.Length > 40)
{
text = text[..40];
}
var guild = new Guild(from, text, "none");
from.Guild = guild;
from.GuildTitle = "Guildmaster";
var stone = new Guildstone(guild);
stone.MoveToWorld(from.Location, from.Map);
guild.Guildstone = stone;
}
}
}
public override void OnCancel(Mobile from)
{
from.SendLocalizedMessage(501145); // Placement of guildstone cancelled.
}
from.SendLocalizedMessage(501145); // Placement of guildstone cancelled.
}
}
}