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

@ -1,133 +1,139 @@
using System;
using Server.Gumps;
using Server.Network;
namespace Server.Engines.ConPVP
{
public class DuelContextGump : Gump
{
public Mobile From { get; }
public class DuelContextGump : Gump
{
public DuelContextGump(Mobile from, DuelContext context) : base(50, 50)
{
From = from;
Context = context;
public DuelContext Context { get; }
from.CloseGump(typeof(RulesetGump));
from.CloseGump(typeof(DuelContextGump));
from.CloseGump(typeof(ParticipantGump));
public string Center( string text )
{
return $"<CENTER>{text}</CENTER>";
}
int count = context.Participants.Count;
public void AddGoldenButton( int x, int y, int bid )
{
AddButton( x , y , 0xD2, 0xD2, bid, GumpButtonType.Reply, 0 );
AddButton( x+3, y+3, 0xD8, 0xD8, bid, GumpButtonType.Reply, 0 );
}
if (count < 3)
count = 3;
public void AddGoldenButtonLabeled( int x, int y, int bid, string text )
{
AddGoldenButton( x, y, bid );
AddHtml( x + 25, y, 200, 20, text, false, false );
}
int height = 35 + 10 + 22 + 30 + 22 + 22 + 2 + count * 22 + 2 + 30;
public DuelContextGump( Mobile from, DuelContext context ) : base( 50, 50 )
{
From = from;
Context = context;
AddPage(0);
from.CloseGump( typeof( RulesetGump ) );
from.CloseGump( typeof( DuelContextGump ) );
from.CloseGump( typeof( ParticipantGump ) );
AddBackground(0, 0, 300, height, 9250);
AddBackground(10, 10, 280, height - 20, 0xDAC);
int count = context.Participants.Count;
AddHtml(35, 25, 230, 20, Center("Duel Setup"), false, false);
if ( count < 3 )
count = 3;
int x = 35;
int y = 47;
int height = 35 + 10 + 22 + 30 + 22 + 22 + 2 + (count * 22) + 2 + 30;
AddGoldenButtonLabeled(x, y, 1, "Rules");
y += 22;
AddGoldenButtonLabeled(x, y, 2, "Start");
y += 22;
AddGoldenButtonLabeled(x, y, 3, "Add Participant");
y += 30;
AddPage( 0 );
AddHtml(35, y, 230, 20, Center("Participants"), false, false);
y += 22;
AddBackground( 0, 0, 300, height, 9250 );
AddBackground( 10, 10, 280, height - 20, 0xDAC );
for (int i = 0; i < context.Participants.Count; ++i)
{
Participant p = (Participant)context.Participants[i];
AddHtml( 35, 25, 230, 20, Center( "Duel Setup" ), false, false );
AddGoldenButtonLabeled(x, y, 4 + i,
string.Format(p.Count == 1 ? "Player {0}: {3}" : "Team {0}: {1}/{2}: {3}", 1 + i, p.FilledSlots, p.Count,
p.NameList));
y += 22;
}
}
int x = 35;
int y = 47;
public Mobile From{ get; }
AddGoldenButtonLabeled( x, y, 1, "Rules" ); y += 22;
AddGoldenButtonLabeled( x, y, 2, "Start" ); y += 22;
AddGoldenButtonLabeled( x, y, 3, "Add Participant" ); y += 30;
public DuelContext Context{ get; }
AddHtml( 35, y, 230, 20, Center( "Participants" ), false, false ); y += 22;
public string Center(string text)
{
return $"<CENTER>{text}</CENTER>";
}
for ( int i = 0; i < context.Participants.Count; ++i )
{
Participant p = (Participant)context.Participants[i];
public void AddGoldenButton(int x, int y, int bid)
{
AddButton(x, y, 0xD2, 0xD2, bid, GumpButtonType.Reply, 0);
AddButton(x + 3, y + 3, 0xD8, 0xD8, bid, GumpButtonType.Reply, 0);
}
AddGoldenButtonLabeled( x, y, 4 + i, string.Format( p.Count == 1 ? "Player {0}: {3}" : "Team {0}: {1}/{2}: {3}", 1 + i, p.FilledSlots, p.Count, p.NameList ) ); y += 22;
}
}
public void AddGoldenButtonLabeled(int x, int y, int bid, string text)
{
AddGoldenButton(x, y, bid);
AddHtml(x + 25, y, 200, 20, text, false, false);
}
public override void OnResponse( NetState sender, RelayInfo info )
{
if ( !Context.Registered )
return;
public override void OnResponse(NetState sender, RelayInfo info)
{
if (!Context.Registered)
return;
int index = info.ButtonID;
int index = info.ButtonID;
switch ( index )
{
case -1: // CloseGump
{
break;
}
case 0: // closed
{
Context.Unregister();
break;
}
case 1: // Rules
{
//m_From.SendGump( new RulesetGump( m_From, m_Context.Ruleset, m_Context.Ruleset.Layout, m_Context ) );
From.SendGump( new PickRulesetGump( From, Context, Context.Ruleset ) );
break;
}
case 2: // Start
{
if ( Context.CheckFull() )
{
Context.CloseAllGumps();
Context.SendReadyUpGump();
//m_Context.SendReadyGump();
}
else
{
From.SendMessage( "You cannot start the duel before all participating players have been assigned." );
From.SendGump( new DuelContextGump( From, Context ) );
}
switch (index)
{
case -1: // CloseGump
{
break;
}
case 0: // closed
{
Context.Unregister();
break;
}
case 1: // Rules
{
//m_From.SendGump( new RulesetGump( m_From, m_Context.Ruleset, m_Context.Ruleset.Layout, m_Context ) );
From.SendGump(new PickRulesetGump(From, Context, Context.Ruleset));
break;
}
case 2: // Start
{
if (Context.CheckFull())
{
Context.CloseAllGumps();
Context.SendReadyUpGump();
//m_Context.SendReadyGump();
}
else
{
From.SendMessage("You cannot start the duel before all participating players have been assigned.");
From.SendGump(new DuelContextGump(From, Context));
}
break;
}
case 3: // New Participant
{
if ( Context.Participants.Count < 10 )
Context.Participants.Add( new Participant( Context, 1 ) );
else
From.SendMessage( "The number of participating parties may not be increased further." );
break;
}
case 3: // New Participant
{
if (Context.Participants.Count < 10)
Context.Participants.Add(new Participant(Context, 1));
else
From.SendMessage("The number of participating parties may not be increased further.");
From.SendGump( new DuelContextGump( From, Context ) );
From.SendGump(new DuelContextGump(From, Context));
break;
}
default: // Participant
{
index -= 4;
break;
}
default: // Participant
{
index -= 4;
if ( index >= 0 && index < Context.Participants.Count )
From.SendGump( new ParticipantGump( From, Context, (Participant)Context.Participants[index] ) );
if (index >= 0 && index < Context.Participants.Count)
From.SendGump(new ParticipantGump(From, Context, (Participant)Context.Participants[index]));
break;
}
}
}
}
break;
}
}
}
}
}