## Summary Migrates the eight concrete New Guild System gumps (CreateGuild, GuildInfo, GuildMemberInfo, GuildRoster, GuildDiplomacy, WarDeclaration, GuildAdvancedSearch, GuildInvitationRequest) and three abstract bases (BaseGuildGump, BaseGuildListGump, OtherGuildInfo) from the legacy `Gump` class to `DynamicGump`. Layout work moves from constructor-side `AddX(...)` calls into `BuildLayout(ref DynamicGumpBuilder builder)` — the abstract `BaseGuildGump` now provides a `BuildContent` callout for shared tab-strip chrome, and `BaseGuildListGump<T>` adds another `BuildListExtras` hook so subclasses can paint highlighted titles after the filter/sort/pagination chrome. The headline win is the **self-refresh pattern** on the list gumps and diplomacy advanced search. Previously each filter/sort/back/forward click allocated a brand new gump via `GetResentGump`. After migration, those handlers mutate `_filter`, `_startNumber`, `_comparer`, `_ascending`, or `_display` on the existing gump and call `from.SendGump(this)`, letting the singleton path in `NetStateGumps.Send` swap in the same instance with the new layout. The original list is preserved separately from the per-render filtered/sorted `_displayList`, so refreshes pick up the latest state without losing the source list. All guild gumps deal with per-instance dynamic strings (guild names, member names, war declarations, alliance names), which would defeat `StaticGump<T>` caching per the cliloc rule, so every concrete subclass migrates to `DynamicGump`. `AllianceRosterGump` (in `Misc/Guild.cs`) is a `GuildDiplomacyGump` subclass and inherits the new behavior; its unused override and stored alliance reference were dropped along with the now-obsolete `GetResentGump` abstract.
705 lines
33 KiB
C#
705 lines
33 KiB
C#
using System;
|
|
using Server.Factions;
|
|
using Server.Gumps;
|
|
using Server.Mobiles;
|
|
using Server.Network;
|
|
|
|
namespace Server.Guilds
|
|
{
|
|
public class OtherGuildInfo : BaseGuildGump
|
|
{
|
|
private readonly Guild _other;
|
|
|
|
public OtherGuildInfo(PlayerMobile pm, Guild g, Guild otherGuild) : base(pm, g, 10, 40)
|
|
{
|
|
_other = otherGuild;
|
|
|
|
g.CheckExpiredWars();
|
|
}
|
|
|
|
protected override bool ShowTabStrip => false;
|
|
|
|
private static void AddButtonAndBackground(ref DynamicGumpBuilder builder, int x, int y, int buttonID, int locNum)
|
|
{
|
|
builder.AddBackground(x, y, 225, 26, 0x2486);
|
|
builder.AddButton(x + 5, y + 5, 0x845, 0x846, buttonID);
|
|
builder.AddHtmlLocalized(x + 30, y + 3, 185, 26, locNum, 0x0);
|
|
}
|
|
|
|
protected override void BuildContent(ref DynamicGumpBuilder builder)
|
|
{
|
|
builder.AddBackground(0, 0, 520, 335, 0x242C);
|
|
|
|
var g = Guild.GetAllianceLeader(Guild);
|
|
var other = Guild.GetAllianceLeader(_other);
|
|
|
|
var war = g.FindPendingWar(other);
|
|
var activeWar = g.FindActiveWar(other);
|
|
|
|
var alliance = Guild.Alliance;
|
|
var otherAlliance = _other.Alliance;
|
|
// NOTE TO SELF: Only only alliance leader can see pending guild alliance statuses
|
|
|
|
var pendingWar = war != null;
|
|
var activeWarFlag = activeWar != null;
|
|
|
|
builder.AddHtmlLocalized(20, 15, 480, 26, 1062975, 0x0); // <div align=center><i>Guild Relationship</i></div>
|
|
builder.AddImageTiled(20, 40, 480, 2, 0x2711);
|
|
builder.AddHtmlLocalized(20, 50, 120, 26, 1062954, 0x0, true); // <i>Guild Name</i>
|
|
builder.AddHtml(150, 53, 360, 26, _other.Name);
|
|
|
|
builder.AddHtmlLocalized(20, 80, 120, 26, 1063025, 0x0, true); // <i>Alliance</i>
|
|
|
|
if (otherAlliance?.IsMember(_other) == true)
|
|
{
|
|
builder.AddHtml(150, 83, 360, 26, otherAlliance.Name);
|
|
}
|
|
|
|
builder.AddHtmlLocalized(20, 110, 120, 26, 1063139, 0x0, true); // <i>Abbreviation</i>
|
|
builder.AddHtml(150, 113, 120, 26, _other.Abbreviation);
|
|
|
|
var kills = "0/0";
|
|
var time = "00:00";
|
|
var otherKills = "0/0";
|
|
|
|
WarDeclaration otherWar;
|
|
|
|
if (activeWarFlag)
|
|
{
|
|
kills = $"{activeWar.Kills}/{activeWar.MaxKills}";
|
|
|
|
var timeRemaining = TimeSpan.Zero;
|
|
|
|
if (activeWar.WarLength != TimeSpan.Zero && activeWar.WarBeginning + activeWar.WarLength > Core.Now)
|
|
{
|
|
timeRemaining = activeWar.WarBeginning + activeWar.WarLength - Core.Now;
|
|
}
|
|
|
|
time = $"{timeRemaining.Hours:D2}:{DateTime.MinValue + timeRemaining:mm}";
|
|
|
|
otherWar = _other.FindActiveWar(Guild);
|
|
if (otherWar != null)
|
|
{
|
|
otherKills = $"{otherWar.Kills}/{otherWar.MaxKills}";
|
|
}
|
|
}
|
|
else if (pendingWar)
|
|
{
|
|
kills = Html.Color($"{war.Kills}/{war.MaxKills}", 0x990000);
|
|
time = Html.Color($"{war.WarLength.Hours:D2}:{DateTime.MinValue + war.WarLength:mm}", 0x990000);
|
|
|
|
otherWar = _other.FindPendingWar(Guild);
|
|
if (otherWar != null)
|
|
{
|
|
otherKills = Html.Color($"{otherWar.Kills}/{otherWar.MaxKills}", 0x990000);
|
|
}
|
|
}
|
|
|
|
builder.AddHtmlLocalized(280, 110, 120, 26, 1062966, 0x0, true); // <i>Your Kills</i>
|
|
builder.AddHtml(410, 113, 120, 26, kills);
|
|
|
|
builder.AddHtmlLocalized(20, 140, 120, 26, 1062968, 0x0, true); // <i>Time Remaining</i>
|
|
builder.AddHtml(150, 143, 120, 26, time);
|
|
|
|
builder.AddHtmlLocalized(280, 140, 120, 26, 1062967, 0x0, true); // <i>Their Kills</i>
|
|
builder.AddHtml(410, 143, 120, 26, otherKills);
|
|
|
|
builder.AddImageTiled(20, 172, 480, 2, 0x2711);
|
|
|
|
var number = 1062973; // <div align=center>You are at peace with this guild.</div>
|
|
|
|
if (pendingWar)
|
|
{
|
|
if (war.WarRequester)
|
|
{
|
|
number = 1063027; // <div align=center>You have challenged this guild to war!</div>
|
|
}
|
|
else
|
|
{
|
|
number = 1062969; // <div align=center>This guild has challenged you to war!</div>
|
|
|
|
AddButtonAndBackground(ref builder, 20, 260, 5, 1062981); // Accept Challenge
|
|
AddButtonAndBackground(ref builder, 275, 260, 6, 1062983); // Modify Terms
|
|
}
|
|
|
|
AddButtonAndBackground(ref builder, 20, 290, 7, 1062982); // Dismiss Challenge
|
|
}
|
|
else if (activeWarFlag)
|
|
{
|
|
number = 1062965; // <div align=center>You are at war with this guild!</div>
|
|
AddButtonAndBackground(ref builder, 20, 290, 8, 1062980); // Surrender
|
|
}
|
|
else if (alliance != null && alliance == otherAlliance) // alliance, Same Alliance
|
|
{
|
|
if (alliance.IsMember(Guild) && alliance.IsMember(_other)) // Both in Same alliance, full members
|
|
{
|
|
number = 1062970; // <div align=center>You are allied with this guild.</div>
|
|
|
|
if (alliance.Leader == Guild)
|
|
{
|
|
AddButtonAndBackground(ref builder, 20, 260, 12, 1062984); // Remove Guild from Alliance
|
|
|
|
// Note: No 'confirmation' like the other leader guild promotion things
|
|
// Promote to Alliance Leader
|
|
AddButtonAndBackground(ref builder, 275, 260, 13, 1063433);
|
|
// Remove guild from alliance //Promote to Alliance Leader
|
|
}
|
|
|
|
// Show roster, Centered, up
|
|
AddButtonAndBackground(ref builder, 148, 215, 10, 1063164); // Show Alliance Roster
|
|
// Leave Alliance
|
|
AddButtonAndBackground(ref builder, 20, 290, 11, 1062985); // Leave Alliance
|
|
}
|
|
else if (alliance.Leader == Guild && alliance.IsPendingMember(_other))
|
|
{
|
|
number = 1062971; // <div align=center>You have requested an alliance with this guild.</div>
|
|
|
|
// Show Alliance Roster, Centered, down.
|
|
AddButtonAndBackground(ref builder, 148, 245, 10, 1063164); // Show Alliance Roster
|
|
// Withdraw Request
|
|
AddButtonAndBackground(ref builder, 20, 290, 14, 1062986); // Withdraw Request
|
|
|
|
builder.AddHtml(150, 83, 360, 26, alliance.Name.Color(0x99));
|
|
}
|
|
else if (alliance.Leader == _other && alliance.IsPendingMember(Guild))
|
|
{
|
|
number = 1062972; // <div align=center>This guild has requested an alliance.</div>
|
|
|
|
// Show alliance Roster, top
|
|
AddButtonAndBackground(ref builder, 148, 215, 10, 1063164); // Show Alliance Roster
|
|
// Deny Request
|
|
// Accept Request
|
|
AddButtonAndBackground(ref builder, 20, 260, 15, 1062988); // Deny Request
|
|
AddButtonAndBackground(ref builder, 20, 290, 16, 1062987); // Accept Request
|
|
|
|
builder.AddHtml(150, 83, 360, 26, alliance.Name.Color(0x99));
|
|
}
|
|
}
|
|
else
|
|
{
|
|
AddButtonAndBackground(ref builder, 20, 260, 2, 1062990); // Request Alliance
|
|
AddButtonAndBackground(ref builder, 20, 290, 1, 1062989); // Declare War!
|
|
}
|
|
|
|
AddButtonAndBackground(ref builder, 275, 290, 0, 3000091); // Cancel
|
|
|
|
builder.AddHtmlLocalized(20, 180, 480, 30, number, 0x0, true);
|
|
builder.AddImageTiled(20, 245, 480, 2, 0x2711);
|
|
}
|
|
|
|
public override void OnResponse(NetState sender, in RelayInfo info)
|
|
{
|
|
if (!(sender.Mobile is PlayerMobile pm && IsMember(pm, Guild)))
|
|
{
|
|
return;
|
|
}
|
|
|
|
var playerRank = pm.GuildRank;
|
|
|
|
var guildLeader = Guild.GetAllianceLeader(Guild);
|
|
var otherGuild = Guild.GetAllianceLeader(_other);
|
|
|
|
var war = guildLeader.FindPendingWar(otherGuild);
|
|
var activeWar = guildLeader.FindActiveWar(otherGuild);
|
|
var otherWar = otherGuild.FindPendingWar(guildLeader);
|
|
|
|
var alliance = Guild.Alliance;
|
|
var otherAlliance = otherGuild.Alliance;
|
|
|
|
switch (info.ButtonID)
|
|
{
|
|
case 5: // Accept the war
|
|
{
|
|
if (war?.WarRequester == false && activeWar == null)
|
|
{
|
|
if (!playerRank.GetFlag(RankFlags.ControlWarStatus))
|
|
{
|
|
pm.SendLocalizedMessage(1063440); // You don't have permission to negotiate wars.
|
|
}
|
|
else if (alliance != null && alliance.Leader != Guild)
|
|
{
|
|
// ~1_val~ is not the leader of the ~2_val~ alliance.
|
|
pm.SendLocalizedMessage(1063239, $"{Guild.Name}\t{alliance.Name}");
|
|
|
|
// You need to negotiate via ~1_val~ instead.
|
|
pm.SendLocalizedMessage(1070707, alliance.Leader.Name);
|
|
}
|
|
else
|
|
{
|
|
// Accept the war
|
|
Guild.PendingWars.Remove(war);
|
|
war.WarBeginning = Core.Now;
|
|
Guild.AcceptedWars.Add(war);
|
|
|
|
if (alliance?.IsMember(Guild) == true)
|
|
{
|
|
// Guild Message: Your guild is now at war with ~1_GUILDNAME~
|
|
alliance.AllianceMessage(1070769, otherAlliance?.Name ?? otherGuild.Name);
|
|
alliance.InvalidateMemberProperties();
|
|
}
|
|
else
|
|
{
|
|
// Guild Message: Your guild is now at war with ~1_GUILDNAME~
|
|
Guild.GuildMessage(1070769, otherAlliance?.Name ?? otherGuild.Name);
|
|
Guild.InvalidateMemberProperties();
|
|
}
|
|
// Technically SHOULD say Your guild is now at war w/out any info, intentional diff.
|
|
|
|
otherGuild.PendingWars.Remove(otherWar);
|
|
otherWar.WarBeginning = Core.Now;
|
|
otherGuild.AcceptedWars.Add(otherWar);
|
|
|
|
if (otherAlliance != null && _other.Alliance.IsMember(_other))
|
|
{
|
|
// Guild Message: Your guild is now at war with ~1_GUILDNAME~
|
|
otherAlliance.AllianceMessage(1070769, alliance?.Name ?? Guild.Name);
|
|
otherAlliance.InvalidateMemberProperties();
|
|
}
|
|
else
|
|
{
|
|
// Guild Message: Your guild is now at war with ~1_GUILDNAME~
|
|
otherGuild.GuildMessage(1070769, alliance?.Name ?? Guild.Name);
|
|
otherGuild.InvalidateMemberProperties();
|
|
}
|
|
}
|
|
}
|
|
|
|
break;
|
|
}
|
|
case 6: // Modify war terms
|
|
{
|
|
if (war?.WarRequester == false && activeWar == null)
|
|
{
|
|
if (!playerRank.GetFlag(RankFlags.ControlWarStatus))
|
|
{
|
|
pm.SendLocalizedMessage(1063440); // You don't have permission to negotiate wars.
|
|
}
|
|
else if (alliance != null && alliance.Leader != Guild)
|
|
{
|
|
// ~1_val~ is not the leader of the ~2_val~ alliance.
|
|
pm.SendLocalizedMessage(1063239, $"{Guild.Name}\t{alliance.Name}");
|
|
|
|
// You need to negotiate via ~1_val~ instead.
|
|
pm.SendLocalizedMessage(1070707, alliance.Leader.Name);
|
|
}
|
|
else
|
|
{
|
|
pm.SendGump(new WarDeclarationGump(pm, Guild, otherGuild));
|
|
}
|
|
}
|
|
|
|
break;
|
|
}
|
|
case 7: // Dismiss war
|
|
{
|
|
if (war != null)
|
|
{
|
|
if (!playerRank.GetFlag(RankFlags.ControlWarStatus))
|
|
{
|
|
pm.SendLocalizedMessage(1063440); // You don't have permission to negotiate wars.
|
|
}
|
|
else if (alliance != null && alliance.Leader != Guild)
|
|
{
|
|
// ~1_val~ is not the leader of the ~2_val~ alliance.
|
|
pm.SendLocalizedMessage(1063239, $"{Guild.Name}\t{alliance.Name}");
|
|
|
|
// You need to negotiate via ~1_val~ instead.
|
|
pm.SendLocalizedMessage(1070707, alliance.Leader.Name);
|
|
}
|
|
else
|
|
{
|
|
// Dismiss the war
|
|
Guild.PendingWars.Remove(war);
|
|
otherGuild.PendingWars.Remove(otherWar);
|
|
pm.SendLocalizedMessage(1070752); // The proposal has been updated.
|
|
// Messages to opposing guild? (Testing on OSI says no)
|
|
}
|
|
}
|
|
|
|
break;
|
|
}
|
|
case 8: // Surrender
|
|
{
|
|
if (!playerRank.GetFlag(RankFlags.ControlWarStatus))
|
|
{
|
|
pm.SendLocalizedMessage(1063440); // You don't have permission to negotiate wars.
|
|
}
|
|
else if (alliance != null && alliance.Leader != Guild)
|
|
{
|
|
// ~1_val~ is not the leader of the ~2_val~ alliance.
|
|
pm.SendLocalizedMessage(1063239, $"{Guild.Name}\t{alliance.Name}");
|
|
|
|
// You need to negotiate via ~1_val~ instead.
|
|
pm.SendLocalizedMessage(1070707, alliance.Leader.Name);
|
|
}
|
|
else
|
|
{
|
|
if (activeWar != null)
|
|
{
|
|
if (alliance?.IsMember(Guild) == true)
|
|
{
|
|
// You have lost the war with ~1_val~.
|
|
alliance.AllianceMessage(1070740, otherAlliance?.Name ?? otherGuild.Name);
|
|
alliance.InvalidateMemberProperties();
|
|
}
|
|
else
|
|
{
|
|
// You have lost the war with ~1_val~.
|
|
Guild.GuildMessage(1070740, otherAlliance?.Name ?? otherGuild.Name);
|
|
Guild.InvalidateMemberProperties();
|
|
}
|
|
|
|
Guild.AcceptedWars.Remove(activeWar);
|
|
|
|
if (otherAlliance?.IsMember(otherGuild) == true)
|
|
{
|
|
// You have won the war against ~1_val~!
|
|
otherAlliance.AllianceMessage(1070739, Guild.Alliance?.Name ?? Guild.Name);
|
|
otherAlliance.InvalidateMemberProperties();
|
|
}
|
|
else
|
|
{
|
|
// You have won the war against ~1_val~!
|
|
otherGuild.GuildMessage(1070739, Guild.Alliance?.Name ?? Guild.Name);
|
|
otherGuild.InvalidateMemberProperties();
|
|
}
|
|
|
|
otherGuild.AcceptedWars.Remove(otherGuild.FindActiveWar(Guild));
|
|
}
|
|
}
|
|
|
|
break;
|
|
}
|
|
case 1: // Declare War
|
|
{
|
|
if (war == null && activeWar == null)
|
|
{
|
|
if (!playerRank.GetFlag(RankFlags.ControlWarStatus))
|
|
{
|
|
pm.SendLocalizedMessage(1063440); // You don't have permission to negotiate wars.
|
|
}
|
|
else if (alliance != null && alliance.Leader != Guild)
|
|
{
|
|
// ~1_val~ is not the leader of the ~2_val~ alliance.
|
|
pm.SendLocalizedMessage(1063239, $"{Guild.Name}\t{alliance.Name}");
|
|
|
|
// You need to negotiate via ~1_val~ instead.
|
|
pm.SendLocalizedMessage(1070707, alliance.Leader.Name);
|
|
}
|
|
else if (otherAlliance != null && otherAlliance.Leader != _other)
|
|
{
|
|
// ~1_val~ is not the leader of the ~2_val~ alliance.
|
|
pm.SendLocalizedMessage(1063239, $"{_other.Name}\t{otherAlliance.Name}");
|
|
|
|
// You need to negotiate via ~1_val~ instead.
|
|
pm.SendLocalizedMessage(1070707, otherAlliance.Leader.Name);
|
|
}
|
|
else
|
|
{
|
|
pm.SendGump(new WarDeclarationGump(pm, Guild, _other));
|
|
}
|
|
}
|
|
|
|
break;
|
|
}
|
|
|
|
case 2: // Request Alliance
|
|
{
|
|
if (alliance == null)
|
|
{
|
|
if (!playerRank.GetFlag(RankFlags.AllianceControl))
|
|
{
|
|
pm.SendLocalizedMessage(1070747); // You don't have permission to create an alliance.
|
|
}
|
|
else if (Faction.Find(Guild.Leader) != Faction.Find(_other.Leader))
|
|
{
|
|
// You cannot propose an alliance to a guild with a different faction allegiance.
|
|
pm.SendLocalizedMessage(1070758);
|
|
}
|
|
else if (otherAlliance != null)
|
|
{
|
|
if (otherAlliance.IsPendingMember(_other))
|
|
{
|
|
// ~1_val~ is currently considering another alliance proposal.
|
|
pm.SendLocalizedMessage(1063416, _other.Name);
|
|
}
|
|
else
|
|
{
|
|
// ~1_val~ already belongs to an alliance.
|
|
pm.SendLocalizedMessage(1063426, _other.Name);
|
|
}
|
|
}
|
|
else if (_other.AcceptedWars.Count > 0 || _other.PendingWars.Count > 0)
|
|
{
|
|
// ~1_val~ is currently involved in a guild war.
|
|
pm.SendLocalizedMessage(1063427, _other.Name);
|
|
}
|
|
else if (Guild.AcceptedWars.Count > 0 || Guild.PendingWars.Count > 0)
|
|
{
|
|
// ~1_val~ is currently involved in a guild war.
|
|
pm.SendLocalizedMessage(1063427, Guild.Name);
|
|
}
|
|
else
|
|
{
|
|
pm.SendLocalizedMessage(1063439); // Enter a name for the new alliance:
|
|
pm.BeginPrompt(CreateAlliance_Callback);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (!playerRank.GetFlag(RankFlags.AllianceControl))
|
|
{
|
|
pm.SendLocalizedMessage(1063436); // You don't have permission to negotiate an alliance.
|
|
}
|
|
else if (alliance.Leader != Guild)
|
|
{
|
|
// ~1_val~ is not the leader of the ~2_val~ alliance.
|
|
pm.SendLocalizedMessage(1063239, $"{Guild.Name}\t{alliance.Name}");
|
|
}
|
|
else if (otherAlliance != null)
|
|
{
|
|
if (otherAlliance.IsPendingMember(_other))
|
|
{
|
|
// ~1_val~ is currently considering another alliance proposal.
|
|
pm.SendLocalizedMessage(1063416, _other.Name);
|
|
}
|
|
else
|
|
{
|
|
// ~1_val~ already belongs to an alliance.
|
|
pm.SendLocalizedMessage(1063426, _other.Name);
|
|
}
|
|
}
|
|
else if (alliance.IsPendingMember(Guild))
|
|
{
|
|
// ~1_val~ is currently considering another alliance proposal.
|
|
pm.SendLocalizedMessage(1063416, Guild.Name);
|
|
}
|
|
else if (_other.AcceptedWars.Count > 0 || _other.PendingWars.Count > 0)
|
|
{
|
|
// ~1_val~ is currently involved in a guild war.
|
|
pm.SendLocalizedMessage(1063427, _other.Name);
|
|
}
|
|
else if (Guild.AcceptedWars.Count > 0 || Guild.PendingWars.Count > 0)
|
|
{
|
|
// ~1_val~ is currently involved in a guild war.
|
|
pm.SendLocalizedMessage(1063427, Guild.Name);
|
|
}
|
|
else if (Faction.Find(Guild.Leader) != Faction.Find(_other.Leader))
|
|
{
|
|
// You cannot propose an alliance to a guild with a different faction allegiance.
|
|
pm.SendLocalizedMessage(1070758);
|
|
}
|
|
else
|
|
{
|
|
// An invitation to join your alliance has been sent to ~1_val~.
|
|
pm.SendLocalizedMessage(1070750, _other.Name);
|
|
|
|
_other.GuildMessage(1070780, Guild.Name); // ~1_val~ has proposed an alliance.
|
|
|
|
_other.Alliance = alliance; // Calls addPendingGuild
|
|
}
|
|
}
|
|
|
|
break;
|
|
}
|
|
case 10: // Show Alliance Roster
|
|
{
|
|
if (alliance != null && alliance == otherAlliance)
|
|
{
|
|
pm.SendGump(new AllianceInfo.AllianceRosterGump(pm, Guild, alliance));
|
|
}
|
|
|
|
break;
|
|
}
|
|
case 11: // Leave Alliance
|
|
{
|
|
if (!playerRank.GetFlag(RankFlags.AllianceControl))
|
|
{
|
|
pm.SendLocalizedMessage(1063436); // You don't have permission to negotiate an alliance.
|
|
}
|
|
else if (alliance?.IsMember(Guild) == true)
|
|
{
|
|
Guild.Alliance = null; // Calls alliance.RemoveGuild
|
|
|
|
_other.InvalidateWarNotoriety();
|
|
|
|
Guild.InvalidateMemberNotoriety();
|
|
}
|
|
|
|
break;
|
|
}
|
|
case 12: // Remove Guild from alliance
|
|
{
|
|
if (!playerRank.GetFlag(RankFlags.AllianceControl))
|
|
{
|
|
pm.SendLocalizedMessage(1063436); // You don't have permission to negotiate an alliance.
|
|
}
|
|
else if (alliance != null && alliance.Leader != Guild)
|
|
{
|
|
// ~1_val~ is not the leader of the ~2_val~ alliance.
|
|
pm.SendLocalizedMessage(1063239, $"{Guild.Name}\t{alliance.Name}");
|
|
}
|
|
else if (alliance?.IsMember(Guild) == true && alliance.IsMember(_other))
|
|
{
|
|
_other.Alliance = null;
|
|
|
|
_other.InvalidateMemberNotoriety();
|
|
|
|
Guild.InvalidateWarNotoriety();
|
|
}
|
|
|
|
break;
|
|
}
|
|
case 13: // Promote to Alliance leader
|
|
{
|
|
if (!playerRank.GetFlag(RankFlags.AllianceControl))
|
|
{
|
|
pm.SendLocalizedMessage(1063436); // You don't have permission to negotiate an alliance.
|
|
}
|
|
else if (alliance != null && alliance.Leader != Guild)
|
|
{
|
|
// ~1_val~ is not the leader of the ~2_val~ alliance.
|
|
pm.SendLocalizedMessage(1063239, $"{Guild.Name}\t{alliance.Name}");
|
|
}
|
|
else if (alliance?.IsMember(Guild) == true && alliance.IsMember(_other))
|
|
{
|
|
// ~1_val~ is now the leader of ~2_val~.
|
|
pm.SendLocalizedMessage(1063434, $"{_other.Name}\t{alliance.Name}");
|
|
|
|
alliance.Leader = _other;
|
|
}
|
|
|
|
break;
|
|
}
|
|
case 14: // Withdraw Request
|
|
{
|
|
if (!playerRank.GetFlag(RankFlags.AllianceControl))
|
|
{
|
|
pm.SendLocalizedMessage(1063436); // You don't have permission to negotiate an alliance.
|
|
}
|
|
else if (alliance != null && alliance.Leader == Guild && alliance.IsPendingMember(_other))
|
|
{
|
|
_other.Alliance = null;
|
|
pm.SendLocalizedMessage(1070752); // The proposal has been updated.
|
|
}
|
|
|
|
break;
|
|
}
|
|
case 15: // Deny Alliance Request
|
|
{
|
|
if (!playerRank.GetFlag(RankFlags.AllianceControl))
|
|
{
|
|
pm.SendLocalizedMessage(1063436); // You don't have permission to negotiate an alliance.
|
|
}
|
|
else if (alliance != null && otherAlliance != null && alliance.Leader == _other &&
|
|
otherAlliance.IsPendingMember(Guild))
|
|
{
|
|
// The proposal has been updated.
|
|
// _other.GuildMessage( 1070782 );
|
|
// // ~1_val~ has responded to your proposal.
|
|
// // Per OSI commented out.
|
|
pm.SendLocalizedMessage(1070752);
|
|
Guild.Alliance = null;
|
|
}
|
|
|
|
break;
|
|
}
|
|
case 16: // Accept Alliance Request
|
|
{
|
|
if (!playerRank.GetFlag(RankFlags.AllianceControl))
|
|
{
|
|
pm.SendLocalizedMessage(1063436); // You don't have permission to negotiate an alliance.
|
|
}
|
|
else if (otherAlliance != null && otherAlliance.Leader == _other &&
|
|
otherAlliance.IsPendingMember(Guild))
|
|
{
|
|
pm.SendLocalizedMessage(1070752); // The proposal has been updated.
|
|
|
|
// No need to verify it's in the guild or already a member, the function does this
|
|
otherAlliance.TurnToMember(_other);
|
|
|
|
otherAlliance.TurnToMember(Guild);
|
|
}
|
|
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
public void CreateAlliance_Callback(Mobile from, string text)
|
|
{
|
|
if (from is not PlayerMobile pm)
|
|
{
|
|
return;
|
|
}
|
|
|
|
var alliance = Guild.Alliance;
|
|
var otherAlliance = _other.Alliance;
|
|
|
|
if (!IsMember(from, Guild) || alliance != null)
|
|
{
|
|
return;
|
|
}
|
|
|
|
var playerRank = pm.GuildRank;
|
|
|
|
if (!playerRank.GetFlag(RankFlags.AllianceControl))
|
|
{
|
|
pm.SendLocalizedMessage(1070747); // You don't have permission to create an alliance.
|
|
}
|
|
else if (Faction.Find(Guild.Leader) != Faction.Find(_other.Leader))
|
|
{
|
|
// Notes about this: OSI only cares/checks when proposing, you can change your faction all you want later.
|
|
// You cannot propose an alliance to a guild with a different faction allegiance.
|
|
pm.SendLocalizedMessage(1070758);
|
|
}
|
|
else if (otherAlliance != null)
|
|
{
|
|
if (otherAlliance.IsPendingMember(_other))
|
|
{
|
|
// ~1_val~ is currently considering another alliance proposal.
|
|
pm.SendLocalizedMessage(1063416, _other.Name);
|
|
}
|
|
else
|
|
{
|
|
pm.SendLocalizedMessage(1063426, _other.Name); // ~1_val~ already belongs to an alliance.
|
|
}
|
|
}
|
|
else if (_other.AcceptedWars.Count > 0 || _other.PendingWars.Count > 0)
|
|
{
|
|
pm.SendLocalizedMessage(1063427, _other.Name); // ~1_val~ is currently involved in a guild war.
|
|
}
|
|
else if (Guild.AcceptedWars.Count > 0 || Guild.PendingWars.Count > 0)
|
|
{
|
|
pm.SendLocalizedMessage(1063427, Guild.Name); // ~1_val~ is currently involved in a guild war.
|
|
}
|
|
else
|
|
{
|
|
var name = text.AsSpan().Trim().FixHtml();
|
|
|
|
if (!CheckProfanity(name))
|
|
{
|
|
pm.SendLocalizedMessage(1070886); // That alliance name is not allowed.
|
|
}
|
|
else if (name.Length > Guild.NameLimit)
|
|
{
|
|
// An alliance name cannot exceed ~1_val~ characters in length.
|
|
pm.SendLocalizedMessage(1070887, Guild.NameLimit.ToString());
|
|
}
|
|
else if (AllianceInfo.Alliances.ContainsKey(name.ToLower()))
|
|
{
|
|
pm.SendLocalizedMessage(1063428); // That alliance name is not available.
|
|
}
|
|
else
|
|
{
|
|
// An invitation to join your alliance has been sent to ~1_val~.
|
|
pm.SendLocalizedMessage(1070750, _other.Name);
|
|
|
|
_other.GuildMessage(1070780, Guild.Name); // ~1_val~ has proposed an alliance.
|
|
|
|
new AllianceInfo(Guild, name, _other);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|