Fixes code according to modern code style. Fixes a few expression bugs.

This commit is contained in:
Kamron Batman 2018-09-15 09:58:51 -07:00
parent 89eea25e5f
commit 970fd563b2
3324 changed files with 441118 additions and 433755 deletions

View file

@ -5,123 +5,125 @@ using Server.Network;
namespace Server.Factions
{
public class ElectionGump : FactionGump
{
private PlayerMobile m_From;
private Election m_Election;
public class ElectionGump : FactionGump
{
private Election m_Election;
private PlayerMobile m_From;
public override void OnResponse( NetState sender, RelayInfo info )
{
switch ( info.ButtonID )
{
case 0: // back
{
m_From.SendGump( new FactionStoneGump( m_From, m_Election.Faction ) );
break;
}
case 1: // vote
{
if ( m_Election.State == ElectionState.Election )
m_From.SendGump( new VoteGump( m_From, m_Election ) );
public ElectionGump(PlayerMobile from, Election election) : base(50, 50)
{
m_From = from;
m_Election = election;
break;
}
case 2: // campaign
{
if ( m_Election.CanBeCandidate( m_From ) )
m_Election.AddCandidate( m_From );
AddPage(0);
break;
}
}
}
AddBackground(0, 0, 420, 180, 5054);
AddBackground(10, 10, 400, 160, 3000);
public ElectionGump( PlayerMobile from, Election election ) : base( 50, 50 )
{
m_From = from;
m_Election = election;
AddHtmlText(20, 20, 380, 20, election.Faction.Definition.Header, false, false);
AddPage( 0 );
// NOTE: Gump not entirely OSI-accurate, intentionally so
AddBackground( 0, 0, 420, 180, 5054 );
AddBackground( 10, 10, 400, 160, 3000 );
switch (election.State)
{
case ElectionState.Pending:
{
TimeSpan toGo = election.LastStateTime + Election.PendingPeriod - DateTime.UtcNow;
int days = (int)(toGo.TotalDays + 0.5);
AddHtmlText( 20, 20, 380, 20, election.Faction.Definition.Header, false, false );
AddHtmlLocalized(20, 40, 380, 20, 1038034, false, false); // A new election campaign is pending
// NOTE: Gump not entirely OSI-accurate, intentionally so
if (days > 0)
{
AddHtmlLocalized(20, 60, 280, 20, 1018062, false, false); // Days until next election :
AddLabel(300, 60, 0, days.ToString());
}
else
{
AddHtmlLocalized(20, 60, 280, 20, 1018059, false, false); // Election campaigning begins tonight.
}
switch ( election.State )
{
case ElectionState.Pending:
{
TimeSpan toGo = ( election.LastStateTime + Election.PendingPeriod ) - DateTime.UtcNow;
int days = (int) (toGo.TotalDays + 0.5);
break;
}
case ElectionState.Campaign:
{
TimeSpan toGo = election.LastStateTime + Election.CampaignPeriod - DateTime.UtcNow;
int days = (int)(toGo.TotalDays + 0.5);
AddHtmlLocalized( 20, 40, 380, 20, 1038034, false, false ); // A new election campaign is pending
AddHtmlLocalized(20, 40, 380, 20, 1018058, false, false); // There is an election campaign in progress.
if ( days > 0 )
{
AddHtmlLocalized( 20, 60, 280, 20, 1018062, false, false ); // Days until next election :
AddLabel( 300, 60, 0, days.ToString() );
}
else
{
AddHtmlLocalized( 20, 60, 280, 20, 1018059, false, false ); // Election campaigning begins tonight.
}
if (days > 0)
{
AddHtmlLocalized(20, 60, 280, 20, 1038033, false, false); // Days to go:
AddLabel(300, 60, 0, days.ToString());
}
else
{
AddHtmlLocalized(20, 60, 280, 20, 1018061, false,
false); // Campaign in progress. Voting begins tonight.
}
break;
}
case ElectionState.Campaign:
{
TimeSpan toGo = ( election.LastStateTime + Election.CampaignPeriod ) - DateTime.UtcNow;
int days = (int) (toGo.TotalDays + 0.5);
if (m_Election.CanBeCandidate(m_From))
{
AddButton(20, 110, 4005, 4007, 2, GumpButtonType.Reply, 0);
AddHtmlLocalized(55, 110, 350, 20, 1011427, false, false); // CAMPAIGN FOR LEADERSHIP
}
else
{
PlayerState pl = PlayerState.Find(m_From);
AddHtmlLocalized( 20, 40, 380, 20, 1018058, false, false ); // There is an election campaign in progress.
if (pl == null || pl.Rank.Rank < Election.CandidateRank)
AddHtmlLocalized(20, 100, 380, 20, 1010118, false,
false); // You must have a higher rank to run for office
}
if ( days > 0 )
{
AddHtmlLocalized( 20, 60, 280, 20, 1038033, false, false ); // Days to go:
AddLabel( 300, 60, 0, days.ToString() );
}
else
{
AddHtmlLocalized( 20, 60, 280, 20, 1018061, false, false ); // Campaign in progress. Voting begins tonight.
}
break;
}
case ElectionState.Election:
{
TimeSpan toGo = election.LastStateTime + Election.VotingPeriod - DateTime.UtcNow;
int days = (int)Math.Ceiling(toGo.TotalDays);
if ( m_Election.CanBeCandidate( m_From ) )
{
AddButton( 20, 110, 4005, 4007, 2, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 55, 110, 350, 20, 1011427, false, false ); // CAMPAIGN FOR LEADERSHIP
}
else
{
PlayerState pl = PlayerState.Find( m_From );
AddHtmlLocalized(20, 40, 380, 20, 1018060, false, false); // There is an election vote in progress.
if ( pl == null || pl.Rank.Rank < Election.CandidateRank )
AddHtmlLocalized( 20, 100, 380, 20, 1010118, false, false ); // You must have a higher rank to run for office
}
AddHtmlLocalized(20, 60, 280, 20, 1038033, false, false);
AddLabel(300, 60, 0, days.ToString());
break;
}
case ElectionState.Election:
{
TimeSpan toGo = ( election.LastStateTime + Election.VotingPeriod ) - DateTime.UtcNow;
int days = (int) Math.Ceiling( toGo.TotalDays );
AddHtmlLocalized(55, 100, 380, 20, 1011428, false, false); // VOTE FOR LEADERSHIP
AddButton(20, 100, 4005, 4007, 1, GumpButtonType.Reply, 0);
AddHtmlLocalized( 20, 40, 380, 20, 1018060, false, false ); // There is an election vote in progress.
break;
}
}
AddHtmlLocalized( 20, 60, 280, 20, 1038033, false, false );
AddLabel( 300, 60, 0, days.ToString() );
AddButton(20, 140, 4005, 4007, 0, GumpButtonType.Reply, 0);
AddHtmlLocalized(55, 140, 350, 20, 1011012, false, false); // CANCEL
}
AddHtmlLocalized( 55, 100, 380, 20, 1011428, false, false ); // VOTE FOR LEADERSHIP
AddButton( 20, 100, 4005, 4007, 1, GumpButtonType.Reply, 0 );
public override void OnResponse(NetState sender, RelayInfo info)
{
switch (info.ButtonID)
{
case 0: // back
{
m_From.SendGump(new FactionStoneGump(m_From, m_Election.Faction));
break;
}
case 1: // vote
{
if (m_Election.State == ElectionState.Election)
m_From.SendGump(new VoteGump(m_From, m_Election));
break;
}
}
break;
}
case 2: // campaign
{
if (m_Election.CanBeCandidate(m_From))
m_Election.AddCandidate(m_From);
AddButton( 20, 140, 4005, 4007, 0, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 55, 140, 350, 20, 1011012, false, false ); // CANCEL
}
}
break;
}
}
}
}
}

View file

@ -1,216 +1,219 @@
using System;
using System.Net;
using Server.Gumps;
using Server.Network;
namespace Server.Factions
{
public class ElectionManagementGump : Gump
{
public string Right( string text )
{
return $"<DIV ALIGN=RIGHT>{text}</DIV>";
}
public class ElectionManagementGump : Gump
{
public const int LabelColor = 0xFFFFFF;
private Candidate m_Candidate;
public string Center( string text )
{
return $"<CENTER>{text}</CENTER>";
}
private Election m_Election;
private int m_Page;
public string Color( string text, int color )
{
return $"<BASEFONT COLOR=#{color:X6}>{text}</BASEFONT>";
}
public ElectionManagementGump(Election election) : this(election, null, 0)
{
}
public static string FormatTimeSpan( TimeSpan ts )
{
return $"{ts.Days:D2}:{ts.Hours % 24:D2}:{ts.Minutes % 60:D2}:{ts.Seconds % 60:D2}";
}
public ElectionManagementGump(Election election, Candidate candidate, int page) : base(40, 40)
{
m_Election = election;
m_Candidate = candidate;
m_Page = page;
public const int LabelColor = 0xFFFFFF;
AddPage(0);
private Election m_Election;
private Candidate m_Candidate;
private int m_Page;
if (candidate != null)
{
AddBackground(0, 0, 448, 354, 9270);
AddAlphaRegion(10, 10, 428, 334);
public override void OnResponse( NetState sender, RelayInfo info )
{
Mobile from = sender.Mobile;
int bid = info.ButtonID;
AddHtml(10, 10, 428, 20, Color(Center("Candidate Management"), LabelColor), false, false);
if ( m_Candidate == null )
{
if ( bid == 0 )
{
}
else if ( bid == 1 )
{
}
else
{
bid -= 2;
AddHtml(45, 35, 100, 20, Color("Player Name:", LabelColor), false, false);
AddHtml(145, 35, 100, 20, Color(candidate.Mobile == null ? "null" : candidate.Mobile.Name, LabelColor),
false, false);
if ( bid >= 0 && bid < m_Election.Candidates.Count )
from.SendGump( new ElectionManagementGump( m_Election, m_Election.Candidates[bid], 0 ) );
}
}
else
{
if ( bid == 0 )
{
from.SendGump( new ElectionManagementGump( m_Election ) );
}
else if ( bid == 1 )
{
m_Election.RemoveCandidate( m_Candidate.Mobile );
from.SendGump( new ElectionManagementGump( m_Election ) );
}
else if ( bid == 2 && m_Page > 0 )
{
from.SendGump( new ElectionManagementGump( m_Election, m_Candidate, m_Page - 1 ) );
}
else if ( bid == 3 && (m_Page + 1) * 10 < m_Candidate.Voters.Count )
{
from.SendGump( new ElectionManagementGump( m_Election, m_Candidate, m_Page + 1 ) );
}
else
{
bid -= 4;
AddHtml(45, 55, 100, 20, Color("Vote Count:", LabelColor), false, false);
AddHtml(145, 55, 100, 20, Color(candidate.Votes.ToString(), LabelColor), false, false);
if ( bid >= 0 && bid < m_Candidate.Voters.Count )
{
m_Candidate.Voters.RemoveAt( bid );
from.SendGump( new ElectionManagementGump( m_Election, m_Candidate, m_Page ) );
}
}
}
}
AddButton(12, 73, 4005, 4007, 1, GumpButtonType.Reply, 0);
AddHtml(45, 75, 100, 20, Color("Drop Candidate", LabelColor), false, false);
public ElectionManagementGump( Election election ) : this( election, null, 0 )
{
}
AddImageTiled(13, 99, 422, 242, 9264);
AddImageTiled(14, 100, 420, 240, 9274);
AddAlphaRegion(14, 100, 420, 240);
public ElectionManagementGump( Election election, Candidate candidate, int page ) : base( 40, 40 )
{
m_Election = election;
m_Candidate = candidate;
m_Page = page;
AddHtml(14, 100, 420, 20, Color(Center("Voters"), LabelColor), false, false);
AddPage( 0 );
if (page > 0)
AddButton(397, 104, 0x15E3, 0x15E7, 2, GumpButtonType.Reply, 0);
else
AddImage(397, 104, 0x25EA);
if ( candidate != null )
{
AddBackground( 0, 0, 448, 354, 9270 );
AddAlphaRegion( 10, 10, 428, 334 );
AddHtml( 10, 10, 428, 20, Color( Center( "Candidate Management" ), LabelColor ), false, false );
AddHtml( 45, 35, 100, 20, Color( "Player Name:", LabelColor ), false, false );
AddHtml( 145, 35, 100, 20, Color( candidate.Mobile == null ? "null" : candidate.Mobile.Name, LabelColor ), false, false );
AddHtml( 45, 55, 100, 20, Color( "Vote Count:", LabelColor ), false, false );
AddHtml( 145, 55, 100, 20, Color( candidate.Votes.ToString(), LabelColor ), false, false );
AddButton( 12, 73, 4005, 4007, 1, GumpButtonType.Reply, 0 );
AddHtml( 45, 75, 100, 20, Color( "Drop Candidate", LabelColor ), false, false );
AddImageTiled( 13, 99, 422, 242, 9264 );
AddImageTiled( 14, 100, 420, 240, 9274 );
AddAlphaRegion( 14, 100, 420, 240 );
AddHtml( 14, 100, 420, 20, Color( Center( "Voters" ), LabelColor ), false, false );
if ( page > 0 )
AddButton( 397, 104, 0x15E3, 0x15E7, 2, GumpButtonType.Reply, 0 );
else
AddImage( 397, 104, 0x25EA );
if ( (page + 1) * 10 < candidate.Voters.Count )
AddButton( 414, 104, 0x15E1, 0x15E5, 3, GumpButtonType.Reply, 0 );
else
AddImage( 414, 104, 0x25E6 );
if ((page + 1) * 10 < candidate.Voters.Count)
AddButton(414, 104, 0x15E1, 0x15E5, 3, GumpButtonType.Reply, 0);
else
AddImage(414, 104, 0x25E6);
AddHtml( 14, 120, 30, 20, Color( Center( "DEL" ), LabelColor ), false, false );
AddHtml( 47, 120, 150, 20, Color( "Name", LabelColor ), false, false );
AddHtml( 195, 120, 100, 20, Color( Center( "Address" ), LabelColor ), false, false );
AddHtml( 295, 120, 80, 20, Color( Center( "Time" ), LabelColor ), false, false );
AddHtml( 355, 120, 60, 20, Color( Center( "Legit" ), LabelColor ), false, false );
AddHtml(14, 120, 30, 20, Color(Center("DEL"), LabelColor), false, false);
AddHtml(47, 120, 150, 20, Color("Name", LabelColor), false, false);
AddHtml(195, 120, 100, 20, Color(Center("Address"), LabelColor), false, false);
AddHtml(295, 120, 80, 20, Color(Center("Time"), LabelColor), false, false);
AddHtml(355, 120, 60, 20, Color(Center("Legit"), LabelColor), false, false);
int idx = 0;
int idx = 0;
for ( int i = page*10; i >= 0 && i < candidate.Voters.Count && i < (page+1)*10; ++i, ++idx )
{
Voter voter = (Voter)candidate.Voters[i];
for (int i = page * 10; i >= 0 && i < candidate.Voters.Count && i < (page + 1) * 10; ++i, ++idx)
{
Voter voter = candidate.Voters[i];
AddButton( 13, 138 + (idx * 20), 4002, 4004, 4 + i, GumpButtonType.Reply, 0 );
AddButton(13, 138 + idx * 20, 4002, 4004, 4 + i, GumpButtonType.Reply, 0);
object[] fields = voter.AcquireFields();
object[] fields = voter.AcquireFields();
int x = 45;
int x = 45;
for ( int j = 0; j < fields.Length; ++j )
{
object obj = fields[j];
for (int j = 0; j < fields.Length; ++j)
{
object obj = fields[j];
if ( obj is Mobile mobile )
{
AddHtml( x + 2, 140 + (idx * 20), 150, 20, Color( mobile.Name, LabelColor ), false, false );
x += 150;
}
else if ( obj is System.Net.IPAddress )
{
AddHtml( x, 140 + (idx * 20), 100, 20, Color( Center( obj.ToString() ), LabelColor ), false, false );
x += 100;
}
else if ( obj is DateTime time )
{
AddHtml( x, 140 + (idx * 20), 80, 20, Color( Center( FormatTimeSpan( time - election.LastStateTime ) ), LabelColor ), false, false );
x += 80;
}
else if ( obj is int i1 )
{
AddHtml( x, 140 + (idx * 20), 60, 20, Color( Center( i1 + "%" ), LabelColor ), false, false );
x += 60;
}
}
}
}
else
{
AddBackground( 0, 0, 288, 334, 9270 );
AddAlphaRegion( 10, 10, 268, 314 );
if (obj is Mobile mobile)
{
AddHtml(x + 2, 140 + idx * 20, 150, 20, Color(mobile.Name, LabelColor), false, false);
x += 150;
}
else if (obj is IPAddress)
{
AddHtml(x, 140 + idx * 20, 100, 20, Color(Center(obj.ToString()), LabelColor), false, false);
x += 100;
}
else if (obj is DateTime time)
{
AddHtml(x, 140 + idx * 20, 80, 20,
Color(Center(FormatTimeSpan(time - election.LastStateTime)), LabelColor), false, false);
x += 80;
}
else if (obj is int i1)
{
AddHtml(x, 140 + idx * 20, 60, 20, Color(Center(i1 + "%"), LabelColor), false, false);
x += 60;
}
}
}
}
else
{
AddBackground(0, 0, 288, 334, 9270);
AddAlphaRegion(10, 10, 268, 314);
AddHtml( 10, 10, 268, 20, Color( Center( "Election Management" ), LabelColor ), false, false );
AddHtml(10, 10, 268, 20, Color(Center("Election Management"), LabelColor), false, false);
AddHtml( 45, 35, 100, 20, Color( "Current State:", LabelColor ), false, false );
AddHtml( 145, 35, 100, 20, Color( election.State.ToString(), LabelColor ), false, false );
AddHtml(45, 35, 100, 20, Color("Current State:", LabelColor), false, false);
AddHtml(145, 35, 100, 20, Color(election.State.ToString(), LabelColor), false, false);
AddButton( 12, 53, 4005, 4007, 1, GumpButtonType.Reply, 0 );
AddHtml( 45, 55, 100, 20, Color( "Transition Time:", LabelColor ), false, false );
AddHtml( 145, 55, 100, 20, Color( FormatTimeSpan( election.NextStateTime ), LabelColor ), false, false );
AddButton(12, 53, 4005, 4007, 1, GumpButtonType.Reply, 0);
AddHtml(45, 55, 100, 20, Color("Transition Time:", LabelColor), false, false);
AddHtml(145, 55, 100, 20, Color(FormatTimeSpan(election.NextStateTime), LabelColor), false, false);
AddImageTiled( 13, 79, 262, 242, 9264 );
AddImageTiled( 14, 80, 260, 240, 9274 );
AddAlphaRegion( 14, 80, 260, 240 );
AddImageTiled(13, 79, 262, 242, 9264);
AddImageTiled(14, 80, 260, 240, 9274);
AddAlphaRegion(14, 80, 260, 240);
AddHtml( 14, 80, 260, 20, Color( Center( "Candidates" ), LabelColor ), false, false );
AddHtml( 14, 100, 30, 20, Color( Center( "-->" ), LabelColor ), false, false );
AddHtml( 47, 100, 150, 20, Color( "Name", LabelColor ), false, false );
AddHtml( 195, 100, 80, 20, Color( Center( "Votes" ), LabelColor ), false, false );
AddHtml(14, 80, 260, 20, Color(Center("Candidates"), LabelColor), false, false);
AddHtml(14, 100, 30, 20, Color(Center("-->"), LabelColor), false, false);
AddHtml(47, 100, 150, 20, Color("Name", LabelColor), false, false);
AddHtml(195, 100, 80, 20, Color(Center("Votes"), LabelColor), false, false);
for ( int i = 0; i < election.Candidates.Count; ++i )
{
Candidate cd = election.Candidates[i];
Mobile mob = cd.Mobile;
for (int i = 0; i < election.Candidates.Count; ++i)
{
Candidate cd = election.Candidates[i];
Mobile mob = cd.Mobile;
if ( mob == null )
continue;
if (mob == null)
continue;
AddButton( 13, 118 + (i * 20), 4005, 4007, 2 + i, GumpButtonType.Reply, 0 );
AddHtml( 47, 120 + (i * 20), 150, 20, Color( mob.Name, LabelColor ), false, false );
AddHtml( 195, 120 + (i * 20), 80, 20, Color( Center( cd.Votes.ToString() ), LabelColor ), false, false );
}
}
}
}
}
AddButton(13, 118 + i * 20, 4005, 4007, 2 + i, GumpButtonType.Reply, 0);
AddHtml(47, 120 + i * 20, 150, 20, Color(mob.Name, LabelColor), false, false);
AddHtml(195, 120 + i * 20, 80, 20, Color(Center(cd.Votes.ToString()), LabelColor), false, false);
}
}
}
public string Right(string text)
{
return $"<DIV ALIGN=RIGHT>{text}</DIV>";
}
public string Center(string text)
{
return $"<CENTER>{text}</CENTER>";
}
public string Color(string text, int color)
{
return $"<BASEFONT COLOR=#{color:X6}>{text}</BASEFONT>";
}
public static string FormatTimeSpan(TimeSpan ts)
{
return $"{ts.Days:D2}:{ts.Hours % 24:D2}:{ts.Minutes % 60:D2}:{ts.Seconds % 60:D2}";
}
public override void OnResponse(NetState sender, RelayInfo info)
{
Mobile from = sender.Mobile;
int bid = info.ButtonID;
if (m_Candidate == null)
{
if (bid == 0)
{
}
else if (bid == 1)
{
}
else
{
bid -= 2;
if (bid >= 0 && bid < m_Election.Candidates.Count)
from.SendGump(new ElectionManagementGump(m_Election, m_Election.Candidates[bid], 0));
}
}
else
{
if (bid == 0)
{
from.SendGump(new ElectionManagementGump(m_Election));
}
else if (bid == 1)
{
m_Election.RemoveCandidate(m_Candidate.Mobile);
from.SendGump(new ElectionManagementGump(m_Election));
}
else if (bid == 2 && m_Page > 0)
{
from.SendGump(new ElectionManagementGump(m_Election, m_Candidate, m_Page - 1));
}
else if (bid == 3 && (m_Page + 1) * 10 < m_Candidate.Voters.Count)
{
from.SendGump(new ElectionManagementGump(m_Election, m_Candidate, m_Page + 1));
}
else
{
bid -= 4;
if (bid >= 0 && bid < m_Candidate.Voters.Count)
{
m_Candidate.Voters.RemoveAt(bid);
from.SendGump(new ElectionManagementGump(m_Election, m_Candidate, m_Page));
}
}
}
}
}
}

View file

@ -2,45 +2,45 @@ using Server.Gumps;
namespace Server.Factions
{
public abstract class FactionGump : Gump
{
public virtual int ButtonTypes => 10;
public abstract class FactionGump : Gump
{
public FactionGump(int x, int y) : base(x, y)
{
}
public int ToButtonID( int type, int index )
{
return 1 + (index * ButtonTypes) + type;
}
public virtual int ButtonTypes => 10;
public bool FromButtonID( int buttonID, out int type, out int index )
{
int offset = buttonID - 1;
public int ToButtonID(int type, int index)
{
return 1 + index * ButtonTypes + type;
}
if ( offset >= 0 )
{
type = offset % ButtonTypes;
index = offset / ButtonTypes;
return true;
}
public bool FromButtonID(int buttonID, out int type, out int index)
{
int offset = buttonID - 1;
type = index = 0;
return false;
}
if (offset >= 0)
{
type = offset % ButtonTypes;
index = offset / ButtonTypes;
return true;
}
public static bool Exists( Mobile mob )
{
return ( mob.FindGump( typeof( FactionGump ) ) != null );
}
type = index = 0;
return false;
}
public void AddHtmlText( int x, int y, int width, int height, TextDefinition text, bool back, bool scroll )
{
if ( text != null && text.Number > 0 )
AddHtmlLocalized( x, y, width, height, text.Number, back, scroll );
else if ( text?.String != null )
AddHtml( x, y, width, height, text.String, back, scroll );
}
public static bool Exists(Mobile mob)
{
return mob.FindGump(typeof(FactionGump)) != null;
}
public FactionGump( int x, int y ) : base( x, y )
{
}
}
public void AddHtmlText(int x, int y, int width, int height, TextDefinition text, bool back, bool scroll)
{
if (text != null && text.Number > 0)
AddHtmlLocalized(x, y, width, height, text.Number, back, scroll);
else if (text?.String != null)
AddHtml(x, y, width, height, text.String, back, scroll);
}
}
}

View file

@ -1,101 +1,102 @@
using Server.Items;
using Server.Gumps;
using Server.Network;
using Server.Engines.Craft;
using Server.Gumps;
using Server.Items;
using Server.Network;
namespace Server.Factions
{
public class FactionImbueGump : FactionGump
{
private Item m_Item;
private Mobile m_Mobile;
private Faction m_Faction;
private CraftSystem m_CraftSystem;
private BaseTool m_Tool;
private object m_Notice;
private int m_Quality;
public class FactionImbueGump : FactionGump
{
private CraftSystem m_CraftSystem;
private FactionItemDefinition m_Definition;
private FactionItemDefinition m_Definition;
private Faction m_Faction;
private Item m_Item;
private Mobile m_Mobile;
private object m_Notice;
private int m_Quality;
private BaseTool m_Tool;
public FactionImbueGump( int quality, Item item, Mobile from, CraftSystem craftSystem, BaseTool tool, object notice, int availableSilver, Faction faction, FactionItemDefinition def ) : base( 100, 200 )
{
m_Item = item;
m_Mobile = from;
m_Faction = faction;
m_CraftSystem = craftSystem;
m_Tool = tool;
m_Notice = notice;
m_Quality = quality;
m_Definition = def;
public FactionImbueGump(int quality, Item item, Mobile from, CraftSystem craftSystem, BaseTool tool, object notice,
int availableSilver, Faction faction, FactionItemDefinition def) : base(100, 200)
{
m_Item = item;
m_Mobile = from;
m_Faction = faction;
m_CraftSystem = craftSystem;
m_Tool = tool;
m_Notice = notice;
m_Quality = quality;
m_Definition = def;
AddPage( 0 );
AddPage(0);
AddBackground( 0, 0, 320, 270, 5054 );
AddBackground( 10, 10, 300, 250, 3000 );
AddBackground(0, 0, 320, 270, 5054);
AddBackground(10, 10, 300, 250, 3000);
AddHtmlLocalized( 20, 20, 210, 25, 1011569, false, false ); // Imbue with Faction properties?
AddHtmlLocalized(20, 20, 210, 25, 1011569, false, false); // Imbue with Faction properties?
AddHtmlLocalized( 20, 60, 170, 25, 1018302, false, false ); // Item quality:
AddHtmlLocalized( 175, 60, 100, 25, 1018305 - m_Quality, false, false ); // Exceptional, Average, Low
AddHtmlLocalized(20, 60, 170, 25, 1018302, false, false); // Item quality:
AddHtmlLocalized(175, 60, 100, 25, 1018305 - m_Quality, false, false); // Exceptional, Average, Low
AddHtmlLocalized( 20, 80, 170, 25, 1011572, false, false ); // Item Cost :
AddLabel( 175, 80, 0x34, def.SilverCost.ToString( "N0" ) ); // NOTE: Added 'N0'
AddHtmlLocalized(20, 80, 170, 25, 1011572, false, false); // Item Cost :
AddLabel(175, 80, 0x34, def.SilverCost.ToString("N0")); // NOTE: Added 'N0'
AddHtmlLocalized( 20, 100, 170, 25, 1011573, false, false ); // Your Silver :
AddLabel( 175, 100, 0x34, availableSilver.ToString( "N0" ) ); // NOTE: Added 'N0'
AddHtmlLocalized(20, 100, 170, 25, 1011573, false, false); // Your Silver :
AddLabel(175, 100, 0x34, availableSilver.ToString("N0")); // NOTE: Added 'N0'
AddRadio( 20, 140, 210, 211, true, 1 );
AddLabel( 55, 140, m_Faction.Definition.HuePrimary - 1, "*****" );
AddHtmlLocalized( 150, 140, 150, 25, 1011570, false, false ); // Primary Color
AddRadio(20, 140, 210, 211, true, 1);
AddLabel(55, 140, m_Faction.Definition.HuePrimary - 1, "*****");
AddHtmlLocalized(150, 140, 150, 25, 1011570, false, false); // Primary Color
AddRadio( 20, 160, 210, 211, false, 2 );
AddLabel( 55, 160, m_Faction.Definition.HueSecondary - 1, "*****" );
AddHtmlLocalized( 150, 160, 150, 25, 1011571, false, false ); // Secondary Color
AddRadio(20, 160, 210, 211, false, 2);
AddLabel(55, 160, m_Faction.Definition.HueSecondary - 1, "*****");
AddHtmlLocalized(150, 160, 150, 25, 1011571, false, false); // Secondary Color
AddHtmlLocalized( 55, 200, 200, 25, 1011011, false, false ); // CONTINUE
AddButton( 20, 200, 4005, 4007, 1, GumpButtonType.Reply, 0 );
AddHtmlLocalized(55, 200, 200, 25, 1011011, false, false); // CONTINUE
AddButton(20, 200, 4005, 4007, 1, GumpButtonType.Reply, 0);
AddHtmlLocalized( 55, 230, 200, 25, 1011012, false, false ); // CANCEL
AddButton( 20, 230, 4005, 4007, 0, GumpButtonType.Reply, 0 );
}
AddHtmlLocalized(55, 230, 200, 25, 1011012, false, false); // CANCEL
AddButton(20, 230, 4005, 4007, 0, GumpButtonType.Reply, 0);
}
public override void OnResponse( NetState sender, RelayInfo info )
{
if ( info.ButtonID == 1 )
{
Container pack = m_Mobile.Backpack;
public override void OnResponse(NetState sender, RelayInfo info)
{
if (info.ButtonID == 1)
{
Container pack = m_Mobile.Backpack;
if ( pack != null && m_Item.IsChildOf( pack ) )
{
if ( pack.ConsumeTotal( typeof( Silver ), m_Definition.SilverCost ) )
{
int hue;
if (pack != null && m_Item.IsChildOf(pack))
{
if (pack.ConsumeTotal(typeof(Silver), m_Definition.SilverCost))
{
int hue;
if ( m_Item is SpellScroll )
hue = 0;
else if ( info.IsSwitched( 1 ) )
hue = m_Faction.Definition.HuePrimary;
else
hue = m_Faction.Definition.HueSecondary;
if (m_Item is SpellScroll)
hue = 0;
else if (info.IsSwitched(1))
hue = m_Faction.Definition.HuePrimary;
else
hue = m_Faction.Definition.HueSecondary;
FactionItem.Imbue( m_Item, m_Faction, true, hue );
}
else
{
m_Mobile.SendLocalizedMessage( 1042204 ); // You do not have enough silver.
}
}
}
FactionItem.Imbue(m_Item, m_Faction, true, hue);
}
else
{
m_Mobile.SendLocalizedMessage(1042204); // You do not have enough silver.
}
}
}
if ( m_Tool != null && !m_Tool.Deleted && m_Tool.UsesRemaining > 0 )
m_Mobile.SendGump( new CraftGump( m_Mobile, m_CraftSystem, m_Tool, m_Notice ) );
else if ( m_Notice is string s )
m_Mobile.SendMessage( s );
else if ( m_Notice is int i && i > 0 )
m_Mobile.SendLocalizedMessage( i );
}
}
}
if (m_Tool != null && !m_Tool.Deleted && m_Tool.UsesRemaining > 0)
m_Mobile.SendGump(new CraftGump(m_Mobile, m_CraftSystem, m_Tool, m_Notice));
else if (m_Notice is string s)
m_Mobile.SendMessage(s);
else if (m_Notice is int i && i > 0)
m_Mobile.SendLocalizedMessage(i);
}
}
}

View file

@ -1,345 +1,359 @@
using System.Collections.Generic;
using Server.Gumps;
using Server.Mobiles;
using Server.Network;
using System.Collections.Generic;
namespace Server.Factions
{
public class FactionStoneGump : FactionGump
{
private PlayerMobile m_From;
private Faction m_Faction;
public class FactionStoneGump : FactionGump
{
private Faction m_Faction;
private PlayerMobile m_From;
public override int ButtonTypes => 4;
public FactionStoneGump(PlayerMobile from, Faction faction) : base(20, 30)
{
m_From = from;
m_Faction = faction;
public FactionStoneGump( PlayerMobile from, Faction faction ) : base( 20, 30 )
{
m_From = from;
m_Faction = faction;
AddPage(0);
AddPage( 0 );
AddBackground(0, 0, 550, 440, 5054);
AddBackground(10, 10, 530, 420, 3000);
AddBackground( 0, 0, 550, 440, 5054 );
AddBackground( 10, 10, 530, 420, 3000 );
#region General
#region General
AddPage( 1 );
AddPage(1);
AddHtmlText( 20, 30, 510, 20, faction.Definition.Header, false, false );
AddHtmlText(20, 30, 510, 20, faction.Definition.Header, false, false);
AddHtmlLocalized( 20, 60, 100, 20, 1011429, false, false ); // Led By :
AddHtml( 125, 60, 200, 20, faction.Commander != null ? faction.Commander.Name : "Nobody", false, false );
AddHtmlLocalized(20, 60, 100, 20, 1011429, false, false); // Led By :
AddHtml(125, 60, 200, 20, faction.Commander != null ? faction.Commander.Name : "Nobody", false, false);
AddHtmlLocalized( 20, 80, 100, 20, 1011457, false, false ); // Tithe rate :
if ( faction.Tithe >= 0 && faction.Tithe <= 100 && (faction.Tithe % 10) == 0 )
AddHtmlLocalized( 125, 80, 350, 20, 1011480 + (faction.Tithe / 10), false, false );
else
AddHtml( 125, 80, 350, 20, faction.Tithe + "%", false, false );
AddHtmlLocalized(20, 80, 100, 20, 1011457, false, false); // Tithe rate :
if (faction.Tithe >= 0 && faction.Tithe <= 100 && faction.Tithe % 10 == 0)
AddHtmlLocalized(125, 80, 350, 20, 1011480 + faction.Tithe / 10, false, false);
else
AddHtml(125, 80, 350, 20, faction.Tithe + "%", false, false);
AddHtmlLocalized( 20, 100, 100, 20, 1011458, false, false ); // Traps placed :
AddHtml( 125, 100, 50, 20, faction.Traps.Count.ToString(), false, false );
AddHtmlLocalized(20, 100, 100, 20, 1011458, false, false); // Traps placed :
AddHtml(125, 100, 50, 20, faction.Traps.Count.ToString(), false, false);
AddHtmlLocalized( 55, 225, 200, 20, 1011428, false, false ); // VOTE FOR LEADERSHIP
AddButton( 20, 225, 4005, 4007, ToButtonID( 0, 0 ), GumpButtonType.Reply, 0 );
AddHtmlLocalized(55, 225, 200, 20, 1011428, false, false); // VOTE FOR LEADERSHIP
AddButton(20, 225, 4005, 4007, ToButtonID(0, 0), GumpButtonType.Reply, 0);
AddHtmlLocalized( 55, 150, 100, 20, 1011430, false, false ); // CITY STATUS
AddButton( 20, 150, 4005, 4007, 0, GumpButtonType.Page, 2 );
AddHtmlLocalized(55, 150, 100, 20, 1011430, false, false); // CITY STATUS
AddButton(20, 150, 4005, 4007, 0, GumpButtonType.Page, 2);
AddHtmlLocalized( 55, 175, 100, 20, 1011444, false, false ); // STATISTICS
AddButton( 20, 175, 4005, 4007, 0, GumpButtonType.Page, 4 );
AddHtmlLocalized(55, 175, 100, 20, 1011444, false, false); // STATISTICS
AddButton(20, 175, 4005, 4007, 0, GumpButtonType.Page, 4);
bool isMerchantQualified = MerchantTitles.HasMerchantQualifications( from );
bool isMerchantQualified = MerchantTitles.HasMerchantQualifications(from);
PlayerState pl = PlayerState.Find( from );
PlayerState pl = PlayerState.Find(from);
if ( pl != null && pl.MerchantTitle != MerchantTitle.None )
{
AddHtmlLocalized( 55, 200, 250, 20, 1011460, false, false ); // UNDECLARE FACTION MERCHANT
AddButton( 20, 200, 4005, 4007, ToButtonID( 1, 0 ), GumpButtonType.Reply, 0 );
}
else if ( isMerchantQualified )
{
AddHtmlLocalized( 55, 200, 250, 20, 1011459, false, false ); // DECLARE FACTION MERCHANT
AddButton( 20, 200, 4005, 4007, 0, GumpButtonType.Page, 5 );
}
else
{
AddHtmlLocalized( 55, 200, 250, 20, 1011467, false, false ); // MERCHANT OPTIONS
AddImage( 20, 200, 4020 );
}
if (pl != null && pl.MerchantTitle != MerchantTitle.None)
{
AddHtmlLocalized(55, 200, 250, 20, 1011460, false, false); // UNDECLARE FACTION MERCHANT
AddButton(20, 200, 4005, 4007, ToButtonID(1, 0), GumpButtonType.Reply, 0);
}
else if (isMerchantQualified)
{
AddHtmlLocalized(55, 200, 250, 20, 1011459, false, false); // DECLARE FACTION MERCHANT
AddButton(20, 200, 4005, 4007, 0, GumpButtonType.Page, 5);
}
else
{
AddHtmlLocalized(55, 200, 250, 20, 1011467, false, false); // MERCHANT OPTIONS
AddImage(20, 200, 4020);
}
AddHtmlLocalized( 55, 250, 300, 20, 1011461, false, false ); // COMMANDER OPTIONS
if ( faction.IsCommander( from ) )
AddButton( 20, 250, 4005, 4007, 0, GumpButtonType.Page, 6 );
else
AddImage( 20, 250, 4020 );
AddHtmlLocalized(55, 250, 300, 20, 1011461, false, false); // COMMANDER OPTIONS
if (faction.IsCommander(from))
AddButton(20, 250, 4005, 4007, 0, GumpButtonType.Page, 6);
else
AddImage(20, 250, 4020);
AddHtmlLocalized( 55, 275, 300, 20, 1011426, false, false ); // LEAVE THIS FACTION
AddButton( 20, 275, 4005, 4007, ToButtonID( 0, 1 ), GumpButtonType.Reply, 0 );
AddHtmlLocalized(55, 275, 300, 20, 1011426, false, false); // LEAVE THIS FACTION
AddButton(20, 275, 4005, 4007, ToButtonID(0, 1), GumpButtonType.Reply, 0);
AddHtmlLocalized( 55, 300, 200, 20, 1011441, false, false ); // EXIT
AddButton( 20, 300, 4005, 4007, 0, GumpButtonType.Reply, 0 );
#endregion
AddHtmlLocalized(55, 300, 200, 20, 1011441, false, false); // EXIT
AddButton(20, 300, 4005, 4007, 0, GumpButtonType.Reply, 0);
#region City Status
AddPage( 2 );
#endregion
AddHtmlLocalized( 20, 30, 250, 20, 1011430, false, false ); // CITY STATUS
#region City Status
List<Town> towns = Town.Towns;
AddPage(2);
for ( int i = 0; i < towns.Count; ++i )
{
Town town = towns[i];
AddHtmlLocalized(20, 30, 250, 20, 1011430, false, false); // CITY STATUS
AddHtmlText( 40, 55 + (i * 30), 150, 20, town.Definition.TownName, false, false );
List<Town> towns = Town.Towns;
if ( town.Owner == null )
{
AddHtmlLocalized( 200, 55 + (i * 30), 150, 20, 1011462, false, false ); // : Neutral
}
else
{
AddHtmlLocalized( 200, 55 + (i * 30), 150, 20, town.Owner.Definition.OwnerLabel, false, false );
for (int i = 0; i < towns.Count; ++i)
{
Town town = towns[i];
BaseMonolith monolith = town.Monolith;
AddHtmlText(40, 55 + i * 30, 150, 20, town.Definition.TownName, false, false);
AddImage( 20, 60 + (i * 30), ( monolith?.Sigil != null && monolith.Sigil.IsPurifying ) ? 0x938 : 0x939 );
}
}
if (town.Owner == null)
{
AddHtmlLocalized(200, 55 + i * 30, 150, 20, 1011462, false, false); // : Neutral
}
else
{
AddHtmlLocalized(200, 55 + i * 30, 150, 20, town.Owner.Definition.OwnerLabel, false, false);
BaseMonolith monolith = town.Monolith;
AddImage( 20, 300, 2361 );
AddHtmlLocalized( 45, 295, 300, 20, 1011491, false, false ); // sigil may be recaptured
AddImage(20, 60 + i * 30, monolith?.Sigil != null && monolith.Sigil.IsPurifying ? 0x938 : 0x939);
}
}
AddImage( 20, 320, 2360 );
AddHtmlLocalized( 45, 315, 300, 20, 1011492, false, false ); // sigil may not be recaptured
AddHtmlLocalized( 55, 350, 100, 20, 1011447, false, false ); // BACK
AddButton( 20, 350, 4005, 4007, 0, GumpButtonType.Page, 1 );
#endregion
AddImage(20, 300, 2361);
AddHtmlLocalized(45, 295, 300, 20, 1011491, false, false); // sigil may be recaptured
#region Statistics
AddPage( 4 );
AddImage(20, 320, 2360);
AddHtmlLocalized(45, 315, 300, 20, 1011492, false, false); // sigil may not be recaptured
AddHtmlLocalized( 20, 30, 150, 20, 1011444, false, false ); // STATISTICS
AddHtmlLocalized(55, 350, 100, 20, 1011447, false, false); // BACK
AddButton(20, 350, 4005, 4007, 0, GumpButtonType.Page, 1);
AddHtmlLocalized( 20, 100, 100, 20, 1011445, false, false ); // Name :
AddHtml( 120, 100, 150, 20, from.Name, false, false );
#endregion
AddHtmlLocalized( 20, 130, 100, 20, 1018064, false, false ); // score :
AddHtml( 120, 130, 100, 20, (pl?.KillPoints ?? 0).ToString(), false, false );
#region Statistics
AddHtmlLocalized( 20, 160, 100, 20, 1011446, false, false ); // Rank :
AddHtml( 120, 160, 100, 20, (pl?.Rank.Rank ?? 0).ToString(), false, false );
AddPage(4);
AddHtmlLocalized( 55, 250, 100, 20, 1011447, false, false ); // BACK
AddButton( 20, 250, 4005, 4007, 0, GumpButtonType.Page, 1 );
#endregion
AddHtmlLocalized(20, 30, 150, 20, 1011444, false, false); // STATISTICS
#region Merchant Options
if ( ( pl == null || pl.MerchantTitle == MerchantTitle.None ) && isMerchantQualified )
{
AddPage( 5 );
AddHtmlLocalized(20, 100, 100, 20, 1011445, false, false); // Name :
AddHtml(120, 100, 150, 20, from.Name, false, false);
AddHtmlLocalized( 20, 30, 250, 20, 1011467, false, false ); // MERCHANT OPTIONS
AddHtmlLocalized(20, 130, 100, 20, 1018064, false, false); // score :
AddHtml(120, 130, 100, 20, (pl?.KillPoints ?? 0).ToString(), false, false);
AddHtmlLocalized( 20, 80, 300, 20, 1011473, false, false ); // Select the title you wish to display
AddHtmlLocalized(20, 160, 100, 20, 1011446, false, false); // Rank :
AddHtml(120, 160, 100, 20, (pl?.Rank.Rank ?? 0).ToString(), false, false);
MerchantTitleInfo[] infos = MerchantTitles.Info;
AddHtmlLocalized(55, 250, 100, 20, 1011447, false, false); // BACK
AddButton(20, 250, 4005, 4007, 0, GumpButtonType.Page, 1);
for ( int i = 0; i < infos.Length; ++i )
{
MerchantTitleInfo info = infos[i];
#endregion
if ( MerchantTitles.IsQualified( from, info ) )
AddButton( 20, 100 + (i * 30), 4005, 4007, ToButtonID( 1, i + 1 ), GumpButtonType.Reply, 0 );
else
AddImage( 20, 100 + (i * 30), 4020 );
#region Merchant Options
AddHtmlText( 55, 100 + (i * 30), 200, 20, info.Label, false, false );
}
if ((pl == null || pl.MerchantTitle == MerchantTitle.None) && isMerchantQualified)
{
AddPage(5);
AddHtmlLocalized( 55, 340, 100, 20, 1011447, false, false ); // BACK
AddButton( 20, 340, 4005, 4007, 0, GumpButtonType.Page, 1 );
}
#endregion
AddHtmlLocalized(20, 30, 250, 20, 1011467, false, false); // MERCHANT OPTIONS
#region Commander Options
if ( faction.IsCommander( from ) )
{
#region General
AddPage( 6 );
AddHtmlLocalized(20, 80, 300, 20, 1011473, false, false); // Select the title you wish to display
AddHtmlLocalized( 20, 30, 200, 20, 1011461, false, false ); // COMMANDER OPTIONS
MerchantTitleInfo[] infos = MerchantTitles.Info;
AddHtmlLocalized( 20, 70, 120, 20, 1011457, false, false ); // Tithe rate :
if ( faction.Tithe >= 0 && faction.Tithe <= 100 && (faction.Tithe % 10) == 0 )
AddHtmlLocalized( 140, 70, 250, 20, 1011480 + (faction.Tithe / 10), false, false );
else
AddHtml( 140, 70, 250, 20, faction.Tithe + "%", false, false );
for (int i = 0; i < infos.Length; ++i)
{
MerchantTitleInfo info = infos[i];
AddHtmlLocalized( 20, 100, 120, 20, 1011474, false, false ); // Silver available :
AddHtml( 140, 100, 50, 20, faction.Silver.ToString( "N0" ), false, false ); // NOTE: Added 'N0' formatting
if (MerchantTitles.IsQualified(from, info))
AddButton(20, 100 + i * 30, 4005, 4007, ToButtonID(1, i + 1), GumpButtonType.Reply, 0);
else
AddImage(20, 100 + i * 30, 4020);
AddHtmlLocalized( 55, 130, 200, 20, 1011478, false, false ); // CHANGE TITHE RATE
AddButton( 20, 130, 4005, 4007, 0, GumpButtonType.Page, 8 );
AddHtmlText(55, 100 + i * 30, 200, 20, info.Label, false, false);
}
AddHtmlLocalized( 55, 160, 200, 20, 1018301, false, false ); // TRANSFER SILVER
if ( faction.Silver >= 10000 )
AddButton( 20, 160, 4005, 4007, 0, GumpButtonType.Page, 7 );
else
AddImage( 20, 160, 4020 );
AddHtmlLocalized(55, 340, 100, 20, 1011447, false, false); // BACK
AddButton(20, 340, 4005, 4007, 0, GumpButtonType.Page, 1);
}
AddHtmlLocalized( 55, 310, 100, 20, 1011447, false, false ); // BACK
AddButton( 20, 310, 4005, 4007, 0, GumpButtonType.Page, 1 );
#endregion
#region Town Finance
if ( faction.Silver >= 10000 )
{
AddPage( 7 );
#endregion
AddHtmlLocalized( 20, 30, 250, 20, 1011476, false, false ); // TOWN FINANCE
#region Commander Options
AddHtmlLocalized( 20, 50, 400, 20, 1011477, false, false ); // Select a town to transfer 10000 silver to
if (faction.IsCommander(from))
{
#region General
for ( int i = 0; i < towns.Count; ++i )
{
Town town = towns[i];
AddPage(6);
AddHtmlText( 55, 75 + (i * 30), 200, 20, town.Definition.TownName, false, false );
if ( town.Owner == faction )
AddButton( 20, 75 + (i * 30), 4005, 4007, ToButtonID( 2, i ), GumpButtonType.Reply, 0 );
else
AddImage( 20, 75 + (i * 30), 4020 );
}
AddHtmlLocalized( 55, 310, 100, 20, 1011447, false, false ); // BACK
AddButton( 20, 310, 4005, 4007, 0, GumpButtonType.Page, 1 );
}
#endregion
#region Change Tithe Rate
AddPage( 8 );
AddHtmlLocalized( 20, 30, 400, 20, 1011479, false, false ); // Select the % for the new tithe rate
int y = 55;
for ( int i = 0; i <= 10; ++i )
{
if ( i == 5 )
y += 5;
AddHtmlLocalized( 55, y, 300, 20, 1011480 + i, false, false );
AddButton( 20, y, 4005, 4007, ToButtonID( 3, i ), GumpButtonType.Reply, 0 );
y += 20;
if ( i == 5 )
y += 5;
}
AddHtmlLocalized( 55, 310, 300, 20, 1011447, false, false ); // BACK
AddButton( 20, 310, 4005, 4007, 0, GumpButtonType.Page, 1 );
#endregion
}
#endregion
}
public override void OnResponse( NetState sender, RelayInfo info )
{
int type, index;
if ( !FromButtonID( info.ButtonID, out type, out index ) )
return;
switch ( type )
{
case 0: // general
{
switch ( index )
{
case 0: // vote
{
m_From.SendGump( new ElectionGump( m_From, m_Faction.Election ) );
break;
}
case 1: // leave
{
m_From.SendGump( new LeaveFactionGump( m_From, m_Faction ) );
break;
}
}
break;
}
case 1: // merchant title
{
if ( index >= 0 && index <= MerchantTitles.Info.Length )
{
PlayerState pl = PlayerState.Find( m_From );
MerchantTitle newTitle = (MerchantTitle)index;
MerchantTitleInfo mti = MerchantTitles.GetInfo( newTitle );
if ( mti == null )
{
m_From.SendLocalizedMessage( 1010120 ); // Your merchant title has been removed
if ( pl != null )
pl.MerchantTitle = newTitle;
}
else if ( MerchantTitles.IsQualified( m_From, mti ) )
{
m_From.SendLocalizedMessage( mti.Assigned );
if ( pl != null )
pl.MerchantTitle = newTitle;
}
}
break;
}
case 2: // transfer silver
{
if ( !m_Faction.IsCommander( m_From ) )
return;
List<Town> towns = Town.Towns;
if ( index >= 0 && index < towns.Count )
{
Town town = towns[index];
if ( town.Owner == m_Faction )
{
if ( m_Faction.Silver >= 10000 )
{
m_Faction.Silver -= 10000;
town.Silver += 10000;
// 10k in silver has been received by:
m_From.SendLocalizedMessage( 1042726, true, " " + town.Definition.FriendlyName );
}
}
}
break;
}
case 3: // change tithe
{
if ( !m_Faction.IsCommander( m_From ) )
return;
if ( index >= 0 && index <= 10 )
m_Faction.Tithe = index*10;
break;
}
}
}
}
}
AddHtmlLocalized(20, 30, 200, 20, 1011461, false, false); // COMMANDER OPTIONS
AddHtmlLocalized(20, 70, 120, 20, 1011457, false, false); // Tithe rate :
if (faction.Tithe >= 0 && faction.Tithe <= 100 && faction.Tithe % 10 == 0)
AddHtmlLocalized(140, 70, 250, 20, 1011480 + faction.Tithe / 10, false, false);
else
AddHtml(140, 70, 250, 20, faction.Tithe + "%", false, false);
AddHtmlLocalized(20, 100, 120, 20, 1011474, false, false); // Silver available :
AddHtml(140, 100, 50, 20, faction.Silver.ToString("N0"), false, false); // NOTE: Added 'N0' formatting
AddHtmlLocalized(55, 130, 200, 20, 1011478, false, false); // CHANGE TITHE RATE
AddButton(20, 130, 4005, 4007, 0, GumpButtonType.Page, 8);
AddHtmlLocalized(55, 160, 200, 20, 1018301, false, false); // TRANSFER SILVER
if (faction.Silver >= 10000)
AddButton(20, 160, 4005, 4007, 0, GumpButtonType.Page, 7);
else
AddImage(20, 160, 4020);
AddHtmlLocalized(55, 310, 100, 20, 1011447, false, false); // BACK
AddButton(20, 310, 4005, 4007, 0, GumpButtonType.Page, 1);
#endregion
#region Town Finance
if (faction.Silver >= 10000)
{
AddPage(7);
AddHtmlLocalized(20, 30, 250, 20, 1011476, false, false); // TOWN FINANCE
AddHtmlLocalized(20, 50, 400, 20, 1011477, false, false); // Select a town to transfer 10000 silver to
for (int i = 0; i < towns.Count; ++i)
{
Town town = towns[i];
AddHtmlText(55, 75 + i * 30, 200, 20, town.Definition.TownName, false, false);
if (town.Owner == faction)
AddButton(20, 75 + i * 30, 4005, 4007, ToButtonID(2, i), GumpButtonType.Reply, 0);
else
AddImage(20, 75 + i * 30, 4020);
}
AddHtmlLocalized(55, 310, 100, 20, 1011447, false, false); // BACK
AddButton(20, 310, 4005, 4007, 0, GumpButtonType.Page, 1);
}
#endregion
#region Change Tithe Rate
AddPage(8);
AddHtmlLocalized(20, 30, 400, 20, 1011479, false, false); // Select the % for the new tithe rate
int y = 55;
for (int i = 0; i <= 10; ++i)
{
if (i == 5)
y += 5;
AddHtmlLocalized(55, y, 300, 20, 1011480 + i, false, false);
AddButton(20, y, 4005, 4007, ToButtonID(3, i), GumpButtonType.Reply, 0);
y += 20;
if (i == 5)
y += 5;
}
AddHtmlLocalized(55, 310, 300, 20, 1011447, false, false); // BACK
AddButton(20, 310, 4005, 4007, 0, GumpButtonType.Page, 1);
#endregion
}
#endregion
}
public override int ButtonTypes => 4;
public override void OnResponse(NetState sender, RelayInfo info)
{
int type, index;
if (!FromButtonID(info.ButtonID, out type, out index))
return;
switch (type)
{
case 0: // general
{
switch (index)
{
case 0: // vote
{
m_From.SendGump(new ElectionGump(m_From, m_Faction.Election));
break;
}
case 1: // leave
{
m_From.SendGump(new LeaveFactionGump(m_From, m_Faction));
break;
}
}
break;
}
case 1: // merchant title
{
if (index >= 0 && index <= MerchantTitles.Info.Length)
{
PlayerState pl = PlayerState.Find(m_From);
MerchantTitle newTitle = (MerchantTitle)index;
MerchantTitleInfo mti = MerchantTitles.GetInfo(newTitle);
if (mti == null)
{
m_From.SendLocalizedMessage(1010120); // Your merchant title has been removed
if (pl != null)
pl.MerchantTitle = newTitle;
}
else if (MerchantTitles.IsQualified(m_From, mti))
{
m_From.SendLocalizedMessage(mti.Assigned);
if (pl != null)
pl.MerchantTitle = newTitle;
}
}
break;
}
case 2: // transfer silver
{
if (!m_Faction.IsCommander(m_From))
return;
List<Town> towns = Town.Towns;
if (index >= 0 && index < towns.Count)
{
Town town = towns[index];
if (town.Owner == m_Faction)
if (m_Faction.Silver >= 10000)
{
m_Faction.Silver -= 10000;
town.Silver += 10000;
// 10k in silver has been received by:
m_From.SendLocalizedMessage(1042726, true, " " + town.Definition.FriendlyName);
}
}
break;
}
case 3: // change tithe
{
if (!m_Faction.IsCommander(m_From))
return;
if (index >= 0 && index <= 10)
m_Faction.Tithe = index * 10;
break;
}
}
}
}
}

View file

@ -1,278 +1,296 @@
using System;
using System.Collections.Generic;
using Server.Gumps;
using Server.Mobiles;
using Server.Multis;
using Server.Network;
using System.Collections.Generic;
namespace Server.Factions
{
public class FinanceGump : FactionGump
{
private PlayerMobile m_From;
private Faction m_Faction;
private Town m_Town;
public class FinanceGump : FactionGump
{
private static int[] m_PriceOffsets =
{
-30, -25, -20, -15, -10, -5,
+50, +100, +150, +200, +250, +300
};
private static int[] m_PriceOffsets = {
-30, -25, -20, -15, -10, -5,
+50, +100, +150, +200, +250, +300
};
private Faction m_Faction;
private PlayerMobile m_From;
private Town m_Town;
public override int ButtonTypes => 2;
public FinanceGump(PlayerMobile from, Faction faction, Town town) : base(50, 50)
{
m_From = from;
m_Faction = faction;
m_Town = town;
public FinanceGump( PlayerMobile from, Faction faction, Town town ) : base( 50, 50 )
{
m_From = from;
m_Faction = faction;
m_Town = town;
AddPage(0);
AddPage( 0 );
AddBackground(0, 0, 320, 410, 5054);
AddBackground(10, 10, 300, 390, 3000);
AddBackground( 0, 0, 320, 410, 5054 );
AddBackground( 10, 10, 300, 390, 3000 );
#region General
#region General
AddPage( 1 );
AddPage(1);
AddHtmlLocalized( 20, 30, 260, 25, 1011541, false, false ); // FINANCE MINISTER
AddHtmlLocalized(20, 30, 260, 25, 1011541, false, false); // FINANCE MINISTER
AddHtmlLocalized( 55, 90, 200, 25, 1011539, false, false ); // CHANGE PRICES
AddButton( 20, 90, 4005, 4007, 0, GumpButtonType.Page, 2 );
AddHtmlLocalized(55, 90, 200, 25, 1011539, false, false); // CHANGE PRICES
AddButton(20, 90, 4005, 4007, 0, GumpButtonType.Page, 2);
AddHtmlLocalized( 55, 120, 200, 25, 1011540, false, false ); // BUY SHOPKEEPERS
AddButton( 20, 120, 4005, 4007, 0, GumpButtonType.Page, 3 );
AddHtmlLocalized(55, 120, 200, 25, 1011540, false, false); // BUY SHOPKEEPERS
AddButton(20, 120, 4005, 4007, 0, GumpButtonType.Page, 3);
AddHtmlLocalized( 55, 150, 200, 25, 1011495, false, false ); // VIEW FINANCES
AddButton( 20, 150, 4005, 4007, 0, GumpButtonType.Page, 4 );
AddHtmlLocalized(55, 150, 200, 25, 1011495, false, false); // VIEW FINANCES
AddButton(20, 150, 4005, 4007, 0, GumpButtonType.Page, 4);
AddHtmlLocalized( 55, 360, 200, 25, 1011441, false, false ); // EXIT
AddButton( 20, 360, 4005, 4007, 0, GumpButtonType.Reply, 0 );
#endregion
AddHtmlLocalized(55, 360, 200, 25, 1011441, false, false); // EXIT
AddButton(20, 360, 4005, 4007, 0, GumpButtonType.Reply, 0);
#region Change Prices
AddPage( 2 );
#endregion
AddHtmlLocalized( 20, 30, 200, 25, 1011539, false, false ); // CHANGE PRICES
#region Change Prices
for ( int i = 0; i < m_PriceOffsets.Length; ++i )
{
int ofs = m_PriceOffsets[i];
AddPage(2);
int x = 20 + ((i / 6) * 150);
int y = 90 + ((i % 6) * 30);
AddHtmlLocalized(20, 30, 200, 25, 1011539, false, false); // CHANGE PRICES
AddRadio( x, y, 208, 209, ( town.Tax == ofs ), i+1 );
for (int i = 0; i < m_PriceOffsets.Length; ++i)
{
int ofs = m_PriceOffsets[i];
if ( ofs < 0 )
AddLabel( x + 35, y, 0x26, string.Concat( "- ", -ofs, "%" ) );
else
AddLabel( x + 35, y, 0x12A, string.Concat( "+ ", ofs, "%" ) );
}
int x = 20 + i / 6 * 150;
int y = 90 + i % 6 * 30;
AddRadio( 20, 270, 208, 209, ( town.Tax == 0 ), 0 );
AddHtmlLocalized( 55, 270, 90, 25, 1011542, false, false ); // normal
AddRadio(x, y, 208, 209, town.Tax == ofs, i + 1);
AddHtmlLocalized( 55, 330, 200, 25, 1011509, false, false ); // Set Prices
AddButton( 20, 330, 4005, 4007, ToButtonID( 0, 0 ), GumpButtonType.Reply, 0 );
if (ofs < 0)
AddLabel(x + 35, y, 0x26, string.Concat("- ", -ofs, "%"));
else
AddLabel(x + 35, y, 0x12A, string.Concat("+ ", ofs, "%"));
}
AddHtmlLocalized( 55, 360, 200, 25, 1011067, false, false ); // Previous page
AddButton( 20, 360, 4005, 4007, 0, GumpButtonType.Page, 1 );
#endregion
AddRadio(20, 270, 208, 209, town.Tax == 0, 0);
AddHtmlLocalized(55, 270, 90, 25, 1011542, false, false); // normal
#region Buy Shopkeepers
AddPage( 3 );
AddHtmlLocalized(55, 330, 200, 25, 1011509, false, false); // Set Prices
AddButton(20, 330, 4005, 4007, ToButtonID(0, 0), GumpButtonType.Reply, 0);
AddHtmlLocalized( 20, 30, 200, 25, 1011540, false, false ); // BUY SHOPKEEPERS
AddHtmlLocalized(55, 360, 200, 25, 1011067, false, false); // Previous page
AddButton(20, 360, 4005, 4007, 0, GumpButtonType.Page, 1);
List<VendorList> vendorLists = town.VendorLists;
#endregion
for ( int i = 0; i < vendorLists.Count; ++i )
{
VendorList list = vendorLists[i];
#region Buy Shopkeepers
AddButton( 20, 90 + (i * 40), 4005, 4007, 0, GumpButtonType.Page, 5 + i );
AddItem( 55, 90 + (i * 40), list.Definition.ItemID );
AddHtmlText( 100, 90 + (i * 40), 200, 25, list.Definition.Label, false, false );
}
AddPage(3);
AddHtmlLocalized( 55, 360, 200, 25, 1011067, false, false ); // Previous page
AddButton( 20, 360, 4005, 4007, 0, GumpButtonType.Page, 1 );
#endregion
AddHtmlLocalized(20, 30, 200, 25, 1011540, false, false); // BUY SHOPKEEPERS
#region View Finances
AddPage( 4 );
List<VendorList> vendorLists = town.VendorLists;
int financeUpkeep = town.FinanceUpkeep;
int sheriffUpkeep = town.SheriffUpkeep;
int dailyIncome = town.DailyIncome;
int netCashFlow = town.NetCashFlow;
for (int i = 0; i < vendorLists.Count; ++i)
{
VendorList list = vendorLists[i];
AddButton(20, 90 + i * 40, 4005, 4007, 0, GumpButtonType.Page, 5 + i);
AddItem(55, 90 + i * 40, list.Definition.ItemID);
AddHtmlText(100, 90 + i * 40, 200, 25, list.Definition.Label, false, false);
}
AddHtmlLocalized( 20, 30, 300, 25, 1011524, false, false ); // FINANCE STATEMENT
AddHtmlLocalized(55, 360, 200, 25, 1011067, false, false); // Previous page
AddButton(20, 360, 4005, 4007, 0, GumpButtonType.Page, 1);
AddHtmlLocalized( 20, 80, 300, 25, 1011538, false, false ); // Current total money for town :
AddLabel( 20, 100, 0x44, town.Silver.ToString() );
#endregion
AddHtmlLocalized( 20, 130, 300, 25, 1011520, false, false ); // Finance Minister Upkeep :
AddLabel( 20, 150, 0x44, financeUpkeep.ToString( "N0" ) ); // NOTE: Added 'N0'
#region View Finances
AddHtmlLocalized( 20, 180, 300, 25, 1011521, false, false ); // Sheriff Upkeep :
AddLabel( 20, 200, 0x44, sheriffUpkeep.ToString( "N0" ) ); // NOTE: Added 'N0'
AddPage(4);
AddHtmlLocalized( 20, 230, 300, 25, 1011522, false, false ); // Town Income :
AddLabel( 20, 250, 0x44, dailyIncome.ToString( "N0" ) ); // NOTE: Added 'N0'
int financeUpkeep = town.FinanceUpkeep;
int sheriffUpkeep = town.SheriffUpkeep;
int dailyIncome = town.DailyIncome;
int netCashFlow = town.NetCashFlow;
AddHtmlLocalized( 20, 280, 300, 25, 1011523, false, false ); // Net Cash flow per day :
AddLabel( 20, 300, 0x44, netCashFlow.ToString( "N0" ) ); // NOTE: Added 'N0'
AddHtmlLocalized( 55, 360, 200, 25, 1011067, false, false ); // Previous page
AddButton( 20, 360, 4005, 4007, 0, GumpButtonType.Page, 1 );
#endregion
AddHtmlLocalized(20, 30, 300, 25, 1011524, false, false); // FINANCE STATEMENT
#region Shopkeeper Pages
for ( int i = 0; i < vendorLists.Count; ++i )
{
VendorList vendorList = vendorLists[i];
AddHtmlLocalized(20, 80, 300, 25, 1011538, false, false); // Current total money for town :
AddLabel(20, 100, 0x44, town.Silver.ToString());
AddPage( 5 + i );
AddHtmlLocalized(20, 130, 300, 25, 1011520, false, false); // Finance Minister Upkeep :
AddLabel(20, 150, 0x44, financeUpkeep.ToString("N0")); // NOTE: Added 'N0'
AddHtmlText( 60, 30, 300, 25, vendorList.Definition.Header, false, false );
AddItem( 20, 30, vendorList.Definition.ItemID );
AddHtmlLocalized(20, 180, 300, 25, 1011521, false, false); // Sheriff Upkeep :
AddLabel(20, 200, 0x44, sheriffUpkeep.ToString("N0")); // NOTE: Added 'N0'
AddHtmlLocalized( 20, 90, 200, 25, 1011514, false, false ); // You have :
AddLabel( 230, 90, 0x26, vendorList.Vendors.Count.ToString() );
AddHtmlLocalized(20, 230, 300, 25, 1011522, false, false); // Town Income :
AddLabel(20, 250, 0x44, dailyIncome.ToString("N0")); // NOTE: Added 'N0'
AddHtmlLocalized( 20, 120, 200, 25, 1011515, false, false ); // Maximum :
AddLabel( 230, 120, 0x256, vendorList.Definition.Maximum.ToString() );
AddHtmlLocalized(20, 280, 300, 25, 1011523, false, false); // Net Cash flow per day :
AddLabel(20, 300, 0x44, netCashFlow.ToString("N0")); // NOTE: Added 'N0'
AddHtmlLocalized( 20, 150, 200, 25, 1011516, false, false ); // Cost :
AddLabel( 230, 150, 0x44, vendorList.Definition.Price.ToString( "N0" ) ); // NOTE: Added 'N0'
AddHtmlLocalized(55, 360, 200, 25, 1011067, false, false); // Previous page
AddButton(20, 360, 4005, 4007, 0, GumpButtonType.Page, 1);
AddHtmlLocalized( 20, 180, 200, 25, 1011517, false, false ); // Daily Pay :
AddLabel( 230, 180, 0x37, vendorList.Definition.Upkeep.ToString( "N0" ) ); // NOTE: Added 'N0'
#endregion
AddHtmlLocalized( 20, 210, 200, 25, 1011518, false, false ); // Current Silver :
AddLabel( 230, 210, 0x44, town.Silver.ToString( "N0" ) ); // NOTE: Added 'N0'
#region Shopkeeper Pages
AddHtmlLocalized( 20, 240, 200, 25, 1011519, false, false ); // Current Payroll :
AddLabel( 230, 240, 0x44, financeUpkeep.ToString( "N0" ) ); // NOTE: Added 'N0'
AddHtmlText( 55, 300, 200, 25, vendorList.Definition.Label, false, false );
if ( town.Silver >= vendorList.Definition.Price )
AddButton( 20, 300, 4005, 4007, ToButtonID( 1, i ), GumpButtonType.Reply, 0 );
else
AddImage( 20, 300, 4020 );
AddHtmlLocalized( 55, 360, 200, 25, 1011067, false, false ); // Previous page
AddButton( 20, 360, 4005, 4007, 0, GumpButtonType.Page, 3 );
}
#endregion
}
public override void OnResponse( NetState sender, RelayInfo info )
{
if ( !m_Town.IsFinance( m_From ) || m_Town.Owner != m_Faction )
{
m_From.SendLocalizedMessage( 1010339 ); // You no longer control this city
return;
}
int type, index;
if ( !FromButtonID( info.ButtonID, out type, out index ) )
return;
switch ( type )
{
case 0: // general
{
switch ( index )
{
case 0: // set price
{
int[] switches = info.Switches;
if ( switches.Length == 0 )
break;
int opt = switches[0];
int newTax = 0;
if ( opt >= 1 && opt <= m_PriceOffsets.Length )
newTax = m_PriceOffsets[opt - 1];
if ( m_Town.Tax == newTax )
break;
if ( m_From.AccessLevel == AccessLevel.Player && !m_Town.TaxChangeReady )
{
TimeSpan remaining = DateTime.UtcNow - ( m_Town.LastTaxChange + Town.TaxChangePeriod );
if ( remaining.TotalMinutes < 4 )
m_From.SendLocalizedMessage( 1042165 ); // You must wait a short while before changing prices again.
else if ( remaining.TotalMinutes < 10 )
m_From.SendLocalizedMessage( 1042166 ); // You must wait several minutes before changing prices again.
else if ( remaining.TotalHours < 1 )
m_From.SendLocalizedMessage( 1042167 ); // You must wait up to an hour before changing prices again.
else if ( remaining.TotalHours < 4 )
m_From.SendLocalizedMessage( 1042168 ); // You must wait a few hours before changing prices again.
else
m_From.SendLocalizedMessage( 1042169 ); // You must wait several hours before changing prices again.
}
else
{
m_Town.Tax = newTax;
if ( m_From.AccessLevel == AccessLevel.Player )
m_Town.LastTaxChange = DateTime.UtcNow;
}
break;
}
}
break;
}
case 1: // make vendor
{
List<VendorList> vendorLists = m_Town.VendorLists;
if ( index >= 0 && index < vendorLists.Count )
{
VendorList vendorList = vendorLists[index];
Town town = Town.FromRegion( m_From.Region );
if ( Town.FromRegion( m_From.Region ) != m_Town )
{
m_From.SendLocalizedMessage( 1010305 ); // You must be in your controlled city to buy Items
}
else if ( vendorList.Vendors.Count >= vendorList.Definition.Maximum )
{
m_From.SendLocalizedMessage( 1010306 ); // You currently have too many of this enhancement type to place another
}
else if ( BaseBoat.FindBoatAt( m_From.Location, m_From.Map ) != null ) {
m_From.SendMessage( "You cannot place a vendor here" );
}
else if ( m_Town.Silver >= vendorList.Definition.Price )
{
BaseFactionVendor vendor = vendorList.Construct( m_Town, m_Faction );
if ( vendor != null )
{
m_Town.Silver -= vendorList.Definition.Price;
vendor.MoveToWorld( m_From.Location, m_From.Map );
vendor.Home = vendor.Location;
}
}
}
break;
}
}
}
}
}
for (int i = 0; i < vendorLists.Count; ++i)
{
VendorList vendorList = vendorLists[i];
AddPage(5 + i);
AddHtmlText(60, 30, 300, 25, vendorList.Definition.Header, false, false);
AddItem(20, 30, vendorList.Definition.ItemID);
AddHtmlLocalized(20, 90, 200, 25, 1011514, false, false); // You have :
AddLabel(230, 90, 0x26, vendorList.Vendors.Count.ToString());
AddHtmlLocalized(20, 120, 200, 25, 1011515, false, false); // Maximum :
AddLabel(230, 120, 0x256, vendorList.Definition.Maximum.ToString());
AddHtmlLocalized(20, 150, 200, 25, 1011516, false, false); // Cost :
AddLabel(230, 150, 0x44, vendorList.Definition.Price.ToString("N0")); // NOTE: Added 'N0'
AddHtmlLocalized(20, 180, 200, 25, 1011517, false, false); // Daily Pay :
AddLabel(230, 180, 0x37, vendorList.Definition.Upkeep.ToString("N0")); // NOTE: Added 'N0'
AddHtmlLocalized(20, 210, 200, 25, 1011518, false, false); // Current Silver :
AddLabel(230, 210, 0x44, town.Silver.ToString("N0")); // NOTE: Added 'N0'
AddHtmlLocalized(20, 240, 200, 25, 1011519, false, false); // Current Payroll :
AddLabel(230, 240, 0x44, financeUpkeep.ToString("N0")); // NOTE: Added 'N0'
AddHtmlText(55, 300, 200, 25, vendorList.Definition.Label, false, false);
if (town.Silver >= vendorList.Definition.Price)
AddButton(20, 300, 4005, 4007, ToButtonID(1, i), GumpButtonType.Reply, 0);
else
AddImage(20, 300, 4020);
AddHtmlLocalized(55, 360, 200, 25, 1011067, false, false); // Previous page
AddButton(20, 360, 4005, 4007, 0, GumpButtonType.Page, 3);
}
#endregion
}
public override int ButtonTypes => 2;
public override void OnResponse(NetState sender, RelayInfo info)
{
if (!m_Town.IsFinance(m_From) || m_Town.Owner != m_Faction)
{
m_From.SendLocalizedMessage(1010339); // You no longer control this city
return;
}
int type, index;
if (!FromButtonID(info.ButtonID, out type, out index))
return;
switch (type)
{
case 0: // general
{
switch (index)
{
case 0: // set price
{
int[] switches = info.Switches;
if (switches.Length == 0)
break;
int opt = switches[0];
int newTax = 0;
if (opt >= 1 && opt <= m_PriceOffsets.Length)
newTax = m_PriceOffsets[opt - 1];
if (m_Town.Tax == newTax)
break;
if (m_From.AccessLevel == AccessLevel.Player && !m_Town.TaxChangeReady)
{
TimeSpan remaining = DateTime.UtcNow - (m_Town.LastTaxChange + Town.TaxChangePeriod);
if (remaining.TotalMinutes < 4)
m_From.SendLocalizedMessage(
1042165); // You must wait a short while before changing prices again.
else if (remaining.TotalMinutes < 10)
m_From.SendLocalizedMessage(
1042166); // You must wait several minutes before changing prices again.
else if (remaining.TotalHours < 1)
m_From.SendLocalizedMessage(
1042167); // You must wait up to an hour before changing prices again.
else if (remaining.TotalHours < 4)
m_From.SendLocalizedMessage(
1042168); // You must wait a few hours before changing prices again.
else
m_From.SendLocalizedMessage(
1042169); // You must wait several hours before changing prices again.
}
else
{
m_Town.Tax = newTax;
if (m_From.AccessLevel == AccessLevel.Player)
m_Town.LastTaxChange = DateTime.UtcNow;
}
break;
}
}
break;
}
case 1: // make vendor
{
List<VendorList> vendorLists = m_Town.VendorLists;
if (index >= 0 && index < vendorLists.Count)
{
VendorList vendorList = vendorLists[index];
Town town = Town.FromRegion(m_From.Region);
if (Town.FromRegion(m_From.Region) != m_Town)
{
m_From.SendLocalizedMessage(1010305); // You must be in your controlled city to buy Items
}
else if (vendorList.Vendors.Count >= vendorList.Definition.Maximum)
{
m_From.SendLocalizedMessage(
1010306); // You currently have too many of this enhancement type to place another
}
else if (BaseBoat.FindBoatAt(m_From.Location, m_From.Map) != null)
{
m_From.SendMessage("You cannot place a vendor here");
}
else if (m_Town.Silver >= vendorList.Definition.Price)
{
BaseFactionVendor vendor = vendorList.Construct(m_Town, m_Faction);
if (vendor != null)
{
m_Town.Silver -= vendorList.Definition.Price;
vendor.MoveToWorld(m_From.Location, m_From.Map);
vendor.Home = vendor.Location;
}
}
}
break;
}
}
}
}
}

View file

@ -1,90 +1,91 @@
using Server.Items;
using Server.Gumps;
using Server.Items;
using Server.Mobiles;
using Server.Network;
namespace Server.Factions
{
public class HorseBreederGump : FactionGump
{
private PlayerMobile m_From;
private Faction m_Faction;
public class HorseBreederGump : FactionGump
{
private Faction m_Faction;
private PlayerMobile m_From;
public HorseBreederGump( PlayerMobile from, Faction faction ) : base( 20, 30 )
{
m_From = from;
m_Faction = faction;
public HorseBreederGump(PlayerMobile from, Faction faction) : base(20, 30)
{
m_From = from;
m_Faction = faction;
AddPage( 0 );
AddPage(0);
AddBackground( 0, 0, 320, 280, 5054 );
AddBackground( 10, 10, 300, 260, 3000 );
AddBackground(0, 0, 320, 280, 5054);
AddBackground(10, 10, 300, 260, 3000);
AddHtmlText( 20, 30, 300, 25, faction.Definition.Header, false, false );
AddHtmlText(20, 30, 300, 25, faction.Definition.Header, false, false);
AddHtmlLocalized( 20, 60, 300, 25, 1018306, false, false ); // Purchase a Faction War Horse
AddItem( 70, 120, 0x3FFE );
AddHtmlLocalized(20, 60, 300, 25, 1018306, false, false); // Purchase a Faction War Horse
AddItem(70, 120, 0x3FFE);
AddItem( 150, 120, 0xEF2 );
AddLabel( 190, 122, 0x3E3, FactionWarHorse.SilverPrice.ToString( "N0" ) ); // NOTE: Added 'N0'
AddItem(150, 120, 0xEF2);
AddLabel(190, 122, 0x3E3, FactionWarHorse.SilverPrice.ToString("N0")); // NOTE: Added 'N0'
AddItem( 150, 150, 0xEEF );
AddLabel( 190, 152, 0x3E3, FactionWarHorse.GoldPrice.ToString( "N0" ) ); // NOTE: Added 'N0'
AddItem(150, 150, 0xEEF);
AddLabel(190, 152, 0x3E3, FactionWarHorse.GoldPrice.ToString("N0")); // NOTE: Added 'N0'
AddHtmlLocalized( 55, 210, 200, 25, 1011011, false, false ); // CONTINUE
AddButton( 20, 210, 4005, 4007, 1, GumpButtonType.Reply, 0 );
AddHtmlLocalized(55, 210, 200, 25, 1011011, false, false); // CONTINUE
AddButton(20, 210, 4005, 4007, 1, GumpButtonType.Reply, 0);
AddHtmlLocalized( 55, 240, 200, 25, 1011012, false, false ); // CANCEL
AddButton( 20, 240, 4005, 4007, 0, GumpButtonType.Reply, 0 );
}
AddHtmlLocalized(55, 240, 200, 25, 1011012, false, false); // CANCEL
AddButton(20, 240, 4005, 4007, 0, GumpButtonType.Reply, 0);
}
public override void OnResponse( NetState sender, RelayInfo info )
{
if ( info.ButtonID != 1 )
return;
public override void OnResponse(NetState sender, RelayInfo info)
{
if (info.ButtonID != 1)
return;
if ( Faction.Find( m_From ) != m_Faction )
return;
if (Faction.Find(m_From) != m_Faction)
return;
Container pack = m_From.Backpack;
Container pack = m_From.Backpack;
if ( pack == null )
return;
if (pack == null)
return;
FactionWarHorse horse = new FactionWarHorse( m_Faction );
FactionWarHorse horse = new FactionWarHorse(m_Faction);
if ( (m_From.Followers + horse.ControlSlots) > m_From.FollowersMax )
{
// TODO: Message?
horse.Delete();
}
else
{
if ( pack.GetAmount( typeof( Silver ) ) < FactionWarHorse.SilverPrice )
{
sender.Mobile.SendLocalizedMessage( 1042204 ); // You do not have enough silver.
horse.Delete();
}
else if ( pack.GetAmount( typeof( Gold ) ) < FactionWarHorse.GoldPrice )
{
sender.Mobile.SendLocalizedMessage( 1042205 ); // You do not have enough gold.
horse.Delete();
}
else if ( pack.ConsumeTotal( typeof( Silver ), FactionWarHorse.SilverPrice ) && pack.ConsumeTotal( typeof( Gold ), FactionWarHorse.GoldPrice ) )
{
horse.Controlled = true;
horse.ControlMaster = m_From;
if (m_From.Followers + horse.ControlSlots > m_From.FollowersMax)
{
// TODO: Message?
horse.Delete();
}
else
{
if (pack.GetAmount(typeof(Silver)) < FactionWarHorse.SilverPrice)
{
sender.Mobile.SendLocalizedMessage(1042204); // You do not have enough silver.
horse.Delete();
}
else if (pack.GetAmount(typeof(Gold)) < FactionWarHorse.GoldPrice)
{
sender.Mobile.SendLocalizedMessage(1042205); // You do not have enough gold.
horse.Delete();
}
else if (pack.ConsumeTotal(typeof(Silver), FactionWarHorse.SilverPrice) &&
pack.ConsumeTotal(typeof(Gold), FactionWarHorse.GoldPrice))
{
horse.Controlled = true;
horse.ControlMaster = m_From;
horse.ControlOrder = OrderType.Follow;
horse.ControlTarget = m_From;
horse.ControlOrder = OrderType.Follow;
horse.ControlTarget = m_From;
horse.MoveToWorld( m_From.Location, m_From.Map );
}
else
{
horse.Delete();
}
}
}
}
horse.MoveToWorld(m_From.Location, m_From.Map);
}
else
{
horse.Delete();
}
}
}
}
}

View file

@ -4,47 +4,47 @@ using Server.Network;
namespace Server.Factions
{
public class JoinStoneGump : FactionGump
{
private PlayerMobile m_From;
private Faction m_Faction;
public class JoinStoneGump : FactionGump
{
private Faction m_Faction;
private PlayerMobile m_From;
public JoinStoneGump( PlayerMobile from, Faction faction ) : base( 20, 30 )
{
m_From = from;
m_Faction = faction;
public JoinStoneGump(PlayerMobile from, Faction faction) : base(20, 30)
{
m_From = from;
m_Faction = faction;
AddPage( 0 );
AddPage(0);
AddBackground( 0, 0, 550, 440, 5054 );
AddBackground( 10, 10, 530, 420, 3000 );
AddBackground(0, 0, 550, 440, 5054);
AddBackground(10, 10, 530, 420, 3000);
AddHtmlText( 20, 30, 510, 20, faction.Definition.Header, false, false );
AddHtmlText( 20, 130, 510, 100, faction.Definition.About, true, true );
AddHtmlText(20, 30, 510, 20, faction.Definition.Header, false, false);
AddHtmlText(20, 130, 510, 100, faction.Definition.About, true, true);
AddHtmlLocalized( 20, 60, 100, 20, 1011429, false, false ); // Led By :
AddHtml( 125, 60, 200, 20, faction.Commander != null ? faction.Commander.Name : "Nobody", false, false );
AddHtmlLocalized(20, 60, 100, 20, 1011429, false, false); // Led By :
AddHtml(125, 60, 200, 20, faction.Commander != null ? faction.Commander.Name : "Nobody", false, false);
AddHtmlLocalized( 20, 80, 100, 20, 1011457, false, false ); // Tithe rate :
if ( faction.Tithe >= 0 && faction.Tithe <= 100 && (faction.Tithe % 10) == 0 )
AddHtmlLocalized( 125, 80, 350, 20, 1011480 + (faction.Tithe / 10), false, false );
else
AddHtml( 125, 80, 350, 20, faction.Tithe + "%", false, false );
AddHtmlLocalized(20, 80, 100, 20, 1011457, false, false); // Tithe rate :
if (faction.Tithe >= 0 && faction.Tithe <= 100 && faction.Tithe % 10 == 0)
AddHtmlLocalized(125, 80, 350, 20, 1011480 + faction.Tithe / 10, false, false);
else
AddHtml(125, 80, 350, 20, faction.Tithe + "%", false, false);
AddButton( 20, 400, 4005, 4007, 1, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 55, 400, 200, 20, 1011425, false, false ); // JOIN THIS FACTION
AddButton(20, 400, 4005, 4007, 1, GumpButtonType.Reply, 0);
AddHtmlLocalized(55, 400, 200, 20, 1011425, false, false); // JOIN THIS FACTION
AddButton( 300, 400, 4005, 4007, 0, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 335, 400, 200, 20, 1011012, false, false ); // CANCEL
}
AddButton(300, 400, 4005, 4007, 0, GumpButtonType.Reply, 0);
AddHtmlLocalized(335, 400, 200, 20, 1011012, false, false); // CANCEL
}
public override void OnResponse( NetState sender, RelayInfo info )
{
if ( info.ButtonID == 1 )
m_Faction.OnJoinAccepted( m_From );
}
}
public override void OnResponse(NetState sender, RelayInfo info)
{
if (info.ButtonID == 1)
m_Faction.OnJoinAccepted(m_From);
}
}
}

View file

@ -1,89 +1,93 @@
using System;
using Server.Gumps;
using Server.Guilds;
using Server.Gumps;
using Server.Mobiles;
using Server.Network;
namespace Server.Factions
{
public class LeaveFactionGump : FactionGump
{
private PlayerMobile m_From;
private Faction m_Faction;
public class LeaveFactionGump : FactionGump
{
private Faction m_Faction;
private PlayerMobile m_From;
public LeaveFactionGump( PlayerMobile from, Faction faction ) : base( 20, 30 )
{
m_From = from;
m_Faction = faction;
public LeaveFactionGump(PlayerMobile from, Faction faction) : base(20, 30)
{
m_From = from;
m_Faction = faction;
AddBackground( 0, 0, 270, 120, 5054 );
AddBackground( 10, 10, 250, 100, 3000 );
AddBackground(0, 0, 270, 120, 5054);
AddBackground(10, 10, 250, 100, 3000);
if ( from.Guild is Guild guild && guild.Leader == from )
AddHtmlLocalized( 20, 15, 230, 60, 1018057, true, true ); // Are you sure you want your entire guild to leave this faction?
else
AddHtmlLocalized( 20, 15, 230, 60, 1018063, true, true ); // Are you sure you want to leave this faction?
if (from.Guild is Guild guild && guild.Leader == from)
AddHtmlLocalized(20, 15, 230, 60, 1018057, true,
true); // Are you sure you want your entire guild to leave this faction?
else
AddHtmlLocalized(20, 15, 230, 60, 1018063, true, true); // Are you sure you want to leave this faction?
AddHtmlLocalized( 55, 80, 75, 20, 1011011, false, false ); // CONTINUE
AddButton( 20, 80, 4005, 4007, 1, GumpButtonType.Reply, 0 );
AddHtmlLocalized(55, 80, 75, 20, 1011011, false, false); // CONTINUE
AddButton(20, 80, 4005, 4007, 1, GumpButtonType.Reply, 0);
AddHtmlLocalized( 170, 80, 75, 20, 1011012, false, false ); // CANCEL
AddButton( 135, 80, 4005, 4007, 2, GumpButtonType.Reply, 0 );
}
AddHtmlLocalized(170, 80, 75, 20, 1011012, false, false); // CANCEL
AddButton(135, 80, 4005, 4007, 2, GumpButtonType.Reply, 0);
}
public override void OnResponse( NetState sender, RelayInfo info )
{
switch ( info.ButtonID )
{
case 1: // continue
{
if ( !(m_From.Guild is Guild guild) )
{
PlayerState pl = PlayerState.Find( m_From );
public override void OnResponse(NetState sender, RelayInfo info)
{
switch (info.ButtonID)
{
case 1: // continue
{
if (!(m_From.Guild is Guild guild))
{
PlayerState pl = PlayerState.Find(m_From);
if ( pl != null )
{
pl.Leaving = DateTime.UtcNow;
if (pl != null)
{
pl.Leaving = DateTime.UtcNow;
if ( Faction.LeavePeriod == TimeSpan.FromDays( 3.0 ) )
m_From.SendLocalizedMessage( 1005065 ); // You will be removed from the faction in 3 days
else
m_From.SendMessage( "You will be removed from the faction in {0} days.", Faction.LeavePeriod.TotalDays );
}
}
else if ( guild.Leader != m_From )
{
m_From.SendLocalizedMessage( 1005061 ); // You cannot quit the faction because you are not the guild master
}
else
{
m_From.SendLocalizedMessage( 1042285 ); // Your guild is now quitting the faction.
if (Faction.LeavePeriod == TimeSpan.FromDays(3.0))
m_From.SendLocalizedMessage(1005065); // You will be removed from the faction in 3 days
else
m_From.SendMessage("You will be removed from the faction in {0} days.",
Faction.LeavePeriod.TotalDays);
}
}
else if (guild.Leader != m_From)
{
m_From.SendLocalizedMessage(
1005061); // You cannot quit the faction because you are not the guild master
}
else
{
m_From.SendLocalizedMessage(1042285); // Your guild is now quitting the faction.
for ( int i = 0; i < guild.Members.Count; ++i )
{
Mobile mob = (Mobile) guild.Members[i];
PlayerState pl = PlayerState.Find( mob );
for (int i = 0; i < guild.Members.Count; ++i)
{
Mobile mob = guild.Members[i];
PlayerState pl = PlayerState.Find(mob);
if ( pl != null )
{
pl.Leaving = DateTime.UtcNow;
if (pl != null)
{
pl.Leaving = DateTime.UtcNow;
if ( Faction.LeavePeriod == TimeSpan.FromDays( 3.0 ) )
mob.SendLocalizedMessage( 1005060 ); // Your guild will quit the faction in 3 days
else
mob.SendMessage( "Your guild will quit the faction in {0} days.", Faction.LeavePeriod.TotalDays );
}
}
}
if (Faction.LeavePeriod == TimeSpan.FromDays(3.0))
mob.SendLocalizedMessage(1005060); // Your guild will quit the faction in 3 days
else
mob.SendMessage("Your guild will quit the faction in {0} days.",
Faction.LeavePeriod.TotalDays);
}
}
}
break;
}
case 2: // cancel
{
m_From.SendLocalizedMessage( 500737 ); // Canceled resignation.
break;
}
}
}
}
}
break;
}
case 2: // cancel
{
m_From.SendLocalizedMessage(500737); // Canceled resignation.
break;
}
}
}
}
}

View file

@ -1,179 +1,189 @@
using System.Collections.Generic;
using Server.Gumps;
using Server.Mobiles;
using Server.Multis;
using Server.Network;
using System.Collections.Generic;
namespace Server.Factions
{
public class SheriffGump : FactionGump
{
private PlayerMobile m_From;
private Faction m_Faction;
private Town m_Town;
public class SheriffGump : FactionGump
{
private Faction m_Faction;
private PlayerMobile m_From;
private Town m_Town;
private void CenterItem( int itemID, int x, int y, int w, int h )
{
Rectangle2D rc = ItemBounds.Table[itemID];
AddItem( x + ((w - rc.Width) / 2) - rc.X, y + ((h - rc.Height) / 2) - rc.Y, itemID );
}
public SheriffGump( PlayerMobile from, Faction faction, Town town ) : base( 50, 50 )
{
m_From = from;
m_Faction = faction;
m_Town = town;
public SheriffGump(PlayerMobile from, Faction faction, Town town) : base(50, 50)
{
m_From = from;
m_Faction = faction;
m_Town = town;
AddPage( 0 );
AddPage(0);
AddBackground( 0, 0, 320, 410, 5054 );
AddBackground( 10, 10, 300, 390, 3000 );
AddBackground(0, 0, 320, 410, 5054);
AddBackground(10, 10, 300, 390, 3000);
#region General
AddPage( 1 );
#region General
AddHtmlLocalized( 20, 30, 260, 25, 1011431, false, false ); // Sheriff
AddPage(1);
AddHtmlLocalized( 55, 90, 200, 25, 1011494, false, false ); // HIRE GUARDS
AddButton( 20, 90, 4005, 4007, 0, GumpButtonType.Page, 3 );
AddHtmlLocalized(20, 30, 260, 25, 1011431, false, false); // Sheriff
AddHtmlLocalized( 55, 120, 200, 25, 1011495, false, false ); // VIEW FINANCES
AddButton( 20, 120, 4005, 4007, 0, GumpButtonType.Page, 2 );
AddHtmlLocalized(55, 90, 200, 25, 1011494, false, false); // HIRE GUARDS
AddButton(20, 90, 4005, 4007, 0, GumpButtonType.Page, 3);
AddHtmlLocalized( 55, 360, 200, 25, 1011441, false, false ); // Exit
AddButton( 20, 360, 4005, 4007, 0, GumpButtonType.Reply, 0 );
#endregion
AddHtmlLocalized(55, 120, 200, 25, 1011495, false, false); // VIEW FINANCES
AddButton(20, 120, 4005, 4007, 0, GumpButtonType.Page, 2);
#region Finances
AddPage( 2 );
AddHtmlLocalized(55, 360, 200, 25, 1011441, false, false); // Exit
AddButton(20, 360, 4005, 4007, 0, GumpButtonType.Reply, 0);
int financeUpkeep = town.FinanceUpkeep;
int sheriffUpkeep = town.SheriffUpkeep;
int dailyIncome = town.DailyIncome;
int netCashFlow = town.NetCashFlow;
#endregion
AddHtmlLocalized( 20, 30, 300, 25, 1011524, false, false ); // FINANCE STATEMENT
AddHtmlLocalized( 20, 80, 300, 25, 1011538, false, false ); // Current total money for town :
AddLabel( 20, 100, 0x44, town.Silver.ToString( "N0" ) ); // NOTE: Added 'N0'
#region Finances
AddHtmlLocalized( 20, 130, 300, 25, 1011520, false, false ); // Finance Minister Upkeep :
AddLabel( 20, 150, 0x44, financeUpkeep.ToString( "N0" ) ); // NOTE: Added 'N0'
AddHtmlLocalized( 20, 180, 300, 25, 1011521, false, false ); // Sheriff Upkeep :
AddLabel( 20, 200, 0x44, sheriffUpkeep.ToString( "N0" ) ); // NOTE: Added 'N0'
AddPage(2);
AddHtmlLocalized( 20, 230, 300, 25, 1011522, false, false ); // Town Income :
AddLabel( 20, 250, 0x44, dailyIncome.ToString( "N0" ) ); // NOTE: Added 'N0'
int financeUpkeep = town.FinanceUpkeep;
int sheriffUpkeep = town.SheriffUpkeep;
int dailyIncome = town.DailyIncome;
int netCashFlow = town.NetCashFlow;
AddHtmlLocalized( 20, 280, 300, 25, 1011523, false, false ); // Net Cash flow per day :
AddLabel( 20, 300, 0x44, netCashFlow.ToString( "N0" ) ); // NOTE: Added 'N0'
AddHtmlLocalized(20, 30, 300, 25, 1011524, false, false); // FINANCE STATEMENT
AddHtmlLocalized( 55, 360, 200, 25, 1011067, false, false ); // Previous page
AddButton( 20, 360, 4005, 4007, 0, GumpButtonType.Page, 1 );
#endregion
AddHtmlLocalized(20, 80, 300, 25, 1011538, false, false); // Current total money for town :
AddLabel(20, 100, 0x44, town.Silver.ToString("N0")); // NOTE: Added 'N0'
#region Hire Guards
AddPage( 3 );
AddHtmlLocalized(20, 130, 300, 25, 1011520, false, false); // Finance Minister Upkeep :
AddLabel(20, 150, 0x44, financeUpkeep.ToString("N0")); // NOTE: Added 'N0'
AddHtmlLocalized( 20, 30, 300, 25, 1011494, false, false ); // HIRE GUARDS
AddHtmlLocalized(20, 180, 300, 25, 1011521, false, false); // Sheriff Upkeep :
AddLabel(20, 200, 0x44, sheriffUpkeep.ToString("N0")); // NOTE: Added 'N0'
List<GuardList> guardLists = town.GuardLists;
AddHtmlLocalized(20, 230, 300, 25, 1011522, false, false); // Town Income :
AddLabel(20, 250, 0x44, dailyIncome.ToString("N0")); // NOTE: Added 'N0'
for ( int i = 0; i < guardLists.Count; ++i )
{
GuardList guardList = guardLists[i];
int y = 90 + (i * 60);
AddHtmlLocalized(20, 280, 300, 25, 1011523, false, false); // Net Cash flow per day :
AddLabel(20, 300, 0x44, netCashFlow.ToString("N0")); // NOTE: Added 'N0'
AddButton( 20, y, 4005, 4007, 0, GumpButtonType.Page, 4 + i );
CenterItem( guardList.Definition.ItemID, 50, y - 20, 70, 60 );
AddHtmlText( 120, y, 200, 25, guardList.Definition.Header, false, false );
}
AddHtmlLocalized(55, 360, 200, 25, 1011067, false, false); // Previous page
AddButton(20, 360, 4005, 4007, 0, GumpButtonType.Page, 1);
AddHtmlLocalized( 55, 360, 200, 25, 1011067, false, false ); // Previous page
AddButton( 20, 360, 4005, 4007, 0, GumpButtonType.Page, 1 );
#endregion
#endregion
#region Guard Pages
for ( int i = 0; i < guardLists.Count; ++i )
{
GuardList guardList = guardLists[i];
#region Hire Guards
AddPage( 4 + i );
AddPage(3);
AddHtmlText( 90, 30, 300, 25, guardList.Definition.Header, false, false );
CenterItem( guardList.Definition.ItemID, 10, 10, 80, 80 );
AddHtmlLocalized(20, 30, 300, 25, 1011494, false, false); // HIRE GUARDS
AddHtmlLocalized( 20, 90, 200, 25, 1011514, false, false ); // You have :
AddLabel( 230, 90, 0x26, guardList.Guards.Count.ToString() );
List<GuardList> guardLists = town.GuardLists;
AddHtmlLocalized( 20, 120, 200, 25, 1011515, false, false ); // Maximum :
AddLabel( 230, 120, 0x12A, guardList.Definition.Maximum.ToString() );
for (int i = 0; i < guardLists.Count; ++i)
{
GuardList guardList = guardLists[i];
int y = 90 + i * 60;
AddHtmlLocalized( 20, 150, 200, 25, 1011516, false, false ); // Cost :
AddLabel( 230, 150, 0x44, guardList.Definition.Price.ToString( "N0" ) ); // NOTE: Added 'N0'
AddButton(20, y, 4005, 4007, 0, GumpButtonType.Page, 4 + i);
CenterItem(guardList.Definition.ItemID, 50, y - 20, 70, 60);
AddHtmlText(120, y, 200, 25, guardList.Definition.Header, false, false);
}
AddHtmlLocalized( 20, 180, 200, 25, 1011517, false, false ); // Daily Pay :
AddLabel( 230, 180, 0x37, guardList.Definition.Upkeep.ToString( "N0" ) ); // NOTE: Added 'N0'
AddHtmlLocalized(55, 360, 200, 25, 1011067, false, false); // Previous page
AddButton(20, 360, 4005, 4007, 0, GumpButtonType.Page, 1);
AddHtmlLocalized( 20, 210, 200, 25, 1011518, false, false ); // Current Silver :
AddLabel( 230, 210, 0x44, town.Silver.ToString( "N0" ) ); // NOTE: Added 'N0'
#endregion
AddHtmlLocalized( 20, 240, 200, 25, 1011519, false, false ); // Current Payroll :
AddLabel( 230, 240, 0x44, sheriffUpkeep.ToString( "N0" ) ); // NOTE: Added 'N0'
#region Guard Pages
AddHtmlText( 55, 300, 200, 25, guardList.Definition.Label, false, false );
AddButton( 20, 300, 4005, 4007, 1 + i, GumpButtonType.Reply, 0 );
for (int i = 0; i < guardLists.Count; ++i)
{
GuardList guardList = guardLists[i];
AddHtmlLocalized( 55, 360, 200, 25, 1011067, false, false ); // Previous page
AddButton( 20, 360, 4005, 4007, 0, GumpButtonType.Page, 3 );
}
#endregion
}
AddPage(4 + i);
public override void OnResponse( NetState sender, RelayInfo info )
{
if ( !m_Town.IsSheriff( m_From ) || m_Town.Owner != m_Faction )
{
m_From.SendLocalizedMessage( 1010339 ); // You no longer control this city
return;
}
AddHtmlText(90, 30, 300, 25, guardList.Definition.Header, false, false);
CenterItem(guardList.Definition.ItemID, 10, 10, 80, 80);
int index = info.ButtonID - 1;
AddHtmlLocalized(20, 90, 200, 25, 1011514, false, false); // You have :
AddLabel(230, 90, 0x26, guardList.Guards.Count.ToString());
if ( index >= 0 && index < m_Town.GuardLists.Count )
{
GuardList guardList = m_Town.GuardLists[index];
Town town = Town.FromRegion( m_From.Region );
AddHtmlLocalized(20, 120, 200, 25, 1011515, false, false); // Maximum :
AddLabel(230, 120, 0x12A, guardList.Definition.Maximum.ToString());
if ( Town.FromRegion( m_From.Region ) != m_Town )
{
m_From.SendLocalizedMessage( 1010305 ); // You must be in your controlled city to buy Items
}
else if ( guardList.Guards.Count >= guardList.Definition.Maximum )
{
m_From.SendLocalizedMessage( 1010306 ); // You currently have too many of this enhancement type to place another
}
else if ( BaseBoat.FindBoatAt( m_From.Location, m_From.Map ) != null ) {
m_From.SendMessage( "You cannot place a guard here" );
}
else if ( m_Town.Silver >= guardList.Definition.Price )
{
BaseFactionGuard guard = guardList.Construct();
AddHtmlLocalized(20, 150, 200, 25, 1011516, false, false); // Cost :
AddLabel(230, 150, 0x44, guardList.Definition.Price.ToString("N0")); // NOTE: Added 'N0'
if ( guard != null )
{
guard.Faction = m_Faction;
guard.Town = m_Town;
AddHtmlLocalized(20, 180, 200, 25, 1011517, false, false); // Daily Pay :
AddLabel(230, 180, 0x37, guardList.Definition.Upkeep.ToString("N0")); // NOTE: Added 'N0'
m_Town.Silver -= guardList.Definition.Price;
AddHtmlLocalized(20, 210, 200, 25, 1011518, false, false); // Current Silver :
AddLabel(230, 210, 0x44, town.Silver.ToString("N0")); // NOTE: Added 'N0'
guard.MoveToWorld( m_From.Location, m_From.Map );
guard.Home = guard.Location;
}
}
}
}
}
AddHtmlLocalized(20, 240, 200, 25, 1011519, false, false); // Current Payroll :
AddLabel(230, 240, 0x44, sheriffUpkeep.ToString("N0")); // NOTE: Added 'N0'
AddHtmlText(55, 300, 200, 25, guardList.Definition.Label, false, false);
AddButton(20, 300, 4005, 4007, 1 + i, GumpButtonType.Reply, 0);
AddHtmlLocalized(55, 360, 200, 25, 1011067, false, false); // Previous page
AddButton(20, 360, 4005, 4007, 0, GumpButtonType.Page, 3);
}
#endregion
}
private void CenterItem(int itemID, int x, int y, int w, int h)
{
Rectangle2D rc = ItemBounds.Table[itemID];
AddItem(x + (w - rc.Width) / 2 - rc.X, y + (h - rc.Height) / 2 - rc.Y, itemID);
}
public override void OnResponse(NetState sender, RelayInfo info)
{
if (!m_Town.IsSheriff(m_From) || m_Town.Owner != m_Faction)
{
m_From.SendLocalizedMessage(1010339); // You no longer control this city
return;
}
int index = info.ButtonID - 1;
if (index >= 0 && index < m_Town.GuardLists.Count)
{
GuardList guardList = m_Town.GuardLists[index];
Town town = Town.FromRegion(m_From.Region);
if (Town.FromRegion(m_From.Region) != m_Town)
{
m_From.SendLocalizedMessage(1010305); // You must be in your controlled city to buy Items
}
else if (guardList.Guards.Count >= guardList.Definition.Maximum)
{
m_From.SendLocalizedMessage(
1010306); // You currently have too many of this enhancement type to place another
}
else if (BaseBoat.FindBoatAt(m_From.Location, m_From.Map) != null)
{
m_From.SendMessage("You cannot place a guard here");
}
else if (m_Town.Silver >= guardList.Definition.Price)
{
BaseFactionGuard guard = guardList.Construct();
if (guard != null)
{
guard.Faction = m_Faction;
guard.Town = m_Town;
m_Town.Silver -= guardList.Definition.Price;
guard.MoveToWorld(m_From.Location, m_From.Map);
guard.Home = guard.Location;
}
}
}
}
}
}

View file

@ -5,198 +5,200 @@ using Server.Targeting;
namespace Server.Factions
{
public class TownStoneGump : FactionGump
{
private PlayerMobile m_From;
private Faction m_Faction;
private Town m_Town;
public class TownStoneGump : FactionGump
{
private Faction m_Faction;
private PlayerMobile m_From;
private Town m_Town;
public TownStoneGump( PlayerMobile from, Faction faction, Town town ) : base( 50, 50 )
{
m_From = from;
m_Faction = faction;
m_Town = town;
public TownStoneGump(PlayerMobile from, Faction faction, Town town) : base(50, 50)
{
m_From = from;
m_Faction = faction;
m_Town = town;
AddPage( 0 );
AddPage(0);
AddBackground( 0, 0, 320, 250, 5054 );
AddBackground( 10, 10, 300, 230, 3000 );
AddBackground(0, 0, 320, 250, 5054);
AddBackground(10, 10, 300, 230, 3000);
AddHtmlText( 25, 30, 250, 25, town.Definition.TownStoneHeader, false, false );
AddHtmlText(25, 30, 250, 25, town.Definition.TownStoneHeader, false, false);
AddHtmlLocalized( 55, 60, 150, 25, 1011557, false, false ); // Hire Sheriff
AddButton( 20, 60, 4005, 4007, 1, GumpButtonType.Reply, 0 );
AddHtmlLocalized(55, 60, 150, 25, 1011557, false, false); // Hire Sheriff
AddButton(20, 60, 4005, 4007, 1, GumpButtonType.Reply, 0);
AddHtmlLocalized( 55, 90, 150, 25, 1011559, false, false ); // Hire Finance Minister
AddButton( 20, 90, 4005, 4007, 2, GumpButtonType.Reply, 0 );
AddHtmlLocalized(55, 90, 150, 25, 1011559, false, false); // Hire Finance Minister
AddButton(20, 90, 4005, 4007, 2, GumpButtonType.Reply, 0);
AddHtmlLocalized( 55, 120, 150, 25, 1011558, false, false ); // Fire Sheriff
AddButton( 20, 120, 4005, 4007, 3, GumpButtonType.Reply, 0 );
AddHtmlLocalized(55, 120, 150, 25, 1011558, false, false); // Fire Sheriff
AddButton(20, 120, 4005, 4007, 3, GumpButtonType.Reply, 0);
AddHtmlLocalized( 55, 150, 150, 25, 1011560, false, false ); // Fire Finance Minister
AddButton( 20, 150, 4005, 4007, 4, GumpButtonType.Reply, 0 );
AddHtmlLocalized(55, 150, 150, 25, 1011560, false, false); // Fire Finance Minister
AddButton(20, 150, 4005, 4007, 4, GumpButtonType.Reply, 0);
AddHtmlLocalized( 55, 210, 150, 25, 1011441, false, false ); // EXIT
AddButton( 20, 210, 4005, 4007, 0, GumpButtonType.Reply, 0 );
}
AddHtmlLocalized(55, 210, 150, 25, 1011441, false, false); // EXIT
AddButton(20, 210, 4005, 4007, 0, GumpButtonType.Reply, 0);
}
public override void OnResponse( NetState sender, RelayInfo info )
{
if ( m_Town.Owner != m_Faction || !m_Faction.IsCommander( m_From ) )
{
m_From.SendLocalizedMessage( 1010339 ); // You no longer control this city
return;
}
public override void OnResponse(NetState sender, RelayInfo info)
{
if (m_Town.Owner != m_Faction || !m_Faction.IsCommander(m_From))
{
m_From.SendLocalizedMessage(1010339); // You no longer control this city
return;
}
switch ( info.ButtonID )
{
case 1: // hire sheriff
{
if ( m_Town.Sheriff != null )
{
m_From.SendLocalizedMessage( 1010342 ); // You must fire your Sheriff before you can elect a new one
}
else
{
m_From.SendLocalizedMessage( 1010347 ); // Who shall be your new sheriff
m_From.BeginTarget( 12, false, TargetFlags.None, HireSheriff_OnTarget );
}
switch (info.ButtonID)
{
case 1: // hire sheriff
{
if (m_Town.Sheriff != null)
{
m_From.SendLocalizedMessage(1010342); // You must fire your Sheriff before you can elect a new one
}
else
{
m_From.SendLocalizedMessage(1010347); // Who shall be your new sheriff
m_From.BeginTarget(12, false, TargetFlags.None, HireSheriff_OnTarget);
}
break;
}
case 2: // hire finance minister
{
if ( m_Town.Finance != null )
{
m_From.SendLocalizedMessage( 1010345 ); // You must fire your finance minister before you can elect a new one
}
else
{
m_From.SendLocalizedMessage( 1010348 ); // Who shall be your new Minister of Finances?
m_From.BeginTarget( 12, false, TargetFlags.None, HireFinanceMinister_OnTarget );
}
break;
}
case 2: // hire finance minister
{
if (m_Town.Finance != null)
{
m_From.SendLocalizedMessage(
1010345); // You must fire your finance minister before you can elect a new one
}
else
{
m_From.SendLocalizedMessage(1010348); // Who shall be your new Minister of Finances?
m_From.BeginTarget(12, false, TargetFlags.None, HireFinanceMinister_OnTarget);
}
break;
}
case 3: // fire sheriff
{
if ( m_Town.Sheriff == null )
{
m_From.SendLocalizedMessage( 1010350 ); // You need to elect a sheriff before you can fire one
}
else
{
m_From.SendLocalizedMessage( 1010349 ); // You have fired your sheriff
m_Town.Sheriff.SendLocalizedMessage( 1010270 ); // You have been fired as Sheriff
m_Town.Sheriff = null;
}
break;
}
case 3: // fire sheriff
{
if (m_Town.Sheriff == null)
{
m_From.SendLocalizedMessage(1010350); // You need to elect a sheriff before you can fire one
}
else
{
m_From.SendLocalizedMessage(1010349); // You have fired your sheriff
m_Town.Sheriff.SendLocalizedMessage(1010270); // You have been fired as Sheriff
m_Town.Sheriff = null;
}
break;
}
case 4: // fire finance minister
{
if ( m_Town.Finance == null )
{
m_From.SendLocalizedMessage( 1010352 ); // You need to elect a financial minister before you can fire one
}
else
{
m_From.SendLocalizedMessage( 1010351 ); // You have fired your financial Minister
m_Town.Finance.SendLocalizedMessage( 1010151 ); // You have been fired as Finance Minister
m_Town.Finance = null;
}
break;
}
case 4: // fire finance minister
{
if (m_Town.Finance == null)
{
m_From.SendLocalizedMessage(
1010352); // You need to elect a financial minister before you can fire one
}
else
{
m_From.SendLocalizedMessage(1010351); // You have fired your financial Minister
m_Town.Finance.SendLocalizedMessage(1010151); // You have been fired as Finance Minister
m_Town.Finance = null;
}
break;
}
}
}
break;
}
}
}
private void HireSheriff_OnTarget( Mobile from, object obj )
{
if ( m_Town.Owner != m_Faction || !m_Faction.IsCommander( from ) )
{
from.SendLocalizedMessage( 1010339 ); // You no longer control this city
return;
}
private void HireSheriff_OnTarget(Mobile from, object obj)
{
if (m_Town.Owner != m_Faction || !m_Faction.IsCommander(from))
{
from.SendLocalizedMessage(1010339); // You no longer control this city
return;
}
if ( m_Town.Sheriff != null )
{
from.SendLocalizedMessage( 1010342 ); // You must fire your Sheriff before you can elect a new one
}
else if ( obj is Mobile targ )
{
PlayerState pl = PlayerState.Find( targ );
if (m_Town.Sheriff != null)
{
from.SendLocalizedMessage(1010342); // You must fire your Sheriff before you can elect a new one
}
else if (obj is Mobile targ)
{
PlayerState pl = PlayerState.Find(targ);
if ( pl == null )
{
from.SendLocalizedMessage( 1010337 ); // You must pick someone in a faction
}
else if ( pl.Faction != m_Faction )
{
from.SendLocalizedMessage( 1010338 ); // You must pick someone in the correct faction
}
else if ( m_Faction.Commander == targ )
{
from.SendLocalizedMessage( 1010335 ); // You cannot elect a commander to a town position
}
else if ( pl.Sheriff != null || pl.Finance != null )
{
from.SendLocalizedMessage( 1005245 ); // You must pick someone who does not already hold a city post
}
else
{
m_Town.Sheriff = targ;
targ.SendLocalizedMessage( 1010340 ); // You are now the Sheriff
from.SendLocalizedMessage( 1010341 ); // You have elected a Sheriff
}
}
else
{
from.SendLocalizedMessage( 1010334 ); // You must select a player to hold a city position!
}
}
if (pl == null)
{
from.SendLocalizedMessage(1010337); // You must pick someone in a faction
}
else if (pl.Faction != m_Faction)
{
from.SendLocalizedMessage(1010338); // You must pick someone in the correct faction
}
else if (m_Faction.Commander == targ)
{
from.SendLocalizedMessage(1010335); // You cannot elect a commander to a town position
}
else if (pl.Sheriff != null || pl.Finance != null)
{
from.SendLocalizedMessage(1005245); // You must pick someone who does not already hold a city post
}
else
{
m_Town.Sheriff = targ;
targ.SendLocalizedMessage(1010340); // You are now the Sheriff
from.SendLocalizedMessage(1010341); // You have elected a Sheriff
}
}
else
{
from.SendLocalizedMessage(1010334); // You must select a player to hold a city position!
}
}
private void HireFinanceMinister_OnTarget( Mobile from, object obj )
{
if ( m_Town.Owner != m_Faction || !m_Faction.IsCommander( from ) )
{
from.SendLocalizedMessage( 1010339 ); // You no longer control this city
}
else if ( m_Town.Finance != null )
{
from.SendLocalizedMessage( 1010342 ); // You must fire your Sheriff before you can elect a new one
}
else if ( obj is Mobile targ )
{
PlayerState pl = PlayerState.Find( targ );
private void HireFinanceMinister_OnTarget(Mobile from, object obj)
{
if (m_Town.Owner != m_Faction || !m_Faction.IsCommander(from))
{
from.SendLocalizedMessage(1010339); // You no longer control this city
}
else if (m_Town.Finance != null)
{
from.SendLocalizedMessage(1010342); // You must fire your Sheriff before you can elect a new one
}
else if (obj is Mobile targ)
{
PlayerState pl = PlayerState.Find(targ);
if ( pl == null )
{
from.SendLocalizedMessage( 1010337 ); // You must pick someone in a faction
}
else if ( pl.Faction != m_Faction )
{
from.SendLocalizedMessage( 1010338 ); // You must pick someone in the correct faction
}
else if ( m_Faction.Commander == targ )
{
from.SendLocalizedMessage( 1010335 ); // You cannot elect a commander to a town position
}
else if ( pl.Sheriff != null || pl.Finance != null )
{
from.SendLocalizedMessage( 1005245 ); // You must pick someone who does not already hold a city post
}
else
{
m_Town.Finance = targ;
targ.SendLocalizedMessage( 1010343 ); // You are now the Financial Minister
from.SendLocalizedMessage( 1010344 ); // You have elected a Financial Minister
}
}
else
{
from.SendLocalizedMessage( 1010334 ); // You must select a player to hold a city position!
}
}
}
}
if (pl == null)
{
from.SendLocalizedMessage(1010337); // You must pick someone in a faction
}
else if (pl.Faction != m_Faction)
{
from.SendLocalizedMessage(1010338); // You must pick someone in the correct faction
}
else if (m_Faction.Commander == targ)
{
from.SendLocalizedMessage(1010335); // You cannot elect a commander to a town position
}
else if (pl.Sheriff != null || pl.Finance != null)
{
from.SendLocalizedMessage(1005245); // You must pick someone who does not already hold a city post
}
else
{
m_Town.Finance = targ;
targ.SendLocalizedMessage(1010343); // You are now the Financial Minister
from.SendLocalizedMessage(1010344); // You have elected a Financial Minister
}
}
else
{
from.SendLocalizedMessage(1010334); // You must select a player to hold a city position!
}
}
}
}

View file

@ -4,63 +4,63 @@ using Server.Network;
namespace Server.Factions
{
public class VoteGump : FactionGump
{
private PlayerMobile m_From;
private Election m_Election;
public class VoteGump : FactionGump
{
private Election m_Election;
private PlayerMobile m_From;
public override void OnResponse( NetState sender, RelayInfo info )
{
if ( info.ButtonID == 0 )
{
m_From.SendGump( new FactionStoneGump( m_From, m_Election.Faction ) );
}
else
{
if ( !m_Election.CanVote( m_From ) )
return;
public VoteGump(PlayerMobile from, Election election) : base(50, 50)
{
m_From = from;
m_Election = election;
int index = info.ButtonID - 1;
bool canVote = election.CanVote(from);
if ( index >= 0 && index < m_Election.Candidates.Count )
m_Election.Candidates[index].Voters.Add( new Voter( m_From, m_Election.Candidates[index].Mobile ) );
AddPage(0);
m_From.SendGump( new VoteGump( m_From, m_Election ) );
}
}
AddBackground(0, 0, 420, 350, 5054);
AddBackground(10, 10, 400, 330, 3000);
public VoteGump( PlayerMobile from, Election election ) : base( 50, 50 )
{
m_From = from;
m_Election = election;
AddHtmlText(20, 20, 380, 20, election.Faction.Definition.Header, false, false);
bool canVote = election.CanVote( from );
if (canVote)
AddHtmlLocalized(20, 60, 380, 20, 1011428, false, false); // VOTE FOR LEADERSHIP
else
AddHtmlLocalized(20, 60, 380, 20, 1038032, false, false); // You have already voted in this election.
AddPage( 0 );
for (int i = 0; i < election.Candidates.Count; ++i)
{
Candidate cd = election.Candidates[i];
AddBackground( 0, 0, 420, 350, 5054 );
AddBackground( 10, 10, 400, 330, 3000 );
if (canVote)
AddButton(20, 100 + i * 20, 4005, 4007, i + 1, GumpButtonType.Reply, 0);
AddHtmlText( 20, 20, 380, 20, election.Faction.Definition.Header, false, false );
AddLabel(55, 100 + i * 20, 0, cd.Mobile.Name);
AddLabel(300, 100 + i * 20, 0, cd.Votes.ToString());
}
if ( canVote )
AddHtmlLocalized( 20, 60, 380, 20, 1011428, false, false ); // VOTE FOR LEADERSHIP
else
AddHtmlLocalized( 20, 60, 380, 20, 1038032, false, false ); // You have already voted in this election.
AddButton(20, 310, 4005, 4007, 0, GumpButtonType.Reply, 0);
AddHtmlLocalized(55, 310, 100, 20, 1011012, false, false); // CANCEL
}
for ( int i = 0; i < election.Candidates.Count; ++i )
{
Candidate cd = election.Candidates[i];
public override void OnResponse(NetState sender, RelayInfo info)
{
if (info.ButtonID == 0)
{
m_From.SendGump(new FactionStoneGump(m_From, m_Election.Faction));
}
else
{
if (!m_Election.CanVote(m_From))
return;
if ( canVote )
AddButton( 20, 100 + (i * 20), 4005, 4007, i + 1, GumpButtonType.Reply, 0 );
int index = info.ButtonID - 1;
AddLabel( 55, 100 + (i * 20), 0, cd.Mobile.Name );
AddLabel( 300, 100 + (i * 20), 0, cd.Votes.ToString() );
}
if (index >= 0 && index < m_Election.Candidates.Count)
m_Election.Candidates[index].Voters.Add(new Voter(m_From, m_Election.Candidates[index].Mobile));
AddButton( 20, 310, 4005, 4007, 0, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 55, 310, 100, 20, 1011012, false, false ); // CANCEL
}
}
m_From.SendGump(new VoteGump(m_From, m_Election));
}
}
}
}