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

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