Fixes code according to modern code style. Fixes a few expression bugs.
This commit is contained in:
parent
89eea25e5f
commit
970fd563b2
3324 changed files with 441118 additions and 433755 deletions
|
|
@ -1,283 +1,282 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using Server.Gumps;
|
||||
using Server.Network;
|
||||
using Server.Mobiles;
|
||||
using Server.Network;
|
||||
|
||||
namespace Server.Engines.ConPVP
|
||||
{
|
||||
public class AcceptDuelGump : Gump
|
||||
{
|
||||
private Mobile m_Challenger, m_Challenged;
|
||||
private DuelContext m_Context;
|
||||
private Participant m_Participant;
|
||||
private int m_Slot;
|
||||
public class AcceptDuelGump : Gump
|
||||
{
|
||||
private const int LabelColor32 = 0xFFFFFF;
|
||||
private const int BlackColor32 = 0x000008;
|
||||
|
||||
public string Center( string text )
|
||||
{
|
||||
return $"<CENTER>{text}</CENTER>";
|
||||
}
|
||||
private static Hashtable m_IgnoreLists = new Hashtable();
|
||||
|
||||
public string Color( string text, int color )
|
||||
{
|
||||
return $"<BASEFONT COLOR=#{color:X6}>{text}</BASEFONT>";
|
||||
}
|
||||
private bool m_Active = true;
|
||||
private Mobile m_Challenger, m_Challenged;
|
||||
private DuelContext m_Context;
|
||||
private Participant m_Participant;
|
||||
private int m_Slot;
|
||||
|
||||
private const int LabelColor32 = 0xFFFFFF;
|
||||
private const int BlackColor32 = 0x000008;
|
||||
public AcceptDuelGump(Mobile challenger, Mobile challenged, DuelContext context, Participant p, int slot) : base(50,
|
||||
50)
|
||||
{
|
||||
m_Challenger = challenger;
|
||||
m_Challenged = challenged;
|
||||
m_Context = context;
|
||||
m_Participant = p;
|
||||
m_Slot = slot;
|
||||
|
||||
private bool m_Active = true;
|
||||
challenged.CloseGump(typeof(AcceptDuelGump));
|
||||
|
||||
public AcceptDuelGump( Mobile challenger, Mobile challenged, DuelContext context, Participant p, int slot ) : base( 50, 50 )
|
||||
{
|
||||
m_Challenger = challenger;
|
||||
m_Challenged = challenged;
|
||||
m_Context = context;
|
||||
m_Participant = p;
|
||||
m_Slot = slot;
|
||||
Closable = false;
|
||||
|
||||
challenged.CloseGump( typeof( AcceptDuelGump ) );
|
||||
AddPage(0);
|
||||
|
||||
Closable = false;
|
||||
//AddBackground( 0, 0, 400, 220, 9150 );
|
||||
AddBackground(1, 1, 398, 218, 3600);
|
||||
//AddBackground( 16, 15, 369, 189, 9100 );
|
||||
|
||||
AddPage( 0 );
|
||||
AddImageTiled(16, 15, 369, 189, 3604);
|
||||
AddAlphaRegion(16, 15, 369, 189);
|
||||
|
||||
//AddBackground( 0, 0, 400, 220, 9150 );
|
||||
AddBackground( 1, 1, 398, 218, 3600 );
|
||||
//AddBackground( 16, 15, 369, 189, 9100 );
|
||||
AddImage(215, -43, 0xEE40);
|
||||
//AddImage( 330, 141, 0x8BA );
|
||||
|
||||
AddImageTiled( 16, 15, 369, 189, 3604 );
|
||||
AddAlphaRegion( 16, 15, 369, 189 );
|
||||
AddHtml(22 - 1, 22, 294, 20, Color(Center("Duel Challenge"), BlackColor32), false, false);
|
||||
AddHtml(22 + 1, 22, 294, 20, Color(Center("Duel Challenge"), BlackColor32), false, false);
|
||||
AddHtml(22, 22 - 1, 294, 20, Color(Center("Duel Challenge"), BlackColor32), false, false);
|
||||
AddHtml(22, 22 + 1, 294, 20, Color(Center("Duel Challenge"), BlackColor32), false, false);
|
||||
AddHtml(22, 22, 294, 20, Color(Center("Duel Challenge"), LabelColor32), false, false);
|
||||
|
||||
AddImage( 215, -43, 0xEE40 );
|
||||
//AddImage( 330, 141, 0x8BA );
|
||||
string fmt;
|
||||
|
||||
AddHtml( 22-1, 22, 294, 20, Color( Center( "Duel Challenge" ), BlackColor32 ), false, false );
|
||||
AddHtml( 22+1, 22, 294, 20, Color( Center( "Duel Challenge" ), BlackColor32 ), false, false );
|
||||
AddHtml( 22, 22-1, 294, 20, Color( Center( "Duel Challenge" ), BlackColor32 ), false, false );
|
||||
AddHtml( 22, 22+1, 294, 20, Color( Center( "Duel Challenge" ), BlackColor32 ), false, false );
|
||||
AddHtml( 22, 22, 294, 20, Color( Center( "Duel Challenge" ), LabelColor32 ), false, false );
|
||||
if (p.Contains(challenger))
|
||||
fmt = "You have been asked to join sides with {0} in a duel. Do you accept?";
|
||||
else
|
||||
fmt = "You have been challenged to a duel from {0}. Do you accept?";
|
||||
|
||||
string fmt;
|
||||
AddHtml(22 - 1, 50, 294, 40, Color(string.Format(fmt, challenger.Name), BlackColor32), false, false);
|
||||
AddHtml(22 + 1, 50, 294, 40, Color(string.Format(fmt, challenger.Name), BlackColor32), false, false);
|
||||
AddHtml(22, 50 - 1, 294, 40, Color(string.Format(fmt, challenger.Name), BlackColor32), false, false);
|
||||
AddHtml(22, 50 + 1, 294, 40, Color(string.Format(fmt, challenger.Name), BlackColor32), false, false);
|
||||
AddHtml(22, 50, 294, 40, Color(string.Format(fmt, challenger.Name), 0xB0C868), false, false);
|
||||
|
||||
if ( p.Contains( challenger ) )
|
||||
fmt = "You have been asked to join sides with {0} in a duel. Do you accept?";
|
||||
else
|
||||
fmt = "You have been challenged to a duel from {0}. Do you accept?";
|
||||
AddImageTiled(32, 88, 264, 1, 9107);
|
||||
AddImageTiled(42, 90, 264, 1, 9157);
|
||||
|
||||
AddHtml( 22-1, 50, 294, 40, Color( string.Format( fmt, challenger.Name ), BlackColor32 ), false, false );
|
||||
AddHtml( 22+1, 50, 294, 40, Color( string.Format( fmt, challenger.Name ), BlackColor32 ), false, false );
|
||||
AddHtml( 22, 50-1, 294, 40, Color( string.Format( fmt, challenger.Name ), BlackColor32 ), false, false );
|
||||
AddHtml( 22, 50+1, 294, 40, Color( string.Format( fmt, challenger.Name ), BlackColor32 ), false, false );
|
||||
AddHtml( 22, 50, 294, 40, Color( string.Format( fmt, challenger.Name ), 0xB0C868 ), false, false );
|
||||
AddRadio(24, 100, 9727, 9730, true, 1);
|
||||
AddHtml(60 - 1, 105, 250, 20, Color("Yes, I will fight this duel.", BlackColor32), false, false);
|
||||
AddHtml(60 + 1, 105, 250, 20, Color("Yes, I will fight this duel.", BlackColor32), false, false);
|
||||
AddHtml(60, 105 - 1, 250, 20, Color("Yes, I will fight this duel.", BlackColor32), false, false);
|
||||
AddHtml(60, 105 + 1, 250, 20, Color("Yes, I will fight this duel.", BlackColor32), false, false);
|
||||
AddHtml(60, 105, 250, 20, Color("Yes, I will fight this duel.", LabelColor32), false, false);
|
||||
|
||||
AddImageTiled( 32, 88, 264, 1, 9107 );
|
||||
AddImageTiled( 42, 90, 264, 1, 9157 );
|
||||
AddRadio(24, 135, 9727, 9730, false, 2);
|
||||
AddHtml(60 - 1, 140, 250, 20, Color("No, I do not wish to fight.", BlackColor32), false, false);
|
||||
AddHtml(60 + 1, 140, 250, 20, Color("No, I do not wish to fight.", BlackColor32), false, false);
|
||||
AddHtml(60, 140 - 1, 250, 20, Color("No, I do not wish to fight.", BlackColor32), false, false);
|
||||
AddHtml(60, 140 + 1, 250, 20, Color("No, I do not wish to fight.", BlackColor32), false, false);
|
||||
AddHtml(60, 140, 250, 20, Color("No, I do not wish to fight.", LabelColor32), false, false);
|
||||
|
||||
AddRadio( 24, 100, 9727, 9730, true, 1 );
|
||||
AddHtml( 60-1, 105, 250, 20, Color( "Yes, I will fight this duel.", BlackColor32 ), false, false );
|
||||
AddHtml( 60+1, 105, 250, 20, Color( "Yes, I will fight this duel.", BlackColor32 ), false, false );
|
||||
AddHtml( 60, 105-1, 250, 20, Color( "Yes, I will fight this duel.", BlackColor32 ), false, false );
|
||||
AddHtml( 60, 105+1, 250, 20, Color( "Yes, I will fight this duel.", BlackColor32 ), false, false );
|
||||
AddHtml( 60, 105, 250, 20, Color( "Yes, I will fight this duel.", LabelColor32 ), false, false );
|
||||
AddRadio(24, 170, 9727, 9730, false, 3);
|
||||
AddHtml(60 - 1, 175, 250, 20, Color("No, knave. Do not ask again.", BlackColor32), false, false);
|
||||
AddHtml(60 + 1, 175, 250, 20, Color("No, knave. Do not ask again.", BlackColor32), false, false);
|
||||
AddHtml(60, 175 - 1, 250, 20, Color("No, knave. Do not ask again.", BlackColor32), false, false);
|
||||
AddHtml(60, 175 + 1, 250, 20, Color("No, knave. Do not ask again.", BlackColor32), false, false);
|
||||
AddHtml(60, 175, 250, 20, Color("No, knave. Do not ask again.", LabelColor32), false, false);
|
||||
|
||||
AddRadio( 24, 135, 9727, 9730, false, 2 );
|
||||
AddHtml( 60-1, 140, 250, 20, Color( "No, I do not wish to fight.", BlackColor32 ), false, false );
|
||||
AddHtml( 60+1, 140, 250, 20, Color( "No, I do not wish to fight.", BlackColor32 ), false, false );
|
||||
AddHtml( 60, 140-1, 250, 20, Color( "No, I do not wish to fight.", BlackColor32 ), false, false );
|
||||
AddHtml( 60, 140+1, 250, 20, Color( "No, I do not wish to fight.", BlackColor32 ), false, false );
|
||||
AddHtml( 60, 140, 250, 20, Color( "No, I do not wish to fight.", LabelColor32 ), false, false );
|
||||
AddButton(314, 173, 247, 248, 1, GumpButtonType.Reply, 0);
|
||||
|
||||
AddRadio( 24, 170, 9727, 9730, false, 3 );
|
||||
AddHtml( 60-1, 175, 250, 20, Color( "No, knave. Do not ask again.", BlackColor32 ), false, false );
|
||||
AddHtml( 60+1, 175, 250, 20, Color( "No, knave. Do not ask again.", BlackColor32 ), false, false );
|
||||
AddHtml( 60, 175-1, 250, 20, Color( "No, knave. Do not ask again.", BlackColor32 ), false, false );
|
||||
AddHtml( 60, 175+1, 250, 20, Color( "No, knave. Do not ask again.", BlackColor32 ), false, false );
|
||||
AddHtml( 60, 175, 250, 20, Color( "No, knave. Do not ask again.", LabelColor32 ), false, false );
|
||||
Timer.DelayCall(TimeSpan.FromSeconds(15.0), AutoReject);
|
||||
}
|
||||
|
||||
AddButton( 314, 173, 247, 248, 1, GumpButtonType.Reply, 0 );
|
||||
public string Center(string text)
|
||||
{
|
||||
return $"<CENTER>{text}</CENTER>";
|
||||
}
|
||||
|
||||
Timer.DelayCall( TimeSpan.FromSeconds( 15.0 ), AutoReject );
|
||||
}
|
||||
public string Color(string text, int color)
|
||||
{
|
||||
return $"<BASEFONT COLOR=#{color:X6}>{text}</BASEFONT>";
|
||||
}
|
||||
|
||||
public void AutoReject()
|
||||
{
|
||||
if ( !m_Active )
|
||||
return;
|
||||
public void AutoReject()
|
||||
{
|
||||
if (!m_Active)
|
||||
return;
|
||||
|
||||
m_Active = false;
|
||||
m_Active = false;
|
||||
|
||||
m_Challenged.CloseGump( typeof( AcceptDuelGump ) );
|
||||
m_Challenged.CloseGump(typeof(AcceptDuelGump));
|
||||
|
||||
m_Challenger.SendMessage( "{0} seems unresponsive.", m_Challenged.Name );
|
||||
m_Challenged.SendMessage( "You decline the challenge." );
|
||||
}
|
||||
m_Challenger.SendMessage("{0} seems unresponsive.", m_Challenged.Name);
|
||||
m_Challenged.SendMessage("You decline the challenge.");
|
||||
}
|
||||
|
||||
private static Hashtable m_IgnoreLists = new Hashtable();
|
||||
public static void BeginIgnore(Mobile source, Mobile toIgnore)
|
||||
{
|
||||
ArrayList list = (ArrayList)m_IgnoreLists[source];
|
||||
|
||||
private class IgnoreEntry
|
||||
{
|
||||
public Mobile m_Ignored;
|
||||
public DateTime m_Expire;
|
||||
if (list == null)
|
||||
m_IgnoreLists[source] = list = new ArrayList();
|
||||
|
||||
public Mobile Ignored => m_Ignored;
|
||||
public bool Expired => ( DateTime.UtcNow >= m_Expire );
|
||||
for (int i = 0; i < list.Count; ++i)
|
||||
{
|
||||
IgnoreEntry ie = (IgnoreEntry)list[i];
|
||||
|
||||
private static TimeSpan ExpireDelay = TimeSpan.FromMinutes( 15.0 );
|
||||
if (ie.Ignored == toIgnore)
|
||||
{
|
||||
ie.Refresh();
|
||||
return;
|
||||
}
|
||||
|
||||
public void Refresh()
|
||||
{
|
||||
m_Expire = DateTime.UtcNow + ExpireDelay;
|
||||
}
|
||||
if (ie.Expired) list.RemoveAt(i--);
|
||||
}
|
||||
|
||||
public IgnoreEntry( Mobile ignored )
|
||||
{
|
||||
m_Ignored = ignored;
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
list.Add(new IgnoreEntry(toIgnore));
|
||||
}
|
||||
|
||||
public static void BeginIgnore( Mobile source, Mobile toIgnore )
|
||||
{
|
||||
ArrayList list = (ArrayList)m_IgnoreLists[source];
|
||||
public static bool IsIgnored(Mobile source, Mobile check)
|
||||
{
|
||||
ArrayList list = (ArrayList)m_IgnoreLists[source];
|
||||
|
||||
if ( list == null )
|
||||
m_IgnoreLists[source] = list = new ArrayList();
|
||||
if (list == null)
|
||||
return false;
|
||||
|
||||
for ( int i = 0; i < list.Count; ++i )
|
||||
{
|
||||
IgnoreEntry ie = (IgnoreEntry)list[i];
|
||||
for (int i = 0; i < list.Count; ++i)
|
||||
{
|
||||
IgnoreEntry ie = (IgnoreEntry)list[i];
|
||||
|
||||
if ( ie.Ignored == toIgnore )
|
||||
{
|
||||
ie.Refresh();
|
||||
return;
|
||||
}
|
||||
if (ie.Expired)
|
||||
list.RemoveAt(i--);
|
||||
else if (ie.Ignored == check)
|
||||
return true;
|
||||
}
|
||||
|
||||
if ( ie.Expired )
|
||||
{
|
||||
list.RemoveAt( i-- );
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
list.Add( new IgnoreEntry( toIgnore ) );
|
||||
}
|
||||
public override void OnResponse(NetState sender, RelayInfo info)
|
||||
{
|
||||
if (info.ButtonID != 1 || !m_Active || !m_Context.Registered)
|
||||
return;
|
||||
|
||||
public static bool IsIgnored( Mobile source, Mobile check )
|
||||
{
|
||||
ArrayList list = (ArrayList)m_IgnoreLists[source];
|
||||
m_Active = false;
|
||||
|
||||
if ( list == null )
|
||||
return false;
|
||||
if (!m_Context.Participants.Contains(m_Participant))
|
||||
return;
|
||||
|
||||
for ( int i = 0; i < list.Count; ++i )
|
||||
{
|
||||
IgnoreEntry ie = (IgnoreEntry)list[i];
|
||||
if (info.IsSwitched(1))
|
||||
{
|
||||
if (!(m_Challenged is PlayerMobile pm))
|
||||
return;
|
||||
|
||||
if ( ie.Expired )
|
||||
list.RemoveAt( i-- );
|
||||
else if ( ie.Ignored == check )
|
||||
return true;
|
||||
}
|
||||
if (pm.DuelContext != null)
|
||||
{
|
||||
if (pm.DuelContext.Initiator == pm)
|
||||
pm.SendMessage(0x22, "You have already started a duel.");
|
||||
else
|
||||
pm.SendMessage(0x22, "You have already been challenged in a duel.");
|
||||
|
||||
return false;
|
||||
}
|
||||
m_Challenger.SendMessage("{0} cannot fight because they are already assigned to another duel.", pm.Name);
|
||||
}
|
||||
else if (DuelContext.CheckCombat(pm))
|
||||
{
|
||||
pm.SendMessage(0x22,
|
||||
"You have recently been in combat with another player and must wait before starting a duel.");
|
||||
m_Challenger.SendMessage(
|
||||
"{0} cannot fight because they have recently been in combat with another player.", pm.Name);
|
||||
}
|
||||
else if (TournamentController.IsActive)
|
||||
{
|
||||
pm.SendMessage(0x22, "A tournament is currently active and you may not duel.");
|
||||
m_Challenger.SendMessage(0x22, "A tournament is currently active and you may not duel.");
|
||||
}
|
||||
else
|
||||
{
|
||||
bool added = false;
|
||||
|
||||
public override void OnResponse( NetState sender, RelayInfo info )
|
||||
{
|
||||
if ( info.ButtonID != 1 || !m_Active || !m_Context.Registered )
|
||||
return;
|
||||
if (m_Slot >= 0 && m_Slot < m_Participant.Players.Length && m_Participant.Players[m_Slot] == null)
|
||||
{
|
||||
added = true;
|
||||
m_Participant.Players[m_Slot] = new DuelPlayer(m_Challenged, m_Participant);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < m_Participant.Players.Length; ++i)
|
||||
if (m_Participant.Players[i] == null)
|
||||
{
|
||||
added = true;
|
||||
m_Participant.Players[i] = new DuelPlayer(m_Challenged, m_Participant);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
m_Active = false;
|
||||
if (added)
|
||||
{
|
||||
m_Challenger.SendMessage("{0} has accepted the request.", m_Challenged.Name);
|
||||
m_Challenged.SendMessage("You have accepted the request from {0}.", m_Challenger.Name);
|
||||
|
||||
if ( !m_Context.Participants.Contains( m_Participant ) )
|
||||
return;
|
||||
NetState ns = m_Challenger.NetState;
|
||||
|
||||
if ( info.IsSwitched( 1 ) )
|
||||
{
|
||||
if ( !(m_Challenged is PlayerMobile pm) )
|
||||
return;
|
||||
if (ns != null)
|
||||
foreach (Gump g in ns.Gumps)
|
||||
{
|
||||
if (g is ParticipantGump pg && pg.Participant == m_Participant)
|
||||
{
|
||||
m_Challenger.SendGump(new ParticipantGump(m_Challenger, m_Context, m_Participant));
|
||||
break;
|
||||
}
|
||||
|
||||
if ( pm.DuelContext != null )
|
||||
{
|
||||
if ( pm.DuelContext.Initiator == pm )
|
||||
pm.SendMessage( 0x22, "You have already started a duel." );
|
||||
else
|
||||
pm.SendMessage( 0x22, "You have already been challenged in a duel." );
|
||||
if (g is DuelContextGump dcg && dcg.Context == m_Context)
|
||||
{
|
||||
m_Challenger.SendGump(new DuelContextGump(m_Challenger, m_Context));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Challenger.SendMessage("The participant list was full and so {0} could not join.",
|
||||
m_Challenged.Name);
|
||||
m_Challenged.SendMessage(
|
||||
"The participant list was full and so you could not join the fight {1} {0}.", m_Challenger.Name,
|
||||
m_Participant.Contains(m_Challenger) ? "with" : "against");
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (info.IsSwitched(3))
|
||||
BeginIgnore(m_Challenged, m_Challenger);
|
||||
|
||||
m_Challenger.SendMessage( "{0} cannot fight because they are already assigned to another duel.", pm.Name );
|
||||
}
|
||||
else if ( DuelContext.CheckCombat( pm ) )
|
||||
{
|
||||
pm.SendMessage( 0x22, "You have recently been in combat with another player and must wait before starting a duel." );
|
||||
m_Challenger.SendMessage( "{0} cannot fight because they have recently been in combat with another player.", pm.Name );
|
||||
}
|
||||
else if ( TournamentController.IsActive )
|
||||
{
|
||||
pm.SendMessage( 0x22, "A tournament is currently active and you may not duel." );
|
||||
m_Challenger.SendMessage( 0x22, "A tournament is currently active and you may not duel." );
|
||||
}
|
||||
else
|
||||
{
|
||||
bool added = false;
|
||||
m_Challenger.SendMessage("{0} does not wish to fight.", m_Challenged.Name);
|
||||
m_Challenged.SendMessage("You chose not to fight {1} {0}.", m_Challenger.Name,
|
||||
m_Participant.Contains(m_Challenger) ? "with" : "against");
|
||||
}
|
||||
}
|
||||
|
||||
if ( m_Slot >= 0 && m_Slot < m_Participant.Players.Length && m_Participant.Players[m_Slot] == null )
|
||||
{
|
||||
added = true;
|
||||
m_Participant.Players[m_Slot] = new DuelPlayer( m_Challenged, m_Participant );
|
||||
}
|
||||
else
|
||||
{
|
||||
for ( int i = 0; i < m_Participant.Players.Length; ++i )
|
||||
{
|
||||
if ( m_Participant.Players[i] == null )
|
||||
{
|
||||
added = true;
|
||||
m_Participant.Players[i] = new DuelPlayer( m_Challenged, m_Participant );
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
private class IgnoreEntry
|
||||
{
|
||||
private static TimeSpan ExpireDelay = TimeSpan.FromMinutes(15.0);
|
||||
public DateTime m_Expire;
|
||||
public Mobile m_Ignored;
|
||||
|
||||
if ( added )
|
||||
{
|
||||
m_Challenger.SendMessage( "{0} has accepted the request.", m_Challenged.Name );
|
||||
m_Challenged.SendMessage( "You have accepted the request from {0}.", m_Challenger.Name );
|
||||
public IgnoreEntry(Mobile ignored)
|
||||
{
|
||||
m_Ignored = ignored;
|
||||
Refresh();
|
||||
}
|
||||
|
||||
NetState ns = m_Challenger.NetState;
|
||||
public Mobile Ignored => m_Ignored;
|
||||
public bool Expired => DateTime.UtcNow >= m_Expire;
|
||||
|
||||
if ( ns != null )
|
||||
{
|
||||
foreach ( Gump g in ns.Gumps )
|
||||
{
|
||||
if ( g is ParticipantGump pg && pg.Participant == m_Participant )
|
||||
{
|
||||
m_Challenger.SendGump( new ParticipantGump( m_Challenger, m_Context, m_Participant ) );
|
||||
break;
|
||||
}
|
||||
if ( g is DuelContextGump dcg && dcg.Context == m_Context )
|
||||
{
|
||||
m_Challenger.SendGump( new DuelContextGump( m_Challenger, m_Context ) );
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Challenger.SendMessage( "The participant list was full and so {0} could not join.", m_Challenged.Name );
|
||||
m_Challenged.SendMessage( "The participant list was full and so you could not join the fight {1} {0}.", m_Challenger.Name, m_Participant.Contains( m_Challenger ) ? "with" : "against" );
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( info.IsSwitched( 3 ) )
|
||||
BeginIgnore( m_Challenged, m_Challenger );
|
||||
|
||||
m_Challenger.SendMessage( "{0} does not wish to fight.", m_Challenged.Name );
|
||||
m_Challenged.SendMessage( "You chose not to fight {1} {0}.", m_Challenger.Name, m_Participant.Contains( m_Challenger ) ? "with" : "against" );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public void Refresh()
|
||||
{
|
||||
m_Expire = DateTime.UtcNow + ExpireDelay;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,289 +1,290 @@
|
|||
using System;
|
||||
using System.Text;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Server.Gumps;
|
||||
using Server.Network;
|
||||
using Server.Mobiles;
|
||||
using Server.Network;
|
||||
|
||||
namespace Server.Engines.ConPVP
|
||||
{
|
||||
public class ArenasMoongate : Item
|
||||
{
|
||||
public override string DefaultName => "arena moongate";
|
||||
public class ArenasMoongate : Item
|
||||
{
|
||||
[Constructible]
|
||||
public ArenasMoongate() : base(0x1FD4)
|
||||
{
|
||||
Movable = false;
|
||||
Light = LightType.Circle300;
|
||||
}
|
||||
|
||||
[Constructible]
|
||||
public ArenasMoongate() : base( 0x1FD4 )
|
||||
{
|
||||
Movable = false;
|
||||
Light = LightType.Circle300;
|
||||
}
|
||||
public ArenasMoongate(Serial serial) : base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public ArenasMoongate( Serial serial ) : base( serial )
|
||||
{
|
||||
}
|
||||
public override string DefaultName => "arena moongate";
|
||||
|
||||
public override void Serialize( GenericWriter writer )
|
||||
{
|
||||
base.Serialize( writer );
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write( (int) 0 );
|
||||
}
|
||||
writer.Write(0);
|
||||
}
|
||||
|
||||
public override void Deserialize( GenericReader reader )
|
||||
{
|
||||
base.Deserialize( reader );
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
int version = reader.ReadInt();
|
||||
Light = LightType.Circle300;
|
||||
}
|
||||
int version = reader.ReadInt();
|
||||
Light = LightType.Circle300;
|
||||
}
|
||||
|
||||
public bool UseGate( Mobile from )
|
||||
{
|
||||
if ( DuelContext.CheckCombat( from ) )
|
||||
{
|
||||
from.SendMessage( 0x22, "You have recently been in combat with another player and cannot use this moongate." );
|
||||
return false;
|
||||
}
|
||||
public bool UseGate(Mobile from)
|
||||
{
|
||||
if (DuelContext.CheckCombat(from))
|
||||
{
|
||||
from.SendMessage(0x22, "You have recently been in combat with another player and cannot use this moongate.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( from.Spell != null )
|
||||
{
|
||||
from.SendLocalizedMessage( 1049616 ); // You are too busy to do that at the moment.
|
||||
return false;
|
||||
}
|
||||
from.CloseGump( typeof( ArenaGump ) );
|
||||
from.SendGump( new ArenaGump( from, this ) );
|
||||
if (from.Spell != null)
|
||||
{
|
||||
from.SendLocalizedMessage(1049616); // You are too busy to do that at the moment.
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( !from.Hidden || from.AccessLevel == AccessLevel.Player )
|
||||
Effects.PlaySound( from.Location, from.Map, 0x20E );
|
||||
from.CloseGump(typeof(ArenaGump));
|
||||
from.SendGump(new ArenaGump(from, this));
|
||||
|
||||
return true;
|
||||
}
|
||||
if (!from.Hidden || from.AccessLevel == AccessLevel.Player)
|
||||
Effects.PlaySound(from.Location, from.Map, 0x20E);
|
||||
|
||||
public override void OnDoubleClick( Mobile from )
|
||||
{
|
||||
if ( from.InRange( GetWorldLocation(), 1 ) )
|
||||
UseGate( from );
|
||||
else
|
||||
from.LocalOverheadMessage( MessageType.Regular, 0x3B2, 1019045 ); // I can't reach that
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool OnMoveOver( Mobile m )
|
||||
{
|
||||
return ( !m.Player || UseGate( m ) );
|
||||
}
|
||||
}
|
||||
public override void OnDoubleClick(Mobile from)
|
||||
{
|
||||
if (from.InRange(GetWorldLocation(), 1))
|
||||
UseGate(from);
|
||||
else
|
||||
from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1019045); // I can't reach that
|
||||
}
|
||||
|
||||
public class ArenaGump : Gump
|
||||
{
|
||||
private Mobile m_From;
|
||||
private ArenasMoongate m_Gate;
|
||||
private List<Arena> m_Arenas;
|
||||
public override bool OnMoveOver(Mobile m)
|
||||
{
|
||||
return !m.Player || UseGate(m);
|
||||
}
|
||||
}
|
||||
|
||||
private void Append( StringBuilder sb, LadderEntry le )
|
||||
{
|
||||
if ( le == null )
|
||||
return;
|
||||
public class ArenaGump : Gump
|
||||
{
|
||||
private List<Arena> m_Arenas;
|
||||
|
||||
if ( sb.Length > 0 )
|
||||
sb.Append( ", " );
|
||||
private int m_ColumnX = 12;
|
||||
private Mobile m_From;
|
||||
private ArenasMoongate m_Gate;
|
||||
|
||||
sb.Append( le.Mobile.Name );
|
||||
}
|
||||
public ArenaGump(Mobile from, ArenasMoongate gate) : base(50, 50)
|
||||
{
|
||||
m_From = from;
|
||||
m_Gate = gate;
|
||||
m_Arenas = Arena.Arenas;
|
||||
|
||||
public override void OnResponse( NetState sender, RelayInfo info )
|
||||
{
|
||||
if ( info.ButtonID != 1 )
|
||||
return;
|
||||
AddPage(0);
|
||||
|
||||
int[] switches = info.Switches;
|
||||
int height = 12 + 20 + m_Arenas.Count * 31 + 24 + 12;
|
||||
|
||||
if ( switches.Length == 0 )
|
||||
return;
|
||||
AddBackground(0, 0, 499 + 40, height, 0x2436);
|
||||
|
||||
int opt = switches[0];
|
||||
List<Arena> list = m_Arenas;
|
||||
|
||||
if ( opt < 0 || opt >= m_Arenas.Count )
|
||||
return;
|
||||
for (int i = 1; i < list.Count; i += 2)
|
||||
AddImageTiled(12, 32 + i * 31, 475 + 40, 30, 0x2430);
|
||||
|
||||
Arena arena = m_Arenas[opt];
|
||||
AddAlphaRegion(10, 10, 479 + 40, height - 20);
|
||||
|
||||
if ( !m_From.InRange( m_Gate.GetWorldLocation(), 1 ) || m_From.Map != m_Gate.Map )
|
||||
{
|
||||
m_From.SendLocalizedMessage( 1019002 ); // You are too far away to use the gate.
|
||||
}
|
||||
else if ( DuelContext.CheckCombat( m_From ) )
|
||||
{
|
||||
m_From.SendMessage( 0x22, "You have recently been in combat with another player and cannot use this moongate." );
|
||||
}
|
||||
else if ( m_From.Spell != null )
|
||||
{
|
||||
m_From.SendLocalizedMessage( 1049616 ); // You are too busy to do that at the moment.
|
||||
}
|
||||
else if ( m_From.Map == arena.Facet && arena.Zone.Contains( m_From ) )
|
||||
{
|
||||
m_From.SendLocalizedMessage( 1019003 ); // You are already there.
|
||||
}
|
||||
else
|
||||
{
|
||||
BaseCreature.TeleportPets( m_From, arena.GateIn, arena.Facet );
|
||||
AddColumnHeader(35, null);
|
||||
AddColumnHeader(115, "Arena");
|
||||
AddColumnHeader(325, "Participants");
|
||||
AddColumnHeader(40, "Obs");
|
||||
|
||||
m_From.Combatant = null;
|
||||
m_From.Warmode = false;
|
||||
m_From.Hidden = true;
|
||||
AddButton(499 + 40 - 12 - 63 - 4 - 63, height - 12 - 24, 247, 248, 1, GumpButtonType.Reply, 0);
|
||||
AddButton(499 + 40 - 12 - 63, height - 12 - 24, 241, 242, 2, GumpButtonType.Reply, 0);
|
||||
|
||||
m_From.MoveToWorld( arena.GateIn, arena.Facet );
|
||||
for (int i = 0; i < list.Count; ++i)
|
||||
{
|
||||
Arena ar = list[i];
|
||||
|
||||
Effects.PlaySound( arena.GateIn, arena.Facet, 0x1FE );
|
||||
}
|
||||
}
|
||||
string name = ar.Name;
|
||||
|
||||
public ArenaGump( Mobile from, ArenasMoongate gate ) : base( 50, 50 )
|
||||
{
|
||||
m_From = from;
|
||||
m_Gate = gate;
|
||||
m_Arenas = Arena.Arenas;
|
||||
if (name == null)
|
||||
name = "(no name)";
|
||||
|
||||
AddPage( 0 );
|
||||
int x = 12;
|
||||
int y = 32 + i * 31;
|
||||
|
||||
int height = 12 + 20 + (m_Arenas.Count * 31) + 24 + 12;
|
||||
int color = ar.Players.Count > 0 ? 0xCCFFCC : 0xCCCCCC;
|
||||
|
||||
AddBackground( 0, 0, 499+40, height, 0x2436 );
|
||||
AddRadio(x + 3, y + 1, 9727, 9730, false, i);
|
||||
x += 35;
|
||||
|
||||
List<Arena> list = m_Arenas;
|
||||
AddBorderedText(x + 5, y + 5, 115 - 5, name, color, 0);
|
||||
x += 115;
|
||||
|
||||
for ( int i = 1; i < list.Count; i += 2 )
|
||||
AddImageTiled( 12, 32 + (i * 31), 475+40, 30, 0x2430 );
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
AddAlphaRegion( 10, 10, 479+40, height - 20 );
|
||||
if (ar.Players.Count > 0)
|
||||
{
|
||||
Ladder ladder = Ladder.Instance;
|
||||
|
||||
AddColumnHeader( 35, null );
|
||||
AddColumnHeader( 115, "Arena" );
|
||||
AddColumnHeader( 325, "Participants" );
|
||||
AddColumnHeader( 40, "Obs" );
|
||||
if (ladder == null)
|
||||
continue;
|
||||
|
||||
AddButton( 499+40 - 12 - 63 - 4 - 63, height - 12 - 24, 247, 248, 1, GumpButtonType.Reply, 0 );
|
||||
AddButton( 499+40 - 12 - 63, height - 12 - 24, 241, 242, 2, GumpButtonType.Reply, 0 );
|
||||
LadderEntry p1 = null, p2 = null, p3 = null, p4 = null;
|
||||
|
||||
for ( int i = 0; i < list.Count; ++i )
|
||||
{
|
||||
Arena ar = list[i];
|
||||
for (int j = 0; j < ar.Players.Count; ++j)
|
||||
{
|
||||
Mobile mob = ar.Players[j];
|
||||
LadderEntry c = ladder.Find(mob);
|
||||
|
||||
string name = ar.Name;
|
||||
if (p1 == null || c.Index < p1.Index)
|
||||
{
|
||||
p4 = p3;
|
||||
p3 = p2;
|
||||
p2 = p1;
|
||||
p1 = c;
|
||||
}
|
||||
else if (p2 == null || c.Index < p2.Index)
|
||||
{
|
||||
p4 = p3;
|
||||
p3 = p2;
|
||||
p2 = c;
|
||||
}
|
||||
else if (p3 == null || c.Index < p3.Index)
|
||||
{
|
||||
p4 = p3;
|
||||
p3 = c;
|
||||
}
|
||||
else if (p4 == null || c.Index < p4.Index)
|
||||
{
|
||||
p4 = c;
|
||||
}
|
||||
}
|
||||
|
||||
if ( name == null )
|
||||
name = "(no name)";
|
||||
Append(sb, p1);
|
||||
Append(sb, p2);
|
||||
Append(sb, p3);
|
||||
Append(sb, p4);
|
||||
|
||||
int x = 12;
|
||||
int y = 32 + (i * 31);
|
||||
if (ar.Players.Count > 4)
|
||||
sb.Append(", ...");
|
||||
}
|
||||
else
|
||||
{
|
||||
sb.Append("Empty");
|
||||
}
|
||||
|
||||
int color = ( ar.Players.Count > 0 ? 0xCCFFCC : 0xCCCCCC );
|
||||
AddBorderedText(x + 5, y + 5, 325 - 5, sb.ToString(), color, 0);
|
||||
x += 325;
|
||||
|
||||
AddRadio( x + 3, y + 1, 9727, 9730, false, i );
|
||||
x += 35;
|
||||
AddBorderedText(x, y + 5, 40, Center(ar.Spectators.ToString()), color, 0);
|
||||
}
|
||||
}
|
||||
|
||||
AddBorderedText( x + 5, y + 5, 115 - 5, name, color, 0 );
|
||||
x += 115;
|
||||
private void Append(StringBuilder sb, LadderEntry le)
|
||||
{
|
||||
if (le == null)
|
||||
return;
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
if (sb.Length > 0)
|
||||
sb.Append(", ");
|
||||
|
||||
if ( ar.Players.Count > 0 )
|
||||
{
|
||||
Ladder ladder = Ladder.Instance;
|
||||
sb.Append(le.Mobile.Name);
|
||||
}
|
||||
|
||||
if ( ladder == null )
|
||||
continue;
|
||||
public override void OnResponse(NetState sender, RelayInfo info)
|
||||
{
|
||||
if (info.ButtonID != 1)
|
||||
return;
|
||||
|
||||
LadderEntry p1 = null, p2 = null, p3 = null, p4 = null;
|
||||
int[] switches = info.Switches;
|
||||
|
||||
for ( int j = 0; j < ar.Players.Count; ++j )
|
||||
{
|
||||
Mobile mob = (Mobile)ar.Players[j];
|
||||
LadderEntry c = ladder.Find( mob );
|
||||
if (switches.Length == 0)
|
||||
return;
|
||||
|
||||
if ( p1 == null || c.Index < p1.Index )
|
||||
{
|
||||
p4 = p3;
|
||||
p3 = p2;
|
||||
p2 = p1;
|
||||
p1 = c;
|
||||
}
|
||||
else if ( p2 == null || c.Index < p2.Index )
|
||||
{
|
||||
p4 = p3;
|
||||
p3 = p2;
|
||||
p2 = c;
|
||||
}
|
||||
else if ( p3 == null || c.Index < p3.Index )
|
||||
{
|
||||
p4 = p3;
|
||||
p3 = c;
|
||||
}
|
||||
else if ( p4 == null || c.Index < p4.Index )
|
||||
{
|
||||
p4 = c;
|
||||
}
|
||||
}
|
||||
int opt = switches[0];
|
||||
|
||||
Append( sb, p1 );
|
||||
Append( sb, p2 );
|
||||
Append( sb, p3 );
|
||||
Append( sb, p4 );
|
||||
if (opt < 0 || opt >= m_Arenas.Count)
|
||||
return;
|
||||
|
||||
if ( ar.Players.Count > 4 )
|
||||
sb.Append( ", ..." );
|
||||
}
|
||||
else
|
||||
{
|
||||
sb.Append( "Empty" );
|
||||
}
|
||||
Arena arena = m_Arenas[opt];
|
||||
|
||||
AddBorderedText( x + 5, y + 5, 325 - 5, sb.ToString(), color, 0 );
|
||||
x += 325;
|
||||
if (!m_From.InRange(m_Gate.GetWorldLocation(), 1) || m_From.Map != m_Gate.Map)
|
||||
{
|
||||
m_From.SendLocalizedMessage(1019002); // You are too far away to use the gate.
|
||||
}
|
||||
else if (DuelContext.CheckCombat(m_From))
|
||||
{
|
||||
m_From.SendMessage(0x22,
|
||||
"You have recently been in combat with another player and cannot use this moongate.");
|
||||
}
|
||||
else if (m_From.Spell != null)
|
||||
{
|
||||
m_From.SendLocalizedMessage(1049616); // You are too busy to do that at the moment.
|
||||
}
|
||||
else if (m_From.Map == arena.Facet && arena.Zone.Contains(m_From))
|
||||
{
|
||||
m_From.SendLocalizedMessage(1019003); // You are already there.
|
||||
}
|
||||
else
|
||||
{
|
||||
BaseCreature.TeleportPets(m_From, arena.GateIn, arena.Facet);
|
||||
|
||||
AddBorderedText( x, y + 5, 40, Center( ar.Spectators.ToString() ), color, 0 );
|
||||
}
|
||||
}
|
||||
m_From.Combatant = null;
|
||||
m_From.Warmode = false;
|
||||
m_From.Hidden = true;
|
||||
|
||||
public string Center( string text )
|
||||
{
|
||||
return $"<CENTER>{text}</CENTER>";
|
||||
}
|
||||
m_From.MoveToWorld(arena.GateIn, arena.Facet);
|
||||
|
||||
public string Color( string text, int color )
|
||||
{
|
||||
return $"<BASEFONT COLOR=#{color:X6}>{text}</BASEFONT>";
|
||||
}
|
||||
Effects.PlaySound(arena.GateIn, arena.Facet, 0x1FE);
|
||||
}
|
||||
}
|
||||
|
||||
private void AddBorderedText( int x, int y, int width, string text, int color, int borderColor )
|
||||
{
|
||||
/*AddColoredText( x - 1, y, width, text, borderColor );
|
||||
AddColoredText( x + 1, y, width, text, borderColor );
|
||||
AddColoredText( x, y - 1, width, text, borderColor );
|
||||
AddColoredText( x, y + 1, width, text, borderColor );*/
|
||||
/*AddColoredText( x - 1, y - 1, width, text, borderColor );
|
||||
AddColoredText( x + 1, y + 1, width, text, borderColor );*/
|
||||
AddColoredText( x, y, width, text, color );
|
||||
}
|
||||
public string Center(string text)
|
||||
{
|
||||
return $"<CENTER>{text}</CENTER>";
|
||||
}
|
||||
|
||||
private void AddColoredText( int x, int y, int width, string text, int color )
|
||||
{
|
||||
if ( color == 0 )
|
||||
AddHtml( x, y, width, 20, text, false, false );
|
||||
else
|
||||
AddHtml( x, y, width, 20, Color( text, color ), false, false );
|
||||
}
|
||||
public string Color(string text, int color)
|
||||
{
|
||||
return $"<BASEFONT COLOR=#{color:X6}>{text}</BASEFONT>";
|
||||
}
|
||||
|
||||
private int m_ColumnX = 12;
|
||||
private void AddBorderedText(int x, int y, int width, string text, int color, int borderColor)
|
||||
{
|
||||
/*AddColoredText( x - 1, y, width, text, borderColor );
|
||||
AddColoredText( x + 1, y, width, text, borderColor );
|
||||
AddColoredText( x, y - 1, width, text, borderColor );
|
||||
AddColoredText( x, y + 1, width, text, borderColor );*/
|
||||
/*AddColoredText( x - 1, y - 1, width, text, borderColor );
|
||||
AddColoredText( x + 1, y + 1, width, text, borderColor );*/
|
||||
AddColoredText(x, y, width, text, color);
|
||||
}
|
||||
|
||||
private void AddColumnHeader( int width, string name )
|
||||
{
|
||||
AddBackground( m_ColumnX, 12, width, 20, 0x242C );
|
||||
AddImageTiled( m_ColumnX + 2, 14, width - 4, 16, 0x2430 );
|
||||
private void AddColoredText(int x, int y, int width, string text, int color)
|
||||
{
|
||||
if (color == 0)
|
||||
AddHtml(x, y, width, 20, text, false, false);
|
||||
else
|
||||
AddHtml(x, y, width, 20, Color(text, color), false, false);
|
||||
}
|
||||
|
||||
if ( name != null )
|
||||
AddBorderedText( m_ColumnX, 13, width, Center( name ), 0xFFFFFF, 0 );
|
||||
private void AddColumnHeader(int width, string name)
|
||||
{
|
||||
AddBackground(m_ColumnX, 12, width, 20, 0x242C);
|
||||
AddImageTiled(m_ColumnX + 2, 14, width - 4, 16, 0x2430);
|
||||
|
||||
m_ColumnX += width;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (name != null)
|
||||
AddBorderedText(m_ColumnX, 13, width, Center(name), 0xFFFFFF, 0);
|
||||
|
||||
m_ColumnX += width;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,58 +1,72 @@
|
|||
using System;
|
||||
using Server.Gumps;
|
||||
|
||||
namespace Server.Engines.ConPVP
|
||||
{
|
||||
public class BeginGump : Gump
|
||||
{
|
||||
public string Center( string text )
|
||||
{
|
||||
return $"<CENTER>{text}</CENTER>";
|
||||
}
|
||||
public class BeginGump : Gump
|
||||
{
|
||||
private const int LabelColor32 = 0xFFFFFF;
|
||||
private const int BlackColor32 = 0x000008;
|
||||
|
||||
public string Color( string text, int color )
|
||||
{
|
||||
return $"<BASEFONT COLOR=#{color:X6}>{text}</BASEFONT>";
|
||||
}
|
||||
public BeginGump(int count) : base(50, 50)
|
||||
{
|
||||
AddPage(0);
|
||||
|
||||
private const int LabelColor32 = 0xFFFFFF;
|
||||
private const int BlackColor32 = 0x000008;
|
||||
const int offset = 50;
|
||||
|
||||
public BeginGump( int count ) : base( 50, 50 )
|
||||
{
|
||||
AddPage( 0 );
|
||||
AddBackground(1, 1, 398, 202 - offset, 3600);
|
||||
|
||||
const int offset = 50;
|
||||
AddImageTiled(16, 15, 369, 173 - offset, 3604);
|
||||
AddAlphaRegion(16, 15, 369, 173 - offset);
|
||||
|
||||
AddBackground( 1, 1, 398, 202-offset, 3600 );
|
||||
AddImage(215, -43, 0xEE40);
|
||||
|
||||
AddImageTiled( 16, 15, 369, 173-offset, 3604 );
|
||||
AddAlphaRegion( 16, 15, 369, 173-offset );
|
||||
AddHtml(22 - 1, 22, 294, 20, Color(Center("Duel Countdown"), BlackColor32), false, false);
|
||||
AddHtml(22 + 1, 22, 294, 20, Color(Center("Duel Countdown"), BlackColor32), false, false);
|
||||
AddHtml(22, 22 - 1, 294, 20, Color(Center("Duel Countdown"), BlackColor32), false, false);
|
||||
AddHtml(22, 22 + 1, 294, 20, Color(Center("Duel Countdown"), BlackColor32), false, false);
|
||||
AddHtml(22, 22, 294, 20, Color(Center("Duel Countdown"), LabelColor32), false, false);
|
||||
|
||||
AddImage( 215, -43, 0xEE40 );
|
||||
AddHtml(22 - 1, 50, 294, 80,
|
||||
Color(
|
||||
"The arranged duel is about to begin. During this countdown period you may not cast spells and you may not move. This message will close automatically when the period ends.",
|
||||
BlackColor32), false, false);
|
||||
AddHtml(22 + 1, 50, 294, 80,
|
||||
Color(
|
||||
"The arranged duel is about to begin. During this countdown period you may not cast spells and you may not move. This message will close automatically when the period ends.",
|
||||
BlackColor32), false, false);
|
||||
AddHtml(22, 50 - 1, 294, 80,
|
||||
Color(
|
||||
"The arranged duel is about to begin. During this countdown period you may not cast spells and you may not move. This message will close automatically when the period ends.",
|
||||
BlackColor32), false, false);
|
||||
AddHtml(22, 50 + 1, 294, 80,
|
||||
Color(
|
||||
"The arranged duel is about to begin. During this countdown period you may not cast spells and you may not move. This message will close automatically when the period ends.",
|
||||
BlackColor32), false, false);
|
||||
AddHtml(22, 50, 294, 80,
|
||||
Color(
|
||||
"The arranged duel is about to begin. During this countdown period you may not cast spells and you may not move. This message will close automatically when the period ends.",
|
||||
0xFFCC66), false, false);
|
||||
|
||||
AddHtml( 22-1, 22, 294, 20, Color( Center( "Duel Countdown" ), BlackColor32 ), false, false );
|
||||
AddHtml( 22+1, 22, 294, 20, Color( Center( "Duel Countdown" ), BlackColor32 ), false, false );
|
||||
AddHtml( 22, 22-1, 294, 20, Color( Center( "Duel Countdown" ), BlackColor32 ), false, false );
|
||||
AddHtml( 22, 22+1, 294, 20, Color( Center( "Duel Countdown" ), BlackColor32 ), false, false );
|
||||
AddHtml( 22, 22, 294, 20, Color( Center( "Duel Countdown" ), LabelColor32 ), false, false );
|
||||
/*AddImageTiled( 32, 128, 264, 1, 9107 );
|
||||
AddImageTiled( 42, 130, 264, 1, 9157 );
|
||||
|
||||
AddHtml( 22-1, 50, 294, 80, Color( "The arranged duel is about to begin. During this countdown period you may not cast spells and you may not move. This message will close automatically when the period ends.", BlackColor32 ), false, false );
|
||||
AddHtml( 22+1, 50, 294, 80, Color( "The arranged duel is about to begin. During this countdown period you may not cast spells and you may not move. This message will close automatically when the period ends.", BlackColor32 ), false, false );
|
||||
AddHtml( 22, 50-1, 294, 80, Color( "The arranged duel is about to begin. During this countdown period you may not cast spells and you may not move. This message will close automatically when the period ends.", BlackColor32 ), false, false );
|
||||
AddHtml( 22, 50+1, 294, 80, Color( "The arranged duel is about to begin. During this countdown period you may not cast spells and you may not move. This message will close automatically when the period ends.", BlackColor32 ), false, false );
|
||||
AddHtml( 22, 50, 294, 80, Color( "The arranged duel is about to begin. During this countdown period you may not cast spells and you may not move. This message will close automatically when the period ends.", 0xFFCC66 ), false, false );
|
||||
AddHtml( 60-1, 140, 250, 20, Color( String.Format( "Duel will begin in <BASEFONT COLOR=#{2:X6}>{0} <BASEFONT COLOR=#{2:X6}>second{1}.", count, count==1?"":"s", BlackColor32 ), BlackColor32 ), false, false );
|
||||
AddHtml( 60+1, 140, 250, 20, Color( String.Format( "Duel will begin in <BASEFONT COLOR=#{2:X6}>{0} <BASEFONT COLOR=#{2:X6}>second{1}.", count, count==1?"":"s", BlackColor32 ), BlackColor32 ), false, false );
|
||||
AddHtml( 60, 140-1, 250, 20, Color( String.Format( "Duel will begin in <BASEFONT COLOR=#{2:X6}>{0} <BASEFONT COLOR=#{2:X6}>second{1}.", count, count==1?"":"s", BlackColor32 ), BlackColor32 ), false, false );
|
||||
AddHtml( 60, 140+1, 250, 20, Color( String.Format( "Duel will begin in <BASEFONT COLOR=#{2:X6}>{0} <BASEFONT COLOR=#{2:X6}>second{1}.", count, count==1?"":"s", BlackColor32 ), BlackColor32 ), false, false );
|
||||
AddHtml( 60, 140, 250, 20, Color( String.Format( "Duel will begin in <BASEFONT COLOR=#FF6666>{0} <BASEFONT COLOR=#{2:X6}>second{1}.", count, count==1?"":"s", 0x66AACC ), 0x66AACC ), false, false );*/
|
||||
|
||||
/*AddImageTiled( 32, 128, 264, 1, 9107 );
|
||||
AddImageTiled( 42, 130, 264, 1, 9157 );
|
||||
AddButton(314 - 50, 157 - offset, 247, 248, 1, GumpButtonType.Reply, 0);
|
||||
}
|
||||
|
||||
AddHtml( 60-1, 140, 250, 20, Color( String.Format( "Duel will begin in <BASEFONT COLOR=#{2:X6}>{0} <BASEFONT COLOR=#{2:X6}>second{1}.", count, count==1?"":"s", BlackColor32 ), BlackColor32 ), false, false );
|
||||
AddHtml( 60+1, 140, 250, 20, Color( String.Format( "Duel will begin in <BASEFONT COLOR=#{2:X6}>{0} <BASEFONT COLOR=#{2:X6}>second{1}.", count, count==1?"":"s", BlackColor32 ), BlackColor32 ), false, false );
|
||||
AddHtml( 60, 140-1, 250, 20, Color( String.Format( "Duel will begin in <BASEFONT COLOR=#{2:X6}>{0} <BASEFONT COLOR=#{2:X6}>second{1}.", count, count==1?"":"s", BlackColor32 ), BlackColor32 ), false, false );
|
||||
AddHtml( 60, 140+1, 250, 20, Color( String.Format( "Duel will begin in <BASEFONT COLOR=#{2:X6}>{0} <BASEFONT COLOR=#{2:X6}>second{1}.", count, count==1?"":"s", BlackColor32 ), BlackColor32 ), false, false );
|
||||
AddHtml( 60, 140, 250, 20, Color( String.Format( "Duel will begin in <BASEFONT COLOR=#FF6666>{0} <BASEFONT COLOR=#{2:X6}>second{1}.", count, count==1?"":"s", 0x66AACC ), 0x66AACC ), false, false );*/
|
||||
public string Center(string text)
|
||||
{
|
||||
return $"<CENTER>{text}</CENTER>";
|
||||
}
|
||||
|
||||
AddButton( 314-50, 157-offset, 247, 248, 1, GumpButtonType.Reply, 0 );
|
||||
}
|
||||
}
|
||||
public string Color(string text, int color)
|
||||
{
|
||||
return $"<BASEFONT COLOR=#{color:X6}>{text}</BASEFONT>";
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2,93 +2,93 @@ using Server.Items;
|
|||
|
||||
namespace Server.Engines.ConPVP
|
||||
{
|
||||
public enum DuelTeleporterType
|
||||
{
|
||||
Squares = 6095,
|
||||
Buds = 6104,
|
||||
Flowers = 6113,
|
||||
Spikes = 6122,
|
||||
Arrows = 6140,
|
||||
Links = 6149
|
||||
}
|
||||
public enum DuelTeleporterType
|
||||
{
|
||||
Squares = 6095,
|
||||
Buds = 6104,
|
||||
Flowers = 6113,
|
||||
Spikes = 6122,
|
||||
Arrows = 6140,
|
||||
Links = 6149
|
||||
}
|
||||
|
||||
public class DuelTeleporterAddon : BaseAddon
|
||||
{
|
||||
[CommandProperty( AccessLevel.GameMaster )]
|
||||
public DuelTeleporterType Type
|
||||
{
|
||||
get
|
||||
{
|
||||
if ( Components.Count > 0 )
|
||||
return (DuelTeleporterType)(((Item)Components[0]).ItemID);
|
||||
public class DuelTeleporterAddon : BaseAddon
|
||||
{
|
||||
[Constructible]
|
||||
public DuelTeleporterAddon() : this(DuelTeleporterType.Squares)
|
||||
{
|
||||
}
|
||||
|
||||
return DuelTeleporterType.Squares;
|
||||
}
|
||||
set
|
||||
{
|
||||
for ( int i = 0; i < Components.Count && i < 9; ++i )
|
||||
((Item)Components[i]).ItemID = i + (int)value;
|
||||
}
|
||||
}
|
||||
[Constructible]
|
||||
public DuelTeleporterAddon(DuelTeleporterType type)
|
||||
{
|
||||
int itemID = (int)type;
|
||||
|
||||
[Constructible]
|
||||
public DuelTeleporterAddon() : this( DuelTeleporterType.Squares )
|
||||
{
|
||||
}
|
||||
AddComponent(new AddonComponent(itemID + 0), -1, -1, 5);
|
||||
AddComponent(new AddonComponent(itemID + 1), -1, 0, 5);
|
||||
AddComponent(new AddonComponent(itemID + 2), 0, -1, 5);
|
||||
AddComponent(new AddonComponent(itemID + 3), -1, +1, 5);
|
||||
AddComponent(new AddonComponent(itemID + 4), 0, 0, 5);
|
||||
AddComponent(new AddonComponent(itemID + 5), +1, -1, 5);
|
||||
AddComponent(new AddonComponent(itemID + 6), 0, +1, 5);
|
||||
AddComponent(new AddonComponent(itemID + 7), +1, 0, 5);
|
||||
AddComponent(new AddonComponent(itemID + 8), +1, +1, 5);
|
||||
|
||||
[Constructible]
|
||||
public DuelTeleporterAddon( DuelTeleporterType type )
|
||||
{
|
||||
int itemID = (int)type;
|
||||
AddComponent(new AddonComponent(0x759), -2, -2, 0);
|
||||
AddComponent(new AddonComponent(0x75A), +2, +2, 0);
|
||||
AddComponent(new AddonComponent(0x75B), -2, +2, 0);
|
||||
AddComponent(new AddonComponent(0x75C), +2, -2, 0);
|
||||
|
||||
AddComponent( new AddonComponent( itemID + 0 ), -1, -1, 5 );
|
||||
AddComponent( new AddonComponent( itemID + 1 ), -1, 0, 5 );
|
||||
AddComponent( new AddonComponent( itemID + 2 ), 0, -1, 5 );
|
||||
AddComponent( new AddonComponent( itemID + 3 ), -1, +1, 5 );
|
||||
AddComponent( new AddonComponent( itemID + 4 ), 0, 0, 5 );
|
||||
AddComponent( new AddonComponent( itemID + 5 ), +1, -1, 5 );
|
||||
AddComponent( new AddonComponent( itemID + 6 ), 0, +1, 5 );
|
||||
AddComponent( new AddonComponent( itemID + 7 ), +1, 0, 5 );
|
||||
AddComponent( new AddonComponent( itemID + 8 ), +1, +1, 5 );
|
||||
AddComponent(new AddonComponent(0x751), -1, +2, 0);
|
||||
AddComponent(new AddonComponent(0x751), 0, +2, 0);
|
||||
AddComponent(new AddonComponent(0x751), +1, +2, 0);
|
||||
|
||||
AddComponent( new AddonComponent( 0x759 ), -2, -2, 0 );
|
||||
AddComponent( new AddonComponent( 0x75A ), +2, +2, 0 );
|
||||
AddComponent( new AddonComponent( 0x75B ), -2, +2, 0 );
|
||||
AddComponent( new AddonComponent( 0x75C ), +2, -2, 0 );
|
||||
AddComponent(new AddonComponent(0x752), +2, -1, 0);
|
||||
AddComponent(new AddonComponent(0x752), +2, 0, 0);
|
||||
AddComponent(new AddonComponent(0x752), +2, +1, 0);
|
||||
|
||||
AddComponent( new AddonComponent( 0x751 ), -1, +2, 0 );
|
||||
AddComponent( new AddonComponent( 0x751 ), 0, +2, 0 );
|
||||
AddComponent( new AddonComponent( 0x751 ), +1, +2, 0 );
|
||||
AddComponent(new AddonComponent(0x753), -1, -2, 0);
|
||||
AddComponent(new AddonComponent(0x753), 0, -2, 0);
|
||||
AddComponent(new AddonComponent(0x753), +1, -2, 0);
|
||||
|
||||
AddComponent( new AddonComponent( 0x752 ), +2, -1, 0 );
|
||||
AddComponent( new AddonComponent( 0x752 ), +2, 0, 0 );
|
||||
AddComponent( new AddonComponent( 0x752 ), +2, +1, 0 );
|
||||
AddComponent(new AddonComponent(0x754), -2, -1, 0);
|
||||
AddComponent(new AddonComponent(0x754), -2, 0, 0);
|
||||
AddComponent(new AddonComponent(0x754), -2, +1, 0);
|
||||
}
|
||||
|
||||
AddComponent( new AddonComponent( 0x753 ), -1, -2, 0 );
|
||||
AddComponent( new AddonComponent( 0x753 ), 0, -2, 0 );
|
||||
AddComponent( new AddonComponent( 0x753 ), +1, -2, 0 );
|
||||
public DuelTeleporterAddon(Serial serial) : base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
AddComponent( new AddonComponent( 0x754 ), -2, -1, 0 );
|
||||
AddComponent( new AddonComponent( 0x754 ), -2, 0, 0 );
|
||||
AddComponent( new AddonComponent( 0x754 ), -2, +1, 0 );
|
||||
}
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public DuelTeleporterType Type
|
||||
{
|
||||
get
|
||||
{
|
||||
if (Components.Count > 0)
|
||||
return (DuelTeleporterType)Components[0].ItemID;
|
||||
|
||||
public DuelTeleporterAddon( Serial serial ) : base( serial )
|
||||
{
|
||||
}
|
||||
return DuelTeleporterType.Squares;
|
||||
}
|
||||
set
|
||||
{
|
||||
for (int i = 0; i < Components.Count && i < 9; ++i)
|
||||
Components[i].ItemID = i + (int)value;
|
||||
}
|
||||
}
|
||||
|
||||
public override void Serialize( GenericWriter writer )
|
||||
{
|
||||
base.Serialize( writer );
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write( (int) 0 ); // version
|
||||
}
|
||||
writer.Write(0); // version
|
||||
}
|
||||
|
||||
public override void Deserialize( GenericReader reader )
|
||||
{
|
||||
base.Deserialize( reader );
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
int version = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
int version = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
|
@ -1,77 +1,77 @@
|
|||
using Server.Gumps;
|
||||
using Server.Items;
|
||||
|
||||
namespace Server.Engines.ConPVP
|
||||
{
|
||||
public abstract class EventController : Item
|
||||
{
|
||||
public abstract EventGame Construct( DuelContext dc );
|
||||
public abstract class EventController : Item
|
||||
{
|
||||
public EventController()
|
||||
: base(0x1B7A)
|
||||
{
|
||||
Visible = false;
|
||||
Movable = false;
|
||||
}
|
||||
|
||||
public abstract string Title { get; }
|
||||
public EventController(Serial serial)
|
||||
: base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public abstract string GetTeamName( int teamID );
|
||||
public abstract string Title{ get; }
|
||||
public abstract EventGame Construct(DuelContext dc);
|
||||
|
||||
public EventController()
|
||||
: base( 0x1B7A )
|
||||
{
|
||||
Visible = false;
|
||||
Movable = false;
|
||||
}
|
||||
public abstract string GetTeamName(int teamID);
|
||||
|
||||
public EventController( Serial serial )
|
||||
: base( serial )
|
||||
{
|
||||
}
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
public override void Serialize( GenericWriter writer )
|
||||
{
|
||||
base.Serialize( writer );
|
||||
writer.Write(0);
|
||||
}
|
||||
|
||||
writer.Write( (int) 0 );
|
||||
}
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
public override void Deserialize( GenericReader reader )
|
||||
{
|
||||
base.Deserialize( reader );
|
||||
int version = reader.ReadInt();
|
||||
}
|
||||
|
||||
int version = reader.ReadInt();
|
||||
}
|
||||
public override void OnDoubleClick(Mobile from)
|
||||
{
|
||||
if (from.AccessLevel >= AccessLevel.GameMaster)
|
||||
from.SendGump(new PropertiesGump(from, this));
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnDoubleClick( Mobile from )
|
||||
{
|
||||
if ( from.AccessLevel >= AccessLevel.GameMaster )
|
||||
from.SendGump( new Gumps.PropertiesGump( from, this ) );
|
||||
}
|
||||
}
|
||||
public abstract class EventGame
|
||||
{
|
||||
protected DuelContext m_Context;
|
||||
|
||||
public abstract class EventGame
|
||||
{
|
||||
protected DuelContext m_Context;
|
||||
public EventGame(DuelContext context)
|
||||
{
|
||||
m_Context = context;
|
||||
}
|
||||
|
||||
public DuelContext Context => m_Context;
|
||||
public DuelContext Context => m_Context;
|
||||
|
||||
public virtual bool FreeConsume => true;
|
||||
public virtual bool FreeConsume => true;
|
||||
|
||||
public EventGame( DuelContext context )
|
||||
{
|
||||
m_Context = context;
|
||||
}
|
||||
public virtual bool OnDeath(Mobile mob, Container corpse)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public virtual bool OnDeath( Mobile mob, Container corpse )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
public virtual bool CantDoAnything(Mobile mob)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public virtual bool CantDoAnything( Mobile mob )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
public virtual void OnStart()
|
||||
{
|
||||
}
|
||||
|
||||
public virtual void OnStart()
|
||||
{
|
||||
}
|
||||
|
||||
public virtual void OnStop()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
public virtual void OnStop()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -3,366 +3,381 @@ using System.Collections;
|
|||
|
||||
namespace Server.Engines.ConPVP
|
||||
{
|
||||
public class LadderController : Item
|
||||
{
|
||||
private Ladder m_Ladder;
|
||||
|
||||
//[CommandProperty( AccessLevel.GameMaster )]
|
||||
public Ladder Ladder{ get => m_Ladder;
|
||||
set{} }
|
||||
|
||||
public override string DefaultName => "ladder controller";
|
||||
|
||||
[Constructible]
|
||||
public LadderController() : base( 0x1B7A )
|
||||
{
|
||||
Visible = false;
|
||||
Movable = false;
|
||||
|
||||
m_Ladder = new Ladder();
|
||||
|
||||
if ( Ladder.Instance == null )
|
||||
Ladder.Instance = m_Ladder;
|
||||
}
|
||||
|
||||
public override void Delete()
|
||||
{
|
||||
if ( Ladder.Instance == m_Ladder )
|
||||
Ladder.Instance = null;
|
||||
|
||||
base.Delete();
|
||||
}
|
||||
|
||||
public LadderController( Serial serial ) : base( serial )
|
||||
{
|
||||
}
|
||||
|
||||
public override void Serialize( GenericWriter writer )
|
||||
{
|
||||
base.Serialize( writer );
|
||||
|
||||
writer.Write( (int) 1 );
|
||||
|
||||
m_Ladder.Serialize( writer );
|
||||
|
||||
writer.Write( (bool) ( Ladder.Instance == m_Ladder ) );
|
||||
}
|
||||
|
||||
public override void Deserialize( GenericReader reader )
|
||||
{
|
||||
base.Deserialize( reader );
|
||||
|
||||
int version = reader.ReadInt();
|
||||
|
||||
switch ( version )
|
||||
{
|
||||
case 1:
|
||||
case 0:
|
||||
{
|
||||
m_Ladder = new Ladder( reader );
|
||||
|
||||
if ( version < 1 || reader.ReadBool() )
|
||||
Ladder.Instance = m_Ladder;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class Ladder
|
||||
{
|
||||
private static int[] m_ShortLevels = {
|
||||
1,
|
||||
2,
|
||||
3, 3,
|
||||
4, 4,
|
||||
5, 5, 5,
|
||||
6, 6, 6,
|
||||
7, 7, 7, 7,
|
||||
8, 8, 8, 8,
|
||||
9, 9, 9, 9, 9
|
||||
};
|
||||
|
||||
public static int GetLevel( int xp )
|
||||
{
|
||||
if ( xp >= 22500 )
|
||||
return 50;
|
||||
if ( xp >= 2500 )
|
||||
return (10 + ((xp - 2500) / 500));
|
||||
if ( xp < 0 )
|
||||
xp = 0;
|
||||
|
||||
return m_ShortLevels[xp / 100];
|
||||
}
|
||||
|
||||
private static int[] m_BaseXP = {
|
||||
0, 100, 200, 400, 600, 900, 1200, 1600, 2000, 2500
|
||||
};
|
||||
|
||||
public static void GetLevelInfo( int level, out int xpBase, out int xpAdvance )
|
||||
{
|
||||
if ( level >= 10 )
|
||||
{
|
||||
xpBase = 2500 + ((level-10)*500);
|
||||
xpAdvance = 500;
|
||||
}
|
||||
else
|
||||
{
|
||||
xpBase = m_BaseXP[level-1];
|
||||
xpAdvance = m_BaseXP[level] - xpBase;
|
||||
}
|
||||
}
|
||||
|
||||
private static int[] m_LossFactors = {
|
||||
10,
|
||||
11, 11,
|
||||
25, 25,
|
||||
43, 43,
|
||||
67, 67
|
||||
};
|
||||
|
||||
public static int GetLossFactor( int level )
|
||||
{
|
||||
if ( level >= 10 )
|
||||
return 100;
|
||||
|
||||
return m_LossFactors[level - 1];
|
||||
}
|
||||
|
||||
private static int[,] m_OffsetScalar = {
|
||||
/* { win, los } */
|
||||
/* -6 */ { 175, 25 },
|
||||
/* -5 */ { 165, 35 },
|
||||
/* -4 */ { 155, 45 },
|
||||
/* -3 */ { 145, 55 },
|
||||
/* -2 */ { 130, 70 },
|
||||
/* -1 */ { 115, 85 },
|
||||
/* 0 */ { 100, 100 },
|
||||
/* +1 */ { 90, 110 },
|
||||
/* +2 */ { 80, 120 },
|
||||
/* +3 */ { 70, 130 },
|
||||
/* +4 */ { 60, 140 },
|
||||
/* +5 */ { 50, 150 },
|
||||
/* +6 */ { 40, 160 }
|
||||
};
|
||||
|
||||
public static int GetOffsetScalar( int ourLevel, int theirLevel, bool win )
|
||||
{
|
||||
int x = ourLevel - theirLevel;
|
||||
|
||||
if ( x < -6 || x > +6 )
|
||||
return 0;
|
||||
|
||||
int y = win ? 0 : 1;
|
||||
|
||||
return m_OffsetScalar[x+6, y];
|
||||
}
|
||||
|
||||
public static int GetExperienceGain( LadderEntry us, LadderEntry them, bool weWon )
|
||||
{
|
||||
if ( us == null || them == null )
|
||||
return 0;
|
||||
|
||||
int ourLevel = GetLevel( us.Experience );
|
||||
int theirLevel = GetLevel( them.Experience );
|
||||
|
||||
int scalar = GetOffsetScalar( ourLevel, theirLevel, weWon );
|
||||
|
||||
if ( scalar == 0 )
|
||||
return 0;
|
||||
|
||||
int xp = 25 * scalar;
|
||||
|
||||
if ( !weWon )
|
||||
xp = (xp * GetLossFactor( ourLevel )) / 100;
|
||||
|
||||
xp /= 100;
|
||||
|
||||
if ( xp <= 0 )
|
||||
xp = 1;
|
||||
|
||||
return xp * (weWon ? 1 : -1);
|
||||
}
|
||||
|
||||
private Hashtable m_Table;
|
||||
private ArrayList m_Entries;
|
||||
|
||||
public ArrayList ToArrayList()
|
||||
{
|
||||
return m_Entries;
|
||||
}
|
||||
|
||||
private int Swap( int idx, int newIdx )
|
||||
{
|
||||
object hold = m_Entries[idx];
|
||||
|
||||
m_Entries[idx] = m_Entries[newIdx];
|
||||
m_Entries[newIdx] = hold;
|
||||
|
||||
((LadderEntry)m_Entries[idx]).Index = idx;
|
||||
((LadderEntry)m_Entries[newIdx]).Index = newIdx;
|
||||
|
||||
return newIdx;
|
||||
}
|
||||
|
||||
public void UpdateEntry( LadderEntry entry )
|
||||
{
|
||||
int index = entry.Index;
|
||||
|
||||
if ( index >= 0 && index < m_Entries.Count )
|
||||
{
|
||||
// sanity
|
||||
|
||||
int c;
|
||||
|
||||
while ( (index - 1) >= 0 && (c = entry.CompareTo( m_Entries[index - 1] )) < 0 )
|
||||
index = Swap( index, index - 1 );
|
||||
public class LadderController : Item
|
||||
{
|
||||
private Ladder m_Ladder;
|
||||
|
||||
[Constructible]
|
||||
public LadderController() : base(0x1B7A)
|
||||
{
|
||||
Visible = false;
|
||||
Movable = false;
|
||||
|
||||
m_Ladder = new Ladder();
|
||||
|
||||
if (Ladder.Instance == null)
|
||||
Ladder.Instance = m_Ladder;
|
||||
}
|
||||
|
||||
public LadderController(Serial serial) : base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
//[CommandProperty( AccessLevel.GameMaster )]
|
||||
public Ladder Ladder
|
||||
{
|
||||
get => m_Ladder;
|
||||
set { }
|
||||
}
|
||||
|
||||
public override string DefaultName => "ladder controller";
|
||||
|
||||
public override void Delete()
|
||||
{
|
||||
if (Ladder.Instance == m_Ladder)
|
||||
Ladder.Instance = null;
|
||||
|
||||
base.Delete();
|
||||
}
|
||||
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write(1);
|
||||
|
||||
m_Ladder.Serialize(writer);
|
||||
|
||||
writer.Write(Ladder.Instance == m_Ladder);
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
int version = reader.ReadInt();
|
||||
|
||||
switch (version)
|
||||
{
|
||||
case 1:
|
||||
case 0:
|
||||
{
|
||||
m_Ladder = new Ladder(reader);
|
||||
|
||||
if (version < 1 || reader.ReadBool())
|
||||
Ladder.Instance = m_Ladder;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class Ladder
|
||||
{
|
||||
private static int[] m_ShortLevels =
|
||||
{
|
||||
1,
|
||||
2,
|
||||
3, 3,
|
||||
4, 4,
|
||||
5, 5, 5,
|
||||
6, 6, 6,
|
||||
7, 7, 7, 7,
|
||||
8, 8, 8, 8,
|
||||
9, 9, 9, 9, 9
|
||||
};
|
||||
|
||||
private static int[] m_BaseXP =
|
||||
{
|
||||
0, 100, 200, 400, 600, 900, 1200, 1600, 2000, 2500
|
||||
};
|
||||
|
||||
private static int[] m_LossFactors =
|
||||
{
|
||||
10,
|
||||
11, 11,
|
||||
25, 25,
|
||||
43, 43,
|
||||
67, 67
|
||||
};
|
||||
|
||||
private static int[,] m_OffsetScalar =
|
||||
{
|
||||
/* { win, los } */
|
||||
/* -6 */ { 175, 25 },
|
||||
/* -5 */ { 165, 35 },
|
||||
/* -4 */ { 155, 45 },
|
||||
/* -3 */ { 145, 55 },
|
||||
/* -2 */ { 130, 70 },
|
||||
/* -1 */ { 115, 85 },
|
||||
/* 0 */ { 100, 100 },
|
||||
/* +1 */ { 90, 110 },
|
||||
/* +2 */ { 80, 120 },
|
||||
/* +3 */ { 70, 130 },
|
||||
/* +4 */ { 60, 140 },
|
||||
/* +5 */ { 50, 150 },
|
||||
/* +6 */ { 40, 160 }
|
||||
};
|
||||
|
||||
private ArrayList m_Entries;
|
||||
|
||||
private Hashtable m_Table;
|
||||
|
||||
public Ladder()
|
||||
{
|
||||
m_Table = new Hashtable();
|
||||
m_Entries = new ArrayList();
|
||||
}
|
||||
|
||||
public Ladder(GenericReader reader)
|
||||
{
|
||||
int version = reader.ReadEncodedInt();
|
||||
|
||||
switch (version)
|
||||
{
|
||||
case 1:
|
||||
case 0:
|
||||
{
|
||||
int count = reader.ReadEncodedInt();
|
||||
|
||||
m_Table = new Hashtable(count);
|
||||
m_Entries = new ArrayList(count);
|
||||
|
||||
for (int i = 0; i < count; ++i)
|
||||
{
|
||||
LadderEntry entry = new LadderEntry(reader, this, version);
|
||||
|
||||
if (entry.Mobile != null)
|
||||
{
|
||||
m_Table[entry.Mobile] = entry;
|
||||
entry.Index = m_Entries.Count;
|
||||
m_Entries.Add(entry);
|
||||
}
|
||||
}
|
||||
|
||||
if (version == 0)
|
||||
{
|
||||
m_Entries.Sort();
|
||||
|
||||
for (int i = 0; i < m_Entries.Count; ++i)
|
||||
{
|
||||
LadderEntry entry = (LadderEntry)m_Entries[i];
|
||||
|
||||
entry.Index = i;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static Ladder Instance{ get; set; }
|
||||
|
||||
public static int GetLevel(int xp)
|
||||
{
|
||||
if (xp >= 22500)
|
||||
return 50;
|
||||
if (xp >= 2500)
|
||||
return 10 + (xp - 2500) / 500;
|
||||
if (xp < 0)
|
||||
xp = 0;
|
||||
|
||||
return m_ShortLevels[xp / 100];
|
||||
}
|
||||
|
||||
public static void GetLevelInfo(int level, out int xpBase, out int xpAdvance)
|
||||
{
|
||||
if (level >= 10)
|
||||
{
|
||||
xpBase = 2500 + (level - 10) * 500;
|
||||
xpAdvance = 500;
|
||||
}
|
||||
else
|
||||
{
|
||||
xpBase = m_BaseXP[level - 1];
|
||||
xpAdvance = m_BaseXP[level] - xpBase;
|
||||
}
|
||||
}
|
||||
|
||||
public static int GetLossFactor(int level)
|
||||
{
|
||||
if (level >= 10)
|
||||
return 100;
|
||||
|
||||
return m_LossFactors[level - 1];
|
||||
}
|
||||
|
||||
public static int GetOffsetScalar(int ourLevel, int theirLevel, bool win)
|
||||
{
|
||||
int x = ourLevel - theirLevel;
|
||||
|
||||
if (x < -6 || x > +6)
|
||||
return 0;
|
||||
|
||||
int y = win ? 0 : 1;
|
||||
|
||||
while ( (index + 1) < m_Entries.Count && (c = entry.CompareTo( m_Entries[index + 1] )) > 0 )
|
||||
index = Swap( index, index + 1 );
|
||||
}
|
||||
}
|
||||
return m_OffsetScalar[x + 6, y];
|
||||
}
|
||||
|
||||
public static int GetExperienceGain(LadderEntry us, LadderEntry them, bool weWon)
|
||||
{
|
||||
if (us == null || them == null)
|
||||
return 0;
|
||||
|
||||
int ourLevel = GetLevel(us.Experience);
|
||||
int theirLevel = GetLevel(them.Experience);
|
||||
|
||||
int scalar = GetOffsetScalar(ourLevel, theirLevel, weWon);
|
||||
|
||||
if (scalar == 0)
|
||||
return 0;
|
||||
|
||||
int xp = 25 * scalar;
|
||||
|
||||
if (!weWon)
|
||||
xp = xp * GetLossFactor(ourLevel) / 100;
|
||||
|
||||
xp /= 100;
|
||||
|
||||
if (xp <= 0)
|
||||
xp = 1;
|
||||
|
||||
return xp * (weWon ? 1 : -1);
|
||||
}
|
||||
|
||||
public ArrayList ToArrayList()
|
||||
{
|
||||
return m_Entries;
|
||||
}
|
||||
|
||||
private int Swap(int idx, int newIdx)
|
||||
{
|
||||
object hold = m_Entries[idx];
|
||||
|
||||
m_Entries[idx] = m_Entries[newIdx];
|
||||
m_Entries[newIdx] = hold;
|
||||
|
||||
((LadderEntry)m_Entries[idx]).Index = idx;
|
||||
((LadderEntry)m_Entries[newIdx]).Index = newIdx;
|
||||
|
||||
return newIdx;
|
||||
}
|
||||
|
||||
public void UpdateEntry(LadderEntry entry)
|
||||
{
|
||||
int index = entry.Index;
|
||||
|
||||
if (index >= 0 && index < m_Entries.Count)
|
||||
{
|
||||
// sanity
|
||||
|
||||
int c;
|
||||
|
||||
while (index - 1 >= 0 && (c = entry.CompareTo(m_Entries[index - 1])) < 0)
|
||||
index = Swap(index, index - 1);
|
||||
|
||||
while (index + 1 < m_Entries.Count && (c = entry.CompareTo(m_Entries[index + 1])) > 0)
|
||||
index = Swap(index, index + 1);
|
||||
}
|
||||
}
|
||||
|
||||
public LadderEntry Find(Mobile mob)
|
||||
{
|
||||
LadderEntry entry = (LadderEntry)m_Table[mob];
|
||||
|
||||
if (entry == null)
|
||||
{
|
||||
m_Table[mob] = entry = new LadderEntry(mob, this);
|
||||
entry.Index = m_Entries.Count;
|
||||
m_Entries.Add(entry);
|
||||
}
|
||||
|
||||
return entry;
|
||||
}
|
||||
|
||||
public LadderEntry FindNoCreate(Mobile mob)
|
||||
{
|
||||
return m_Table[mob] as LadderEntry;
|
||||
}
|
||||
|
||||
public LadderEntry Find( Mobile mob )
|
||||
{
|
||||
LadderEntry entry = (LadderEntry) m_Table[mob];
|
||||
public void Serialize(GenericWriter writer)
|
||||
{
|
||||
writer.WriteEncodedInt(1); // version;
|
||||
|
||||
if ( entry == null )
|
||||
{
|
||||
m_Table[mob] = entry = new LadderEntry( mob, this );
|
||||
entry.Index = m_Entries.Count;
|
||||
m_Entries.Add( entry );
|
||||
}
|
||||
writer.WriteEncodedInt(m_Entries.Count);
|
||||
|
||||
return entry;
|
||||
}
|
||||
for (int i = 0; i < m_Entries.Count; ++i)
|
||||
((LadderEntry)m_Entries[i]).Serialize(writer);
|
||||
}
|
||||
}
|
||||
|
||||
public LadderEntry FindNoCreate( Mobile mob )
|
||||
{
|
||||
return m_Table[mob] as LadderEntry;
|
||||
}
|
||||
public class LadderEntry : IComparable
|
||||
{
|
||||
private int m_Experience;
|
||||
private Ladder m_Ladder;
|
||||
|
||||
public static Ladder Instance { get; set; }
|
||||
|
||||
public Ladder()
|
||||
{
|
||||
m_Table = new Hashtable();
|
||||
m_Entries = new ArrayList();
|
||||
}
|
||||
|
||||
public Ladder( GenericReader reader )
|
||||
{
|
||||
int version = reader.ReadEncodedInt();
|
||||
|
||||
switch ( version )
|
||||
{
|
||||
case 1:
|
||||
case 0:
|
||||
{
|
||||
int count = reader.ReadEncodedInt();
|
||||
|
||||
m_Table = new Hashtable( count );
|
||||
m_Entries = new ArrayList( count );
|
||||
|
||||
for ( int i = 0; i < count; ++i )
|
||||
{
|
||||
LadderEntry entry = new LadderEntry( reader, this, version );
|
||||
|
||||
if ( entry.Mobile != null )
|
||||
{
|
||||
m_Table[entry.Mobile] = entry;
|
||||
entry.Index = m_Entries.Count;
|
||||
m_Entries.Add( entry );
|
||||
}
|
||||
}
|
||||
|
||||
if ( version == 0 )
|
||||
{
|
||||
m_Entries.Sort();
|
||||
|
||||
for ( int i = 0; i < m_Entries.Count; ++i )
|
||||
{
|
||||
LadderEntry entry = (LadderEntry)m_Entries[i];
|
||||
|
||||
entry.Index = i;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Serialize( GenericWriter writer )
|
||||
{
|
||||
writer.WriteEncodedInt( (int) 1 ); // version;
|
||||
|
||||
writer.WriteEncodedInt( (int) m_Entries.Count );
|
||||
|
||||
for ( int i = 0; i < m_Entries.Count; ++i )
|
||||
((LadderEntry)m_Entries[i]).Serialize( writer );
|
||||
}
|
||||
}
|
||||
|
||||
public class LadderEntry : IComparable
|
||||
{
|
||||
private int m_Experience;
|
||||
private Ladder m_Ladder;
|
||||
|
||||
public Mobile Mobile { get; }
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster, AccessLevel.Administrator )]
|
||||
public int Experience{ get => m_Experience;
|
||||
set{ m_Experience = value; m_Ladder.UpdateEntry(this); } }
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster, AccessLevel.Administrator )]
|
||||
public int Wins { get; set; }
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster, AccessLevel.Administrator )]
|
||||
public int Losses { get; set; }
|
||||
|
||||
public int Index { get; set; }
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster )]
|
||||
public int Rank => Index;
|
||||
|
||||
public LadderEntry( Mobile mob, Ladder ladder )
|
||||
{
|
||||
m_Ladder = ladder;
|
||||
Mobile = mob;
|
||||
}
|
||||
|
||||
public LadderEntry( GenericReader reader, Ladder ladder, int version )
|
||||
{
|
||||
m_Ladder = ladder;
|
||||
|
||||
switch ( version )
|
||||
{
|
||||
case 1:
|
||||
case 0:
|
||||
{
|
||||
Mobile = reader.ReadMobile();
|
||||
m_Experience = reader.ReadEncodedInt();
|
||||
Wins = reader.ReadEncodedInt();
|
||||
Losses = reader.ReadEncodedInt();
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Serialize( GenericWriter writer )
|
||||
{
|
||||
writer.Write( (Mobile) Mobile );
|
||||
writer.WriteEncodedInt( (int) m_Experience );
|
||||
writer.WriteEncodedInt( (int) Wins );
|
||||
writer.WriteEncodedInt( (int) Losses );
|
||||
}
|
||||
|
||||
public int CompareTo( object obj )
|
||||
{
|
||||
return ((LadderEntry)obj).m_Experience - m_Experience;
|
||||
}
|
||||
}
|
||||
public LadderEntry(Mobile mob, Ladder ladder)
|
||||
{
|
||||
m_Ladder = ladder;
|
||||
Mobile = mob;
|
||||
}
|
||||
|
||||
public LadderEntry(GenericReader reader, Ladder ladder, int version)
|
||||
{
|
||||
m_Ladder = ladder;
|
||||
|
||||
switch (version)
|
||||
{
|
||||
case 1:
|
||||
case 0:
|
||||
{
|
||||
Mobile = reader.ReadMobile();
|
||||
m_Experience = reader.ReadEncodedInt();
|
||||
Wins = reader.ReadEncodedInt();
|
||||
Losses = reader.ReadEncodedInt();
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Mobile Mobile{ get; }
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster, AccessLevel.Administrator)]
|
||||
public int Experience
|
||||
{
|
||||
get => m_Experience;
|
||||
set
|
||||
{
|
||||
m_Experience = value;
|
||||
m_Ladder.UpdateEntry(this);
|
||||
}
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster, AccessLevel.Administrator)]
|
||||
public int Wins{ get; set; }
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster, AccessLevel.Administrator)]
|
||||
public int Losses{ get; set; }
|
||||
|
||||
public int Index{ get; set; }
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public int Rank => Index;
|
||||
|
||||
public int CompareTo(object obj)
|
||||
{
|
||||
return ((LadderEntry)obj).m_Experience - m_Experience;
|
||||
}
|
||||
|
||||
public void Serialize(GenericWriter writer)
|
||||
{
|
||||
writer.Write(Mobile);
|
||||
writer.WriteEncodedInt(m_Experience);
|
||||
writer.WriteEncodedInt(Wins);
|
||||
writer.WriteEncodedInt(Losses);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -5,250 +5,253 @@ using Server.Network;
|
|||
|
||||
namespace Server.Engines.ConPVP
|
||||
{
|
||||
public class LadderItem : Item
|
||||
{
|
||||
[CommandProperty( AccessLevel.GameMaster )]
|
||||
public LadderController Ladder { get; set; }
|
||||
public class LadderItem : Item
|
||||
{
|
||||
[Constructible]
|
||||
public LadderItem() : base(0x117F)
|
||||
{
|
||||
Movable = false;
|
||||
}
|
||||
|
||||
public override string DefaultName => "1v1 leaderboard";
|
||||
public LadderItem(Serial serial) : base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
[Constructible]
|
||||
public LadderItem() : base( 0x117F )
|
||||
{
|
||||
Movable = false;
|
||||
}
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public LadderController Ladder{ get; set; }
|
||||
|
||||
public LadderItem( Serial serial ) : base( serial )
|
||||
{
|
||||
}
|
||||
public override string DefaultName => "1v1 leaderboard";
|
||||
|
||||
public override void Serialize( GenericWriter writer )
|
||||
{
|
||||
base.Serialize( writer );
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write( (int) 1 );
|
||||
writer.Write(1);
|
||||
|
||||
writer.Write( (Item) Ladder );
|
||||
}
|
||||
writer.Write(Ladder);
|
||||
}
|
||||
|
||||
public override void Deserialize( GenericReader reader )
|
||||
{
|
||||
base.Deserialize( reader );
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
int version = reader.ReadInt();
|
||||
int version = reader.ReadInt();
|
||||
|
||||
switch ( version )
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
Ladder = reader.ReadItem() as LadderController;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
switch (version)
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
Ladder = reader.ReadItem() as LadderController;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnDoubleClick( Mobile from )
|
||||
{
|
||||
if ( from.InRange( GetWorldLocation(), 2 ) )
|
||||
{
|
||||
Ladder ladder = Server.Engines.ConPVP.Ladder.Instance;
|
||||
public override void OnDoubleClick(Mobile from)
|
||||
{
|
||||
if (from.InRange(GetWorldLocation(), 2))
|
||||
{
|
||||
Ladder ladder = ConPVP.Ladder.Instance;
|
||||
|
||||
if ( Ladder != null )
|
||||
ladder = Ladder.Ladder;
|
||||
if (Ladder != null)
|
||||
ladder = Ladder.Ladder;
|
||||
|
||||
if ( ladder != null )
|
||||
{
|
||||
from.CloseGump( typeof( LadderGump ) );
|
||||
from.SendGump( new LadderGump( ladder, 0 ) );
|
||||
}
|
||||
}
|
||||
else
|
||||
from.LocalOverheadMessage( MessageType.Regular, 0x3B2, 1019045 ); // I can't reach that
|
||||
}
|
||||
}
|
||||
if (ladder != null)
|
||||
{
|
||||
from.CloseGump(typeof(LadderGump));
|
||||
from.SendGump(new LadderGump(ladder, 0));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1019045); // I can't reach that
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class LadderGump : Gump
|
||||
{
|
||||
private Ladder m_Ladder;
|
||||
private int m_Page;
|
||||
public class LadderGump : Gump
|
||||
{
|
||||
private int m_ColumnX = 12;
|
||||
private Ladder m_Ladder;
|
||||
|
||||
public LadderGump( Ladder ladder ) : this( ladder, 0 )
|
||||
{
|
||||
}
|
||||
private ArrayList m_List;
|
||||
private int m_Page;
|
||||
|
||||
public static string Rank( int num )
|
||||
{
|
||||
string numStr = num.ToString( "N0" );
|
||||
public LadderGump(Ladder ladder) : this(ladder, 0)
|
||||
{
|
||||
}
|
||||
|
||||
if ( (num%100) > 10 && (num%100) < 20 )
|
||||
return numStr + "th";
|
||||
public LadderGump(Ladder ladder, int page) : base(50, 50)
|
||||
{
|
||||
m_Ladder = ladder;
|
||||
m_Page = page;
|
||||
|
||||
switch ( num % 10 )
|
||||
{
|
||||
case 1: return numStr + "st";
|
||||
case 2: return numStr + "nd";
|
||||
case 3: return numStr + "rd";
|
||||
default: return numStr + "th";
|
||||
}
|
||||
}
|
||||
AddPage(0);
|
||||
|
||||
public override void OnResponse(NetState sender, RelayInfo info)
|
||||
{
|
||||
Mobile from = sender.Mobile;
|
||||
ArrayList list = ladder.ToArrayList();
|
||||
m_List = list;
|
||||
|
||||
if ( info.ButtonID == 1 && m_Page > 0 )
|
||||
from.SendGump( new LadderGump( m_Ladder, m_Page - 1 ) );
|
||||
else if ( info.ButtonID == 2 && ((m_Page+1)*15)<Math.Min(m_List.Count,150) )
|
||||
from.SendGump( new LadderGump( m_Ladder, m_Page + 1 ) );
|
||||
}
|
||||
int lc = Math.Min(list.Count, 150);
|
||||
|
||||
private ArrayList m_List;
|
||||
int start = page * 15;
|
||||
int end = start + 15;
|
||||
|
||||
public LadderGump( Ladder ladder, int page ) : base( 50, 50 )
|
||||
{
|
||||
m_Ladder = ladder;
|
||||
m_Page = page;
|
||||
if (end > lc)
|
||||
end = lc;
|
||||
|
||||
AddPage( 0 );
|
||||
int ct = end - start;
|
||||
|
||||
ArrayList list = ladder.ToArrayList();
|
||||
m_List = list;
|
||||
int height = 12 + 20 + ct * 20 + 23 + 12;
|
||||
|
||||
int lc = Math.Min( list.Count, 150 );
|
||||
AddBackground(0, 0, 499, height, 0x2436);
|
||||
|
||||
int start = page * 15;
|
||||
int end = start+15;
|
||||
for (int i = start + 1; i < end; i += 2)
|
||||
AddImageTiled(12, 32 + (i - start) * 20, 475, 20, 0x2430);
|
||||
|
||||
if ( end > lc )
|
||||
end = lc;
|
||||
AddAlphaRegion(10, 10, 479, height - 20);
|
||||
|
||||
int ct = end-start;
|
||||
if (page > 0)
|
||||
AddButton(446, height - 12 - 2 - 16, 0x15E3, 0x15E7, 1, GumpButtonType.Reply, 0);
|
||||
else
|
||||
AddImage(446, height - 12 - 2 - 16, 0x2626);
|
||||
|
||||
int height = 12 + 20 + (ct*20) + 23 + 12;
|
||||
if ((page + 1) * 15 < lc)
|
||||
AddButton(466, height - 12 - 2 - 16, 0x15E1, 0x15E5, 2, GumpButtonType.Reply, 0);
|
||||
else
|
||||
AddImage(466, height - 12 - 2 - 16, 0x2622);
|
||||
|
||||
AddBackground( 0, 0, 499, height, 0x2436 );
|
||||
AddHtml(16, height - 12 - 2 - 18, 400, 20,
|
||||
Color(string.Format("Top {3} of {0:N0} duelists, page {1} of {2}", list.Count, page + 1, (lc + 14) / 15, lc),
|
||||
0xFFC000), false, false);
|
||||
|
||||
for ( int i = start + 1; i < end; i += 2 )
|
||||
AddImageTiled( 12, 32 + ((i - start) * 20), 475, 20, 0x2430 );
|
||||
AddColumnHeader(75, "Rank");
|
||||
AddColumnHeader(115, "Level");
|
||||
AddColumnHeader(50, "Guild");
|
||||
AddColumnHeader(115, "Name");
|
||||
AddColumnHeader(60, "Wins");
|
||||
AddColumnHeader(60, "Losses");
|
||||
|
||||
AddAlphaRegion( 10, 10, 479, height - 20 );
|
||||
for (int i = start; i < end && i < lc; ++i)
|
||||
{
|
||||
LadderEntry entry = (LadderEntry)list[i];
|
||||
|
||||
if ( page > 0 )
|
||||
AddButton( 446, height-12-2-16, 0x15E3, 0x15E7, 1, GumpButtonType.Reply, 0 );
|
||||
else
|
||||
AddImage( 446, height-12-2-16, 0x2626 );
|
||||
int y = 32 + (i - start) * 20;
|
||||
int x = 12;
|
||||
|
||||
if ( ((page+1)*15)<lc )
|
||||
AddButton( 466, height-12-2-16, 0x15E1, 0x15E5, 2, GumpButtonType.Reply, 0 );
|
||||
else
|
||||
AddImage( 466, height-12-2-16, 0x2622 );
|
||||
AddBorderedText(x, y, 75, Center(Rank(i + 1)), 0xFFFFFF, 0);
|
||||
x += 75;
|
||||
|
||||
AddHtml( 16, height-12-2-18, 400, 20, Color( string.Format( "Top {3} of {0:N0} duelists, page {1} of {2}", list.Count, page+1, (lc+14)/15, lc ), 0xFFC000 ), false, false );
|
||||
/*AddImage( 20, y + 5, 0x2616, 0x96C );
|
||||
AddImage( 22, y + 5, 0x2616, 0x96C );
|
||||
AddImage( 20, y + 7, 0x2616, 0x96C );
|
||||
AddImage( 22, y + 7, 0x2616, 0x96C );
|
||||
|
||||
AddColumnHeader( 75, "Rank" );
|
||||
AddColumnHeader( 115, "Level" );
|
||||
AddColumnHeader( 50, "Guild" );
|
||||
AddColumnHeader( 115, "Name" );
|
||||
AddColumnHeader( 60, "Wins" );
|
||||
AddColumnHeader( 60, "Losses" );
|
||||
AddImage( 21, y + 6, 0x2616, 0x454 );*/
|
||||
|
||||
for ( int i = start; i < end && i < lc; ++i )
|
||||
{
|
||||
LadderEntry entry = (LadderEntry)list[i];
|
||||
AddImage(x + 3, y + 4, 0x805);
|
||||
|
||||
int y = 32 + ((i - start) * 20);
|
||||
int x = 12;
|
||||
int xp = entry.Experience;
|
||||
int level = Ladder.GetLevel(xp);
|
||||
|
||||
AddBorderedText( x, y, 75, Center( Rank( i+1 ) ), 0xFFFFFF, 0 );
|
||||
x += 75;
|
||||
int xpBase, xpAdvance;
|
||||
Ladder.GetLevelInfo(level, out xpBase, out xpAdvance);
|
||||
|
||||
/*AddImage( 20, y + 5, 0x2616, 0x96C );
|
||||
AddImage( 22, y + 5, 0x2616, 0x96C );
|
||||
AddImage( 20, y + 7, 0x2616, 0x96C );
|
||||
AddImage( 22, y + 7, 0x2616, 0x96C );
|
||||
int width;
|
||||
|
||||
AddImage( 21, y + 6, 0x2616, 0x454 );*/
|
||||
int xpOffset = xp - xpBase;
|
||||
|
||||
AddImage( x + 3, y + 4, 0x805 );
|
||||
if (xpOffset >= xpAdvance)
|
||||
width = 109; // level 50
|
||||
else
|
||||
width = (109 * xpOffset + xpAdvance / 2) / (xpAdvance - 1);
|
||||
|
||||
int xp = entry.Experience;
|
||||
int level = Ladder.GetLevel( xp );
|
||||
//AddImageTiled( 21, y + 6, width, 8, 0x2617 );
|
||||
AddImageTiled(x + 3, y + 4, width, 11, 0x806);
|
||||
AddBorderedText(x, y, 115, Center(level.ToString()), 0xFFFFFF, 0);
|
||||
x += 115;
|
||||
|
||||
int xpBase, xpAdvance;
|
||||
Ladder.GetLevelInfo( level, out xpBase, out xpAdvance );
|
||||
Mobile mob = entry.Mobile;
|
||||
|
||||
int width;
|
||||
if (mob.Guild != null)
|
||||
AddBorderedText(x, y, 50, Center(mob.Guild.Abbreviation), 0xFFFFFF, 0);
|
||||
|
||||
int xpOffset = xp - xpBase;
|
||||
x += 50;
|
||||
|
||||
if ( xpOffset >= xpAdvance )
|
||||
width = 109; // level 50
|
||||
else
|
||||
width = ((109 * xpOffset) + (xpAdvance / 2)) / (xpAdvance - 1);
|
||||
AddBorderedText(x + 5, y, 115 - 5, mob.Name, 0xFFFFFF, 0);
|
||||
x += 115;
|
||||
|
||||
//AddImageTiled( 21, y + 6, width, 8, 0x2617 );
|
||||
AddImageTiled( x + 3, y + 4, width, 11, 0x806 );
|
||||
AddBorderedText( x, y, 115, Center( level.ToString() ), 0xFFFFFF, 0 );
|
||||
x += 115;
|
||||
AddBorderedText(x, y, 60, Center(entry.Wins.ToString()), 0xFFFFFF, 0);
|
||||
x += 60;
|
||||
|
||||
Mobile mob = entry.Mobile;
|
||||
AddBorderedText(x, y, 60, Center(entry.Losses.ToString()), 0xFFFFFF, 0);
|
||||
x += 60;
|
||||
|
||||
if ( mob.Guild != null )
|
||||
AddBorderedText( x, y, 50, Center( mob.Guild.Abbreviation ), 0xFFFFFF, 0 );
|
||||
//AddBorderedText( 292 + 15, y, 115 - 30, String.Format( "{0} <DIV ALIGN=CENTER>/</DIV> <DIV ALIGN=RIGHT>{1}</DIV>", entry.Wins, entry.Losses ), 0xFFC000, 0 );
|
||||
}
|
||||
}
|
||||
|
||||
x += 50;
|
||||
public static string Rank(int num)
|
||||
{
|
||||
string numStr = num.ToString("N0");
|
||||
|
||||
AddBorderedText( x + 5, y, 115 - 5, ( mob.Name ), 0xFFFFFF, 0 );
|
||||
x += 115;
|
||||
if (num % 100 > 10 && num % 100 < 20)
|
||||
return numStr + "th";
|
||||
|
||||
AddBorderedText( x, y, 60, Center( entry.Wins.ToString() ), 0xFFFFFF, 0 );
|
||||
x += 60;
|
||||
switch (num % 10)
|
||||
{
|
||||
case 1: return numStr + "st";
|
||||
case 2: return numStr + "nd";
|
||||
case 3: return numStr + "rd";
|
||||
default: return numStr + "th";
|
||||
}
|
||||
}
|
||||
|
||||
AddBorderedText( x, y, 60, Center( entry.Losses.ToString() ), 0xFFFFFF, 0 );
|
||||
x += 60;
|
||||
public override void OnResponse(NetState sender, RelayInfo info)
|
||||
{
|
||||
Mobile from = sender.Mobile;
|
||||
|
||||
//AddBorderedText( 292 + 15, y, 115 - 30, String.Format( "{0} <DIV ALIGN=CENTER>/</DIV> <DIV ALIGN=RIGHT>{1}</DIV>", entry.Wins, entry.Losses ), 0xFFC000, 0 );
|
||||
}
|
||||
}
|
||||
if (info.ButtonID == 1 && m_Page > 0)
|
||||
from.SendGump(new LadderGump(m_Ladder, m_Page - 1));
|
||||
else if (info.ButtonID == 2 && (m_Page + 1) * 15 < Math.Min(m_List.Count, 150))
|
||||
from.SendGump(new LadderGump(m_Ladder, m_Page + 1));
|
||||
}
|
||||
|
||||
public string Center( string text )
|
||||
{
|
||||
return $"<CENTER>{text}</CENTER>";
|
||||
}
|
||||
public string Center(string text)
|
||||
{
|
||||
return $"<CENTER>{text}</CENTER>";
|
||||
}
|
||||
|
||||
public string Color( string text, int color )
|
||||
{
|
||||
return $"<BASEFONT COLOR=#{color:X6}>{text}</BASEFONT>";
|
||||
}
|
||||
public string Color(string text, int color)
|
||||
{
|
||||
return $"<BASEFONT COLOR=#{color:X6}>{text}</BASEFONT>";
|
||||
}
|
||||
|
||||
private void AddBorderedText( int x, int y, int width, string text, int color, int borderColor )
|
||||
{
|
||||
/*AddColoredText( x - 1, y, width, text, borderColor );
|
||||
AddColoredText( x + 1, y, width, text, borderColor );
|
||||
AddColoredText( x, y - 1, width, text, borderColor );
|
||||
AddColoredText( x, y + 1, width, text, borderColor );*/
|
||||
/*AddColoredText( x - 1, y - 1, width, text, borderColor );
|
||||
AddColoredText( x + 1, y + 1, width, text, borderColor );*/
|
||||
AddColoredText( x, y, width, text, color );
|
||||
}
|
||||
private void AddBorderedText(int x, int y, int width, string text, int color, int borderColor)
|
||||
{
|
||||
/*AddColoredText( x - 1, y, width, text, borderColor );
|
||||
AddColoredText( x + 1, y, width, text, borderColor );
|
||||
AddColoredText( x, y - 1, width, text, borderColor );
|
||||
AddColoredText( x, y + 1, width, text, borderColor );*/
|
||||
/*AddColoredText( x - 1, y - 1, width, text, borderColor );
|
||||
AddColoredText( x + 1, y + 1, width, text, borderColor );*/
|
||||
AddColoredText(x, y, width, text, color);
|
||||
}
|
||||
|
||||
private void AddColoredText( int x, int y, int width, string text, int color )
|
||||
{
|
||||
if ( color == 0 )
|
||||
AddHtml( x, y, width, 20, text, false, false );
|
||||
else
|
||||
AddHtml( x, y, width, 20, Color( text, color ), false, false );
|
||||
}
|
||||
private void AddColoredText(int x, int y, int width, string text, int color)
|
||||
{
|
||||
if (color == 0)
|
||||
AddHtml(x, y, width, 20, text, false, false);
|
||||
else
|
||||
AddHtml(x, y, width, 20, Color(text, color), false, false);
|
||||
}
|
||||
|
||||
private int m_ColumnX = 12;
|
||||
private void AddColumnHeader(int width, string name)
|
||||
{
|
||||
AddBackground(m_ColumnX, 12, width, 20, 0x242C);
|
||||
AddImageTiled(m_ColumnX + 2, 14, width - 4, 16, 0x2430);
|
||||
AddBorderedText(m_ColumnX, 13, width, Center(name), 0xFFFFFF, 0);
|
||||
|
||||
private void AddColumnHeader( int width, string name )
|
||||
{
|
||||
AddBackground( m_ColumnX, 12, width, 20, 0x242C );
|
||||
AddImageTiled( m_ColumnX + 2, 14, width - 4, 16, 0x2430 );
|
||||
AddBorderedText( m_ColumnX, 13, width, Center( name ), 0xFFFFFF, 0 );
|
||||
|
||||
m_ColumnX += width;
|
||||
}
|
||||
}
|
||||
m_ColumnX += width;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,230 +1,231 @@
|
|||
using System;
|
||||
using System.Text;
|
||||
using Server.Mobiles;
|
||||
using Server.Network;
|
||||
|
||||
namespace Server.Engines.ConPVP
|
||||
{
|
||||
public class Participant
|
||||
{
|
||||
public int Count => Players.Length;
|
||||
public DuelPlayer[] Players { get; private set; }
|
||||
public class Participant
|
||||
{
|
||||
public Participant(DuelContext context, int count)
|
||||
{
|
||||
Context = context;
|
||||
//m_Stakes = new StakesContainer( context, this );
|
||||
Resize(count);
|
||||
}
|
||||
|
||||
public DuelContext Context { get; }
|
||||
public int Count => Players.Length;
|
||||
public DuelPlayer[] Players{ get; private set; }
|
||||
|
||||
public TournyParticipant TournyPart { get; set; }
|
||||
public DuelContext Context{ get; }
|
||||
|
||||
public DuelPlayer Find( Mobile mob )
|
||||
{
|
||||
if ( mob is PlayerMobile pm )
|
||||
{
|
||||
if ( pm.DuelContext == Context && pm.DuelPlayer.Participant == this )
|
||||
return pm.DuelPlayer;
|
||||
public TournyParticipant TournyPart{ get; set; }
|
||||
|
||||
return null;
|
||||
}
|
||||
public int FilledSlots
|
||||
{
|
||||
get
|
||||
{
|
||||
int count = 0;
|
||||
|
||||
for ( int i = 0; i < Players.Length; ++i )
|
||||
{
|
||||
if ( Players[i] != null && Players[i].Mobile == mob )
|
||||
return Players[i];
|
||||
}
|
||||
for (int i = 0; i < Players.Length; ++i)
|
||||
if (Players[i] != null)
|
||||
++count;
|
||||
|
||||
return null;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
}
|
||||
|
||||
public bool Contains( Mobile mob )
|
||||
{
|
||||
return ( Find( mob ) != null );
|
||||
}
|
||||
public bool HasOpenSlot
|
||||
{
|
||||
get
|
||||
{
|
||||
for (int i = 0; i < Players.Length; ++i)
|
||||
if (Players[i] == null)
|
||||
return true;
|
||||
|
||||
public void Broadcast( int hue, string message, string nonLocalOverhead, string localOverhead )
|
||||
{
|
||||
for ( int i = 0; i < Players.Length; ++i )
|
||||
{
|
||||
if ( Players[i] != null )
|
||||
{
|
||||
if ( message != null )
|
||||
Players[i].Mobile.SendMessage( hue, message );
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if ( nonLocalOverhead != null )
|
||||
Players[i].Mobile.NonlocalOverheadMessage( Network.MessageType.Regular, hue, false, string.Format( nonLocalOverhead, Players[i].Mobile.Name, Players[i].Mobile.Female ? "her" : "his" ) );
|
||||
public bool Eliminated
|
||||
{
|
||||
get
|
||||
{
|
||||
for (int i = 0; i < Players.Length; ++i)
|
||||
if (Players[i] != null && !Players[i].Eliminated)
|
||||
return false;
|
||||
|
||||
if ( localOverhead != null )
|
||||
Players[i].Mobile.LocalOverheadMessage( Network.MessageType.Regular, hue, false, localOverhead );
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public int FilledSlots
|
||||
{
|
||||
get
|
||||
{
|
||||
int count = 0;
|
||||
public string NameList
|
||||
{
|
||||
get
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
for ( int i = 0; i < Players.Length; ++i )
|
||||
{
|
||||
if ( Players[i] != null )
|
||||
++count;
|
||||
}
|
||||
for (int i = 0; i < Players.Length; ++i)
|
||||
{
|
||||
if (Players[i] == null)
|
||||
continue;
|
||||
|
||||
return count;
|
||||
}
|
||||
}
|
||||
Mobile mob = Players[i].Mobile;
|
||||
|
||||
public bool HasOpenSlot
|
||||
{
|
||||
get
|
||||
{
|
||||
for ( int i = 0; i < Players.Length; ++i )
|
||||
{
|
||||
if ( Players[i] == null )
|
||||
return true;
|
||||
}
|
||||
if (sb.Length > 0)
|
||||
sb.Append(", ");
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
sb.Append(mob.Name);
|
||||
}
|
||||
|
||||
public bool Eliminated
|
||||
{
|
||||
get
|
||||
{
|
||||
for ( int i = 0; i < Players.Length; ++i )
|
||||
{
|
||||
if ( Players[i] != null && !Players[i].Eliminated )
|
||||
return false;
|
||||
}
|
||||
if (sb.Length == 0)
|
||||
return "Empty";
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return sb.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
public string NameList
|
||||
{
|
||||
get
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
public DuelPlayer Find(Mobile mob)
|
||||
{
|
||||
if (mob is PlayerMobile pm)
|
||||
{
|
||||
if (pm.DuelContext == Context && pm.DuelPlayer.Participant == this)
|
||||
return pm.DuelPlayer;
|
||||
|
||||
for ( int i = 0; i < Players.Length; ++i )
|
||||
{
|
||||
if ( Players[i] == null )
|
||||
continue;
|
||||
return null;
|
||||
}
|
||||
|
||||
Mobile mob = Players[i].Mobile;
|
||||
for (int i = 0; i < Players.Length; ++i)
|
||||
if (Players[i] != null && Players[i].Mobile == mob)
|
||||
return Players[i];
|
||||
|
||||
if ( sb.Length > 0 )
|
||||
sb.Append( ", " );
|
||||
return null;
|
||||
}
|
||||
|
||||
sb.Append( mob.Name );
|
||||
}
|
||||
public bool Contains(Mobile mob)
|
||||
{
|
||||
return Find(mob) != null;
|
||||
}
|
||||
|
||||
if ( sb.Length == 0 )
|
||||
return "Empty";
|
||||
public void Broadcast(int hue, string message, string nonLocalOverhead, string localOverhead)
|
||||
{
|
||||
for (int i = 0; i < Players.Length; ++i)
|
||||
if (Players[i] != null)
|
||||
{
|
||||
if (message != null)
|
||||
Players[i].Mobile.SendMessage(hue, message);
|
||||
|
||||
return sb.ToString();
|
||||
}
|
||||
}
|
||||
if (nonLocalOverhead != null)
|
||||
Players[i].Mobile.NonlocalOverheadMessage(MessageType.Regular, hue, false,
|
||||
string.Format(nonLocalOverhead, Players[i].Mobile.Name,
|
||||
Players[i].Mobile.Female ? "her" : "his"));
|
||||
|
||||
public void Nullify( DuelPlayer player )
|
||||
{
|
||||
if ( player == null )
|
||||
return;
|
||||
if (localOverhead != null)
|
||||
Players[i].Mobile.LocalOverheadMessage(MessageType.Regular, hue, false, localOverhead);
|
||||
}
|
||||
}
|
||||
|
||||
int index = Array.IndexOf( Players, player );
|
||||
public void Nullify(DuelPlayer player)
|
||||
{
|
||||
if (player == null)
|
||||
return;
|
||||
|
||||
if ( index == -1 )
|
||||
return;
|
||||
int index = Array.IndexOf(Players, player);
|
||||
|
||||
Players[index] = null;
|
||||
}
|
||||
if (index == -1)
|
||||
return;
|
||||
|
||||
public void Remove( DuelPlayer player )
|
||||
{
|
||||
if ( player == null )
|
||||
return;
|
||||
Players[index] = null;
|
||||
}
|
||||
|
||||
int index = Array.IndexOf( Players, player );
|
||||
public void Remove(DuelPlayer player)
|
||||
{
|
||||
if (player == null)
|
||||
return;
|
||||
|
||||
if ( index == -1 )
|
||||
return;
|
||||
int index = Array.IndexOf(Players, player);
|
||||
|
||||
DuelPlayer[] old = Players;
|
||||
Players = new DuelPlayer[old.Length - 1];
|
||||
if (index == -1)
|
||||
return;
|
||||
|
||||
for ( int i = 0; i < index; ++i )
|
||||
Players[i] = old[i];
|
||||
DuelPlayer[] old = Players;
|
||||
Players = new DuelPlayer[old.Length - 1];
|
||||
|
||||
for ( int i = index + 1; i < old.Length; ++i )
|
||||
Players[i - 1] = old[i];
|
||||
}
|
||||
for (int i = 0; i < index; ++i)
|
||||
Players[i] = old[i];
|
||||
|
||||
public void Remove( Mobile player )
|
||||
{
|
||||
Remove( Find( player ) );
|
||||
}
|
||||
for (int i = index + 1; i < old.Length; ++i)
|
||||
Players[i - 1] = old[i];
|
||||
}
|
||||
|
||||
public void Add( Mobile player )
|
||||
{
|
||||
if ( Contains( player ) )
|
||||
return;
|
||||
public void Remove(Mobile player)
|
||||
{
|
||||
Remove(Find(player));
|
||||
}
|
||||
|
||||
for ( int i = 0; i < Players.Length; ++i )
|
||||
{
|
||||
if ( Players[i] == null )
|
||||
{
|
||||
Players[i] = new DuelPlayer( player, this );
|
||||
return;
|
||||
}
|
||||
}
|
||||
public void Add(Mobile player)
|
||||
{
|
||||
if (Contains(player))
|
||||
return;
|
||||
|
||||
Resize( Players.Length + 1 );
|
||||
Players[Players.Length - 1] = new DuelPlayer( player, this );
|
||||
}
|
||||
for (int i = 0; i < Players.Length; ++i)
|
||||
if (Players[i] == null)
|
||||
{
|
||||
Players[i] = new DuelPlayer(player, this);
|
||||
return;
|
||||
}
|
||||
|
||||
public void Resize( int count )
|
||||
{
|
||||
DuelPlayer[] old = Players;
|
||||
Players = new DuelPlayer[count];
|
||||
Resize(Players.Length + 1);
|
||||
Players[Players.Length - 1] = new DuelPlayer(player, this);
|
||||
}
|
||||
|
||||
if ( old != null )
|
||||
{
|
||||
int ct = 0;
|
||||
public void Resize(int count)
|
||||
{
|
||||
DuelPlayer[] old = Players;
|
||||
Players = new DuelPlayer[count];
|
||||
|
||||
for ( int i = 0; i < old.Length; ++i )
|
||||
{
|
||||
if ( old[i] != null && ct < count )
|
||||
Players[ct++] = old[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
if (old != null)
|
||||
{
|
||||
int ct = 0;
|
||||
|
||||
public Participant( DuelContext context, int count )
|
||||
{
|
||||
Context = context;
|
||||
//m_Stakes = new StakesContainer( context, this );
|
||||
Resize( count );
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < old.Length; ++i)
|
||||
if (old[i] != null && ct < count)
|
||||
Players[ct++] = old[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class DuelPlayer
|
||||
{
|
||||
private bool m_Eliminated;
|
||||
public class DuelPlayer
|
||||
{
|
||||
private bool m_Eliminated;
|
||||
|
||||
public Mobile Mobile { get; }
|
||||
public DuelPlayer(Mobile mob, Participant p)
|
||||
{
|
||||
Mobile = mob;
|
||||
Participant = p;
|
||||
|
||||
public bool Ready { get; set; }
|
||||
if (mob is PlayerMobile mobile)
|
||||
mobile.DuelPlayer = this;
|
||||
}
|
||||
|
||||
public bool Eliminated{ get => m_Eliminated;
|
||||
set{ m_Eliminated = value; if ( Participant.Context.m_Tournament != null && m_Eliminated ){ Participant.Context.m_Tournament.OnEliminated( this ); Mobile.SendEverything(); } } }
|
||||
public Participant Participant { get; set; }
|
||||
public Mobile Mobile{ get; }
|
||||
|
||||
public DuelPlayer( Mobile mob, Participant p )
|
||||
{
|
||||
Mobile = mob;
|
||||
Participant = p;
|
||||
public bool Ready{ get; set; }
|
||||
|
||||
if ( mob is PlayerMobile mobile )
|
||||
mobile.DuelPlayer = this;
|
||||
}
|
||||
}
|
||||
}
|
||||
public bool Eliminated
|
||||
{
|
||||
get => m_Eliminated;
|
||||
set
|
||||
{
|
||||
m_Eliminated = value;
|
||||
if (Participant.Context.m_Tournament != null && m_Eliminated)
|
||||
{
|
||||
Participant.Context.m_Tournament.OnEliminated(this);
|
||||
Mobile.SendEverything();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Participant Participant{ get; set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -1,241 +1,253 @@
|
|||
using System;
|
||||
using Server.Gumps;
|
||||
using Server.Mobiles;
|
||||
using Server.Network;
|
||||
using Server.Targeting;
|
||||
using Server.Mobiles;
|
||||
|
||||
namespace Server.Engines.ConPVP
|
||||
{
|
||||
public class ParticipantGump : Gump
|
||||
{
|
||||
public Mobile From { get; }
|
||||
public class ParticipantGump : Gump
|
||||
{
|
||||
public ParticipantGump(Mobile from, DuelContext context, Participant p) : base(50, 50)
|
||||
{
|
||||
From = from;
|
||||
Context = context;
|
||||
Participant = p;
|
||||
|
||||
public DuelContext Context { get; }
|
||||
from.CloseGump(typeof(RulesetGump));
|
||||
from.CloseGump(typeof(DuelContextGump));
|
||||
from.CloseGump(typeof(ParticipantGump));
|
||||
|
||||
public Participant Participant { get; }
|
||||
int count = p.Players.Length;
|
||||
|
||||
public string Center( string text )
|
||||
{
|
||||
return $"<CENTER>{text}</CENTER>";
|
||||
}
|
||||
if (count < 4)
|
||||
count = 4;
|
||||
|
||||
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 );
|
||||
}
|
||||
AddPage(0);
|
||||
|
||||
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 + 22 + 30 + 22 + 2 + count * 22 + 2 + 30;
|
||||
|
||||
public ParticipantGump( Mobile from, DuelContext context, Participant p ) : base( 50, 50 )
|
||||
{
|
||||
From = from;
|
||||
Context = context;
|
||||
Participant = p;
|
||||
AddBackground(0, 0, 300, height, 9250);
|
||||
AddBackground(10, 10, 280, height - 20, 0xDAC);
|
||||
|
||||
from.CloseGump( typeof( RulesetGump ) );
|
||||
from.CloseGump( typeof( DuelContextGump ) );
|
||||
from.CloseGump( typeof( ParticipantGump ) );
|
||||
AddButton(240, 25, 0xFB1, 0xFB3, 3, GumpButtonType.Reply, 0);
|
||||
|
||||
int count = p.Players.Length;
|
||||
//AddButton( 223, 54, 0x265A, 0x265A, 4, GumpButtonType.Reply, 0 );
|
||||
|
||||
if ( count < 4 )
|
||||
count = 4;
|
||||
AddHtml(35, 25, 230, 20, Center("Participant Setup"), false, false);
|
||||
|
||||
AddPage( 0 );
|
||||
int x = 35;
|
||||
int y = 47;
|
||||
|
||||
int height = 35 + 10 + 22 + 22 + 30 + 22 + 2 + (count * 22) + 2 + 30;
|
||||
AddHtml(x, y, 200, 20, $"Team Size: {p.Players.Length}", false, false);
|
||||
y += 22;
|
||||
|
||||
AddBackground( 0, 0, 300, height, 9250 );
|
||||
AddBackground( 10, 10, 280, height - 20, 0xDAC );
|
||||
AddGoldenButtonLabeled(x + 20, y, 1, "Increase");
|
||||
y += 22;
|
||||
AddGoldenButtonLabeled(x + 20, y, 2, "Decrease");
|
||||
y += 30;
|
||||
|
||||
AddButton( 240, 25, 0xFB1, 0xFB3, 3, GumpButtonType.Reply, 0 );
|
||||
AddHtml(35, y, 230, 20, Center("Players"), false, false);
|
||||
y += 22;
|
||||
|
||||
//AddButton( 223, 54, 0x265A, 0x265A, 4, GumpButtonType.Reply, 0 );
|
||||
for (int i = 0; i < p.Players.Length; ++i)
|
||||
{
|
||||
DuelPlayer pl = p.Players[i];
|
||||
|
||||
AddHtml( 35, 25, 230, 20, Center( "Participant Setup" ), false, false );
|
||||
AddGoldenButtonLabeled(x, y, 5 + i, $"{1 + i}: {(pl == null ? "Empty" : pl.Mobile.Name)}");
|
||||
y += 22;
|
||||
}
|
||||
}
|
||||
|
||||
int x = 35;
|
||||
int y = 47;
|
||||
public Mobile From{ get; }
|
||||
|
||||
AddHtml( x, y, 200, 20, $"Team Size: {p.Players.Length}", false, false ); y += 22;
|
||||
public DuelContext Context{ get; }
|
||||
|
||||
AddGoldenButtonLabeled( x + 20, y, 1, "Increase" ); y += 22;
|
||||
AddGoldenButtonLabeled( x + 20, y, 2, "Decrease" ); y += 30;
|
||||
public Participant Participant{ get; }
|
||||
|
||||
AddHtml( 35, y, 230, 20, Center( "Players" ), false, false ); y += 22;
|
||||
public string Center(string text)
|
||||
{
|
||||
return $"<CENTER>{text}</CENTER>";
|
||||
}
|
||||
|
||||
for ( int i = 0; i < p.Players.Length; ++i )
|
||||
{
|
||||
DuelPlayer pl = p.Players[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, 5 + i, $"{1 + i}: {(pl == null ? "Empty" : pl.Mobile.Name)}"); 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 bid = info.ButtonID;
|
||||
int bid = info.ButtonID;
|
||||
|
||||
if ( bid == 0 )
|
||||
{
|
||||
From.SendGump( new DuelContextGump( From, Context ) );
|
||||
}
|
||||
else if ( bid == 1 )
|
||||
{
|
||||
if ( Participant.Count < 8 )
|
||||
Participant.Resize( Participant.Count + 1 );
|
||||
else
|
||||
From.SendMessage( "You may not raise the team size any further." );
|
||||
if (bid == 0)
|
||||
{
|
||||
From.SendGump(new DuelContextGump(From, Context));
|
||||
}
|
||||
else if (bid == 1)
|
||||
{
|
||||
if (Participant.Count < 8)
|
||||
Participant.Resize(Participant.Count + 1);
|
||||
else
|
||||
From.SendMessage("You may not raise the team size any further.");
|
||||
|
||||
From.SendGump( new ParticipantGump( From, Context, Participant ) );
|
||||
}
|
||||
else if ( bid == 2 )
|
||||
{
|
||||
if ( Participant.Count > 1 && Participant.Count > Participant.FilledSlots )
|
||||
Participant.Resize( Participant.Count - 1 );
|
||||
else
|
||||
From.SendMessage( "You may not lower the team size any further." );
|
||||
From.SendGump(new ParticipantGump(From, Context, Participant));
|
||||
}
|
||||
else if (bid == 2)
|
||||
{
|
||||
if (Participant.Count > 1 && Participant.Count > Participant.FilledSlots)
|
||||
Participant.Resize(Participant.Count - 1);
|
||||
else
|
||||
From.SendMessage("You may not lower the team size any further.");
|
||||
|
||||
From.SendGump( new ParticipantGump( From, Context, Participant ) );
|
||||
}
|
||||
else if ( bid == 3 )
|
||||
{
|
||||
if ( Participant.FilledSlots > 0 )
|
||||
{
|
||||
From.SendMessage( "There is at least one currently active player. You must remove them first." );
|
||||
From.SendGump( new ParticipantGump( From, Context, Participant ) );
|
||||
}
|
||||
else if ( Context.Participants.Count > 2 )
|
||||
{
|
||||
/*Container cont = m_Participant.Stakes;
|
||||
From.SendGump(new ParticipantGump(From, Context, Participant));
|
||||
}
|
||||
else if (bid == 3)
|
||||
{
|
||||
if (Participant.FilledSlots > 0)
|
||||
{
|
||||
From.SendMessage("There is at least one currently active player. You must remove them first.");
|
||||
From.SendGump(new ParticipantGump(From, Context, Participant));
|
||||
}
|
||||
else if (Context.Participants.Count > 2)
|
||||
{
|
||||
/*Container cont = m_Participant.Stakes;
|
||||
|
||||
if ( cont != null )
|
||||
cont.Delete();*/
|
||||
if ( cont != null )
|
||||
cont.Delete();*/
|
||||
|
||||
Context.Participants.Remove( Participant );
|
||||
From.SendGump( new DuelContextGump( From, Context ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
From.SendMessage( "Duels must have at least two participating parties." );
|
||||
From.SendGump( new ParticipantGump( From, Context, Participant ) );
|
||||
}
|
||||
}
|
||||
/*else if ( bid == 4 )
|
||||
{
|
||||
m_From.SendGump( new ParticipantGump( m_From, m_Context, m_Participant ) );
|
||||
Context.Participants.Remove(Participant);
|
||||
From.SendGump(new DuelContextGump(From, Context));
|
||||
}
|
||||
else
|
||||
{
|
||||
From.SendMessage("Duels must have at least two participating parties.");
|
||||
From.SendGump(new ParticipantGump(From, Context, Participant));
|
||||
}
|
||||
}
|
||||
/*else if ( bid == 4 )
|
||||
{
|
||||
m_From.SendGump( new ParticipantGump( m_From, m_Context, m_Participant ) );
|
||||
|
||||
Container cont = m_Participant.Stakes;
|
||||
Container cont = m_Participant.Stakes;
|
||||
|
||||
if ( cont != null && !cont.Deleted )
|
||||
{
|
||||
cont.DisplayTo( m_From );
|
||||
if ( cont != null && !cont.Deleted )
|
||||
{
|
||||
cont.DisplayTo( m_From );
|
||||
|
||||
Item[] checks = cont.FindItemsByType( typeof( BankCheck ) );
|
||||
Item[] checks = cont.FindItemsByType( typeof( BankCheck ) );
|
||||
|
||||
int gold = cont.TotalGold;
|
||||
int gold = cont.TotalGold;
|
||||
|
||||
for ( int i = 0; i < checks.Length; ++i )
|
||||
gold += ((BankCheck)checks[i]).Worth;
|
||||
for ( int i = 0; i < checks.Length; ++i )
|
||||
gold += ((BankCheck)checks[i]).Worth;
|
||||
|
||||
m_From.SendMessage( "This container has {0} item{1} and {2} stone{3}. In gold or check form there is a total of {4:D}gp.", cont.TotalItems, cont.TotalItems==1?"":"s", cont.TotalWeight, cont.TotalWeight==1?"":"s", gold );
|
||||
}
|
||||
}*/
|
||||
else
|
||||
{
|
||||
bid -= 5;
|
||||
m_From.SendMessage( "This container has {0} item{1} and {2} stone{3}. In gold or check form there is a total of {4:D}gp.", cont.TotalItems, cont.TotalItems==1?"":"s", cont.TotalWeight, cont.TotalWeight==1?"":"s", gold );
|
||||
}
|
||||
}*/
|
||||
else
|
||||
{
|
||||
bid -= 5;
|
||||
|
||||
if ( bid >= 0 && bid < Participant.Players.Length )
|
||||
{
|
||||
if ( Participant.Players[bid] == null )
|
||||
{
|
||||
From.Target = new ParticipantTarget( Context, Participant, bid );
|
||||
From.SendMessage( "Target a player." );
|
||||
}
|
||||
else
|
||||
{
|
||||
Participant.Players[bid].Mobile.SendMessage( "You have been removed from the duel." );
|
||||
if (bid >= 0 && bid < Participant.Players.Length)
|
||||
{
|
||||
if (Participant.Players[bid] == null)
|
||||
{
|
||||
From.Target = new ParticipantTarget(Context, Participant, bid);
|
||||
From.SendMessage("Target a player.");
|
||||
}
|
||||
else
|
||||
{
|
||||
Participant.Players[bid].Mobile.SendMessage("You have been removed from the duel.");
|
||||
|
||||
if ( Participant.Players[bid].Mobile is PlayerMobile )
|
||||
((PlayerMobile)(Participant.Players[bid].Mobile)).DuelPlayer = null;
|
||||
if (Participant.Players[bid].Mobile is PlayerMobile)
|
||||
((PlayerMobile)Participant.Players[bid].Mobile).DuelPlayer = null;
|
||||
|
||||
Participant.Players[bid] = null;
|
||||
From.SendMessage( "They have been removed from the duel." );
|
||||
From.SendGump( new ParticipantGump( From, Context, Participant ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Participant.Players[bid] = null;
|
||||
From.SendMessage("They have been removed from the duel.");
|
||||
From.SendGump(new ParticipantGump(From, Context, Participant));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class ParticipantTarget : Target
|
||||
{
|
||||
private DuelContext m_Context;
|
||||
private Participant m_Participant;
|
||||
private int m_Index;
|
||||
private class ParticipantTarget : Target
|
||||
{
|
||||
private DuelContext m_Context;
|
||||
private int m_Index;
|
||||
private Participant m_Participant;
|
||||
|
||||
public ParticipantTarget( DuelContext context, Participant p, int index ) : base( 12, false, TargetFlags.None )
|
||||
{
|
||||
m_Context = context;
|
||||
m_Participant = p;
|
||||
m_Index = index;
|
||||
}
|
||||
public ParticipantTarget(DuelContext context, Participant p, int index) : base(12, false, TargetFlags.None)
|
||||
{
|
||||
m_Context = context;
|
||||
m_Participant = p;
|
||||
m_Index = index;
|
||||
}
|
||||
|
||||
protected override void OnTarget( Mobile from, object targeted )
|
||||
{
|
||||
if ( !m_Context.Registered )
|
||||
return;
|
||||
protected override void OnTarget(Mobile from, object targeted)
|
||||
{
|
||||
if (!m_Context.Registered)
|
||||
return;
|
||||
|
||||
int index = m_Index;
|
||||
int index = m_Index;
|
||||
|
||||
if ( index < 0 || index >= m_Participant.Players.Length )
|
||||
return;
|
||||
if (index < 0 || index >= m_Participant.Players.Length)
|
||||
return;
|
||||
|
||||
if ( !(targeted is Mobile mob) )
|
||||
{
|
||||
from.SendMessage( "That is not a player." );
|
||||
}
|
||||
else if ( !mob.Player )
|
||||
{
|
||||
if ( mob.Body.IsHuman )
|
||||
mob.SayTo( from, 1005443 ); // Nay, I would rather stay here and watch a nail rust.
|
||||
else
|
||||
mob.SayTo( from, 1005444 ); // The creature ignores your offer.
|
||||
}
|
||||
else if ( AcceptDuelGump.IsIgnored( mob, from ) || mob.Blessed )
|
||||
{
|
||||
from.SendMessage( "They ignore your offer." );
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( !(mob is PlayerMobile pm) )
|
||||
return;
|
||||
if (!(targeted is Mobile mob))
|
||||
{
|
||||
from.SendMessage("That is not a player.");
|
||||
}
|
||||
else if (!mob.Player)
|
||||
{
|
||||
if (mob.Body.IsHuman)
|
||||
mob.SayTo(from, 1005443); // Nay, I would rather stay here and watch a nail rust.
|
||||
else
|
||||
mob.SayTo(from, 1005444); // The creature ignores your offer.
|
||||
}
|
||||
else if (AcceptDuelGump.IsIgnored(mob, from) || mob.Blessed)
|
||||
{
|
||||
from.SendMessage("They ignore your offer.");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!(mob is PlayerMobile pm))
|
||||
return;
|
||||
|
||||
if ( pm.DuelContext != null )
|
||||
from.SendMessage( "{0} cannot fight because they are already assigned to another duel.", pm.Name );
|
||||
else if ( DuelContext.CheckCombat( pm ) )
|
||||
from.SendMessage( "{0} cannot fight because they have recently been in combat with another player.", pm.Name );
|
||||
else if ( mob.HasGump( typeof( AcceptDuelGump ) ) )
|
||||
from.SendMessage( "{0} has already been offered a duel." );
|
||||
else
|
||||
{
|
||||
from.SendMessage( "You send {0} to {1}.", m_Participant.Find( from ) == null ? "a challenge" : "an invitation", mob.Name );
|
||||
mob.SendGump( new AcceptDuelGump( from, mob, m_Context, m_Participant, m_Index ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
if (pm.DuelContext != null)
|
||||
{
|
||||
from.SendMessage("{0} cannot fight because they are already assigned to another duel.", pm.Name);
|
||||
}
|
||||
else if (DuelContext.CheckCombat(pm))
|
||||
{
|
||||
from.SendMessage("{0} cannot fight because they have recently been in combat with another player.",
|
||||
pm.Name);
|
||||
}
|
||||
else if (mob.HasGump(typeof(AcceptDuelGump)))
|
||||
{
|
||||
from.SendMessage("{0} has already been offered a duel.");
|
||||
}
|
||||
else
|
||||
{
|
||||
from.SendMessage("You send {0} to {1}.",
|
||||
m_Participant.Find(from) == null ? "a challenge" : "an invitation", mob.Name);
|
||||
mob.SendGump(new AcceptDuelGump(from, mob, m_Context, m_Participant, m_Index));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnTargetFinish( Mobile from )
|
||||
{
|
||||
from.SendGump( new ParticipantGump( from, m_Context, m_Participant ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
protected override void OnTargetFinish(Mobile from)
|
||||
{
|
||||
from.SendGump(new ParticipantGump(from, m_Context, m_Participant));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,127 +1,126 @@
|
|||
using System;
|
||||
using Server.Gumps;
|
||||
using Server.Network;
|
||||
|
||||
namespace Server.Engines.ConPVP
|
||||
{
|
||||
public class PickRulesetGump : Gump
|
||||
{
|
||||
private Mobile m_From;
|
||||
private DuelContext m_Context;
|
||||
private Ruleset m_Ruleset;
|
||||
private Ruleset[] m_Defaults;
|
||||
private Ruleset[] m_Flavors;
|
||||
public class PickRulesetGump : Gump
|
||||
{
|
||||
private DuelContext m_Context;
|
||||
private Ruleset[] m_Defaults;
|
||||
private Ruleset[] m_Flavors;
|
||||
private Mobile m_From;
|
||||
private Ruleset m_Ruleset;
|
||||
|
||||
public string Center( string text )
|
||||
{
|
||||
return $"<CENTER>{text}</CENTER>";
|
||||
}
|
||||
public PickRulesetGump(Mobile from, DuelContext context, Ruleset ruleset) : base(50, 50)
|
||||
{
|
||||
m_From = from;
|
||||
m_Context = context;
|
||||
m_Ruleset = ruleset;
|
||||
m_Defaults = ruleset.Layout.Defaults;
|
||||
m_Flavors = ruleset.Layout.Flavors;
|
||||
|
||||
public PickRulesetGump( Mobile from, DuelContext context, Ruleset ruleset ) : base( 50, 50 )
|
||||
{
|
||||
m_From = from;
|
||||
m_Context = context;
|
||||
m_Ruleset = ruleset;
|
||||
m_Defaults = ruleset.Layout.Defaults;
|
||||
m_Flavors = ruleset.Layout.Flavors;
|
||||
int height = 25 + 20 + (m_Defaults.Length + 1) * 22 + 6 + 20 + m_Flavors.Length * 22 + 25;
|
||||
|
||||
int height = 25 + 20 + ((m_Defaults.Length + 1) * 22) + 6 + 20 + (m_Flavors.Length * 22) + 25;
|
||||
AddPage(0);
|
||||
|
||||
AddPage( 0 );
|
||||
AddBackground(0, 0, 260, height, 9250);
|
||||
AddBackground(10, 10, 240, height - 20, 0xDAC);
|
||||
|
||||
AddBackground( 0, 0, 260, height, 9250 );
|
||||
AddBackground( 10, 10, 240, height - 20, 0xDAC );
|
||||
AddHtml(35, 25, 190, 20, Center("Rules"), false, false);
|
||||
|
||||
AddHtml( 35, 25, 190, 20, Center( "Rules" ), false, false );
|
||||
int y = 25 + 20;
|
||||
|
||||
int y = 25 + 20;
|
||||
for (int i = 0; i < m_Defaults.Length; ++i)
|
||||
{
|
||||
Ruleset cur = m_Defaults[i];
|
||||
|
||||
for ( int i = 0; i < m_Defaults.Length; ++i )
|
||||
{
|
||||
Ruleset cur = m_Defaults[i];
|
||||
AddHtml(35 + 14, y, 176, 20, cur.Title, false, false);
|
||||
|
||||
AddHtml( 35 + 14, y, 176, 20, cur.Title, false, false );
|
||||
if (ruleset.Base == cur && !ruleset.Changed)
|
||||
AddImage(35, y + 4, 0x939);
|
||||
else if (ruleset.Base == cur)
|
||||
AddButton(35, y + 4, 0x93A, 0x939, 2 + i, GumpButtonType.Reply, 0);
|
||||
else
|
||||
AddButton(35, y + 4, 0x938, 0x939, 2 + i, GumpButtonType.Reply, 0);
|
||||
|
||||
if ( ruleset.Base == cur && !ruleset.Changed )
|
||||
AddImage( 35, y + 4, 0x939 );
|
||||
else if ( ruleset.Base == cur )
|
||||
AddButton( 35, y + 4, 0x93A, 0x939, 2 + i, GumpButtonType.Reply, 0 );
|
||||
else
|
||||
AddButton( 35, y + 4, 0x938, 0x939, 2 + i, GumpButtonType.Reply, 0 );
|
||||
y += 22;
|
||||
}
|
||||
|
||||
y += 22;
|
||||
}
|
||||
AddHtml(35 + 14, y, 176, 20, "Custom", false, false);
|
||||
AddButton(35, y + 4, ruleset.Changed ? 0x939 : 0x938, 0x939, 1, GumpButtonType.Reply, 0);
|
||||
|
||||
AddHtml( 35 + 14, y, 176, 20, "Custom", false, false );
|
||||
AddButton( 35, y + 4, ruleset.Changed ? 0x939 : 0x938, 0x939, 1, GumpButtonType.Reply, 0 );
|
||||
y += 22;
|
||||
y += 6;
|
||||
|
||||
y += 22;
|
||||
y += 6;
|
||||
AddHtml(35, y, 190, 20, Center("Flavors"), false, false);
|
||||
y += 20;
|
||||
|
||||
AddHtml( 35, y, 190, 20, Center( "Flavors" ), false, false );
|
||||
y += 20;
|
||||
for (int i = 0; i < m_Flavors.Length; ++i)
|
||||
{
|
||||
Ruleset cur = m_Flavors[i];
|
||||
|
||||
for ( int i = 0; i < m_Flavors.Length; ++i )
|
||||
{
|
||||
Ruleset cur = m_Flavors[i];
|
||||
AddHtml(35 + 14, y, 176, 20, cur.Title, false, false);
|
||||
|
||||
AddHtml( 35 + 14, y, 176, 20, cur.Title, false, false );
|
||||
if (ruleset.Flavors.Contains(cur))
|
||||
AddButton(35, y + 4, 0x939, 0x938, 2 + m_Defaults.Length + i, GumpButtonType.Reply, 0);
|
||||
else
|
||||
AddButton(35, y + 4, 0x938, 0x939, 2 + m_Defaults.Length + i, GumpButtonType.Reply, 0);
|
||||
|
||||
if ( ruleset.Flavors.Contains( cur ) )
|
||||
AddButton( 35, y + 4, 0x939, 0x938, 2 + m_Defaults.Length + i, GumpButtonType.Reply, 0 );
|
||||
else
|
||||
AddButton( 35, y + 4, 0x938, 0x939, 2 + m_Defaults.Length + i, GumpButtonType.Reply, 0 );
|
||||
y += 22;
|
||||
}
|
||||
}
|
||||
|
||||
y += 22;
|
||||
}
|
||||
}
|
||||
public string Center(string text)
|
||||
{
|
||||
return $"<CENTER>{text}</CENTER>";
|
||||
}
|
||||
|
||||
public override void OnResponse( NetState sender, RelayInfo info )
|
||||
{
|
||||
if ( m_Context != null && !m_Context.Registered )
|
||||
return;
|
||||
public override void OnResponse(NetState sender, RelayInfo info)
|
||||
{
|
||||
if (m_Context != null && !m_Context.Registered)
|
||||
return;
|
||||
|
||||
switch ( info.ButtonID )
|
||||
{
|
||||
case 0: // closed
|
||||
{
|
||||
if ( m_Context != null )
|
||||
m_From.SendGump( new DuelContextGump( m_From, m_Context ) );
|
||||
switch (info.ButtonID)
|
||||
{
|
||||
case 0: // closed
|
||||
{
|
||||
if (m_Context != null)
|
||||
m_From.SendGump(new DuelContextGump(m_From, m_Context));
|
||||
|
||||
break;
|
||||
}
|
||||
case 1: // customize
|
||||
{
|
||||
m_From.SendGump( new RulesetGump( m_From, m_Ruleset, m_Ruleset.Layout, m_Context ) );
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
int idx = info.ButtonID - 2;
|
||||
break;
|
||||
}
|
||||
case 1: // customize
|
||||
{
|
||||
m_From.SendGump(new RulesetGump(m_From, m_Ruleset, m_Ruleset.Layout, m_Context));
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
int idx = info.ButtonID - 2;
|
||||
|
||||
if ( idx >= 0 && idx < m_Defaults.Length )
|
||||
{
|
||||
m_Ruleset.ApplyDefault( m_Defaults[idx] );
|
||||
m_From.SendGump( new PickRulesetGump( m_From, m_Context, m_Ruleset ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
idx -= m_Defaults.Length;
|
||||
if (idx >= 0 && idx < m_Defaults.Length)
|
||||
{
|
||||
m_Ruleset.ApplyDefault(m_Defaults[idx]);
|
||||
m_From.SendGump(new PickRulesetGump(m_From, m_Context, m_Ruleset));
|
||||
}
|
||||
else
|
||||
{
|
||||
idx -= m_Defaults.Length;
|
||||
|
||||
if ( idx >= 0 && idx < m_Flavors.Length )
|
||||
{
|
||||
if ( m_Ruleset.Flavors.Contains( m_Flavors[idx] ) )
|
||||
m_Ruleset.RemoveFlavor( m_Flavors[idx] );
|
||||
else
|
||||
m_Ruleset.AddFlavor( m_Flavors[idx] );
|
||||
if (idx >= 0 && idx < m_Flavors.Length)
|
||||
{
|
||||
if (m_Ruleset.Flavors.Contains(m_Flavors[idx]))
|
||||
m_Ruleset.RemoveFlavor(m_Flavors[idx]);
|
||||
else
|
||||
m_Ruleset.AddFlavor(m_Flavors[idx]);
|
||||
|
||||
m_From.SendGump( new PickRulesetGump( m_From, m_Context, m_Ruleset ) );
|
||||
}
|
||||
}
|
||||
m_From.SendGump(new PickRulesetGump(m_From, m_Context, m_Ruleset));
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,4 +1,3 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Server.Gumps;
|
||||
|
|
@ -6,297 +5,299 @@ using Server.Network;
|
|||
|
||||
namespace Server.Engines.ConPVP
|
||||
{
|
||||
public class PreferencesController : Item
|
||||
{
|
||||
private Preferences m_Preferences;
|
||||
|
||||
//[CommandProperty( AccessLevel.GameMaster )]
|
||||
public Preferences Preferences{ get => m_Preferences;
|
||||
set{} }
|
||||
|
||||
public override string DefaultName => "preferences controller";
|
||||
|
||||
[Constructible]
|
||||
public PreferencesController() : base( 0x1B7A )
|
||||
{
|
||||
Visible = false;
|
||||
Movable = false;
|
||||
|
||||
m_Preferences = new Preferences();
|
||||
|
||||
if ( Preferences.Instance == null )
|
||||
Preferences.Instance = m_Preferences;
|
||||
else
|
||||
Delete();
|
||||
}
|
||||
|
||||
public override void Delete()
|
||||
{
|
||||
if ( Preferences.Instance != m_Preferences )
|
||||
base.Delete();
|
||||
}
|
||||
|
||||
public PreferencesController( Serial serial ) : base( serial )
|
||||
{
|
||||
}
|
||||
|
||||
public override void Serialize( GenericWriter writer )
|
||||
{
|
||||
base.Serialize( writer );
|
||||
|
||||
writer.Write( (int) 0 );
|
||||
|
||||
m_Preferences.Serialize( writer );
|
||||
}
|
||||
|
||||
public override void Deserialize( GenericReader reader )
|
||||
{
|
||||
base.Deserialize( reader );
|
||||
|
||||
int version = reader.ReadInt();
|
||||
|
||||
switch ( version )
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
m_Preferences = new Preferences( reader );
|
||||
Preferences.Instance = m_Preferences;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class Preferences
|
||||
{
|
||||
private Hashtable m_Table;
|
||||
|
||||
public ArrayList Entries { get; }
|
||||
|
||||
public PreferencesEntry Find( Mobile mob )
|
||||
{
|
||||
PreferencesEntry entry = (PreferencesEntry) m_Table[mob];
|
||||
public class PreferencesController : Item
|
||||
{
|
||||
private Preferences m_Preferences;
|
||||
|
||||
[Constructible]
|
||||
public PreferencesController() : base(0x1B7A)
|
||||
{
|
||||
Visible = false;
|
||||
Movable = false;
|
||||
|
||||
m_Preferences = new Preferences();
|
||||
|
||||
if (Preferences.Instance == null)
|
||||
Preferences.Instance = m_Preferences;
|
||||
else
|
||||
Delete();
|
||||
}
|
||||
|
||||
public PreferencesController(Serial serial) : base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
//[CommandProperty( AccessLevel.GameMaster )]
|
||||
public Preferences Preferences
|
||||
{
|
||||
get => m_Preferences;
|
||||
set { }
|
||||
}
|
||||
|
||||
public override string DefaultName => "preferences controller";
|
||||
|
||||
public override void Delete()
|
||||
{
|
||||
if (Preferences.Instance != m_Preferences)
|
||||
base.Delete();
|
||||
}
|
||||
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write(0);
|
||||
|
||||
m_Preferences.Serialize(writer);
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
int version = reader.ReadInt();
|
||||
|
||||
switch (version)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
m_Preferences = new Preferences(reader);
|
||||
Preferences.Instance = m_Preferences;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class Preferences
|
||||
{
|
||||
private Hashtable m_Table;
|
||||
|
||||
public Preferences()
|
||||
{
|
||||
m_Table = new Hashtable();
|
||||
Entries = new ArrayList();
|
||||
}
|
||||
|
||||
public Preferences(GenericReader reader)
|
||||
{
|
||||
int version = reader.ReadEncodedInt();
|
||||
|
||||
switch (version)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
int count = reader.ReadEncodedInt();
|
||||
|
||||
m_Table = new Hashtable(count);
|
||||
Entries = new ArrayList(count);
|
||||
|
||||
for (int i = 0; i < count; ++i)
|
||||
{
|
||||
PreferencesEntry entry = new PreferencesEntry(reader, this, version);
|
||||
|
||||
if (entry.Mobile != null)
|
||||
{
|
||||
m_Table[entry.Mobile] = entry;
|
||||
Entries.Add(entry);
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( entry == null )
|
||||
{
|
||||
m_Table[mob] = entry = new PreferencesEntry( mob, this );
|
||||
Entries.Add( entry );
|
||||
}
|
||||
|
||||
return entry;
|
||||
}
|
||||
|
||||
public static Preferences Instance { get; set; }
|
||||
|
||||
public Preferences()
|
||||
{
|
||||
m_Table = new Hashtable();
|
||||
Entries = new ArrayList();
|
||||
}
|
||||
|
||||
public Preferences( GenericReader reader )
|
||||
{
|
||||
int version = reader.ReadEncodedInt();
|
||||
|
||||
switch ( version )
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
int count = reader.ReadEncodedInt();
|
||||
public ArrayList Entries{ get; }
|
||||
|
||||
m_Table = new Hashtable( count );
|
||||
Entries = new ArrayList( count );
|
||||
|
||||
for ( int i = 0; i < count; ++i )
|
||||
{
|
||||
PreferencesEntry entry = new PreferencesEntry( reader, this, version );
|
||||
|
||||
if ( entry.Mobile != null )
|
||||
{
|
||||
m_Table[entry.Mobile] = entry;
|
||||
Entries.Add( entry );
|
||||
}
|
||||
}
|
||||
public static Preferences Instance{ get; set; }
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
public PreferencesEntry Find(Mobile mob)
|
||||
{
|
||||
PreferencesEntry entry = (PreferencesEntry)m_Table[mob];
|
||||
|
||||
public void Serialize( GenericWriter writer )
|
||||
{
|
||||
writer.WriteEncodedInt( (int) 0 ); // version;
|
||||
if (entry == null)
|
||||
{
|
||||
m_Table[mob] = entry = new PreferencesEntry(mob, this);
|
||||
Entries.Add(entry);
|
||||
}
|
||||
|
||||
writer.WriteEncodedInt( (int) Entries.Count );
|
||||
return entry;
|
||||
}
|
||||
|
||||
for ( int i = 0; i < Entries.Count; ++i )
|
||||
((PreferencesEntry)Entries[i]).Serialize( writer );
|
||||
}
|
||||
}
|
||||
public void Serialize(GenericWriter writer)
|
||||
{
|
||||
writer.WriteEncodedInt(0); // version;
|
||||
|
||||
public class PreferencesEntry
|
||||
{
|
||||
private Preferences m_Preferences;
|
||||
writer.WriteEncodedInt(Entries.Count);
|
||||
|
||||
public Mobile Mobile { get; }
|
||||
for (int i = 0; i < Entries.Count; ++i)
|
||||
((PreferencesEntry)Entries[i]).Serialize(writer);
|
||||
}
|
||||
}
|
||||
|
||||
public ArrayList Disliked { get; }
|
||||
public class PreferencesEntry
|
||||
{
|
||||
private Preferences m_Preferences;
|
||||
|
||||
public PreferencesEntry( Mobile mob, Preferences prefs )
|
||||
{
|
||||
m_Preferences = prefs;
|
||||
Mobile = mob;
|
||||
Disliked = new ArrayList();
|
||||
}
|
||||
public PreferencesEntry(Mobile mob, Preferences prefs)
|
||||
{
|
||||
m_Preferences = prefs;
|
||||
Mobile = mob;
|
||||
Disliked = new ArrayList();
|
||||
}
|
||||
|
||||
public PreferencesEntry( GenericReader reader, Preferences prefs, int version )
|
||||
{
|
||||
m_Preferences = prefs;
|
||||
public PreferencesEntry(GenericReader reader, Preferences prefs, int version)
|
||||
{
|
||||
m_Preferences = prefs;
|
||||
|
||||
switch ( version )
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
Mobile = reader.ReadMobile();
|
||||
switch (version)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
Mobile = reader.ReadMobile();
|
||||
|
||||
int count = reader.ReadEncodedInt();
|
||||
int count = reader.ReadEncodedInt();
|
||||
|
||||
Disliked = new ArrayList( count );
|
||||
Disliked = new ArrayList(count);
|
||||
|
||||
for ( int i = 0; i < count; ++i )
|
||||
Disliked.Add( reader.ReadString() );
|
||||
for (int i = 0; i < count; ++i)
|
||||
Disliked.Add(reader.ReadString());
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Serialize( GenericWriter writer )
|
||||
{
|
||||
writer.Write( (Mobile) Mobile );
|
||||
public Mobile Mobile{ get; }
|
||||
|
||||
writer.WriteEncodedInt( (int) Disliked.Count );
|
||||
public ArrayList Disliked{ get; }
|
||||
|
||||
for ( int i = 0; i < Disliked.Count; ++i )
|
||||
writer.Write( (string) Disliked[i] );
|
||||
}
|
||||
}
|
||||
public void Serialize(GenericWriter writer)
|
||||
{
|
||||
writer.Write(Mobile);
|
||||
|
||||
public class PreferencesGump : Gump
|
||||
{
|
||||
private Mobile m_From;
|
||||
private PreferencesEntry m_Entry;
|
||||
writer.WriteEncodedInt(Disliked.Count);
|
||||
|
||||
public override void OnResponse( NetState sender, RelayInfo info )
|
||||
{
|
||||
if ( m_Entry == null )
|
||||
return;
|
||||
for (int i = 0; i < Disliked.Count; ++i)
|
||||
writer.Write((string)Disliked[i]);
|
||||
}
|
||||
}
|
||||
|
||||
if ( info.ButtonID != 1 )
|
||||
return;
|
||||
public class PreferencesGump : Gump
|
||||
{
|
||||
private int m_ColumnX = 12;
|
||||
private PreferencesEntry m_Entry;
|
||||
private Mobile m_From;
|
||||
|
||||
m_Entry.Disliked.Clear();
|
||||
public PreferencesGump(Mobile from, Preferences prefs) : base(50, 50)
|
||||
{
|
||||
m_From = from;
|
||||
m_Entry = prefs.Find(from);
|
||||
|
||||
List<Arena> arenas = Arena.Arenas;
|
||||
if (m_Entry == null)
|
||||
return;
|
||||
|
||||
for ( int i = 0; i < info.Switches.Length; ++i )
|
||||
{
|
||||
int idx = info.Switches[i];
|
||||
List<Arena> arenas = Arena.Arenas;
|
||||
|
||||
if ( idx >= 0 && idx < arenas.Count )
|
||||
m_Entry.Disliked.Add( arenas[idx].Name );
|
||||
}
|
||||
}
|
||||
AddPage(0);
|
||||
|
||||
public PreferencesGump( Mobile from, Preferences prefs ) : base( 50, 50 )
|
||||
{
|
||||
m_From = from;
|
||||
m_Entry = prefs.Find( from );
|
||||
int height = 12 + 20 + arenas.Count * 31 + 24 + 12;
|
||||
|
||||
if ( m_Entry == null )
|
||||
return;
|
||||
AddBackground(0, 0, 499 + 40 - 365, height, 0x2436);
|
||||
|
||||
List<Arena> arenas = Arena.Arenas;
|
||||
for (int i = 1; i < arenas.Count; i += 2)
|
||||
AddImageTiled(12, 32 + i * 31, 475 + 40 - 365, 30, 0x2430);
|
||||
|
||||
AddPage( 0 );
|
||||
AddAlphaRegion(10, 10, 479 + 40 - 365, height - 20);
|
||||
|
||||
int height = 12 + 20 + (arenas.Count * 31) + 24 + 12;
|
||||
AddColumnHeader(35, null);
|
||||
AddColumnHeader(115, "Arena");
|
||||
|
||||
AddBackground( 0, 0, 499+40-365, height, 0x2436 );
|
||||
AddButton(499 + 40 - 365 - 12 - 63 - 4 - 63, height - 12 - 24, 247, 248, 1, GumpButtonType.Reply, 0);
|
||||
AddButton(499 + 40 - 365 - 12 - 63, height - 12 - 24, 241, 242, 2, GumpButtonType.Reply, 0);
|
||||
|
||||
for ( int i = 1; i < arenas.Count; i += 2 )
|
||||
AddImageTiled( 12, 32 + (i * 31), 475+40-365, 30, 0x2430 );
|
||||
for (int i = 0; i < arenas.Count; ++i)
|
||||
{
|
||||
Arena ar = arenas[i];
|
||||
|
||||
AddAlphaRegion( 10, 10, 479+40-365, height - 20 );
|
||||
string name = ar.Name;
|
||||
|
||||
AddColumnHeader( 35, null );
|
||||
AddColumnHeader( 115, "Arena" );
|
||||
if (name == null)
|
||||
name = "(no name)";
|
||||
|
||||
AddButton( 499+40-365 - 12 - 63 - 4 - 63, height - 12 - 24, 247, 248, 1, GumpButtonType.Reply, 0 );
|
||||
AddButton( 499+40-365 - 12 - 63, height - 12 - 24, 241, 242, 2, GumpButtonType.Reply, 0 );
|
||||
int x = 12;
|
||||
int y = 32 + i * 31;
|
||||
|
||||
for ( int i = 0; i < arenas.Count; ++i )
|
||||
{
|
||||
Arena ar = arenas[i];
|
||||
int color = 0xCCFFCC;
|
||||
|
||||
string name = ar.Name;
|
||||
AddCheck(x + 3, y + 1, 9730, 9727, m_Entry.Disliked.Contains(name), i);
|
||||
x += 35;
|
||||
|
||||
if ( name == null )
|
||||
name = "(no name)";
|
||||
AddBorderedText(x + 5, y + 5, 115 - 5, name, color, 0);
|
||||
x += 115;
|
||||
}
|
||||
}
|
||||
|
||||
int x = 12;
|
||||
int y = 32 + (i * 31);
|
||||
public override void OnResponse(NetState sender, RelayInfo info)
|
||||
{
|
||||
if (m_Entry == null)
|
||||
return;
|
||||
|
||||
int color = 0xCCFFCC;
|
||||
if (info.ButtonID != 1)
|
||||
return;
|
||||
|
||||
AddCheck( x + 3, y + 1, 9730, 9727, m_Entry.Disliked.Contains(name), i );
|
||||
x += 35;
|
||||
m_Entry.Disliked.Clear();
|
||||
|
||||
AddBorderedText( x + 5, y + 5, 115 - 5, name, color, 0 );
|
||||
x += 115;
|
||||
}
|
||||
}
|
||||
List<Arena> arenas = Arena.Arenas;
|
||||
|
||||
public string Center( string text )
|
||||
{
|
||||
return $"<CENTER>{text}</CENTER>";
|
||||
}
|
||||
for (int i = 0; i < info.Switches.Length; ++i)
|
||||
{
|
||||
int idx = info.Switches[i];
|
||||
|
||||
public string Color( string text, int color )
|
||||
{
|
||||
return $"<BASEFONT COLOR=#{color:X6}>{text}</BASEFONT>";
|
||||
}
|
||||
if (idx >= 0 && idx < arenas.Count)
|
||||
m_Entry.Disliked.Add(arenas[idx].Name);
|
||||
}
|
||||
}
|
||||
|
||||
private void AddBorderedText( int x, int y, int width, string text, int color, int borderColor )
|
||||
{
|
||||
/*AddColoredText( x - 1, y, width, text, borderColor );
|
||||
AddColoredText( x + 1, y, width, text, borderColor );
|
||||
AddColoredText( x, y - 1, width, text, borderColor );
|
||||
AddColoredText( x, y + 1, width, text, borderColor );*/
|
||||
/*AddColoredText( x - 1, y - 1, width, text, borderColor );
|
||||
AddColoredText( x + 1, y + 1, width, text, borderColor );*/
|
||||
AddColoredText( x, y, width, text, color );
|
||||
}
|
||||
public string Center(string text)
|
||||
{
|
||||
return $"<CENTER>{text}</CENTER>";
|
||||
}
|
||||
|
||||
private void AddColoredText( int x, int y, int width, string text, int color )
|
||||
{
|
||||
if ( color == 0 )
|
||||
AddHtml( x, y, width, 20, text, false, false );
|
||||
else
|
||||
AddHtml( x, y, width, 20, Color( text, color ), false, false );
|
||||
}
|
||||
public string Color(string text, int color)
|
||||
{
|
||||
return $"<BASEFONT COLOR=#{color:X6}>{text}</BASEFONT>";
|
||||
}
|
||||
|
||||
private int m_ColumnX = 12;
|
||||
private void AddBorderedText(int x, int y, int width, string text, int color, int borderColor)
|
||||
{
|
||||
/*AddColoredText( x - 1, y, width, text, borderColor );
|
||||
AddColoredText( x + 1, y, width, text, borderColor );
|
||||
AddColoredText( x, y - 1, width, text, borderColor );
|
||||
AddColoredText( x, y + 1, width, text, borderColor );*/
|
||||
/*AddColoredText( x - 1, y - 1, width, text, borderColor );
|
||||
AddColoredText( x + 1, y + 1, width, text, borderColor );*/
|
||||
AddColoredText(x, y, width, text, color);
|
||||
}
|
||||
|
||||
private void AddColumnHeader( int width, string name )
|
||||
{
|
||||
AddBackground( m_ColumnX, 12, width, 20, 0x242C );
|
||||
AddImageTiled( m_ColumnX + 2, 14, width - 4, 16, 0x2430 );
|
||||
private void AddColoredText(int x, int y, int width, string text, int color)
|
||||
{
|
||||
if (color == 0)
|
||||
AddHtml(x, y, width, 20, text, false, false);
|
||||
else
|
||||
AddHtml(x, y, width, 20, Color(text, color), false, false);
|
||||
}
|
||||
|
||||
if ( name != null )
|
||||
AddBorderedText( m_ColumnX, 13, width, Center( name ), 0xFFFFFF, 0 );
|
||||
private void AddColumnHeader(int width, string name)
|
||||
{
|
||||
AddBackground(m_ColumnX, 12, width, 20, 0x242C);
|
||||
AddImageTiled(m_ColumnX + 2, 14, width - 4, 16, 0x2430);
|
||||
|
||||
m_ColumnX += width;
|
||||
}
|
||||
}
|
||||
if (name != null)
|
||||
AddBorderedText(m_ColumnX, 13, width, Center(name), 0xFFFFFF, 0);
|
||||
|
||||
m_ColumnX += width;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,110 +1,109 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using Server.Gumps;
|
||||
using Server.Network;
|
||||
|
||||
namespace Server.Engines.ConPVP
|
||||
{
|
||||
public class ReadyGump : Gump
|
||||
{
|
||||
private Mobile m_From;
|
||||
private DuelContext m_Context;
|
||||
private int m_Count;
|
||||
public class ReadyGump : Gump
|
||||
{
|
||||
private DuelContext m_Context;
|
||||
private int m_Count;
|
||||
private Mobile m_From;
|
||||
|
||||
public string Center( string text )
|
||||
{
|
||||
return $"<CENTER>{text}</CENTER>";
|
||||
}
|
||||
public ReadyGump(Mobile from, DuelContext context, int count) : base(50, 50)
|
||||
{
|
||||
m_From = from;
|
||||
m_Context = context;
|
||||
m_Count = count;
|
||||
|
||||
public ReadyGump( Mobile from, DuelContext context, int count ) : base( 50, 50 )
|
||||
{
|
||||
m_From = from;
|
||||
m_Context = context;
|
||||
m_Count = count;
|
||||
ArrayList parts = context.Participants;
|
||||
|
||||
ArrayList parts = context.Participants;
|
||||
int height = 25 + 20;
|
||||
|
||||
int height = 25 + 20;
|
||||
for (int i = 0; i < parts.Count; ++i)
|
||||
{
|
||||
Participant p = (Participant)parts[i];
|
||||
|
||||
for ( int i = 0; i < parts.Count; ++i )
|
||||
{
|
||||
Participant p = (Participant)parts[i];
|
||||
height += 4;
|
||||
|
||||
height += 4;
|
||||
if (p.Players.Length > 1)
|
||||
height += 22;
|
||||
|
||||
if ( p.Players.Length > 1 )
|
||||
height += 22;
|
||||
height += p.Players.Length * 22;
|
||||
}
|
||||
|
||||
height += (p.Players.Length * 22);
|
||||
}
|
||||
height += 25;
|
||||
|
||||
height += 25;
|
||||
Closable = false;
|
||||
Dragable = false;
|
||||
|
||||
Closable = false;
|
||||
Dragable = false;
|
||||
AddPage(0);
|
||||
|
||||
AddPage( 0 );
|
||||
AddBackground(0, 0, 260, height, 9250);
|
||||
AddBackground(10, 10, 240, height - 20, 0xDAC);
|
||||
|
||||
AddBackground( 0, 0, 260, height, 9250 );
|
||||
AddBackground( 10, 10, 240, height - 20, 0xDAC );
|
||||
if (count == -1)
|
||||
{
|
||||
AddHtml(35, 25, 190, 20, Center("Ready"), false, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
AddHtml(35, 25, 190, 20, Center("Starting"), false, false);
|
||||
AddHtml(35, 25, 190, 20, "<DIV ALIGN=RIGHT>" + count, false, false);
|
||||
}
|
||||
|
||||
if ( count == -1 )
|
||||
{
|
||||
AddHtml( 35, 25, 190, 20, Center( "Ready" ), false, false );
|
||||
}
|
||||
else
|
||||
{
|
||||
AddHtml( 35, 25, 190, 20, Center( "Starting" ), false, false );
|
||||
AddHtml( 35, 25, 190, 20, "<DIV ALIGN=RIGHT>" + count.ToString(), false, false );
|
||||
}
|
||||
int y = 25 + 20;
|
||||
|
||||
int y = 25 + 20;
|
||||
for (int i = 0; i < parts.Count; ++i)
|
||||
{
|
||||
Participant p = (Participant)parts[i];
|
||||
|
||||
for ( int i = 0; i < parts.Count; ++i )
|
||||
{
|
||||
Participant p = (Participant)parts[i];
|
||||
y += 4;
|
||||
|
||||
y += 4;
|
||||
bool isAllReady = true;
|
||||
int yStore = y;
|
||||
int offset = 0;
|
||||
|
||||
bool isAllReady = true;
|
||||
int yStore = y;
|
||||
int offset = 0;
|
||||
if (p.Players.Length > 1)
|
||||
{
|
||||
AddHtml(35 + 14, y, 176, 20, $"Participant #{i + 1}", false, false);
|
||||
y += 22;
|
||||
offset = 10;
|
||||
}
|
||||
|
||||
if ( p.Players.Length > 1 )
|
||||
{
|
||||
AddHtml( 35 + 14, y, 176, 20, $"Participant #{i + 1}", false, false );
|
||||
y += 22;
|
||||
offset = 10;
|
||||
}
|
||||
for (int j = 0; j < p.Players.Length; ++j)
|
||||
{
|
||||
DuelPlayer pl = p.Players[j];
|
||||
|
||||
for ( int j = 0; j < p.Players.Length; ++j )
|
||||
{
|
||||
DuelPlayer pl = p.Players[j];
|
||||
if (pl != null && pl.Ready)
|
||||
{
|
||||
AddImage(35 + offset, y + 4, 0x939);
|
||||
}
|
||||
else
|
||||
{
|
||||
AddImage(35 + offset, y + 4, 0x938);
|
||||
isAllReady = false;
|
||||
}
|
||||
|
||||
if ( pl != null && pl.Ready )
|
||||
{
|
||||
AddImage( 35 + offset, y + 4, 0x939 );
|
||||
}
|
||||
else
|
||||
{
|
||||
AddImage( 35 + offset, y + 4, 0x938 );
|
||||
isAllReady = false;
|
||||
}
|
||||
string name = pl == null ? "(Empty)" : pl.Mobile.Name;
|
||||
|
||||
string name = ( pl == null ? "(Empty)" : pl.Mobile.Name );
|
||||
AddHtml(35 + offset + 14, y, 166, 20, name, false, false);
|
||||
|
||||
AddHtml( 35 + offset + 14, y, 166, 20, name, false, false );
|
||||
y += 22;
|
||||
}
|
||||
|
||||
y += 22;
|
||||
}
|
||||
if (p.Players.Length > 1)
|
||||
AddImage(35, yStore + 4, isAllReady ? 0x939 : 0x938);
|
||||
}
|
||||
}
|
||||
|
||||
if ( p.Players.Length > 1 )
|
||||
AddImage( 35, yStore + 4, isAllReady ? 0x939 : 0x938 );
|
||||
}
|
||||
}
|
||||
public string Center(string text)
|
||||
{
|
||||
return $"<CENTER>{text}</CENTER>";
|
||||
}
|
||||
|
||||
public override void OnResponse( NetState sender, RelayInfo info )
|
||||
{
|
||||
}
|
||||
}
|
||||
public override void OnResponse(NetState sender, RelayInfo info)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,233 +1,232 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using Server.Gumps;
|
||||
using Server.Network;
|
||||
using Server.Mobiles;
|
||||
using Server.Network;
|
||||
|
||||
namespace Server.Engines.ConPVP
|
||||
{
|
||||
public class ReadyUpGump : Gump
|
||||
{
|
||||
private Mobile m_From;
|
||||
private DuelContext m_Context;
|
||||
public class ReadyUpGump : Gump
|
||||
{
|
||||
private DuelContext m_Context;
|
||||
private Mobile m_From;
|
||||
|
||||
public string Center( string text )
|
||||
{
|
||||
return $"<CENTER>{text}</CENTER>";
|
||||
}
|
||||
public ReadyUpGump(Mobile from, DuelContext context) : base(50, 50)
|
||||
{
|
||||
m_From = from;
|
||||
m_Context = context;
|
||||
|
||||
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 );
|
||||
}
|
||||
Closable = false;
|
||||
AddPage(0);
|
||||
|
||||
public ReadyUpGump( Mobile from, DuelContext context ) : base( 50, 50 )
|
||||
{
|
||||
m_From = from;
|
||||
m_Context = context;
|
||||
if (context.Rematch)
|
||||
{
|
||||
int height = 25 + 20 + 10 + 22 + 25;
|
||||
|
||||
Closable = false;
|
||||
AddPage( 0 );
|
||||
AddBackground(0, 0, 210, height, 9250);
|
||||
AddBackground(10, 10, 190, height - 20, 0xDAC);
|
||||
|
||||
if ( context.Rematch )
|
||||
{
|
||||
int height = 25 + 20 + 10 + 22 + 25;
|
||||
AddHtml(35, 25, 140, 20, Center("Rematch?"), false, false);
|
||||
|
||||
AddBackground( 0, 0, 210, height, 9250 );
|
||||
AddBackground( 10, 10, 190, height - 20, 0xDAC );
|
||||
AddButton(35, 55, 247, 248, 1, GumpButtonType.Reply, 0);
|
||||
AddButton(115, 55, 242, 241, 2, GumpButtonType.Reply, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
#region Participants
|
||||
|
||||
AddHtml( 35, 25, 140, 20, Center( "Rematch?" ), false, false );
|
||||
AddPage(1);
|
||||
|
||||
AddButton( 35, 55, 247, 248, 1, GumpButtonType.Reply, 0 );
|
||||
AddButton( 115, 55, 242, 241, 2, GumpButtonType.Reply, 0 );
|
||||
}
|
||||
else
|
||||
{
|
||||
#region Participants
|
||||
AddPage( 1 );
|
||||
ArrayList parts = context.Participants;
|
||||
|
||||
ArrayList parts = context.Participants;
|
||||
int height = 25 + 20;
|
||||
|
||||
int height = 25 + 20;
|
||||
for (int i = 0; i < parts.Count; ++i)
|
||||
{
|
||||
Participant p = (Participant)parts[i];
|
||||
|
||||
for ( int i = 0; i < parts.Count; ++i )
|
||||
{
|
||||
Participant p = (Participant)parts[i];
|
||||
height += 4;
|
||||
|
||||
height += 4;
|
||||
if (p.Players.Length > 1)
|
||||
height += 22;
|
||||
|
||||
if ( p.Players.Length > 1 )
|
||||
height += 22;
|
||||
height += p.Players.Length * 22;
|
||||
}
|
||||
|
||||
height += (p.Players.Length * 22);
|
||||
}
|
||||
height += 10 + 22 + 25;
|
||||
|
||||
height += 10 + 22 + 25;
|
||||
AddBackground(0, 0, 260, height, 9250);
|
||||
AddBackground(10, 10, 240, height - 20, 0xDAC);
|
||||
|
||||
AddBackground( 0, 0, 260, height, 9250 );
|
||||
AddBackground( 10, 10, 240, height - 20, 0xDAC );
|
||||
AddHtml(35, 25, 190, 20, Center("Participants"), false, false);
|
||||
|
||||
AddHtml( 35, 25, 190, 20, Center( "Participants" ), false, false );
|
||||
int y = 20 + 25;
|
||||
|
||||
int y = 20 + 25;
|
||||
for (int i = 0; i < parts.Count; ++i)
|
||||
{
|
||||
Participant p = (Participant)parts[i];
|
||||
|
||||
for ( int i = 0; i < parts.Count; ++i )
|
||||
{
|
||||
Participant p = (Participant)parts[i];
|
||||
y += 4;
|
||||
|
||||
y += 4;
|
||||
int offset = 0;
|
||||
|
||||
int offset = 0;
|
||||
if (p.Players.Length > 1)
|
||||
{
|
||||
AddHtml(35, y, 176, 20, $"Team #{i + 1}", false, false);
|
||||
y += 22;
|
||||
offset = 10;
|
||||
}
|
||||
|
||||
if ( p.Players.Length > 1 )
|
||||
{
|
||||
AddHtml( 35, y, 176, 20, $"Team #{i + 1}", false, false );
|
||||
y += 22;
|
||||
offset = 10;
|
||||
}
|
||||
for (int j = 0; j < p.Players.Length; ++j)
|
||||
{
|
||||
DuelPlayer pl = p.Players[j];
|
||||
|
||||
for ( int j = 0; j < p.Players.Length; ++j )
|
||||
{
|
||||
DuelPlayer pl = p.Players[j];
|
||||
string name = pl == null ? "(Empty)" : pl.Mobile.Name;
|
||||
|
||||
string name = ( pl == null ? "(Empty)" : pl.Mobile.Name );
|
||||
AddHtml(35 + offset, y, 166, 20, name, false, false);
|
||||
|
||||
AddHtml( 35 + offset, y, 166, 20, name, false, false );
|
||||
y += 22;
|
||||
}
|
||||
}
|
||||
|
||||
y += 22;
|
||||
}
|
||||
}
|
||||
y += 8;
|
||||
|
||||
y += 8;
|
||||
AddHtml(35, y, 176, 20, "Continue?", false, false);
|
||||
|
||||
AddHtml( 35, y, 176, 20, "Continue?", false, false );
|
||||
y -= 2;
|
||||
|
||||
y -= 2;
|
||||
AddButton(102, y, 247, 248, 0, GumpButtonType.Page, 2);
|
||||
AddButton(169, y, 242, 241, 2, GumpButtonType.Reply, 0);
|
||||
|
||||
AddButton( 102, y, 247, 248, 0, GumpButtonType.Page, 2 );
|
||||
AddButton( 169, y, 242, 241, 2, GumpButtonType.Reply, 0 );
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Rules
|
||||
AddPage( 2 );
|
||||
#region Rules
|
||||
|
||||
Ruleset ruleset = context.Ruleset;
|
||||
Ruleset basedef = ruleset.Base;
|
||||
AddPage(2);
|
||||
|
||||
height = 25 + 20 + 5 + 20 + 20 + 4;
|
||||
Ruleset ruleset = context.Ruleset;
|
||||
Ruleset basedef = ruleset.Base;
|
||||
|
||||
int changes = 0;
|
||||
height = 25 + 20 + 5 + 20 + 20 + 4;
|
||||
|
||||
BitArray defs;
|
||||
int changes = 0;
|
||||
|
||||
if ( ruleset.Flavors.Count > 0 )
|
||||
{
|
||||
defs = new BitArray( basedef.Options );
|
||||
BitArray defs;
|
||||
|
||||
for ( int i = 0; i < ruleset.Flavors.Count; ++i )
|
||||
defs.Or( ((Ruleset)ruleset.Flavors[i]).Options );
|
||||
if (ruleset.Flavors.Count > 0)
|
||||
{
|
||||
defs = new BitArray(basedef.Options);
|
||||
|
||||
height += ruleset.Flavors.Count * 18;
|
||||
}
|
||||
else
|
||||
{
|
||||
defs = basedef.Options;
|
||||
}
|
||||
for (int i = 0; i < ruleset.Flavors.Count; ++i)
|
||||
defs.Or(((Ruleset)ruleset.Flavors[i]).Options);
|
||||
|
||||
BitArray opts = ruleset.Options;
|
||||
height += ruleset.Flavors.Count * 18;
|
||||
}
|
||||
else
|
||||
{
|
||||
defs = basedef.Options;
|
||||
}
|
||||
|
||||
for ( int i = 0; i < opts.Length; ++i )
|
||||
{
|
||||
if ( defs[i] != opts[i] )
|
||||
++changes;
|
||||
}
|
||||
BitArray opts = ruleset.Options;
|
||||
|
||||
height += (changes * 22);
|
||||
for (int i = 0; i < opts.Length; ++i)
|
||||
if (defs[i] != opts[i])
|
||||
++changes;
|
||||
|
||||
height += 10 + 22 + 25;
|
||||
height += changes * 22;
|
||||
|
||||
AddBackground( 0, 0, 260, height, 9250 );
|
||||
AddBackground( 10, 10, 240, height - 20, 0xDAC );
|
||||
height += 10 + 22 + 25;
|
||||
|
||||
AddHtml( 35, 25, 190, 20, Center( "Rules" ), false, false );
|
||||
AddBackground(0, 0, 260, height, 9250);
|
||||
AddBackground(10, 10, 240, height - 20, 0xDAC);
|
||||
|
||||
AddHtml( 35, 50, 190, 20, $"Set: {basedef.Title}", false, false );
|
||||
AddHtml(35, 25, 190, 20, Center("Rules"), false, false);
|
||||
|
||||
y = 70;
|
||||
AddHtml(35, 50, 190, 20, $"Set: {basedef.Title}", false, false);
|
||||
|
||||
for ( int i = 0; i < ruleset.Flavors.Count; ++i, y += 18 )
|
||||
AddHtml( 35, y, 190, 20, $" + {((Ruleset) ruleset.Flavors[i]).Title}", false, false );
|
||||
y = 70;
|
||||
|
||||
y += 4;
|
||||
for (int i = 0; i < ruleset.Flavors.Count; ++i, y += 18)
|
||||
AddHtml(35, y, 190, 20, $" + {((Ruleset)ruleset.Flavors[i]).Title}", false, false);
|
||||
|
||||
if ( changes > 0 )
|
||||
{
|
||||
AddHtml( 35, y, 190, 20, "Modifications:", false, false );
|
||||
y += 20;
|
||||
y += 4;
|
||||
|
||||
for ( int i = 0; i < opts.Length; ++i )
|
||||
{
|
||||
if ( defs[i] != opts[i] )
|
||||
{
|
||||
string name = ruleset.Layout.FindByIndex( i );
|
||||
if (changes > 0)
|
||||
{
|
||||
AddHtml(35, y, 190, 20, "Modifications:", false, false);
|
||||
y += 20;
|
||||
|
||||
if ( name != null ) // sanity
|
||||
{
|
||||
AddImage( 35, y, opts[i] ? 0xD3 : 0xD2 );
|
||||
AddHtml( 60, y, 165, 22, name, false, false );
|
||||
}
|
||||
for (int i = 0; i < opts.Length; ++i)
|
||||
if (defs[i] != opts[i])
|
||||
{
|
||||
string name = ruleset.Layout.FindByIndex(i);
|
||||
|
||||
y += 22;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
AddHtml( 35, y, 190, 20, "Modifications: None", false, false );
|
||||
y += 20;
|
||||
}
|
||||
if (name != null) // sanity
|
||||
{
|
||||
AddImage(35, y, opts[i] ? 0xD3 : 0xD2);
|
||||
AddHtml(60, y, 165, 22, name, false, false);
|
||||
}
|
||||
|
||||
y += 8;
|
||||
y += 22;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
AddHtml(35, y, 190, 20, "Modifications: None", false, false);
|
||||
y += 20;
|
||||
}
|
||||
|
||||
AddHtml( 35, y, 176, 20, "Continue?", false, false );
|
||||
y += 8;
|
||||
|
||||
y -= 2;
|
||||
AddHtml(35, y, 176, 20, "Continue?", false, false);
|
||||
|
||||
AddButton( 102, y, 247, 248, 1, GumpButtonType.Reply, 0 );
|
||||
AddButton( 169, y, 242, 241, 3, GumpButtonType.Reply, 0 );
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
y -= 2;
|
||||
|
||||
public override void OnResponse( NetState sender, RelayInfo info )
|
||||
{
|
||||
if ( !m_Context.Registered || !m_Context.ReadyWait )
|
||||
return;
|
||||
AddButton(102, y, 247, 248, 1, GumpButtonType.Reply, 0);
|
||||
AddButton(169, y, 242, 241, 3, GumpButtonType.Reply, 0);
|
||||
|
||||
switch ( info.ButtonID )
|
||||
{
|
||||
case 1: // okay
|
||||
{
|
||||
if ( !(m_From is PlayerMobile pm) )
|
||||
break;
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
pm.DuelPlayer.Ready = true;
|
||||
m_Context.SendReadyGump();
|
||||
public string Center(string text)
|
||||
{
|
||||
return $"<CENTER>{text}</CENTER>";
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case 2: // reject participants
|
||||
{
|
||||
m_Context.RejectReady( m_From, "participants" );
|
||||
break;
|
||||
}
|
||||
case 3: // reject rules
|
||||
{
|
||||
m_Context.RejectReady( m_From, "rules" );
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
public override void OnResponse(NetState sender, RelayInfo info)
|
||||
{
|
||||
if (!m_Context.Registered || !m_Context.ReadyWait)
|
||||
return;
|
||||
|
||||
switch (info.ButtonID)
|
||||
{
|
||||
case 1: // okay
|
||||
{
|
||||
if (!(m_From is PlayerMobile pm))
|
||||
break;
|
||||
|
||||
pm.DuelPlayer.Ready = true;
|
||||
m_Context.SendReadyGump();
|
||||
|
||||
break;
|
||||
}
|
||||
case 2: // reject participants
|
||||
{
|
||||
m_Context.RejectReady(m_From, "participants");
|
||||
break;
|
||||
}
|
||||
case 3: // reject rules
|
||||
{
|
||||
m_Context.RejectReady(m_From, "rules");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2,100 +2,100 @@ using System.Collections;
|
|||
|
||||
namespace Server.Engines.ConPVP
|
||||
{
|
||||
public class Ruleset
|
||||
{
|
||||
public RulesetLayout Layout { get; }
|
||||
public class Ruleset
|
||||
{
|
||||
public Ruleset(RulesetLayout layout)
|
||||
{
|
||||
Layout = layout;
|
||||
Options = new BitArray(layout.TotalLength);
|
||||
}
|
||||
|
||||
public BitArray Options { get; private set; }
|
||||
public RulesetLayout Layout{ get; }
|
||||
|
||||
public string Title { get; set; }
|
||||
public BitArray Options{ get; private set; }
|
||||
|
||||
public Ruleset Base { get; private set; }
|
||||
public string Title{ get; set; }
|
||||
|
||||
public ArrayList Flavors { get; } = new ArrayList();
|
||||
public Ruleset Base{ get; private set; }
|
||||
|
||||
public bool Changed { get; set; }
|
||||
public ArrayList Flavors{ get; } = new ArrayList();
|
||||
|
||||
public void ApplyDefault( Ruleset newDefault )
|
||||
{
|
||||
Base = newDefault;
|
||||
Changed = false;
|
||||
public bool Changed{ get; set; }
|
||||
|
||||
Options = new BitArray( newDefault.Options );
|
||||
public void ApplyDefault(Ruleset newDefault)
|
||||
{
|
||||
Base = newDefault;
|
||||
Changed = false;
|
||||
|
||||
ApplyFlavorsTo( this );
|
||||
}
|
||||
Options = new BitArray(newDefault.Options);
|
||||
|
||||
public void ApplyFlavorsTo( Ruleset ruleset )
|
||||
{
|
||||
for ( int i = 0; i < Flavors.Count; ++i )
|
||||
{
|
||||
Ruleset flavor = (Ruleset)Flavors[i];
|
||||
ApplyFlavorsTo(this);
|
||||
}
|
||||
|
||||
Options.Or( flavor.Options );
|
||||
}
|
||||
}
|
||||
public void ApplyFlavorsTo(Ruleset ruleset)
|
||||
{
|
||||
for (int i = 0; i < Flavors.Count; ++i)
|
||||
{
|
||||
Ruleset flavor = (Ruleset)Flavors[i];
|
||||
|
||||
public void AddFlavor( Ruleset flavor )
|
||||
{
|
||||
if ( Flavors.Contains( flavor ) )
|
||||
return;
|
||||
Options.Or(flavor.Options);
|
||||
}
|
||||
}
|
||||
|
||||
Flavors.Add( flavor );
|
||||
Options.Or( flavor.Options );
|
||||
}
|
||||
public void AddFlavor(Ruleset flavor)
|
||||
{
|
||||
if (Flavors.Contains(flavor))
|
||||
return;
|
||||
|
||||
public void RemoveFlavor( Ruleset flavor )
|
||||
{
|
||||
if ( !Flavors.Contains( flavor ) )
|
||||
return;
|
||||
Flavors.Add(flavor);
|
||||
Options.Or(flavor.Options);
|
||||
}
|
||||
|
||||
Flavors.Remove( flavor );
|
||||
Options.And( flavor.Options.Not() );
|
||||
flavor.Options.Not();
|
||||
}
|
||||
public void RemoveFlavor(Ruleset flavor)
|
||||
{
|
||||
if (!Flavors.Contains(flavor))
|
||||
return;
|
||||
|
||||
public void SetOptionRange( string title, bool value )
|
||||
{
|
||||
RulesetLayout layout = Layout.FindByTitle( title );
|
||||
Flavors.Remove(flavor);
|
||||
Options.And(flavor.Options.Not());
|
||||
flavor.Options.Not();
|
||||
}
|
||||
|
||||
if ( layout == null )
|
||||
return;
|
||||
public void SetOptionRange(string title, bool value)
|
||||
{
|
||||
RulesetLayout layout = Layout.FindByTitle(title);
|
||||
|
||||
for ( int i = 0; i < layout.TotalLength; ++i )
|
||||
Options[i + layout.Offset] = value;
|
||||
if (layout == null)
|
||||
return;
|
||||
|
||||
Changed = true;
|
||||
}
|
||||
for (int i = 0; i < layout.TotalLength; ++i)
|
||||
Options[i + layout.Offset] = value;
|
||||
|
||||
public bool GetOption( string title, string option )
|
||||
{
|
||||
int index = 0;
|
||||
RulesetLayout layout = Layout.FindByOption( title, option, ref index );
|
||||
Changed = true;
|
||||
}
|
||||
|
||||
if ( layout == null )
|
||||
return true;
|
||||
public bool GetOption(string title, string option)
|
||||
{
|
||||
int index = 0;
|
||||
RulesetLayout layout = Layout.FindByOption(title, option, ref index);
|
||||
|
||||
return Options[layout.Offset + index];
|
||||
}
|
||||
if (layout == null)
|
||||
return true;
|
||||
|
||||
public void SetOption( string title, string option, bool value )
|
||||
{
|
||||
int index = 0;
|
||||
RulesetLayout layout = Layout.FindByOption( title, option, ref index );
|
||||
return Options[layout.Offset + index];
|
||||
}
|
||||
|
||||
if ( layout == null )
|
||||
return;
|
||||
public void SetOption(string title, string option, bool value)
|
||||
{
|
||||
int index = 0;
|
||||
RulesetLayout layout = Layout.FindByOption(title, option, ref index);
|
||||
|
||||
Options[layout.Offset + index] = value;
|
||||
if (layout == null)
|
||||
return;
|
||||
|
||||
Changed = true;
|
||||
}
|
||||
Options[layout.Offset + index] = value;
|
||||
|
||||
public Ruleset( RulesetLayout layout )
|
||||
{
|
||||
Layout = layout;
|
||||
Options = new BitArray( layout.TotalLength );
|
||||
}
|
||||
}
|
||||
Changed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,136 +1,135 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using Server.Gumps;
|
||||
using Server.Network;
|
||||
|
||||
namespace Server.Engines.ConPVP
|
||||
{
|
||||
public class RulesetGump : Gump
|
||||
{
|
||||
private Mobile m_From;
|
||||
private Ruleset m_Ruleset;
|
||||
private RulesetLayout m_Page;
|
||||
private DuelContext m_DuelContext;
|
||||
private bool m_ReadOnly;
|
||||
public class RulesetGump : Gump
|
||||
{
|
||||
private DuelContext m_DuelContext;
|
||||
private Mobile m_From;
|
||||
private RulesetLayout m_Page;
|
||||
private bool m_ReadOnly;
|
||||
private Ruleset m_Ruleset;
|
||||
|
||||
public string Center( string text )
|
||||
{
|
||||
return $"<CENTER>{text}</CENTER>";
|
||||
}
|
||||
public RulesetGump(Mobile from, Ruleset ruleset, RulesetLayout page, DuelContext duelContext) : this(from, ruleset,
|
||||
page, duelContext, false)
|
||||
{
|
||||
}
|
||||
|
||||
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 );
|
||||
}
|
||||
public RulesetGump(Mobile from, Ruleset ruleset, RulesetLayout page, DuelContext duelContext, bool readOnly) : base(
|
||||
readOnly ? 310 : 50, 50)
|
||||
{
|
||||
m_From = from;
|
||||
m_Ruleset = ruleset;
|
||||
m_Page = page;
|
||||
m_DuelContext = duelContext;
|
||||
m_ReadOnly = readOnly;
|
||||
|
||||
public RulesetGump( Mobile from, Ruleset ruleset, RulesetLayout page, DuelContext duelContext ) : this( from, ruleset, page, duelContext, false )
|
||||
{
|
||||
}
|
||||
Dragable = !readOnly;
|
||||
|
||||
public RulesetGump( Mobile from, Ruleset ruleset, RulesetLayout page, DuelContext duelContext, bool readOnly ) : base( readOnly ? 310 : 50, 50 )
|
||||
{
|
||||
m_From = from;
|
||||
m_Ruleset = ruleset;
|
||||
m_Page = page;
|
||||
m_DuelContext = duelContext;
|
||||
m_ReadOnly = readOnly;
|
||||
from.CloseGump(typeof(RulesetGump));
|
||||
from.CloseGump(typeof(DuelContextGump));
|
||||
from.CloseGump(typeof(ParticipantGump));
|
||||
|
||||
Dragable = !readOnly;
|
||||
RulesetLayout depthCounter = page;
|
||||
int depth = 0;
|
||||
|
||||
from.CloseGump( typeof( RulesetGump ) );
|
||||
from.CloseGump( typeof( DuelContextGump ) );
|
||||
from.CloseGump( typeof( ParticipantGump ) );
|
||||
while (depthCounter != null)
|
||||
{
|
||||
++depth;
|
||||
depthCounter = depthCounter.Parent;
|
||||
}
|
||||
|
||||
RulesetLayout depthCounter = page;
|
||||
int depth = 0;
|
||||
int count = page.Children.Length + page.Options.Length;
|
||||
|
||||
while ( depthCounter != null )
|
||||
{
|
||||
++depth;
|
||||
depthCounter = depthCounter.Parent;
|
||||
}
|
||||
AddPage(0);
|
||||
|
||||
int count = page.Children.Length + page.Options.Length;
|
||||
int height = 35 + 10 + 2 + count * 22 + 2 + 30;
|
||||
|
||||
AddPage( 0 );
|
||||
AddBackground(0, 0, 260, height, 9250);
|
||||
AddBackground(10, 10, 240, height - 20, 0xDAC);
|
||||
|
||||
int height = 35 + 10 + 2 + (count * 22) + 2 + 30;
|
||||
AddHtml(35, 25, 190, 20, Center(page.Title), false, false);
|
||||
|
||||
AddBackground( 0, 0, 260, height, 9250 );
|
||||
AddBackground( 10, 10, 240, height - 20, 0xDAC );
|
||||
int x = 35;
|
||||
int y = 47;
|
||||
|
||||
AddHtml( 35, 25, 190, 20, Center( page.Title ), false, false );
|
||||
for (int i = 0; i < page.Children.Length; ++i)
|
||||
{
|
||||
AddGoldenButton(x, y, 1 + i);
|
||||
AddHtml(x + 25, y, 250, 22, page.Children[i].Title, false, false);
|
||||
|
||||
int x = 35;
|
||||
int y = 47;
|
||||
y += 22;
|
||||
}
|
||||
|
||||
for ( int i = 0; i < page.Children.Length; ++i )
|
||||
{
|
||||
AddGoldenButton( x, y, 1 + i );
|
||||
AddHtml( x + 25, y, 250, 22, page.Children[i].Title, false, false );
|
||||
for (int i = 0; i < page.Options.Length; ++i)
|
||||
{
|
||||
bool enabled = ruleset.Options[page.Offset + i];
|
||||
|
||||
y += 22;
|
||||
}
|
||||
if (readOnly)
|
||||
AddImage(x, y, enabled ? 0xD3 : 0xD2);
|
||||
else
|
||||
AddCheck(x, y, 0xD2, 0xD3, enabled, i);
|
||||
|
||||
for ( int i = 0; i < page.Options.Length; ++i )
|
||||
{
|
||||
bool enabled = ruleset.Options[page.Offset + i];
|
||||
AddHtml(x + 25, y, 250, 22, page.Options[i], false, false);
|
||||
|
||||
if ( readOnly )
|
||||
AddImage( x, y, enabled ? 0xD3 : 0xD2 );
|
||||
else
|
||||
AddCheck( x, y, 0xD2, 0xD3, enabled, i );
|
||||
y += 22;
|
||||
}
|
||||
}
|
||||
|
||||
AddHtml( x + 25, y, 250, 22, page.Options[i], false, false );
|
||||
public string Center(string text)
|
||||
{
|
||||
return $"<CENTER>{text}</CENTER>";
|
||||
}
|
||||
|
||||
y += 22;
|
||||
}
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
public override void OnResponse( NetState sender, RelayInfo info )
|
||||
{
|
||||
if ( m_DuelContext != null && !m_DuelContext.Registered )
|
||||
return;
|
||||
public override void OnResponse(NetState sender, RelayInfo info)
|
||||
{
|
||||
if (m_DuelContext != null && !m_DuelContext.Registered)
|
||||
return;
|
||||
|
||||
if ( !m_ReadOnly )
|
||||
{
|
||||
BitArray opts = new BitArray( m_Page.Options.Length );
|
||||
if (!m_ReadOnly)
|
||||
{
|
||||
BitArray opts = new BitArray(m_Page.Options.Length);
|
||||
|
||||
for ( int i = 0; i < info.Switches.Length; ++i )
|
||||
{
|
||||
int sid = info.Switches[i];
|
||||
for (int i = 0; i < info.Switches.Length; ++i)
|
||||
{
|
||||
int sid = info.Switches[i];
|
||||
|
||||
if ( sid >= 0 && sid < m_Page.Options.Length )
|
||||
opts[sid] = true;
|
||||
}
|
||||
if (sid >= 0 && sid < m_Page.Options.Length)
|
||||
opts[sid] = true;
|
||||
}
|
||||
|
||||
for ( int i = 0; i < opts.Length; ++i )
|
||||
{
|
||||
if ( m_Ruleset.Options[m_Page.Offset + i] != opts[i] )
|
||||
{
|
||||
m_Ruleset.Options[m_Page.Offset + i] = opts[i];
|
||||
m_Ruleset.Changed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < opts.Length; ++i)
|
||||
if (m_Ruleset.Options[m_Page.Offset + i] != opts[i])
|
||||
{
|
||||
m_Ruleset.Options[m_Page.Offset + i] = opts[i];
|
||||
m_Ruleset.Changed = true;
|
||||
}
|
||||
}
|
||||
|
||||
int bid = info.ButtonID;
|
||||
int bid = info.ButtonID;
|
||||
|
||||
if ( bid == 0 )
|
||||
{
|
||||
if ( m_Page.Parent != null )
|
||||
m_From.SendGump( new RulesetGump( m_From, m_Ruleset, m_Page.Parent, m_DuelContext, m_ReadOnly ) );
|
||||
else if ( !m_ReadOnly )
|
||||
m_From.SendGump( new PickRulesetGump( m_From, m_DuelContext, m_Ruleset ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
bid -= 1;
|
||||
if (bid == 0)
|
||||
{
|
||||
if (m_Page.Parent != null)
|
||||
m_From.SendGump(new RulesetGump(m_From, m_Ruleset, m_Page.Parent, m_DuelContext, m_ReadOnly));
|
||||
else if (!m_ReadOnly)
|
||||
m_From.SendGump(new PickRulesetGump(m_From, m_DuelContext, m_Ruleset));
|
||||
}
|
||||
else
|
||||
{
|
||||
bid -= 1;
|
||||
|
||||
if ( bid >= 0 && bid < m_Page.Children.Length )
|
||||
m_From.SendGump( new RulesetGump( m_From, m_Ruleset, m_Page.Children[bid], m_DuelContext, m_ReadOnly ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
if (bid >= 0 && bid < m_Page.Children.Length)
|
||||
m_From.SendGump(new RulesetGump(m_From, m_Ruleset, m_Page.Children[bid], m_DuelContext, m_ReadOnly));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,69 +1,70 @@
|
|||
using Server.Factions;
|
||||
using Server.Mobiles;
|
||||
using Server.Regions;
|
||||
|
||||
namespace Server.Engines.ConPVP
|
||||
{
|
||||
public class SafeZone : GuardedRegion
|
||||
{
|
||||
public static readonly int SafeZonePriority = HouseRegion.HousePriority + 1;
|
||||
public class SafeZone : GuardedRegion
|
||||
{
|
||||
public static readonly int SafeZonePriority = HouseRegion.HousePriority + 1;
|
||||
|
||||
/*public override bool AllowReds => true;*/
|
||||
/*public override bool AllowReds => true;*/
|
||||
|
||||
public SafeZone( Rectangle2D area, Point3D goloc, Map map, bool isGuarded ) : base( null, map, SafeZonePriority, area )
|
||||
{
|
||||
GoLocation = goloc;
|
||||
public SafeZone(Rectangle2D area, Point3D goloc, Map map, bool isGuarded) : base(null, map, SafeZonePriority, area)
|
||||
{
|
||||
GoLocation = goloc;
|
||||
|
||||
Disabled = !isGuarded;
|
||||
Disabled = !isGuarded;
|
||||
|
||||
Register();
|
||||
}
|
||||
Register();
|
||||
}
|
||||
|
||||
public override bool AllowHousing( Mobile from, Point3D p )
|
||||
{
|
||||
if ( from.AccessLevel < AccessLevel.GameMaster )
|
||||
return false;
|
||||
public override bool AllowHousing(Mobile from, Point3D p)
|
||||
{
|
||||
if (from.AccessLevel < AccessLevel.GameMaster)
|
||||
return false;
|
||||
|
||||
return base.AllowHousing( from, p );
|
||||
}
|
||||
return base.AllowHousing(from, p);
|
||||
}
|
||||
|
||||
public override bool OnMoveInto( Mobile m, Direction d, Point3D newLocation, Point3D oldLocation )
|
||||
{
|
||||
if ( m.Player && Factions.Sigil.ExistsOn( m ) )
|
||||
{
|
||||
m.SendMessage( 0x22, "You are holding a sigil and cannot enter this zone." );
|
||||
return false;
|
||||
}
|
||||
public override bool OnMoveInto(Mobile m, Direction d, Point3D newLocation, Point3D oldLocation)
|
||||
{
|
||||
if (m.Player && Sigil.ExistsOn(m))
|
||||
{
|
||||
m.SendMessage(0x22, "You are holding a sigil and cannot enter this zone.");
|
||||
return false;
|
||||
}
|
||||
|
||||
PlayerMobile pm = m as PlayerMobile;
|
||||
PlayerMobile pm = m as PlayerMobile;
|
||||
|
||||
if ( pm == null && m is BaseCreature bc && bc.Summoned )
|
||||
pm = bc.SummonMaster as PlayerMobile;
|
||||
if (pm == null && m is BaseCreature bc && bc.Summoned)
|
||||
pm = bc.SummonMaster as PlayerMobile;
|
||||
|
||||
if ( pm?.DuelContext != null && pm.DuelContext.StartedBeginCountdown )
|
||||
return true;
|
||||
if (pm?.DuelContext != null && pm.DuelContext.StartedBeginCountdown)
|
||||
return true;
|
||||
|
||||
if ( DuelContext.CheckCombat( m ) )
|
||||
{
|
||||
m.SendMessage( 0x22, "You have recently been in combat and cannot enter this zone." );
|
||||
return false;
|
||||
}
|
||||
if (DuelContext.CheckCombat(m))
|
||||
{
|
||||
m.SendMessage(0x22, "You have recently been in combat and cannot enter this zone.");
|
||||
return false;
|
||||
}
|
||||
|
||||
return base.OnMoveInto( m, d, newLocation, oldLocation );
|
||||
}
|
||||
return base.OnMoveInto(m, d, newLocation, oldLocation);
|
||||
}
|
||||
|
||||
public override void OnEnter( Mobile m )
|
||||
{
|
||||
m.SendMessage( "You have entered a dueling safezone. No combat other than duels are allowed in this zone." );
|
||||
}
|
||||
public override void OnEnter(Mobile m)
|
||||
{
|
||||
m.SendMessage("You have entered a dueling safezone. No combat other than duels are allowed in this zone.");
|
||||
}
|
||||
|
||||
public override void OnExit( Mobile m )
|
||||
{
|
||||
m.SendMessage( "You have left a dueling safezone. Combat is now unrestricted." );
|
||||
}
|
||||
public override void OnExit(Mobile m)
|
||||
{
|
||||
m.SendMessage("You have left a dueling safezone. Combat is now unrestricted.");
|
||||
}
|
||||
|
||||
public override bool CanUseStuckMenu( Mobile m )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
public override bool CanUseStuckMenu(Mobile m)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -2,105 +2,118 @@ using System;
|
|||
|
||||
namespace Server.Items
|
||||
{
|
||||
public enum TrophyRank
|
||||
{
|
||||
Bronze,
|
||||
Silver,
|
||||
Gold
|
||||
}
|
||||
public enum TrophyRank
|
||||
{
|
||||
Bronze,
|
||||
Silver,
|
||||
Gold
|
||||
}
|
||||
|
||||
[Flippable( 5020, 4647 )]
|
||||
public class Trophy : Item
|
||||
{
|
||||
private TrophyRank m_Rank;
|
||||
[Flippable(5020, 4647)]
|
||||
public class Trophy : Item
|
||||
{
|
||||
private TrophyRank m_Rank;
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster )]
|
||||
public string Title { get; set; }
|
||||
[Constructible]
|
||||
public Trophy(string title, TrophyRank rank) : base(5020)
|
||||
{
|
||||
Title = title;
|
||||
m_Rank = rank;
|
||||
Date = DateTime.UtcNow;
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster )]
|
||||
public TrophyRank Rank{ get => m_Rank;
|
||||
set{ m_Rank = value; UpdateStyle(); } }
|
||||
LootType = LootType.Blessed;
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster )]
|
||||
public Mobile Owner { get; set; }
|
||||
UpdateStyle();
|
||||
}
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster )]
|
||||
public DateTime Date { get; private set; }
|
||||
public Trophy(Serial serial) : base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
[Constructible]
|
||||
public Trophy( string title, TrophyRank rank ) : base( 5020 )
|
||||
{
|
||||
Title = title;
|
||||
m_Rank = rank;
|
||||
Date = DateTime.UtcNow;
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public string Title{ get; set; }
|
||||
|
||||
LootType = LootType.Blessed;
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public TrophyRank Rank
|
||||
{
|
||||
get => m_Rank;
|
||||
set
|
||||
{
|
||||
m_Rank = value;
|
||||
UpdateStyle();
|
||||
}
|
||||
}
|
||||
|
||||
UpdateStyle();
|
||||
}
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public Mobile Owner{ get; set; }
|
||||
|
||||
public Trophy( Serial serial ) : base( serial )
|
||||
{
|
||||
}
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public DateTime Date{ get; private set; }
|
||||
|
||||
public override void Serialize( GenericWriter writer )
|
||||
{
|
||||
base.Serialize( writer );
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write( (int) 1 ); // version
|
||||
writer.Write(1); // version
|
||||
|
||||
writer.Write( (string) Title );
|
||||
writer.Write( (int) m_Rank );
|
||||
writer.Write( (Mobile) Owner );
|
||||
writer.Write( (DateTime) Date );
|
||||
}
|
||||
writer.Write(Title);
|
||||
writer.Write((int)m_Rank);
|
||||
writer.Write(Owner);
|
||||
writer.Write(Date);
|
||||
}
|
||||
|
||||
public override void Deserialize( GenericReader reader )
|
||||
{
|
||||
base.Deserialize( reader );
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
int version = reader.ReadInt();
|
||||
int version = reader.ReadInt();
|
||||
|
||||
Title = reader.ReadString();
|
||||
m_Rank = (TrophyRank) reader.ReadInt();
|
||||
Owner = reader.ReadMobile();
|
||||
Date = reader.ReadDateTime();
|
||||
Title = reader.ReadString();
|
||||
m_Rank = (TrophyRank)reader.ReadInt();
|
||||
Owner = reader.ReadMobile();
|
||||
Date = reader.ReadDateTime();
|
||||
|
||||
if ( version == 0 )
|
||||
LootType = LootType.Blessed;
|
||||
}
|
||||
if (version == 0)
|
||||
LootType = LootType.Blessed;
|
||||
}
|
||||
|
||||
public override void OnAdded(IEntity parent)
|
||||
{
|
||||
base.OnAdded( parent );
|
||||
public override void OnAdded(IEntity parent)
|
||||
{
|
||||
base.OnAdded(parent);
|
||||
|
||||
if ( Owner == null )
|
||||
Owner = RootParent as Mobile;
|
||||
}
|
||||
if (Owner == null)
|
||||
Owner = RootParent as Mobile;
|
||||
}
|
||||
|
||||
public override void OnSingleClick( Mobile from )
|
||||
{
|
||||
base.OnSingleClick( from );
|
||||
public override void OnSingleClick(Mobile from)
|
||||
{
|
||||
base.OnSingleClick(from);
|
||||
|
||||
if ( Owner != null )
|
||||
LabelTo( from, "{0} -- {1}", Title, Owner.RawName );
|
||||
else if ( Title != null )
|
||||
LabelTo( from, Title );
|
||||
if (Owner != null)
|
||||
LabelTo(from, "{0} -- {1}", Title, Owner.RawName);
|
||||
else if (Title != null)
|
||||
LabelTo(from, Title);
|
||||
|
||||
if ( Date != DateTime.MinValue )
|
||||
LabelTo( from, Date.ToString( "d" ) );
|
||||
}
|
||||
if (Date != DateTime.MinValue)
|
||||
LabelTo(from, Date.ToString("d"));
|
||||
}
|
||||
|
||||
public void UpdateStyle()
|
||||
{
|
||||
Name = $"{m_Rank.ToString().ToLower()} trophy";
|
||||
public void UpdateStyle()
|
||||
{
|
||||
Name = $"{m_Rank.ToString().ToLower()} trophy";
|
||||
|
||||
switch ( m_Rank )
|
||||
{
|
||||
case TrophyRank.Gold: Hue = 2213; break;
|
||||
case TrophyRank.Silver: Hue = 0; break;
|
||||
case TrophyRank.Bronze: Hue = 2206; break;
|
||||
}
|
||||
}
|
||||
}
|
||||
switch (m_Rank)
|
||||
{
|
||||
case TrophyRank.Gold:
|
||||
Hue = 2213;
|
||||
break;
|
||||
case TrophyRank.Silver:
|
||||
Hue = 0;
|
||||
break;
|
||||
case TrophyRank.Bronze:
|
||||
Hue = 2206;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue