Formatting FIxes (#58)

This commit is contained in:
Kamron Batman 2019-10-04 23:08:13 -07:00 committed by GitHub
parent 57fb9fb525
commit 096d39609e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
1318 changed files with 11633 additions and 22129 deletions

View file

@ -92,15 +92,9 @@ namespace Server.Engines.ConPVP
Timer.DelayCall(TimeSpan.FromSeconds(15.0), AutoReject);
}
public string Center(string text)
{
return $"<CENTER>{text}</CENTER>";
}
public string Center(string text) => $"<CENTER>{text}</CENTER>";
public string Color(string text, int color)
{
return $"<BASEFONT COLOR=#{color:X6}>{text}</BASEFONT>";
}
public string Color(string text, int color) => $"<BASEFONT COLOR=#{color:X6}>{text}</BASEFONT>";
public void AutoReject()
{

View file

@ -86,10 +86,7 @@ namespace Server.Engines.ConPVP
[PropertyObject]
public class ArenaStartPoints
{
public ArenaStartPoints(Point3D[] points = null)
{
Points = points ?? new Point3D[8];
}
public ArenaStartPoints(Point3D[] points = null) => Points = points ?? new Point3D[8];
public ArenaStartPoints(GenericReader reader)
{
@ -157,10 +154,7 @@ namespace Server.Engines.ConPVP
set => Points[7] = value;
}
public override string ToString()
{
return "...";
}
public override string ToString() => "...";
public void Serialize(GenericWriter writer)
{
@ -471,10 +465,7 @@ namespace Server.Engines.ConPVP
return a.CompareTo(b);
}
public Ladder AcquireLadder()
{
return Ladder?.Ladder ?? ConPVP.Ladder.Instance;
}
public Ladder AcquireLadder() => Ladder?.Ladder ?? ConPVP.Ladder.Instance;
public void Delete()
{
@ -483,10 +474,7 @@ namespace Server.Engines.ConPVP
m_Region = null;
}
public override string ToString()
{
return "...";
}
public override string ToString() => "...";
public Point3D GetBaseStartPoint(int index)
{
@ -754,10 +742,7 @@ namespace Server.Engines.ConPVP
public int m_VotesAgainst;
public int m_VotesFor;
public ArenaEntry(Arena arena)
{
m_Arena = arena;
}
public ArenaEntry(Arena arena) => m_Arena = arena;
public int Value => m_VotesFor;
}

View file

@ -117,11 +117,7 @@ namespace Server.Engines.ConPVP
Timer.DelayCall(ts, () => DelayBounce_Callback(mob, corpse));
}
public static bool AllowSpecialMove(Mobile from, string name, SpecialMove move)
{
// No DuelContext, or InstaAllowSpecialMove
return (from as PlayerMobile)?.DuelContext?.InstAllowSpecialMove(from, name, move) != false;
}
public static bool AllowSpecialMove(Mobile from, string name, SpecialMove move) => (from as PlayerMobile)?.DuelContext?.InstAllowSpecialMove(from, name, move) != false;
public bool InstAllowSpecialMove(Mobile from, string name, SpecialMove move)
{
@ -958,10 +954,7 @@ namespace Server.Engines.ConPVP
m_SDWarnTimer = null;
}
public static bool CheckSuddenDeath(Mobile mob)
{
return mob is PlayerMobile pm && pm.DuelPlayer?.Eliminated == false && pm.DuelContext?.IsSuddenDeath == true;
}
public static bool CheckSuddenDeath(Mobile mob) => mob is PlayerMobile pm && pm.DuelPlayer?.Eliminated == false && pm.DuelContext?.IsSuddenDeath == true;
public void ActivateSuddenDeath()
{
@ -2204,10 +2197,7 @@ namespace Server.Engines.ConPVP
private class InternalWall : Item
{
public InternalWall() : base(0x80)
{
Movable = false;
}
public InternalWall() : base(0x80) => Movable = false;
public InternalWall(Serial serial) : base(serial)
{

View file

@ -918,10 +918,8 @@ namespace Server.Engines.ConPVP
[Constructible]
public BRBoard()
: base(7774)
{
: base(7774) =>
Movable = false;
}
public BRBoard(Serial serial)
: base(serial)
@ -1088,15 +1086,9 @@ namespace Server.Engines.ConPVP
AddButton(314, height - 42, 247, 248, 1);
}
public string Center(string text)
{
return $"<CENTER>{text}</CENTER>";
}
public string Center(string text) => $"<CENTER>{text}</CENTER>";
public string Color(string text, int color)
{
return $"<BASEFONT COLOR=#{color:X6}>{text}</BASEFONT>";
}
public string Color(string text, int color) => $"<BASEFONT COLOR=#{color:X6}>{text}</BASEFONT>";
private void AddBorderedText(int x, int y, int width, int height, string text, int color, int borderColor)
{
@ -1362,15 +1354,9 @@ namespace Server.Engines.ConPVP
public override string Title => "Bombing Run";
public override string DefaultName => "Bombing Run Controller";
public override string GetTeamName(int teamID)
{
return TeamInfo[teamID % TeamInfo.Length].Name;
}
public override string GetTeamName(int teamID) => TeamInfo[teamID % TeamInfo.Length].Name;
public override EventGame Construct(DuelContext context)
{
return new BRGame(this, context);
}
public override EventGame Construct(DuelContext context) => new BRGame(this, context);
public override void Serialize(GenericWriter writer)
{
@ -1421,10 +1407,7 @@ namespace Server.Engines.ConPVP
private TimerCallback m_UnhideCallback;
public BRGame(BRController controller, DuelContext context) : base(context)
{
Controller = controller;
}
public BRGame(BRController controller, DuelContext context) : base(context) => Controller = controller;
public BRController Controller{ get; }
@ -1439,10 +1422,7 @@ namespace Server.Engines.ConPVP
}
}
public override bool CantDoAnything(Mobile mob)
{
return mob.Backpack?.FindItemByType<BRBomb>() != null && GetTeamInfo(mob) != null;
}
public override bool CantDoAnything(Mobile mob) => mob.Backpack?.FindItemByType<BRBomb>() != null && GetTeamInfo(mob) != null;
public void ReturnBomb()
{
@ -1508,10 +1488,7 @@ namespace Server.Engines.ConPVP
return pm.DuelContext.Participants.IndexOf(pm.DuelPlayer.Participant);
}
public int GetColor(Mobile mob)
{
return GetTeamInfo(mob)?.Color ?? -1;
}
public int GetColor(Mobile mob) => GetTeamInfo(mob)?.Color ?? -1;
private void ApplyHues(Participant p, int hueOverride)
{

View file

@ -15,10 +15,8 @@ namespace Server.Engines.ConPVP
[Constructible]
public CTFBoard()
: base(7774)
{
: base(7774) =>
Movable = false;
}
public CTFBoard(Serial serial)
: base(serial)
@ -181,15 +179,9 @@ namespace Server.Engines.ConPVP
AddButton(314, height - 42, 247, 248, 1);
}
public string Center(string text)
{
return $"<CENTER>{text}</CENTER>";
}
public string Center(string text) => $"<CENTER>{text}</CENTER>";
public string Color(string text, int color)
{
return $"<BASEFONT COLOR=#{color:X6}>{text}</BASEFONT>";
}
public string Color(string text, int color) => $"<BASEFONT COLOR=#{color:X6}>{text}</BASEFONT>";
private void AddBorderedText(int x, int y, int width, int height, string text, int color, int borderColor)
{
@ -223,10 +215,8 @@ namespace Server.Engines.ConPVP
[Constructible]
public CTFFlag()
: base(5643)
{
: base(5643) =>
Movable = false;
}
public CTFFlag(Serial serial)
: base(serial)
@ -684,10 +674,7 @@ namespace Server.Engines.ConPVP
op.Write(Origin);
}
public override string ToString()
{
return "...";
}
public override string ToString() => "...";
}
public sealed class CTFController : EventController
@ -742,15 +729,9 @@ namespace Server.Engines.ConPVP
public override string Title => "CTF";
public override string GetTeamName(int teamID)
{
return TeamInfo[teamID % TeamInfo.Length].Name;
}
public override string GetTeamName(int teamID) => TeamInfo[teamID % TeamInfo.Length].Name;
public override EventGame Construct(DuelContext context)
{
return new CTFGame(this, context);
}
public override EventGame Construct(DuelContext context) => new CTFGame(this, context);
public override void Serialize(GenericWriter writer)
{
@ -809,10 +790,7 @@ namespace Server.Engines.ConPVP
{
private Timer m_FinishTimer;
public CTFGame(CTFController controller, DuelContext context) : base(context)
{
Controller = controller;
}
public CTFGame(CTFController controller, DuelContext context) : base(context) => Controller = controller;
public CTFController Controller{ get; }

View file

@ -13,10 +13,8 @@ namespace Server.Engines.ConPVP
[Constructible]
public DDBoard()
: base(7774)
{
: base(7774) =>
Movable = false;
}
public DDBoard(Serial serial)
: base(serial)
@ -177,15 +175,9 @@ namespace Server.Engines.ConPVP
AddButton(314, height - 42, 247, 248, 1);
}
public string Center(string text)
{
return $"<CENTER>{text}</CENTER>";
}
public string Center(string text) => $"<CENTER>{text}</CENTER>";
public string Color(string text, int color)
{
return $"<BASEFONT COLOR=#{color:X6}>{text}</BASEFONT>";
}
public string Color(string text, int color) => $"<BASEFONT COLOR=#{color:X6}>{text}</BASEFONT>";
private void AddBorderedText(int x, int y, int width, int height, string text, int color, int borderColor)
{
@ -354,10 +346,7 @@ namespace Server.Engines.ConPVP
op.Write(Origin);
}
public override string ToString()
{
return "...";
}
public override string ToString() => "...";
}
public sealed class DDController : EventController
@ -402,15 +391,9 @@ namespace Server.Engines.ConPVP
public override string DefaultName => "DD Controller";
public override string GetTeamName(int teamID)
{
return TeamInfo[teamID % TeamInfo.Length].Name;
}
public override string GetTeamName(int teamID) => TeamInfo[teamID % TeamInfo.Length].Name;
public override EventGame Construct(DuelContext context)
{
return new DDGame(this, context);
}
public override EventGame Construct(DuelContext context) => new DDGame(this, context);
public override void Serialize(GenericWriter writer)
{
@ -464,10 +447,7 @@ namespace Server.Engines.ConPVP
private Timer m_FinishTimer;
private Timer m_UncaptureTimer;
public DDGame(DDController controller, DuelContext context) : base(context)
{
Controller = controller;
}
public DDGame(DDController controller, DuelContext context) : base(context) => Controller = controller;
public DDController Controller{ get; }
@ -525,10 +505,7 @@ namespace Server.Engines.ConPVP
return pm.DuelContext.Participants.IndexOf(pm.DuelPlayer.Participant);
}
public int GetColor(Mobile mob)
{
return GetTeamInfo(mob)?.Color ?? -1;
}
public int GetColor(Mobile mob) => GetTeamInfo(mob)?.Color ?? -1;
private void ApplyHues(Participant p, int hueOverride)
{
@ -1077,10 +1054,7 @@ namespace Server.Engines.ConPVP
public class DDStep : AddonComponent
{
public DDStep(int itemID) : base(itemID)
{
Visible = true;
}
public DDStep(int itemID) : base(itemID) => Visible = true;
public DDStep(Serial serial) : base(serial)
{
@ -1100,10 +1074,7 @@ namespace Server.Engines.ConPVP
writer.Write(0); //version
}
public override bool OnMoveOver(Mobile m)
{
return Addon.OnMoveOver(m);
}
public override bool OnMoveOver(Mobile m) => Addon.OnMoveOver(m);
}
}
}

View file

@ -47,24 +47,15 @@ namespace Server.Engines.ConPVP
{
protected DuelContext m_Context;
public EventGame(DuelContext context)
{
m_Context = context;
}
public EventGame(DuelContext context) => m_Context = context;
public DuelContext Context => m_Context;
public virtual bool FreeConsume => true;
public virtual bool OnDeath(Mobile mob, Container corpse)
{
return true;
}
public virtual bool OnDeath(Mobile mob, Container corpse) => true;
public virtual bool CantDoAnything(Mobile mob)
{
return false;
}
public virtual bool CantDoAnything(Mobile mob) => false;
public virtual void OnStart()
{

View file

@ -463,15 +463,9 @@ namespace Server.Engines.ConPVP
AddButton(314, height - 42, 247, 248, 1);
}
public string Center(string text)
{
return $"<CENTER>{text}</CENTER>";
}
public string Center(string text) => $"<CENTER>{text}</CENTER>";
public string Color(string text, int color)
{
return $"<BASEFONT COLOR=#{color:X6}>{text}</BASEFONT>";
}
public string Color(string text, int color) => $"<BASEFONT COLOR=#{color:X6}>{text}</BASEFONT>";
private void AddBorderedText(int x, int y, int width, int height, string text, int color, int borderColor)
{
@ -650,10 +644,7 @@ namespace Server.Engines.ConPVP
op.WriteEncodedInt(Color);
}
public override string ToString()
{
return TeamName != null ? $"({Name}) ..." : "...";
}
public override string ToString() => TeamName != null ? $"({Name}) ..." : "...";
}
public sealed class KHController : EventController
@ -745,15 +736,9 @@ namespace Server.Engines.ConPVP
public override string Title => "King of the Hill";
public override string GetTeamName(int teamID)
{
return TeamInfo[teamID % TeamInfo.Length].Name;
}
public override string GetTeamName(int teamID) => TeamInfo[teamID % TeamInfo.Length].Name;
public override EventGame Construct(DuelContext context)
{
return new KHGame(this, context);
}
public override EventGame Construct(DuelContext context) => new KHGame(this, context);
public void RemoveBoard(KHBoard b)
{
@ -824,10 +809,7 @@ namespace Server.Engines.ConPVP
{
private Timer m_FinishTimer;
public KHGame(KHController controller, DuelContext context) : base(context)
{
Controller = controller;
}
public KHGame(KHController controller, DuelContext context) : base(context) => Controller = controller;
public KHController Controller{ get; }
@ -895,10 +877,7 @@ namespace Server.Engines.ConPVP
return pm.DuelContext.Participants.IndexOf(pm.DuelPlayer.Participant);
}
public int GetColor(Mobile mob)
{
return GetTeamInfo(mob)?.Color ?? -1;
}
public int GetColor(Mobile mob) => GetTeamInfo(mob)?.Color ?? -1;
private void ApplyHues(Participant p, int hueOverride)
{

View file

@ -248,15 +248,9 @@ namespace Server.Engines.ConPVP
Timer.DelayCall(TimeSpan.FromSeconds(15.0), AutoReject);
}
public string Center(string text)
{
return $"<CENTER>{text}</CENTER>";
}
public string Center(string text) => $"<CENTER>{text}</CENTER>";
public string Color(string text, int color)
{
return $"<BASEFONT COLOR=#{color:X6}>{text}</BASEFONT>";
}
public string Color(string text, int color) => $"<BASEFONT COLOR=#{color:X6}>{text}</BASEFONT>";
private void AddBorderedText(int x, int y, int width, int height, string text, int color, int borderColor)
{

View file

@ -67,10 +67,7 @@ namespace Server.Engines.ConPVP
from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1019045); // I can't reach that
}
public override bool OnMoveOver(Mobile m)
{
return !m.Player || UseGate(m);
}
public override bool OnMoveOver(Mobile m) => !m.Player || UseGate(m);
}
public class ArenaGump : Gump
@ -242,15 +239,9 @@ namespace Server.Engines.ConPVP
}
}
public string Center(string text)
{
return $"<CENTER>{text}</CENTER>";
}
public string Center(string text) => $"<CENTER>{text}</CENTER>";
public string Color(string text, int color)
{
return $"<BASEFONT COLOR=#{color:X6}>{text}</BASEFONT>";
}
public string Color(string text, int color) => $"<BASEFONT COLOR=#{color:X6}>{text}</BASEFONT>";
private void AddBorderedText(int x, int y, int width, string text, int color, int borderColor)
{

View file

@ -59,14 +59,8 @@ namespace Server.Engines.ConPVP
AddButton(314 - 50, 157 - offset, 247, 248, 1);
}
public string Center(string text)
{
return $"<CENTER>{text}</CENTER>";
}
public string Center(string text) => $"<CENTER>{text}</CENTER>";
public string Color(string text, int color)
{
return $"<BASEFONT COLOR=#{color:X6}>{text}</BASEFONT>";
}
public string Color(string text, int color) => $"<BASEFONT COLOR=#{color:X6}>{text}</BASEFONT>";
}
}

View file

@ -281,15 +281,9 @@ public class ConfirmSignupGump : Gump
AddButton(314, y, 247, 248, 1);
}
public string Center(string text)
{
return $"<CENTER>{text}</CENTER>";
}
public string Center(string text) => $"<CENTER>{text}</CENTER>";
public string Color(string text, int color)
{
return $"<BASEFONT COLOR=#{color:X6}>{text}</BASEFONT>";
}
public string Color(string text, int color) => $"<BASEFONT COLOR=#{color:X6}>{text}</BASEFONT>";
private void AddBorderedText(int x, int y, int width, int height, string text, int color, int borderColor)
{

View file

@ -56,10 +56,7 @@ namespace Server.Engines.ConPVP
public DuelContext Context{ get; }
public string Center(string text)
{
return $"<CENTER>{text}</CENTER>";
}
public string Center(string text) => $"<CENTER>{text}</CENTER>";
public void AddGoldenButton(int x, int y, int bid)
{

View file

@ -8,10 +8,7 @@ namespace Server.Engines.ConPVP
public class LadderItem : Item
{
[Constructible]
public LadderItem() : base(0x117F)
{
Movable = false;
}
public LadderItem() : base(0x117F) => Movable = false;
public LadderItem(Serial serial) : base(serial)
{
@ -207,15 +204,9 @@ namespace Server.Engines.ConPVP
from.SendGump(new LadderGump(m_Ladder, m_Page + 1));
}
public string Center(string text)
{
return $"<CENTER>{text}</CENTER>";
}
public string Center(string text) => $"<CENTER>{text}</CENTER>";
public string Color(string text, int color)
{
return $"<BASEFONT COLOR=#{color:X6}>{text}</BASEFONT>";
}
public string Color(string text, int color) => $"<BASEFONT COLOR=#{color:X6}>{text}</BASEFONT>";
private void AddBorderedText(int x, int y, int width, string text, int color, int borderColor)
{

View file

@ -64,10 +64,7 @@ namespace Server.Engines.ConPVP
public Participant Participant{ get; }
public string Center(string text)
{
return $"<CENTER>{text}</CENTER>";
}
public string Center(string text) => $"<CENTER>{text}</CENTER>";
public void AddGoldenButton(int x, int y, int bid)
{

View file

@ -70,10 +70,7 @@ namespace Server.Engines.ConPVP
}
}
public string Center(string text)
{
return $"<CENTER>{text}</CENTER>";
}
public string Center(string text) => $"<CENTER>{text}</CENTER>";
public override void OnResponse(NetState sender, RelayInfo info)
{

View file

@ -97,10 +97,7 @@ namespace Server.Engines.ConPVP
}
}
public string Center(string text)
{
return $"<CENTER>{text}</CENTER>";
}
public string Center(string text) => $"<CENTER>{text}</CENTER>";
public override void OnResponse(NetState sender, RelayInfo info)
{

View file

@ -189,10 +189,7 @@ namespace Server.Engines.ConPVP
}
}
public string Center(string text)
{
return $"<CENTER>{text}</CENTER>";
}
public string Center(string text) => $"<CENTER>{text}</CENTER>";
public void AddGoldenButton(int x, int y, int bid)
{

View file

@ -73,10 +73,7 @@ namespace Server.Engines.ConPVP
}
}
public string Center(string text)
{
return $"<CENTER>{text}</CENTER>";
}
public string Center(string text) => $"<CENTER>{text}</CENTER>";
public void AddGoldenButton(int x, int y, int bid)
{

View file

@ -614,15 +614,9 @@ namespace Server.Engines.ConPVP
}
}
public string Center(string text)
{
return $"<CENTER>{text}</CENTER>";
}
public string Center(string text) => $"<CENTER>{text}</CENTER>";
public string Color(string text, int color)
{
return $"<BASEFONT COLOR=#{color:X6}>{text}</BASEFONT>";
}
public string Color(string text, int color) => $"<BASEFONT COLOR=#{color:X6}>{text}</BASEFONT>";
private void AddBorderedText(int x, int y, int width, int height, string text, int color, int borderColor)
{
@ -667,10 +661,7 @@ namespace Server.Engines.ConPVP
AddLeftArrow(x, y, bid, null);
}
public int ToButtonID(int type, int index)
{
return 1 + index * 7 + type;
}
public int ToButtonID(int type, int index) => 1 + index * 7 + type;
public bool FromButtonID(int bid, out int type, out int index)
{

View file

@ -118,10 +118,7 @@ namespace Server.Engines.ConPVP
private Dictionary<Mobile, LadderEntry> m_Table;
public Ladder()
{
m_Table = new Dictionary<Mobile, LadderEntry>();
}
public Ladder() => m_Table = new Dictionary<Mobile, LadderEntry>();
public Ladder(GenericReader reader)
{
@ -350,10 +347,7 @@ namespace Server.Engines.ConPVP
[CommandProperty(AccessLevel.GameMaster)]
public int Rank => Index;
public int CompareTo(LadderEntry l)
{
return (l?.m_Experience ?? 0) - m_Experience;
}
public int CompareTo(LadderEntry l) => (l?.m_Experience ?? 0) - m_Experience;
public void Serialize(GenericWriter writer)
{

View file

@ -102,10 +102,7 @@ namespace Server.Engines.ConPVP
return null;
}
public bool Contains(Mobile mob)
{
return Find(mob) != null;
}
public bool Contains(Mobile mob) => Find(mob) != null;
public void Broadcast(int hue, string message, string nonLocalOverhead, string localOverhead)
{

View file

@ -240,15 +240,9 @@ namespace Server.Engines.ConPVP
}
}
public string Center(string text)
{
return $"<CENTER>{text}</CENTER>";
}
public string Center(string text) => $"<CENTER>{text}</CENTER>";
public string Color(string text, int color)
{
return $"<BASEFONT COLOR=#{color:X6}>{text}</BASEFONT>";
}
public string Color(string text, int color) => $"<BASEFONT COLOR=#{color:X6}>{text}</BASEFONT>";
private void AddBorderedText(int x, int y, int width, string text, int color, int borderColor)
{

View file

@ -736,10 +736,7 @@ namespace Server.Engines.ConPVP
return null;
}
public int GetOptionIndex(string option)
{
return Array.IndexOf(Options, option);
}
public int GetOptionIndex(string option) => Array.IndexOf(Options, option);
public void ComputeOffsets()
{

View file

@ -19,10 +19,7 @@ namespace Server.Engines.ConPVP
Register();
}
public override bool AllowHousing(Mobile from, Point3D p)
{
return from.AccessLevel >= AccessLevel.GameMaster && base.AllowHousing(from, p);
}
public override bool AllowHousing(Mobile from, Point3D p) => from.AccessLevel >= AccessLevel.GameMaster && base.AllowHousing(from, p);
public override bool OnMoveInto(Mobile m, Direction d, Point3D newLocation, Point3D oldLocation)
{
@ -58,9 +55,6 @@ namespace Server.Engines.ConPVP
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) => false;
}
}

View file

@ -426,10 +426,7 @@ namespace Server.Engines.ConPVP
Alert(arena, sb.ToString());
}
private int ComputeCashAward()
{
return Participants.Count * m_PlayersPerParticipant * 2500;
}
private int ComputeCashAward() => Participants.Count * m_PlayersPerParticipant * 2500;
private void GiveAwards()
{

View file

@ -1,65 +1,62 @@
using Server.Network;
namespace Server.Engines.ConPVP
{
public class TournamentBracketItem : Item
{
[Constructible]
public TournamentBracketItem() : base(3774)
{
Movable = false;
}
public TournamentBracketItem(Serial serial) : base(serial)
{
}
[CommandProperty(AccessLevel.GameMaster)]
public TournamentController Tournament{ get; set; }
public override string DefaultName => "tournament bracket";
public override void OnDoubleClick(Mobile from)
{
if (!from.InRange(GetWorldLocation(), 2))
{
from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1019045); // I can't reach that
}
else
{
Tournament tourney = Tournament?.Tournament;
if (tourney != null)
{
from.CloseGump<TournamentBracketGump>();
from.SendGump(new TournamentBracketGump(from, tourney, TourneyBracketGumpType.Index));
}
}
}
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.Write(0);
writer.Write(Tournament);
}
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
int version = reader.ReadInt();
switch (version)
{
case 0:
{
Tournament = reader.ReadItem() as TournamentController;
break;
}
}
}
}
using Server.Network;
namespace Server.Engines.ConPVP
{
public class TournamentBracketItem : Item
{
[Constructible]
public TournamentBracketItem() : base(3774) => Movable = false;
public TournamentBracketItem(Serial serial) : base(serial)
{
}
[CommandProperty(AccessLevel.GameMaster)]
public TournamentController Tournament{ get; set; }
public override string DefaultName => "tournament bracket";
public override void OnDoubleClick(Mobile from)
{
if (!from.InRange(GetWorldLocation(), 2))
{
from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1019045); // I can't reach that
}
else
{
Tournament tourney = Tournament?.Tournament;
if (tourney != null)
{
from.CloseGump<TournamentBracketGump>();
from.SendGump(new TournamentBracketGump(from, tourney, TourneyBracketGumpType.Index));
}
}
}
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.Write(0);
writer.Write(Tournament);
}
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
int version = reader.ReadInt();
switch (version)
{
case 0:
{
Tournament = reader.ReadItem() as TournamentController;
break;
}
}
}
}
}

View file

@ -1,143 +1,137 @@
using System;
using System.Collections.Generic;
using Server.ContextMenus;
using Server.Gumps;
namespace Server.Engines.ConPVP
{
public class TournamentController : Item
{
private static List<TournamentController> m_Instances = new List<TournamentController>();
[Constructible]
public TournamentController() : base(0x1B7A)
{
Visible = false;
Movable = false;
Tournament = new Tournament();
m_Instances.Add(this);
}
public TournamentController(Serial serial) : base(serial)
{
}
[CommandProperty(AccessLevel.GameMaster)]
public Tournament Tournament{ get; private set; }
public static bool IsActive
{
get
{
for (int i = 0; i < m_Instances.Count; ++i)
{
TournamentController controller = m_Instances[i];
if (controller?.Deleted == false && controller.Tournament != null &&
controller.Tournament.Stage != TournamentStage.Inactive)
return true;
}
return false;
}
}
public override string DefaultName => "tournament controller";
public override void GetContextMenuEntries(Mobile from, List<ContextMenuEntry> list)
{
base.GetContextMenuEntries(from, list);
if (from.AccessLevel >= AccessLevel.GameMaster && Tournament != null)
{
list.Add(new EditEntry(Tournament));
if (Tournament.CurrentStage == TournamentStage.Inactive)
list.Add(new StartEntry(Tournament));
}
}
public override void OnDoubleClick(Mobile from)
{
if (from.AccessLevel >= AccessLevel.GameMaster && Tournament != null)
{
from.CloseGump<PickRulesetGump>();
from.CloseGump<RulesetGump>();
from.SendGump(new PickRulesetGump(from, null, Tournament.Ruleset));
}
}
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.Write(0);
Tournament.Serialize(writer);
}
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
int version = reader.ReadInt();
switch (version)
{
case 0:
{
Tournament = new Tournament(reader);
break;
}
}
m_Instances.Add(this);
}
public override void OnDelete()
{
base.OnDelete();
m_Instances.Remove(this);
}
private class EditEntry : ContextMenuEntry
{
private Tournament m_Tournament;
public EditEntry(Tournament tourney) : base(5101)
{
m_Tournament = tourney;
}
public override void OnClick()
{
Owner.From.SendGump(new PropertiesGump(Owner.From, m_Tournament));
}
}
private class StartEntry : ContextMenuEntry
{
private Tournament m_Tournament;
public StartEntry(Tournament tourney) : base(5113)
{
m_Tournament = tourney;
}
public override void OnClick()
{
if (m_Tournament.Stage == TournamentStage.Inactive)
{
m_Tournament.SignupStart = DateTime.UtcNow;
m_Tournament.Stage = TournamentStage.Signup;
m_Tournament.Participants.Clear();
m_Tournament.Pyramid.Levels.Clear();
m_Tournament.Alert("Hear ye! Hear ye!",
"Tournament signup has opened. You can enter by signing up with the registrar.");
}
}
}
}
}
using System;
using System.Collections.Generic;
using Server.ContextMenus;
using Server.Gumps;
namespace Server.Engines.ConPVP
{
public class TournamentController : Item
{
private static List<TournamentController> m_Instances = new List<TournamentController>();
[Constructible]
public TournamentController() : base(0x1B7A)
{
Visible = false;
Movable = false;
Tournament = new Tournament();
m_Instances.Add(this);
}
public TournamentController(Serial serial) : base(serial)
{
}
[CommandProperty(AccessLevel.GameMaster)]
public Tournament Tournament{ get; private set; }
public static bool IsActive
{
get
{
for (int i = 0; i < m_Instances.Count; ++i)
{
TournamentController controller = m_Instances[i];
if (controller?.Deleted == false && controller.Tournament != null &&
controller.Tournament.Stage != TournamentStage.Inactive)
return true;
}
return false;
}
}
public override string DefaultName => "tournament controller";
public override void GetContextMenuEntries(Mobile from, List<ContextMenuEntry> list)
{
base.GetContextMenuEntries(from, list);
if (from.AccessLevel >= AccessLevel.GameMaster && Tournament != null)
{
list.Add(new EditEntry(Tournament));
if (Tournament.CurrentStage == TournamentStage.Inactive)
list.Add(new StartEntry(Tournament));
}
}
public override void OnDoubleClick(Mobile from)
{
if (from.AccessLevel >= AccessLevel.GameMaster && Tournament != null)
{
from.CloseGump<PickRulesetGump>();
from.CloseGump<RulesetGump>();
from.SendGump(new PickRulesetGump(from, null, Tournament.Ruleset));
}
}
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.Write(0);
Tournament.Serialize(writer);
}
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
int version = reader.ReadInt();
switch (version)
{
case 0:
{
Tournament = new Tournament(reader);
break;
}
}
m_Instances.Add(this);
}
public override void OnDelete()
{
base.OnDelete();
m_Instances.Remove(this);
}
private class EditEntry : ContextMenuEntry
{
private Tournament m_Tournament;
public EditEntry(Tournament tourney) : base(5101) => m_Tournament = tourney;
public override void OnClick()
{
Owner.From.SendGump(new PropertiesGump(Owner.From, m_Tournament));
}
}
private class StartEntry : ContextMenuEntry
{
private Tournament m_Tournament;
public StartEntry(Tournament tourney) : base(5113) => m_Tournament = tourney;
public override void OnClick()
{
if (m_Tournament.Stage == TournamentStage.Inactive)
{
m_Tournament.SignupStart = DateTime.UtcNow;
m_Tournament.Stage = TournamentStage.Signup;
m_Tournament.Participants.Clear();
m_Tournament.Pyramid.Levels.Clear();
m_Tournament.Alert("Hear ye! Hear ye!",
"Tournament signup has opened. You can enter by signing up with the registrar.");
}
}
}
}
}

View file

@ -1,190 +1,187 @@
using System.Collections.Generic;
using Server.Ethics;
using Server.Factions;
namespace Server.Engines.ConPVP
{
public class TourneyPyramid
{
public TourneyPyramid()
{
Levels = new List<PyramidLevel>();
}
public List<PyramidLevel> Levels{ get; set; }
public void AddLevel(int partsPerMatch, List<TourneyParticipant> participants, GroupingType groupType, TourneyType tourneyType)
{
List<TourneyParticipant> copy = new List<TourneyParticipant>(participants);
if (groupType == GroupingType.Nearest || groupType == GroupingType.HighVsLow)
copy.Sort();
PyramidLevel level = new PyramidLevel();
switch (tourneyType)
{
case TourneyType.RedVsBlue:
{
TourneyParticipant[] parts = new TourneyParticipant[2];
for (int i = 0; i < parts.Length; ++i)
parts[i] = new TourneyParticipant(new List<Mobile>());
for (int i = 0; i < copy.Count; ++i)
{
List<Mobile> players = copy[i].Players;
for (int j = 0; j < players.Count; ++j)
{
Mobile mob = players[j];
if (mob.Kills >= 5)
parts[0].Players.Add(mob);
else
parts[1].Players.Add(mob);
}
}
level.Matches.Add(new TourneyMatch(new List<TourneyParticipant>(parts)));
break;
}
case TourneyType.Faction:
{
TourneyParticipant[] parts = new TourneyParticipant[partsPerMatch];
for (int i = 0; i < parts.Length; ++i)
parts[i] = new TourneyParticipant(new List<Mobile>());
for (int i = 0; i < copy.Count; ++i)
{
List<Mobile> players = copy[i].Players;
for (int j = 0; j < players.Count; ++j)
{
Mobile mob = players[j];
int index = -1;
if (partsPerMatch == 4)
{
Faction fac = Faction.Find(mob);
if (fac != null)
index = fac.Definition.Sort;
}
else if (partsPerMatch == 2)
{
if (Ethic.Evil.IsEligible(mob))
index = 0;
else if (Ethic.Hero.IsEligible(mob)) index = 1;
}
if (index < 0 || index >= partsPerMatch) index = i % partsPerMatch;
parts[index].Players.Add(mob);
}
}
level.Matches.Add(new TourneyMatch(new List<TourneyParticipant>(parts)));
break;
}
case TourneyType.RandomTeam:
{
TourneyParticipant[] parts = new TourneyParticipant[partsPerMatch];
for (int i = 0; i < partsPerMatch; ++i)
parts[i] = new TourneyParticipant(new List<Mobile>());
for (int i = 0; i < copy.Count; ++i)
parts[i % parts.Length].Players.AddRange(copy[i].Players);
level.Matches.Add(new TourneyMatch(new List<TourneyParticipant>(parts)));
break;
}
case TourneyType.FreeForAll:
{
level.Matches.Add(new TourneyMatch(copy));
break;
}
case TourneyType.Standard:
{
if (partsPerMatch >= 2 && participants.Count % partsPerMatch == 1)
{
int lowAdvances = int.MaxValue;
for (int i = 0; i < participants.Count; ++i)
{
TourneyParticipant p = participants[i];
if (p.FreeAdvances < lowAdvances)
lowAdvances = p.FreeAdvances;
}
List<TourneyParticipant> toAdvance = new List<TourneyParticipant>();
for (int i = 0; i < participants.Count; ++i)
{
TourneyParticipant p = participants[i];
if (p.FreeAdvances == lowAdvances)
toAdvance.Add(p);
}
if (toAdvance.Count == 0)
toAdvance = copy; // sanity
int idx = Utility.Random(toAdvance.Count);
toAdvance[idx].AddLog(
"Advanced automatically due to an odd number of challengers.");
level.FreeAdvance = toAdvance[idx];
++level.FreeAdvance.FreeAdvances;
copy.Remove(toAdvance[idx]);
}
while (copy.Count >= partsPerMatch)
{
List<TourneyParticipant> thisMatch = new List<TourneyParticipant>();
for (int i = 0; i < partsPerMatch; ++i)
{
int idx = 0;
switch (groupType)
{
case GroupingType.HighVsLow:
idx = i * (copy.Count - 1) / (partsPerMatch - 1);
break;
case GroupingType.Nearest:
idx = 0;
break;
case GroupingType.Random:
idx = Utility.Random(copy.Count);
break;
}
thisMatch.Add(copy[idx]);
copy.RemoveAt(idx);
}
level.Matches.Add(new TourneyMatch(thisMatch));
}
if (copy.Count > 1)
level.Matches.Add(new TourneyMatch(copy));
break;
}
}
Levels.Add(level);
}
}
public class PyramidLevel
{
public List<TourneyMatch> Matches{ get; set; } = new List<TourneyMatch>();
public TourneyParticipant FreeAdvance{ get; set; }
}
}
using System.Collections.Generic;
using Server.Ethics;
using Server.Factions;
namespace Server.Engines.ConPVP
{
public class TourneyPyramid
{
public TourneyPyramid() => Levels = new List<PyramidLevel>();
public List<PyramidLevel> Levels{ get; set; }
public void AddLevel(int partsPerMatch, List<TourneyParticipant> participants, GroupingType groupType, TourneyType tourneyType)
{
List<TourneyParticipant> copy = new List<TourneyParticipant>(participants);
if (groupType == GroupingType.Nearest || groupType == GroupingType.HighVsLow)
copy.Sort();
PyramidLevel level = new PyramidLevel();
switch (tourneyType)
{
case TourneyType.RedVsBlue:
{
TourneyParticipant[] parts = new TourneyParticipant[2];
for (int i = 0; i < parts.Length; ++i)
parts[i] = new TourneyParticipant(new List<Mobile>());
for (int i = 0; i < copy.Count; ++i)
{
List<Mobile> players = copy[i].Players;
for (int j = 0; j < players.Count; ++j)
{
Mobile mob = players[j];
if (mob.Kills >= 5)
parts[0].Players.Add(mob);
else
parts[1].Players.Add(mob);
}
}
level.Matches.Add(new TourneyMatch(new List<TourneyParticipant>(parts)));
break;
}
case TourneyType.Faction:
{
TourneyParticipant[] parts = new TourneyParticipant[partsPerMatch];
for (int i = 0; i < parts.Length; ++i)
parts[i] = new TourneyParticipant(new List<Mobile>());
for (int i = 0; i < copy.Count; ++i)
{
List<Mobile> players = copy[i].Players;
for (int j = 0; j < players.Count; ++j)
{
Mobile mob = players[j];
int index = -1;
if (partsPerMatch == 4)
{
Faction fac = Faction.Find(mob);
if (fac != null)
index = fac.Definition.Sort;
}
else if (partsPerMatch == 2)
{
if (Ethic.Evil.IsEligible(mob))
index = 0;
else if (Ethic.Hero.IsEligible(mob)) index = 1;
}
if (index < 0 || index >= partsPerMatch) index = i % partsPerMatch;
parts[index].Players.Add(mob);
}
}
level.Matches.Add(new TourneyMatch(new List<TourneyParticipant>(parts)));
break;
}
case TourneyType.RandomTeam:
{
TourneyParticipant[] parts = new TourneyParticipant[partsPerMatch];
for (int i = 0; i < partsPerMatch; ++i)
parts[i] = new TourneyParticipant(new List<Mobile>());
for (int i = 0; i < copy.Count; ++i)
parts[i % parts.Length].Players.AddRange(copy[i].Players);
level.Matches.Add(new TourneyMatch(new List<TourneyParticipant>(parts)));
break;
}
case TourneyType.FreeForAll:
{
level.Matches.Add(new TourneyMatch(copy));
break;
}
case TourneyType.Standard:
{
if (partsPerMatch >= 2 && participants.Count % partsPerMatch == 1)
{
int lowAdvances = int.MaxValue;
for (int i = 0; i < participants.Count; ++i)
{
TourneyParticipant p = participants[i];
if (p.FreeAdvances < lowAdvances)
lowAdvances = p.FreeAdvances;
}
List<TourneyParticipant> toAdvance = new List<TourneyParticipant>();
for (int i = 0; i < participants.Count; ++i)
{
TourneyParticipant p = participants[i];
if (p.FreeAdvances == lowAdvances)
toAdvance.Add(p);
}
if (toAdvance.Count == 0)
toAdvance = copy; // sanity
int idx = Utility.Random(toAdvance.Count);
toAdvance[idx].AddLog(
"Advanced automatically due to an odd number of challengers.");
level.FreeAdvance = toAdvance[idx];
++level.FreeAdvance.FreeAdvances;
copy.Remove(toAdvance[idx]);
}
while (copy.Count >= partsPerMatch)
{
List<TourneyParticipant> thisMatch = new List<TourneyParticipant>();
for (int i = 0; i < partsPerMatch; ++i)
{
int idx = 0;
switch (groupType)
{
case GroupingType.HighVsLow:
idx = i * (copy.Count - 1) / (partsPerMatch - 1);
break;
case GroupingType.Nearest:
idx = 0;
break;
case GroupingType.Random:
idx = Utility.Random(copy.Count);
break;
}
thisMatch.Add(copy[idx]);
copy.RemoveAt(idx);
}
level.Matches.Add(new TourneyMatch(thisMatch));
}
if (copy.Count > 1)
level.Matches.Add(new TourneyMatch(copy));
break;
}
}
Levels.Add(level);
}
}
public class PyramidLevel
{
public List<TourneyMatch> Matches{ get; set; } = new List<TourneyMatch>();
public TourneyParticipant FreeAdvance{ get; set; }
}
}

View file

@ -1,149 +1,146 @@
using System.Collections.Generic;
using Server.Factions;
using Server.Mobiles;
using Server.Network;
namespace Server.Engines.ConPVP
{
public class TournamentSignupItem : Item
{
[Constructible]
public TournamentSignupItem() : base(4029)
{
Movable = false;
}
public TournamentSignupItem(Serial serial) : base(serial)
{
}
[CommandProperty(AccessLevel.GameMaster)]
public TournamentController Tournament{ get; set; }
[CommandProperty(AccessLevel.GameMaster)]
public Mobile Registrar{ get; set; }
public override string DefaultName => "tournament signup book";
public override void OnDoubleClick(Mobile from)
{
if (!from.InRange(GetWorldLocation(), 2))
{
from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1019045); // I can't reach that
}
else
{
Tournament tourney = Tournament?.Tournament;
if (tourney == null)
return;
if (Registrar != null)
Registrar.Direction = Registrar.GetDirectionTo(this);
switch (tourney.Stage)
{
case TournamentStage.Fighting:
{
if (Registrar != null)
{
if (tourney.HasParticipant(from))
Registrar.PrivateOverheadMessage(MessageType.Regular,
0x35, false, "Excuse me? You are already signed up.", from.NetState);
else
Registrar.PrivateOverheadMessage(MessageType.Regular,
0x22, false, "The tournament has already begun. You are too late to signup now.",
from.NetState);
}
break;
}
case TournamentStage.Inactive:
{
Registrar?.PrivateOverheadMessage(MessageType.Regular,
0x35, false, "The tournament is closed.", from.NetState);
break;
}
case TournamentStage.Signup:
{
Ladder ladder = Ladder.Instance;
LadderEntry entry = ladder?.Find(from);
if (entry != null && Ladder.GetLevel(entry.Experience) < tourney.LevelRequirement)
{
Registrar?.PrivateOverheadMessage(MessageType.Regular,
0x35, false, "You have not yet proven yourself a worthy dueler.", from.NetState);
break;
}
if (tourney.IsFactionRestricted && Faction.Find(from) == null)
{
Registrar?.PrivateOverheadMessage(MessageType.Regular,
0x35, false, "Only those who have declared their faction allegiance may participate.",
from.NetState);
break;
}
if (from.HasGump<AcceptTeamGump>())
{
Registrar?.PrivateOverheadMessage(MessageType.Regular,
0x22, false, "You must first respond to the offer I've given you.", from.NetState);
}
else if (from.HasGump<AcceptDuelGump>())
{
Registrar?.PrivateOverheadMessage(MessageType.Regular,
0x22, false, "You must first cancel your duel offer.", from.NetState);
}
else if (from is PlayerMobile mobile && mobile.DuelContext != null)
{
Registrar?.PrivateOverheadMessage(MessageType.Regular,
0x22, false, "You are already participating in a duel.", mobile.NetState);
}
else if (!tourney.HasParticipant(from))
{
from.CloseGump<ConfirmSignupGump>();
from.SendGump(new ConfirmSignupGump(from, Registrar, tourney, new List<Mobile> { from }));
}
else
{
Registrar?.PrivateOverheadMessage(MessageType.Regular,
0x35, false, "You have already entered this tournament.", from.NetState);
}
break;
}
}
}
}
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.Write(0);
writer.Write(Tournament);
writer.Write(Registrar);
}
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
int version = reader.ReadInt();
switch (version)
{
case 0:
{
Tournament = reader.ReadItem() as TournamentController;
Registrar = reader.ReadMobile();
break;
}
}
}
}
using System.Collections.Generic;
using Server.Factions;
using Server.Mobiles;
using Server.Network;
namespace Server.Engines.ConPVP
{
public class TournamentSignupItem : Item
{
[Constructible]
public TournamentSignupItem() : base(4029) => Movable = false;
public TournamentSignupItem(Serial serial) : base(serial)
{
}
[CommandProperty(AccessLevel.GameMaster)]
public TournamentController Tournament{ get; set; }
[CommandProperty(AccessLevel.GameMaster)]
public Mobile Registrar{ get; set; }
public override string DefaultName => "tournament signup book";
public override void OnDoubleClick(Mobile from)
{
if (!from.InRange(GetWorldLocation(), 2))
{
from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1019045); // I can't reach that
}
else
{
Tournament tourney = Tournament?.Tournament;
if (tourney == null)
return;
if (Registrar != null)
Registrar.Direction = Registrar.GetDirectionTo(this);
switch (tourney.Stage)
{
case TournamentStage.Fighting:
{
if (Registrar != null)
{
if (tourney.HasParticipant(from))
Registrar.PrivateOverheadMessage(MessageType.Regular,
0x35, false, "Excuse me? You are already signed up.", from.NetState);
else
Registrar.PrivateOverheadMessage(MessageType.Regular,
0x22, false, "The tournament has already begun. You are too late to signup now.",
from.NetState);
}
break;
}
case TournamentStage.Inactive:
{
Registrar?.PrivateOverheadMessage(MessageType.Regular,
0x35, false, "The tournament is closed.", from.NetState);
break;
}
case TournamentStage.Signup:
{
Ladder ladder = Ladder.Instance;
LadderEntry entry = ladder?.Find(from);
if (entry != null && Ladder.GetLevel(entry.Experience) < tourney.LevelRequirement)
{
Registrar?.PrivateOverheadMessage(MessageType.Regular,
0x35, false, "You have not yet proven yourself a worthy dueler.", from.NetState);
break;
}
if (tourney.IsFactionRestricted && Faction.Find(from) == null)
{
Registrar?.PrivateOverheadMessage(MessageType.Regular,
0x35, false, "Only those who have declared their faction allegiance may participate.",
from.NetState);
break;
}
if (from.HasGump<AcceptTeamGump>())
{
Registrar?.PrivateOverheadMessage(MessageType.Regular,
0x22, false, "You must first respond to the offer I've given you.", from.NetState);
}
else if (from.HasGump<AcceptDuelGump>())
{
Registrar?.PrivateOverheadMessage(MessageType.Regular,
0x22, false, "You must first cancel your duel offer.", from.NetState);
}
else if (from is PlayerMobile mobile && mobile.DuelContext != null)
{
Registrar?.PrivateOverheadMessage(MessageType.Regular,
0x22, false, "You are already participating in a duel.", mobile.NetState);
}
else if (!tourney.HasParticipant(from))
{
from.CloseGump<ConfirmSignupGump>();
from.SendGump(new ConfirmSignupGump(from, Registrar, tourney, new List<Mobile> { from }));
}
else
{
Registrar?.PrivateOverheadMessage(MessageType.Regular,
0x35, false, "You have already entered this tournament.", from.NetState);
}
break;
}
}
}
}
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.Write(0);
writer.Write(Tournament);
writer.Write(Registrar);
}
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
int version = reader.ReadInt();
switch (version)
{
case 0:
{
Tournament = reader.ReadItem() as TournamentController;
Registrar = reader.ReadMobile();
break;
}
}
}
}
}

View file

@ -81,10 +81,7 @@ namespace Server.Engines.ConPVP
}
}
public int CompareTo(TourneyParticipant p)
{
return p.TotalLadderXP - TotalLadderXP;
}
public int CompareTo(TourneyParticipant p) => p.TotalLadderXP - TotalLadderXP;
public void AddLog(string text)
{