## Summary Migrates the Old Guild System (pre-AOS guild stones) gumps from the legacy `Gump` class to `DynamicGump`, following the same pattern used for the Quest gump migration in #2416. All concrete gumps now have private constructors gated by static `DisplayTo` entry points (empty-gump rule), and `Singleton => true` is set across the board so reopening a sibling dialog automatically closes the previous one. **Migrated gumps:** - `GuildGump` - main guild dialog - `GuildmasterGump` - guildmaster functions - `GuildCharterGump` - charter and website display - `GuildWarGump` - warfare status (kept as player-facing) - `GuildWarAdminGump` - war menu (retained as player-facing - reachable from `GuildmasterGump`'s WAR button by guildmasters) - `GuildChangeTypeGump` - Standard/Order/Chaos selection **Abstract bases:** `GuildListGump` and `GuildMobileListGump` keep their shared list-rendering chrome inside a single concrete `BuildLayout` on the abstract class and expose a `protected abstract void BuildHeader(ref DynamicGumpBuilder builder)` hook for subclasses (replacing the old `Design()` override). This mirrors the abstract-base treatment used for the ML quest base in the quest-gump migration PR. **Concrete subclasses migrated alongside the abstract bases:** - `GuildListGump` subclasses: `GuildAcceptWarGump`, `GuildDeclarePeaceGump`, `GuildDeclareWarGump`, `GuildRejectWarGump`, `GuildRescindDeclarationGump` - `GuildMobileListGump` subclasses: `DeclareFealtyGump`, `GrantGuildTitleGump`, `GuildAdminCandidatesGump`, `GuildCandidatesGump`, `GuildDismissGump`, `GuildRosterGump` **Cliloc rule:** Every gump bakes per-instance dynamic content (guild names, member names, war declarations, candidate lists), which would defeat `StaticGump<T>` caching. Per the cliloc rule, all are `DynamicGump`. **External callers updated:** the prompt files (`GuildAbbrvPrompt`, `GuildCharterPrompt`, `GuildDeclareWarPrompt`, `GuildNamePrompt`, `GuildTitlePrompt`, `GuildWebsitePrompt`), `RecruitTarget`, the `Guildstone` item, and the New Guild System `GuildInfoGump`'s Order/Chaos handler all now go through static `DisplayTo` entry points instead of `new XGump(...)`.
130 lines
3.6 KiB
C#
130 lines
3.6 KiB
C#
/*************************************************************************
|
|
* ModernUO *
|
|
* Copyright 2019-2026 - ModernUO Development Team *
|
|
* Email: hi@modernuo.com *
|
|
* File: Guild.cs *
|
|
* *
|
|
* This program is free software: you can redistribute it and/or modify *
|
|
* it under the terms of the GNU General Public License as published by *
|
|
* the Free Software Foundation, either version 3 of the License, or *
|
|
* (at your option) any later version. *
|
|
* *
|
|
* You should have received a copy of the GNU General Public License *
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
|
*************************************************************************/
|
|
|
|
using System;
|
|
using System.Collections.Generic;
|
|
|
|
namespace Server.Guilds;
|
|
|
|
public enum GuildType
|
|
{
|
|
Regular,
|
|
Chaos,
|
|
Order
|
|
}
|
|
|
|
public abstract class BaseGuild : ISerializable
|
|
{
|
|
protected BaseGuild()
|
|
{
|
|
Serial = World.NewGuild;
|
|
World.AddGuild(this);
|
|
}
|
|
|
|
protected BaseGuild(Serial serial) => Serial = serial;
|
|
|
|
public abstract string Abbreviation { get; set; }
|
|
public abstract string Name { get; set; }
|
|
public abstract GuildType Type { get; set; }
|
|
public abstract bool Disbanded { get; }
|
|
|
|
public abstract void Delete();
|
|
|
|
public bool Deleted => Disbanded;
|
|
|
|
[IgnoreDupe]
|
|
[CommandProperty(AccessLevel.Counselor)]
|
|
public Serial Serial { get; }
|
|
|
|
[IgnoreDupe]
|
|
[CommandProperty(AccessLevel.GameMaster, readOnly: true)]
|
|
public DateTime Created { get; set; } = Core.Now;
|
|
|
|
public byte SerializedThread { get; set; }
|
|
public int SerializedPosition { get; set; }
|
|
public int SerializedLength { get; set; }
|
|
|
|
public abstract void Serialize(IGenericWriter writer);
|
|
|
|
public abstract void Deserialize(IGenericReader reader);
|
|
|
|
public abstract void OnDelete(Mobile mob);
|
|
|
|
public static BaseGuild FindByName(ReadOnlySpan<char> name)
|
|
{
|
|
foreach (var g in World.Guilds.Values)
|
|
{
|
|
if (g.Name.InsensitiveEquals(name))
|
|
{
|
|
return g;
|
|
}
|
|
}
|
|
|
|
return null;
|
|
}
|
|
|
|
public static BaseGuild FindByAbbrev(ReadOnlySpan<char> abbr)
|
|
{
|
|
foreach (var g in World.Guilds.Values)
|
|
{
|
|
if (g.Abbreviation.InsensitiveEquals(abbr))
|
|
{
|
|
return g;
|
|
}
|
|
}
|
|
|
|
return null;
|
|
}
|
|
|
|
public static HashSet<BaseGuild> Search(ReadOnlySpan<char> find)
|
|
{
|
|
var results = new HashSet<BaseGuild>();
|
|
find = find.Trim();
|
|
if (find.IsEmpty)
|
|
{
|
|
return results;
|
|
}
|
|
|
|
foreach (var g in World.Guilds.Values)
|
|
{
|
|
var name = g.Name.AsSpan();
|
|
|
|
var all = true;
|
|
foreach (var wordRange in find.Split(' '))
|
|
{
|
|
var word = find[wordRange];
|
|
if (word.IsEmpty)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
if (name.InsensitiveContains(word))
|
|
{
|
|
all = false;
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (all)
|
|
{
|
|
results.Add(g);
|
|
}
|
|
}
|
|
|
|
return results;
|
|
}
|
|
|
|
public override string ToString() => $"{Serial} \"{Name} [{Abbreviation}]\"";
|
|
}
|