Adds style cop (#109)

This commit is contained in:
Kamron Batman 2020-04-26 00:16:02 -07:00 committed by GitHub
parent 3e715bcb60
commit 556a17aba8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
1725 changed files with 33831 additions and 38046 deletions

View file

@ -30,34 +30,34 @@ namespace Server.Factions
switch (version)
{
case 0:
{
Faction = Faction.ReadReference(reader);
LastStateTime = reader.ReadDateTime();
CurrentState = (ElectionState)reader.ReadEncodedInt();
Candidates = new List<Candidate>();
int count = reader.ReadEncodedInt();
for (int i = 0; i < count; ++i)
{
Candidate cd = new Candidate(reader);
Faction = Faction.ReadReference(reader);
if (cd.Mobile != null)
Candidates.Add(cd);
LastStateTime = reader.ReadDateTime();
CurrentState = (ElectionState)reader.ReadEncodedInt();
Candidates = new List<Candidate>();
int count = reader.ReadEncodedInt();
for (int i = 0; i < count; ++i)
{
Candidate cd = new Candidate(reader);
if (cd.Mobile != null)
Candidates.Add(cd);
}
break;
}
break;
}
}
StartTimer();
}
public Faction Faction{ get; }
public Faction Faction { get; }
public List<Candidate> Candidates{ get; }
public List<Candidate> Candidates { get; }
public ElectionState State
{
@ -69,10 +69,10 @@ namespace Server.Factions
}
}
public DateTime LastStateTime{ get; private set; }
public DateTime LastStateTime { get; private set; }
[CommandProperty(AccessLevel.GameMaster)]
public ElectionState CurrentState{ get; private set; }
public ElectionState CurrentState { get; private set; }
[CommandProperty(AccessLevel.GameMaster, AccessLevel.Administrator)]
public TimeSpan NextStateTime
@ -263,100 +263,100 @@ namespace Server.Factions
switch (CurrentState)
{
case ElectionState.Pending:
{
if (LastStateTime + PendingPeriod > DateTime.UtcNow)
break;
Faction.Broadcast(1038023); // Campaigning for the Faction Commander election has begun.
Candidates.Clear();
State = ElectionState.Campaign;
break;
}
case ElectionState.Campaign:
{
if (LastStateTime + CampaignPeriod > DateTime.UtcNow)
break;
if (Candidates.Count == 0)
{
Faction.Broadcast(1038025); // Nobody ran for office.
State = ElectionState.Pending;
if (LastStateTime + PendingPeriod > DateTime.UtcNow)
break;
Faction.Broadcast(1038023); // Campaigning for the Faction Commander election has begun.
Candidates.Clear();
State = ElectionState.Campaign;
break;
}
else if (Candidates.Count == 1)
case ElectionState.Campaign:
{
Faction.Broadcast(1038029); // Only one member ran for office.
if (LastStateTime + CampaignPeriod > DateTime.UtcNow)
break;
Candidate winner = Candidates[0];
if (Candidates.Count == 0)
{
Faction.Broadcast(1038025); // Nobody ran for office.
State = ElectionState.Pending;
}
else if (Candidates.Count == 1)
{
Faction.Broadcast(1038029); // Only one member ran for office.
Mobile mob = winner.Mobile;
PlayerState pl = PlayerState.Find(mob);
Candidate winner = Candidates[0];
if (pl == null || pl.Faction != Faction || mob == Faction.Commander)
Mobile mob = winner.Mobile;
PlayerState pl = PlayerState.Find(mob);
if (pl == null || pl.Faction != Faction || mob == Faction.Commander)
{
Faction.Broadcast(1038026); // Faction leadership has not changed.
}
else
{
Faction.Broadcast(1038028); // The faction has a new commander.
Faction.Commander = mob;
}
Candidates.Clear();
State = ElectionState.Pending;
}
else
{
Faction.Broadcast(1038030);
State = ElectionState.Election;
}
break;
}
case ElectionState.Election:
{
if (LastStateTime + VotingPeriod > DateTime.UtcNow)
break;
Faction.Broadcast(1038024); // The results for the Faction Commander election are in
Candidate winner = null;
for (int i = 0; i < Candidates.Count; ++i)
{
Candidate cd = Candidates[i];
PlayerState pl = PlayerState.Find(cd.Mobile);
if (pl == null || pl.Faction != Faction)
continue;
// cd.CleanMuleVotes();
if (winner == null || cd.Votes > winner.Votes)
winner = cd;
}
if (winner == null)
{
Faction.Broadcast(1038026); // Faction leadership has not changed.
}
else if (winner.Mobile == Faction.Commander)
{
Faction.Broadcast(1038027); // The incumbent won the election.
}
else
{
Faction.Broadcast(1038028); // The faction has a new commander.
Faction.Commander = mob;
Faction.Commander = winner.Mobile;
}
Candidates.Clear();
State = ElectionState.Pending;
}
else
{
Faction.Broadcast(1038030);
State = ElectionState.Election;
}
break;
}
case ElectionState.Election:
{
if (LastStateTime + VotingPeriod > DateTime.UtcNow)
break;
Faction.Broadcast(1038024); // The results for the Faction Commander election are in
Candidate winner = null;
for (int i = 0; i < Candidates.Count; ++i)
{
Candidate cd = Candidates[i];
PlayerState pl = PlayerState.Find(cd.Mobile);
if (pl == null || pl.Faction != Faction)
continue;
//cd.CleanMuleVotes();
if (winner == null || cd.Votes > winner.Votes)
winner = cd;
}
if (winner == null)
{
Faction.Broadcast(1038026); // Faction leadership has not changed.
}
else if (winner.Mobile == Faction.Commander)
{
Faction.Broadcast(1038027); // The incumbent won the election.
}
else
{
Faction.Broadcast(1038028); // The faction has a new commander.
Faction.Commander = winner.Mobile;
}
Candidates.Clear();
State = ElectionState.Pending;
break;
}
}
}
}
@ -385,23 +385,23 @@ namespace Server.Factions
switch (version)
{
case 0:
{
From = reader.ReadMobile();
Address = Utility.Intern(reader.ReadIPAddress());
Time = reader.ReadDateTime();
{
From = reader.ReadMobile();
Address = Utility.Intern(reader.ReadIPAddress());
Time = reader.ReadDateTime();
break;
}
break;
}
}
}
public Mobile From{ get; }
public Mobile From { get; }
public Mobile Candidate{ get; }
public Mobile Candidate { get; }
public IPAddress Address{ get; }
public IPAddress Address { get; }
public DateTime Time{ get; }
public DateTime Time { get; }
public object[] AcquireFields()
{
@ -458,40 +458,40 @@ namespace Server.Factions
switch (version)
{
case 1:
{
Mobile = reader.ReadMobile();
int count = reader.ReadEncodedInt();
Voters = new List<Voter>(count);
for (int i = 0; i < count; ++i)
{
Voter voter = new Voter(reader, Mobile);
Mobile = reader.ReadMobile();
if (voter.From != null)
Voters.Add(voter);
int count = reader.ReadEncodedInt();
Voters = new List<Voter>(count);
for (int i = 0; i < count; ++i)
{
Voter voter = new Voter(reader, Mobile);
if (voter.From != null)
Voters.Add(voter);
}
break;
}
break;
}
case 0:
{
Mobile = reader.ReadMobile();
{
Mobile = reader.ReadMobile();
List<Mobile> mobs = reader.ReadStrongMobileList();
Voters = new List<Voter>(mobs.Count);
List<Mobile> mobs = reader.ReadStrongMobileList();
Voters = new List<Voter>(mobs.Count);
for (int i = 0; i < mobs.Count; ++i)
Voters.Add(new Voter(mobs[i], Mobile));
for (int i = 0; i < mobs.Count; ++i)
Voters.Add(new Voter(mobs[i], Mobile));
break;
}
break;
}
}
}
public Mobile Mobile{ get; }
public Mobile Mobile { get; }
public List<Voter> Voters{ get; }
public List<Voter> Voters { get; }
public int Votes => Voters.Count;

View file

@ -28,7 +28,7 @@ namespace Server.Factions
public Faction() => State = new FactionState(this);
public StrongholdRegion StrongholdRegion{ get; set; }
public StrongholdRegion StrongholdRegion { get; set; }
public FactionDefinition Definition
{
@ -40,7 +40,7 @@ namespace Server.Factions
}
}
public FactionState State{ get; set; }
public FactionState State { get; set; }
public Election Election
{
@ -312,8 +312,8 @@ namespace Server.Factions
int killPoints = pl.KillPoints;
//Ordinarily, through normal faction removal, this will never find any sigils.
//Only with a leave delay less than the ReturnPeriod or a Faction Kick/Ban, will this ever do anything
// Ordinarily, through normal faction removal, this will never find any sigils.
// Only with a leave delay less than the ReturnPeriod or a Faction Kick/Ban, will this ever do anything
mob.Backpack?.FindItemsByType<Sigil>().ForEach(sigil => sigil.ReturnHome());
if (pl.RankIndex != -1)
@ -451,8 +451,7 @@ namespace Server.Factions
pm.SendLocalizedMessage(
1042161); // You cannot join a faction because your guild is an Order or Chaos type.
}
else if (!Guild.NewGuildSystem && guild.Enemies?.Count > 0
) //CAN join w/wars in new system
else if (!Guild.NewGuildSystem && guild.Enemies?.Count > 0) // CAN join w/wars in new system
{
pm.SendLocalizedMessage(1005056); // You cannot join a faction with active Wars
}
@ -735,7 +734,7 @@ namespace Server.Factions
if (faction != null)
from.SendGump(new ElectionManagementGump(faction.Election));
//from.SendGump( new Gumps.PropertiesGump( from, faction.Election ) );
// from.SendGump( new Gumps.PropertiesGump( from, faction.Election ) );
else
from.SendMessage("That stone has no faction assigned.");
}
@ -944,8 +943,6 @@ namespace Server.Factions
silver.ToString("N0")); // Thou hast earned ~1_AMOUNT~ silver for vanquishing the vile creature.
}
#region Ethics
if (bc.Map == Facet && bc.GetEthicAllegiance(killer) == BaseCreature.Allegiance.Enemy)
{
Player killerEPL = Player.Find(killer);
@ -957,8 +954,6 @@ namespace Server.Factions
}
}
#endregion
return;
}
@ -967,13 +962,9 @@ namespace Server.Factions
if (victimState == null)
return;
#region Dueling
if (victim.Region.IsPartOf<SafeZone>())
return;
#endregion
if (killer == victim || killerState.Faction != victimState.Faction)
ApplySkillLoss(victim);
@ -983,8 +974,6 @@ namespace Server.Factions
{
killer?.SendLocalizedMessage(501693); // This victim is not worth enough to get kill points from.
#region Ethics
Player killerEPL = Player.Find(killer);
Player victimEPL = Player.Find(victim);
@ -1005,8 +994,6 @@ namespace Server.Factions
victimState.OnGivenSilverTo(killer);
}
}
#endregion
}
else
{
@ -1023,7 +1010,7 @@ namespace Server.Factions
{
victimState.IsActive = true;
if (1 > Utility.Random(3))
if (Utility.Random(3) < 1)
killerState.IsActive = true;
int silver = killerState.Faction.AwardSilver(killer, award * 40);
@ -1045,8 +1032,6 @@ namespace Server.Factions
victim.SendLocalizedMessage(1042738 + offset,
args); // Thou has lost ~1_KILL_POINTS~ kill point(s) to ~3_ATTACKER_NAME~ for being vanquished!
#region Ethics
Player killerEPL = Player.Find(killer);
Player victimEPL = Player.Find(victim);
@ -1066,8 +1051,6 @@ namespace Server.Factions
}
}
#endregion
victimState.OnGivenSilverTo(killer);
}
else
@ -1139,7 +1122,7 @@ namespace Server.Factions
private class BroadcastPrompt : Prompt
{
private Faction m_Faction;
private readonly Faction m_Faction;
public BroadcastPrompt(Faction faction) => m_Faction = faction;
@ -1149,12 +1132,10 @@ namespace Server.Factions
}
}
#region Skill Loss
public const double SkillLossFactor = 1.0 / 3;
public static readonly TimeSpan SkillLossPeriod = TimeSpan.FromMinutes(20.0);
private static Dictionary<Mobile, SkillLossContext> m_SkillLoss = new Dictionary<Mobile, SkillLossContext>();
private static readonly Dictionary<Mobile, SkillLossContext> m_SkillLoss = new Dictionary<Mobile, SkillLossContext>();
private class SkillLossContext
{
@ -1207,8 +1188,6 @@ namespace Server.Factions
return true;
}
#endregion
}
public enum FactionKickType
@ -1220,7 +1199,7 @@ namespace Server.Factions
public class FactionKickCommand : BaseCommand
{
private FactionKickType m_KickType;
private readonly FactionKickType m_KickType;
public FactionKickCommand(FactionKickType kickType)
{
@ -1233,28 +1212,28 @@ namespace Server.Factions
switch (m_KickType)
{
case FactionKickType.Kick:
{
Commands = new[] { "FactionKick" };
Usage = "FactionKick";
Description =
"Kicks the targeted player out of his current faction. This does not prevent them from rejoining.";
break;
}
{
Commands = new[] { "FactionKick" };
Usage = "FactionKick";
Description =
"Kicks the targeted player out of his current faction. This does not prevent them from rejoining.";
break;
}
case FactionKickType.Ban:
{
Commands = new[] { "FactionBan" };
Usage = "FactionBan";
Description =
"Bans the account of a targeted player from joining factions. All players on the account are removed from their current faction, if any.";
break;
}
{
Commands = new[] { "FactionBan" };
Usage = "FactionBan";
Description =
"Bans the account of a targeted player from joining factions. All players on the account are removed from their current faction, if any.";
break;
}
case FactionKickType.Unban:
{
Commands = new[] { "FactionUnban" };
Usage = "FactionUnban";
Description = "Unbans the account of a targeted player from joining factions.";
break;
}
{
Commands = new[] { "FactionUnban" };
Usage = "FactionUnban";
Description = "Unbans the account of a targeted player from joining factions.";
break;
}
}
}
@ -1265,81 +1244,81 @@ namespace Server.Factions
switch (m_KickType)
{
case FactionKickType.Kick:
{
PlayerState pl = PlayerState.Find(mob);
{
PlayerState pl = PlayerState.Find(mob);
if (pl != null)
{
pl.Faction.RemoveMember(mob);
mob.SendMessage("You have been kicked from your faction.");
AddResponse("They have been kicked from their faction.");
}
else
{
LogFailure("They are not in a faction.");
}
break;
}
case FactionKickType.Ban:
{
if (mob.Account is Account acct)
{
if (acct.GetTag("FactionBanned") == null)
if (pl != null)
{
acct.SetTag("FactionBanned", "true");
AddResponse("The account has been banned from joining factions.");
pl.Faction.RemoveMember(mob);
mob.SendMessage("You have been kicked from your faction.");
AddResponse("They have been kicked from their faction.");
}
else
{
AddResponse("The account is already banned from joining factions.");
LogFailure("They are not in a faction.");
}
for (int i = 0; i < acct.Length; ++i)
break;
}
case FactionKickType.Ban:
{
if (mob.Account is Account acct)
{
mob = acct[i];
if (mob != null)
if (acct.GetTag("FactionBanned") == null)
{
PlayerState pl = PlayerState.Find(mob);
acct.SetTag("FactionBanned", "true");
AddResponse("The account has been banned from joining factions.");
}
else
{
AddResponse("The account is already banned from joining factions.");
}
if (pl != null)
for (int i = 0; i < acct.Length; ++i)
{
mob = acct[i];
if (mob != null)
{
pl.Faction.RemoveMember(mob);
mob.SendMessage("You have been kicked from your faction.");
AddResponse("They have been kicked from their faction.");
PlayerState pl = PlayerState.Find(mob);
if (pl != null)
{
pl.Faction.RemoveMember(mob);
mob.SendMessage("You have been kicked from your faction.");
AddResponse("They have been kicked from their faction.");
}
}
}
}
}
else
{
LogFailure("They have no assigned account.");
}
break;
}
case FactionKickType.Unban:
{
if (mob.Account is Account acct)
{
if (acct.GetTag("FactionBanned") == null)
else
{
AddResponse("The account is not already banned from joining factions.");
LogFailure("They have no assigned account.");
}
break;
}
case FactionKickType.Unban:
{
if (mob.Account is Account acct)
{
if (acct.GetTag("FactionBanned") == null)
{
AddResponse("The account is not already banned from joining factions.");
}
else
{
acct.RemoveTag("FactionBanned");
AddResponse("The account may now freely join factions.");
}
}
else
{
acct.RemoveTag("FactionBanned");
AddResponse("The account may now freely join factions.");
LogFailure("They have no assigned account.");
}
}
else
{
LogFailure("They have no assigned account.");
}
break;
}
break;
}
}
}
}

View file

@ -4,7 +4,7 @@ namespace Server.Factions
{
public interface IFactionItem
{
FactionItem FactionItemState{ get; set; }
FactionItem FactionItemState { get; set; }
}
public class FactionItem
@ -24,21 +24,21 @@ namespace Server.Factions
switch (version)
{
case 0:
{
Item = reader.ReadItem();
Expiration = reader.ReadDateTime();
break;
}
{
Item = reader.ReadItem();
Expiration = reader.ReadDateTime();
break;
}
}
Faction = faction;
}
public Item Item{ get; }
public Item Item { get; }
public Faction Faction{ get; }
public Faction Faction { get; }
public DateTime Expiration{ get; private set; }
public DateTime Expiration { get; private set; }
public bool HasExpired
{

View file

@ -8,9 +8,9 @@ namespace Server.Factions
private const int BroadcastsPerPeriod = 2;
private static readonly TimeSpan BroadcastPeriod = TimeSpan.FromHours(1.0);
private Mobile m_Commander;
private Faction m_Faction;
private readonly Faction m_Faction;
private DateTime[] m_LastBroadcasts = new DateTime[BroadcastsPerPeriod];
private readonly DateTime[] m_LastBroadcasts = new DateTime[BroadcastsPerPeriod];
public FactionState(Faction faction)
{
@ -29,113 +29,113 @@ namespace Server.Factions
switch (version)
{
case 5:
{
LastAtrophy = reader.ReadDateTime();
goto case 4;
}
case 4:
{
int count = reader.ReadEncodedInt();
for (int i = 0; i < count; ++i)
{
DateTime time = reader.ReadDateTime();
if (i < m_LastBroadcasts.Length)
m_LastBroadcasts[i] = time;
LastAtrophy = reader.ReadDateTime();
goto case 4;
}
case 4:
{
int count = reader.ReadEncodedInt();
goto case 3;
}
for (int i = 0; i < count; ++i)
{
DateTime time = reader.ReadDateTime();
if (i < m_LastBroadcasts.Length)
m_LastBroadcasts[i] = time;
}
goto case 3;
}
case 3:
case 2:
case 1:
{
Election = new Election(reader);
{
Election = new Election(reader);
goto case 0;
}
goto case 0;
}
case 0:
{
m_Faction = Faction.ReadReference(reader);
m_Commander = reader.ReadMobile();
if (version < 5)
LastAtrophy = DateTime.UtcNow;
if (version < 4)
{
DateTime time = reader.ReadDateTime();
m_Faction = Faction.ReadReference(reader);
if (m_LastBroadcasts.Length > 0)
m_LastBroadcasts[0] = time;
}
m_Commander = reader.ReadMobile();
Tithe = reader.ReadEncodedInt();
Silver = reader.ReadEncodedInt();
if (version < 5)
LastAtrophy = DateTime.UtcNow;
int memberCount = reader.ReadEncodedInt();
Members = new List<PlayerState>();
for (int i = 0; i < memberCount; ++i)
{
PlayerState pl = new PlayerState(reader, m_Faction, Members);
if (pl.Mobile != null)
Members.Add(pl);
}
m_Faction.State = this;
m_Faction.ZeroRankOffset = Members.Count;
Members.Sort();
for (int i = Members.Count - 1; i >= 0; i--)
{
PlayerState player = Members[i];
if (player.KillPoints <= 0)
m_Faction.ZeroRankOffset = i;
else
player.RankIndex = i;
}
FactionItems = new List<FactionItem>();
if (version >= 2)
{
int factionItemCount = reader.ReadEncodedInt();
for (int i = 0; i < factionItemCount; ++i)
if (version < 4)
{
FactionItem factionItem = new FactionItem(reader, m_Faction);
DateTime time = reader.ReadDateTime();
Timer.DelayCall(TimeSpan.Zero, factionItem.CheckAttach); // sandbox attachment
if (m_LastBroadcasts.Length > 0)
m_LastBroadcasts[0] = time;
}
Tithe = reader.ReadEncodedInt();
Silver = reader.ReadEncodedInt();
int memberCount = reader.ReadEncodedInt();
Members = new List<PlayerState>();
for (int i = 0; i < memberCount; ++i)
{
PlayerState pl = new PlayerState(reader, m_Faction, Members);
if (pl.Mobile != null)
Members.Add(pl);
}
m_Faction.State = this;
m_Faction.ZeroRankOffset = Members.Count;
Members.Sort();
for (int i = Members.Count - 1; i >= 0; i--)
{
PlayerState player = Members[i];
if (player.KillPoints <= 0)
m_Faction.ZeroRankOffset = i;
else
player.RankIndex = i;
}
FactionItems = new List<FactionItem>();
if (version >= 2)
{
int factionItemCount = reader.ReadEncodedInt();
for (int i = 0; i < factionItemCount; ++i)
{
FactionItem factionItem = new FactionItem(reader, m_Faction);
Timer.DelayCall(TimeSpan.Zero, factionItem.CheckAttach); // sandbox attachment
}
}
Traps = new List<BaseFactionTrap>();
if (version >= 3)
{
int factionTrapCount = reader.ReadEncodedInt();
for (int i = 0; i < factionTrapCount; ++i)
if (reader.ReadItem() is BaseFactionTrap trap && !trap.CheckDecay())
Traps.Add(trap);
}
break;
}
Traps = new List<BaseFactionTrap>();
if (version >= 3)
{
int factionTrapCount = reader.ReadEncodedInt();
for (int i = 0; i < factionTrapCount; ++i)
if (reader.ReadItem() is BaseFactionTrap trap && !trap.CheckDecay())
Traps.Add(trap);
}
break;
}
}
if (version < 1)
Election = new Election(m_Faction);
}
public DateTime LastAtrophy{ get; set; }
public DateTime LastAtrophy { get; set; }
public bool FactionMessageReady
{
@ -151,11 +151,11 @@ namespace Server.Factions
public bool IsAtrophyReady => DateTime.UtcNow >= LastAtrophy + TimeSpan.FromHours(47.0);
public List<FactionItem> FactionItems{ get; set; }
public List<FactionItem> FactionItems { get; set; }
public List<BaseFactionTrap> Traps{ get; set; }
public List<BaseFactionTrap> Traps { get; set; }
public Election Election{ get; set; }
public Election Election { get; set; }
public Mobile Commander
{
@ -183,11 +183,11 @@ namespace Server.Factions
}
}
public int Tithe{ get; set; }
public int Tithe { get; set; }
public int Silver{ get; set; }
public int Silver { get; set; }
public List<PlayerState> Members{ get; set; }
public List<PlayerState> Members { get; set; }
public int CheckAtrophy()
{

View file

@ -1,6 +1,5 @@
using Server.Utilities;
using System;
using System.Collections.Generic;
using Server.Utilities;
namespace Server.Factions
{
@ -12,9 +11,9 @@ namespace Server.Factions
Guards = new List<BaseFactionGuard>();
}
public GuardDefinition Definition{ get; }
public GuardDefinition Definition { get; }
public List<BaseFactionGuard> Guards{ get; }
public List<BaseFactionGuard> Guards { get; }
public BaseFactionGuard Construct()
{

View file

@ -26,128 +26,128 @@ namespace Server.Factions
switch (keywords[i])
{
case 0x00E4: // *i wish to access the city treasury*
{
Town town = Town.FromRegion(from.Region);
if (town?.IsFinance(from) != true || !from.Alive)
break;
if (FactionGump.Exists(from))
from.SendLocalizedMessage(1042160); // You already have a faction menu open.
else if (town.Owner != null && from is PlayerMobile mobile)
mobile.SendGump(new FinanceGump(mobile, town.Owner, town));
break;
}
case 0x0ED: // *i am sheriff*
{
Town town = Town.FromRegion(from.Region);
if (town?.IsSheriff(from) != true || !from.Alive)
break;
if (FactionGump.Exists(from))
from.SendLocalizedMessage(1042160); // You already have a faction menu open.
else if (town.Owner != null)
from.SendGump(new SheriffGump((PlayerMobile)from, town.Owner, town));
break;
}
case 0x00EF: // *you are fired*
{
Town town = Town.FromRegion(from.Region);
if (town == null)
break;
if (town.IsFinance(from) || town.IsSheriff(from))
town.BeginOrderFiring(from);
break;
}
case 0x00E5: // *i wish to resign as finance minister*
{
PlayerState pl = PlayerState.Find(from);
if (pl?.Finance != null)
{
pl.Finance.Finance = null;
from.SendLocalizedMessage(1005081); // You have been fired as Finance Minister
}
Town town = Town.FromRegion(from.Region);
break;
}
case 0x00EE: // *i wish to resign as sheriff*
{
PlayerState pl = PlayerState.Find(from);
if (pl?.Sheriff != null)
{
pl.Sheriff.Sheriff = null;
from.SendLocalizedMessage(1010270); // You have been fired as Sheriff
}
break;
}
case 0x00E9: // *what is my faction term status*
{
PlayerState pl = PlayerState.Find(from);
if (pl?.IsLeaving == true)
{
if (Faction.CheckLeaveTimer(from))
if (town?.IsFinance(from) != true || !from.Alive)
break;
TimeSpan remaining = pl.Leaving + Faction.LeavePeriod - DateTime.UtcNow;
if (FactionGump.Exists(from))
from.SendLocalizedMessage(1042160); // You already have a faction menu open.
else if (town.Owner != null && from is PlayerMobile mobile)
mobile.SendGump(new FinanceGump(mobile, town.Owner, town));
if (remaining.TotalDays >= 1)
from.SendLocalizedMessage(1042743,
remaining.TotalDays
.ToString("N0")); // Your term of service will come to an end in ~1_DAYS~ days.
else if (remaining.TotalHours >= 1)
from.SendLocalizedMessage(1042741,
remaining.TotalHours
.ToString("N0")); // Your term of service will come to an end in ~1_HOURS~ hours.
else
from.SendLocalizedMessage(
1042742); // Your term of service will come to an end in less than one hour.
}
else if (pl != null)
{
from.SendLocalizedMessage(1042233); // You are not in the process of quitting the faction.
}
break;
}
case 0x00EA: // *message faction*
{
Faction faction = Faction.Find(from);
if (faction?.IsCommander(from) != true)
break;
}
case 0x0ED: // *i am sheriff*
{
Town town = Town.FromRegion(from.Region);
if (from.AccessLevel == AccessLevel.Player && !faction.FactionMessageReady)
from.SendLocalizedMessage(
1010264); // The required time has not yet passed since the last message was sent
else
faction.BeginBroadcast(from);
if (town?.IsSheriff(from) != true || !from.Alive)
break;
break;
}
if (FactionGump.Exists(from))
from.SendLocalizedMessage(1042160); // You already have a faction menu open.
else if (town.Owner != null)
from.SendGump(new SheriffGump((PlayerMobile)from, town.Owner, town));
break;
}
case 0x00EF: // *you are fired*
{
Town town = Town.FromRegion(from.Region);
if (town == null)
break;
if (town.IsFinance(from) || town.IsSheriff(from))
town.BeginOrderFiring(from);
break;
}
case 0x00E5: // *i wish to resign as finance minister*
{
PlayerState pl = PlayerState.Find(from);
if (pl?.Finance != null)
{
pl.Finance.Finance = null;
from.SendLocalizedMessage(1005081); // You have been fired as Finance Minister
}
break;
}
case 0x00EE: // *i wish to resign as sheriff*
{
PlayerState pl = PlayerState.Find(from);
if (pl?.Sheriff != null)
{
pl.Sheriff.Sheriff = null;
from.SendLocalizedMessage(1010270); // You have been fired as Sheriff
}
break;
}
case 0x00E9: // *what is my faction term status*
{
PlayerState pl = PlayerState.Find(from);
if (pl?.IsLeaving == true)
{
if (Faction.CheckLeaveTimer(from))
break;
TimeSpan remaining = pl.Leaving + Faction.LeavePeriod - DateTime.UtcNow;
if (remaining.TotalDays >= 1)
from.SendLocalizedMessage(1042743,
remaining.TotalDays
.ToString("N0")); // Your term of service will come to an end in ~1_DAYS~ days.
else if (remaining.TotalHours >= 1)
from.SendLocalizedMessage(1042741,
remaining.TotalHours
.ToString("N0")); // Your term of service will come to an end in ~1_HOURS~ hours.
else
from.SendLocalizedMessage(
1042742); // Your term of service will come to an end in less than one hour.
}
else if (pl != null)
{
from.SendLocalizedMessage(1042233); // You are not in the process of quitting the faction.
}
break;
}
case 0x00EA: // *message faction*
{
Faction faction = Faction.Find(from);
if (faction?.IsCommander(from) != true)
break;
if (from.AccessLevel == AccessLevel.Player && !faction.FactionMessageReady)
from.SendLocalizedMessage(
1010264); // The required time has not yet passed since the last message was sent
else
faction.BeginBroadcast(from);
break;
}
case 0x00EC: // *showscore*
{
PlayerState pl = PlayerState.Find(from);
{
PlayerState pl = PlayerState.Find(from);
if (pl != null)
Timer.DelayCall(TimeSpan.Zero, ShowScore_Sandbox, pl);
if (pl != null)
Timer.DelayCall(TimeSpan.Zero, ShowScore_Sandbox, pl);
break;
}
break;
}
case 0x0178: // i honor your leadership
{
Faction.Find(from)?.BeginHonorLeadership(from);
break;
}
{
Faction.Find(from)?.BeginHonorLeadership(from);
break;
}
}
}
}

View file

@ -22,20 +22,20 @@ namespace Server.Factions
Assigned = assigned;
}
public SkillName Skill{ get; }
public SkillName Skill { get; }
public double Requirement{ get; }
public double Requirement { get; }
public TextDefinition Title{ get; }
public TextDefinition Title { get; }
public TextDefinition Label{ get; }
public TextDefinition Label { get; }
public TextDefinition Assigned{ get; }
public TextDefinition Assigned { get; }
}
public class MerchantTitles
{
public static MerchantTitleInfo[] Info{ get; } =
public static MerchantTitleInfo[] Info { get; } =
{
new MerchantTitleInfo(SkillName.Inscribe, 90.0, new TextDefinition(1060773, "Scribe"),
new TextDefinition(1011468, "SCRIBE"),

View file

@ -16,7 +16,7 @@ namespace Server.Factions
public FactionPersistance(Serial serial) : base(serial) => Instance = this;
public static FactionPersistance Instance{ get; private set; }
public static FactionPersistance Instance { get; private set; }
public override string DefaultName => "Faction Persistance - Internal";
@ -54,22 +54,22 @@ namespace Server.Factions
switch (version)
{
case 0:
{
PersistedType type;
{
PersistedType type;
while ((type = (PersistedType)reader.ReadEncodedInt()) != PersistedType.Terminator)
switch (type)
{
case PersistedType.Faction:
new FactionState(reader);
break;
case PersistedType.Town:
new TownState(reader);
break;
}
while ((type = (PersistedType)reader.ReadEncodedInt()) != PersistedType.Terminator)
switch (type)
{
case PersistedType.Faction:
new FactionState(reader);
break;
case PersistedType.Town:
new TownState(reader);
break;
}
break;
}
break;
}
}
}

View file

@ -36,32 +36,32 @@ namespace Server.Factions
switch (version)
{
case 1:
{
IsActive = reader.ReadBool();
LastHonorTime = reader.ReadDateTime();
goto case 0;
}
{
IsActive = reader.ReadBool();
LastHonorTime = reader.ReadDateTime();
goto case 0;
}
case 0:
{
Mobile = reader.ReadMobile();
{
Mobile = reader.ReadMobile();
m_KillPoints = reader.ReadEncodedInt();
m_MerchantTitle = (MerchantTitle)reader.ReadEncodedInt();
m_KillPoints = reader.ReadEncodedInt();
m_MerchantTitle = (MerchantTitle)reader.ReadEncodedInt();
Leaving = reader.ReadDateTime();
Leaving = reader.ReadDateTime();
break;
}
break;
}
}
Attach();
}
public Mobile Mobile{ get; }
public Mobile Mobile { get; }
public Faction Faction{ get; }
public Faction Faction { get; }
public List<PlayerState> Owner{ get; }
public List<PlayerState> Owner { get; }
public MerchantTitle MerchantTitle
{
@ -93,7 +93,7 @@ namespace Server.Factions
}
}
public List<SilverGivenEntry> SilverGiven{ get; private set; }
public List<SilverGivenEntry> SilverGiven { get; private set; }
public int KillPoints
{
@ -233,13 +233,13 @@ namespace Server.Factions
}
}
public DateTime LastHonorTime{ get; set; }
public DateTime LastHonorTime { get; set; }
public DateTime Leaving{ get; set; }
public DateTime Leaving { get; set; }
public bool IsLeaving => Leaving > DateTime.MinValue;
public bool IsActive{ get; set; }
public bool IsActive { get; set; }
public int CompareTo(PlayerState ps) => (ps?.m_KillPoints ?? 0) - m_KillPoints;

View file

@ -1,8 +1,8 @@
using Server.Utilities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using Server.Utilities;
namespace Server.Factions
{

View file

@ -12,9 +12,9 @@ namespace Server.Factions
TimeOfGift = DateTime.UtcNow;
}
public Mobile GivenTo{ get; }
public Mobile GivenTo { get; }
public DateTime TimeOfGift{ get; }
public DateTime TimeOfGift { get; }
public bool IsExpired => TimeOfGift + ExpirePeriod < DateTime.UtcNow;
}

View file

@ -13,7 +13,7 @@ namespace Server.Factions
Register();
}
public Faction Faction{ get; set; }
public Faction Faction { get; set; }
public override bool OnMoveInto(Mobile m, Direction d, Point3D newLocation, Point3D oldLocation)
{

View file

@ -23,7 +23,7 @@ namespace Server.Factions
StartIncomeTimer();
}
public TownDefinition Definition{ get; set; }
public TownDefinition Definition { get; set; }
public TownState State
{
@ -125,9 +125,9 @@ namespace Server.Factions
set => m_State.LastIncome = value;
}
public List<VendorList> VendorLists{ get; set; }
public List<VendorList> VendorLists { get; set; }
public List<GuardList> GuardLists{ get; set; }
public List<GuardList> GuardLists { get; set; }
public static List<Town> Towns => Reflector.Towns;

View file

@ -16,42 +16,42 @@ namespace Server.Factions
switch (version)
{
case 3:
{
LastIncome = reader.ReadDateTime();
{
LastIncome = reader.ReadDateTime();
goto case 2;
}
goto case 2;
}
case 2:
{
Tax = reader.ReadEncodedInt();
LastTaxChange = reader.ReadDateTime();
{
Tax = reader.ReadEncodedInt();
LastTaxChange = reader.ReadDateTime();
goto case 1;
}
goto case 1;
}
case 1:
{
Silver = reader.ReadEncodedInt();
{
Silver = reader.ReadEncodedInt();
goto case 0;
}
goto case 0;
}
case 0:
{
Town = Town.ReadReference(reader);
Owner = Faction.ReadReference(reader);
{
Town = Town.ReadReference(reader);
Owner = Faction.ReadReference(reader);
m_Sheriff = reader.ReadMobile();
m_Finance = reader.ReadMobile();
m_Sheriff = reader.ReadMobile();
m_Finance = reader.ReadMobile();
Town.State = this;
Town.State = this;
break;
}
break;
}
}
}
public Town Town{ get; set; }
public Town Town { get; set; }
public Faction Owner{ get; set; }
public Faction Owner { get; set; }
public Mobile Sheriff
{
@ -103,13 +103,13 @@ namespace Server.Factions
}
}
public int Silver{ get; set; }
public int Silver { get; set; }
public int Tax{ get; set; }
public int Tax { get; set; }
public DateTime LastTaxChange{ get; set; }
public DateTime LastTaxChange { get; set; }
public DateTime LastIncome{ get; set; }
public DateTime LastIncome { get; set; }
public void Serialize(IGenericWriter writer)
{

View file

@ -1,6 +1,5 @@
using Server.Utilities;
using System;
using System.Collections.Generic;
using Server.Utilities;
namespace Server.Factions
{
@ -12,9 +11,9 @@ namespace Server.Factions
Vendors = new List<BaseFactionVendor>();
}
public VendorDefinition Definition{ get; }
public VendorDefinition Definition { get; }
public List<BaseFactionVendor> Vendors{ get; }
public List<BaseFactionVendor> Vendors { get; }
public BaseFactionVendor Construct(Town town, Faction faction)
{

View file

@ -36,54 +36,54 @@ namespace Server.Factions
Guards = guards;
}
public int Sort{ get; }
public int Sort { get; }
public int HuePrimary{ get; }
public int HuePrimary { get; }
public int HueSecondary{ get; }
public int HueSecondary { get; }
public int HueJoin{ get; }
public int HueJoin { get; }
public int HueBroadcast{ get; }
public int HueBroadcast { get; }
public int WarHorseBody{ get; }
public int WarHorseBody { get; }
public int WarHorseItem{ get; }
public int WarHorseItem { get; }
public string FriendlyName{ get; }
public string FriendlyName { get; }
public string Keyword{ get; }
public string Keyword { get; }
public string Abbreviation{ get; }
public string Abbreviation { get; }
public TextDefinition Name{ get; }
public TextDefinition Name { get; }
public TextDefinition PropName{ get; }
public TextDefinition PropName { get; }
public TextDefinition Header{ get; }
public TextDefinition Header { get; }
public TextDefinition About{ get; }
public TextDefinition About { get; }
public TextDefinition CityControl{ get; }
public TextDefinition CityControl { get; }
public TextDefinition SigilControl{ get; }
public TextDefinition SigilControl { get; }
public TextDefinition SignupName{ get; }
public TextDefinition SignupName { get; }
public TextDefinition FactionStoneName{ get; }
public TextDefinition FactionStoneName { get; }
public TextDefinition OwnerLabel{ get; }
public TextDefinition OwnerLabel { get; }
public TextDefinition GuardIgnore{ get; }
public TextDefinition GuardIgnore { get; }
public TextDefinition GuardWarn{ get; }
public TextDefinition GuardWarn { get; }
public TextDefinition GuardAttack{ get; }
public TextDefinition GuardAttack { get; }
public StrongholdDefinition Stronghold{ get; }
public StrongholdDefinition Stronghold { get; }
public RankDefinition[] Ranks{ get; }
public RankDefinition[] Ranks { get; }
public GuardDefinition[] Guards{ get; }
public GuardDefinition[] Guards { get; }
}
}

View file

@ -6,12 +6,12 @@ namespace Server.Factions
{
public class FactionItemDefinition
{
private static FactionItemDefinition m_MetalArmor = new FactionItemDefinition(1000, typeof(Blacksmith));
private static FactionItemDefinition m_Weapon = new FactionItemDefinition(1000, typeof(Blacksmith));
private static FactionItemDefinition m_RangedWeapon = new FactionItemDefinition(1000, typeof(Bowyer));
private static FactionItemDefinition m_LeatherArmor = new FactionItemDefinition(750, typeof(Tailor));
private static FactionItemDefinition m_Clothing = new FactionItemDefinition(200, typeof(Tailor));
private static FactionItemDefinition m_Scroll = new FactionItemDefinition(500, typeof(Mage));
private static readonly FactionItemDefinition m_MetalArmor = new FactionItemDefinition(1000, typeof(Blacksmith));
private static readonly FactionItemDefinition m_Weapon = new FactionItemDefinition(1000, typeof(Blacksmith));
private static readonly FactionItemDefinition m_RangedWeapon = new FactionItemDefinition(1000, typeof(Bowyer));
private static readonly FactionItemDefinition m_LeatherArmor = new FactionItemDefinition(750, typeof(Tailor));
private static readonly FactionItemDefinition m_Clothing = new FactionItemDefinition(200, typeof(Tailor));
private static readonly FactionItemDefinition m_Scroll = new FactionItemDefinition(500, typeof(Mage));
public FactionItemDefinition(int silverCost, Type vendorType)
{
@ -19,9 +19,9 @@ namespace Server.Factions
VendorType = vendorType;
}
public int SilverCost{ get; }
public int SilverCost { get; }
public Type VendorType{ get; }
public Type VendorType { get; }
public static FactionItemDefinition Identify(Item item)
{

View file

@ -18,18 +18,18 @@ namespace Server.Factions
Label = label;
}
public Type Type{ get; }
public Type Type { get; }
public int Price{ get; }
public int Price { get; }
public int Upkeep{ get; }
public int Upkeep { get; }
public int Maximum{ get; }
public int Maximum { get; }
public int ItemID{ get; }
public int ItemID { get; }
public TextDefinition Header{ get; }
public TextDefinition Header { get; }
public TextDefinition Label{ get; }
public TextDefinition Label { get; }
}
}

View file

@ -10,12 +10,12 @@ namespace Server.Factions
MaxWearables = maxWearables;
}
public int Rank{ get; }
public int Rank { get; }
public int Required{ get; }
public int Required { get; }
public int MaxWearables{ get; }
public int MaxWearables { get; }
public TextDefinition Title{ get; }
public TextDefinition Title { get; }
}
}

View file

@ -10,12 +10,12 @@ namespace Server.Factions
Monoliths = monoliths;
}
public Rectangle2D[] Area{ get; }
public Rectangle2D[] Area { get; }
public Point3D JoinStone{ get; }
public Point3D JoinStone { get; }
public Point3D FactionStone{ get; }
public Point3D FactionStone { get; }
public Point3D[] Monoliths{ get; }
public Point3D[] Monoliths { get; }
}
}

View file

@ -22,30 +22,30 @@ namespace Server.Factions
TownStone = townStone;
}
public int Sort{ get; }
public int Sort { get; }
public int SigilID{ get; }
public int SigilID { get; }
public string Region{ get; }
public string Region { get; }
public string FriendlyName{ get; }
public string FriendlyName { get; }
public TextDefinition TownName{ get; }
public TextDefinition TownName { get; }
public TextDefinition TownStoneHeader{ get; }
public TextDefinition TownStoneHeader { get; }
public TextDefinition StrongholdMonolithName{ get; }
public TextDefinition StrongholdMonolithName { get; }
public TextDefinition TownMonolithName{ get; }
public TextDefinition TownMonolithName { get; }
public TextDefinition TownStoneName{ get; }
public TextDefinition TownStoneName { get; }
public TextDefinition SigilName{ get; }
public TextDefinition SigilName { get; }
public TextDefinition CorruptedSigilName{ get; }
public TextDefinition CorruptedSigilName { get; }
public Point3D Monolith{ get; }
public Point3D Monolith { get; }
public Point3D TownStone{ get; }
public Point3D TownStone { get; }
}
}

View file

@ -18,57 +18,52 @@ namespace Server.Factions
Label = label;
}
public Type Type{ get; }
public Type Type { get; }
public int Price{ get; }
public int Price { get; }
public int Upkeep{ get; }
public int Upkeep { get; }
public int Maximum{ get; }
public int Maximum { get; }
public int ItemID{ get; }
public int ItemID { get; }
public TextDefinition Header{ get; }
public TextDefinition Header { get; }
public TextDefinition Label{ get; }
public TextDefinition Label { get; }
public static VendorDefinition[] Definitions{ get; } =
public static VendorDefinition[] Definitions { get; } =
{
new VendorDefinition(typeof(FactionBottleVendor), 0xF0E,
5000,
1000,
10,
new TextDefinition(1011549, "POTION BOTTLE VENDOR"),
new TextDefinition(1011544, "Buy Potion Bottle Vendor")
),
new TextDefinition(1011544, "Buy Potion Bottle Vendor")),
new VendorDefinition(typeof(FactionBoardVendor), 0x1BD7,
3000,
500,
10,
new TextDefinition(1011552, "WOOD VENDOR"),
new TextDefinition(1011545, "Buy Wooden Board Vendor")
),
new TextDefinition(1011545, "Buy Wooden Board Vendor")),
new VendorDefinition(typeof(FactionOreVendor), 0x19B8,
3000,
500,
10,
new TextDefinition(1011553, "IRON ORE VENDOR"),
new TextDefinition(1011546, "Buy Iron Ore Vendor")
),
new TextDefinition(1011546, "Buy Iron Ore Vendor")),
new VendorDefinition(typeof(FactionReagentVendor), 0xF86,
5000,
1000,
10,
new TextDefinition(1011554, "REAGENT VENDOR"),
new TextDefinition(1011547, "Buy Reagent Vendor")
),
new TextDefinition(1011547, "Buy Reagent Vendor")),
new VendorDefinition(typeof(FactionHorseVendor), 0x20DD,
5000,
1000,
1,
new TextDefinition(1011556, "HORSE BREEDER"),
new TextDefinition(1011555, "Buy Horse Breeder")
)
new TextDefinition(1011555, "Buy Horse Breeder"))
};
}
}

View file

@ -7,8 +7,8 @@ namespace Server.Factions
{
public class ElectionGump : FactionGump
{
private Election m_Election;
private PlayerMobile m_From;
private readonly Election m_Election;
private readonly PlayerMobile m_From;
public ElectionGump(PlayerMobile from, Election election) : base(50, 50)
{
@ -27,71 +27,71 @@ namespace Server.Factions
switch (election.State)
{
case ElectionState.Pending:
{
TimeSpan toGo = election.LastStateTime + Election.PendingPeriod - DateTime.UtcNow;
int days = (int)(toGo.TotalDays + 0.5);
AddHtmlLocalized(20, 40, 380, 20, 1038034); // A new election campaign is pending
if (days > 0)
{
AddHtmlLocalized(20, 60, 280, 20, 1018062); // Days until next election :
AddLabel(300, 60, 0, days.ToString());
}
else
{
AddHtmlLocalized(20, 60, 280, 20, 1018059); // Election campaigning begins tonight.
}
TimeSpan toGo = election.LastStateTime + Election.PendingPeriod - DateTime.UtcNow;
int days = (int)(toGo.TotalDays + 0.5);
break;
}
AddHtmlLocalized(20, 40, 380, 20, 1038034); // A new election campaign is pending
if (days > 0)
{
AddHtmlLocalized(20, 60, 280, 20, 1018062); // Days until next election :
AddLabel(300, 60, 0, days.ToString());
}
else
{
AddHtmlLocalized(20, 60, 280, 20, 1018059); // Election campaigning begins tonight.
}
break;
}
case ElectionState.Campaign:
{
TimeSpan toGo = election.LastStateTime + Election.CampaignPeriod - DateTime.UtcNow;
int days = (int)(toGo.TotalDays + 0.5);
AddHtmlLocalized(20, 40, 380, 20, 1018058); // There is an election campaign in progress.
if (days > 0)
{
AddHtmlLocalized(20, 60, 280, 20, 1038033); // Days to go:
AddLabel(300, 60, 0, days.ToString());
}
else
{
AddHtmlLocalized(20, 60, 280, 20, 1018061); // Campaign in progress. Voting begins tonight.
}
TimeSpan toGo = election.LastStateTime + Election.CampaignPeriod - DateTime.UtcNow;
int days = (int)(toGo.TotalDays + 0.5);
if (m_Election.CanBeCandidate(m_From))
{
AddButton(20, 110, 4005, 4007, 2);
AddHtmlLocalized(55, 110, 350, 20, 1011427); // CAMPAIGN FOR LEADERSHIP
}
else
{
PlayerState pl = PlayerState.Find(m_From);
AddHtmlLocalized(20, 40, 380, 20, 1018058); // There is an election campaign in progress.
if (pl == null || pl.Rank.Rank < Election.CandidateRank)
AddHtmlLocalized(20, 100, 380, 20, 1010118); // You must have a higher rank to run for office
}
if (days > 0)
{
AddHtmlLocalized(20, 60, 280, 20, 1038033); // Days to go:
AddLabel(300, 60, 0, days.ToString());
}
else
{
AddHtmlLocalized(20, 60, 280, 20, 1018061); // Campaign in progress. Voting begins tonight.
}
break;
}
if (m_Election.CanBeCandidate(m_From))
{
AddButton(20, 110, 4005, 4007, 2);
AddHtmlLocalized(55, 110, 350, 20, 1011427); // CAMPAIGN FOR LEADERSHIP
}
else
{
PlayerState pl = PlayerState.Find(m_From);
if (pl == null || pl.Rank.Rank < Election.CandidateRank)
AddHtmlLocalized(20, 100, 380, 20, 1010118); // You must have a higher rank to run for office
}
break;
}
case ElectionState.Election:
{
TimeSpan toGo = election.LastStateTime + Election.VotingPeriod - DateTime.UtcNow;
int days = (int)Math.Ceiling(toGo.TotalDays);
{
TimeSpan toGo = election.LastStateTime + Election.VotingPeriod - DateTime.UtcNow;
int days = (int)Math.Ceiling(toGo.TotalDays);
AddHtmlLocalized(20, 40, 380, 20, 1018060); // There is an election vote in progress.
AddHtmlLocalized(20, 40, 380, 20, 1018060); // There is an election vote in progress.
AddHtmlLocalized(20, 60, 280, 20, 1038033);
AddLabel(300, 60, 0, days.ToString());
AddHtmlLocalized(20, 60, 280, 20, 1038033);
AddLabel(300, 60, 0, days.ToString());
AddHtmlLocalized(55, 100, 380, 20, 1011428); // VOTE FOR LEADERSHIP
AddButton(20, 100, 4005, 4007, 1);
AddHtmlLocalized(55, 100, 380, 20, 1011428); // VOTE FOR LEADERSHIP
AddButton(20, 100, 4005, 4007, 1);
break;
}
break;
}
}
AddButton(20, 140, 4005, 4007, 0);
@ -103,24 +103,24 @@ namespace Server.Factions
switch (info.ButtonID)
{
case 0: // back
{
m_From.SendGump(new FactionStoneGump(m_From, m_Election.Faction));
break;
}
{
m_From.SendGump(new FactionStoneGump(m_From, m_Election.Faction));
break;
}
case 1: // vote
{
if (m_Election.State == ElectionState.Election)
m_From.SendGump(new VoteGump(m_From, m_Election));
{
if (m_Election.State == ElectionState.Election)
m_From.SendGump(new VoteGump(m_From, m_Election));
break;
}
break;
}
case 2: // campaign
{
if (m_Election.CanBeCandidate(m_From))
m_Election.AddCandidate(m_From);
{
if (m_Election.CanBeCandidate(m_From))
m_Election.AddCandidate(m_From);
break;
}
break;
}
}
}
}

View file

@ -8,10 +8,10 @@ namespace Server.Factions
public class ElectionManagementGump : Gump
{
public const int LabelColor = 0xFFFFFF;
private Candidate m_Candidate;
private readonly Candidate m_Candidate;
private Election m_Election;
private int m_Page;
private readonly Election m_Election;
private readonly int m_Page;
public ElectionManagementGump(Election election, Candidate candidate = null, int page = 0) : base(40, 40)
{
@ -53,7 +53,6 @@ namespace Server.Factions
else
AddImage(414, 104, 0x25E6);
AddHtml(14, 120, 30, 20, Color(Center("DEL"), LabelColor));
AddHtml(47, 120, 150, 20, Color("Name", LabelColor));
AddHtml(195, 120, 100, 20, Color(Center("Address"), LabelColor));

View file

@ -7,14 +7,14 @@ namespace Server.Factions
{
public class FactionImbueGump : FactionGump
{
private CraftSystem m_CraftSystem;
private readonly CraftSystem m_CraftSystem;
private FactionItemDefinition m_Definition;
private Faction m_Faction;
private Item m_Item;
private Mobile m_Mobile;
private object m_Notice;
private BaseTool m_Tool;
private readonly FactionItemDefinition m_Definition;
private readonly Faction m_Faction;
private readonly Item m_Item;
private readonly Mobile m_Mobile;
private readonly object m_Notice;
private readonly BaseTool m_Tool;
public FactionImbueGump(int quality, Item item, Mobile from, CraftSystem craftSystem, BaseTool tool, object notice,
int availableSilver, Faction faction, FactionItemDefinition def) : base(100, 200)
@ -34,9 +34,8 @@ namespace Server.Factions
AddHtmlLocalized(20, 20, 210, 25, 1011569); // Imbue with Faction properties?
AddHtmlLocalized(20, 60, 170, 25, 1018302); // Item quality:
AddHtmlLocalized(175, 60, 100, 25, 1018305 - quality); // Exceptional, Average, Low
AddHtmlLocalized(175, 60, 100, 25, 1018305 - quality); // Exceptional, Average, Low
AddHtmlLocalized(20, 80, 170, 25, 1011572); // Item Cost :
AddLabel(175, 80, 0x34, def.SilverCost.ToString("N0")); // NOTE: Added 'N0'
@ -44,7 +43,6 @@ namespace Server.Factions
AddHtmlLocalized(20, 100, 170, 25, 1011573); // Your Silver :
AddLabel(175, 100, 0x34, availableSilver.ToString("N0")); // NOTE: Added 'N0'
AddRadio(20, 140, 210, 211, true, 1);
AddLabel(55, 140, m_Faction.Definition.HuePrimary - 1, "*****");
AddHtmlLocalized(150, 140, 150, 25, 1011570); // Primary Color
@ -53,7 +51,6 @@ namespace Server.Factions
AddLabel(55, 160, m_Faction.Definition.HueSecondary - 1, "*****");
AddHtmlLocalized(150, 160, 150, 25, 1011571); // Secondary Color
AddHtmlLocalized(55, 200, 200, 25, 1011011); // CONTINUE
AddButton(20, 200, 4005, 4007, 1);

View file

@ -7,8 +7,8 @@ namespace Server.Factions
{
public class FactionStoneGump : FactionGump
{
private Faction m_Faction;
private PlayerMobile m_From;
private readonly Faction m_Faction;
private readonly PlayerMobile m_From;
public FactionStoneGump(PlayerMobile from, Faction faction) : base(20, 30)
{
@ -20,8 +20,6 @@ namespace Server.Factions
AddBackground(0, 0, 550, 440, 5054);
AddBackground(10, 10, 530, 420, 3000);
#region General
AddPage(1);
AddHtmlText(20, 30, 510, 20, faction.Definition.Header, false, false);
@ -79,10 +77,6 @@ namespace Server.Factions
AddHtmlLocalized(55, 300, 200, 20, 1011441); // EXIT
AddButton(20, 300, 4005, 4007, 0);
#endregion
#region City Status
AddPage(2);
AddHtmlLocalized(20, 30, 250, 20, 1011430); // CITY STATUS
@ -109,7 +103,6 @@ namespace Server.Factions
}
}
AddImage(20, 300, 2361);
AddHtmlLocalized(45, 295, 300, 20, 1011491); // sigil may be recaptured
@ -119,10 +112,6 @@ namespace Server.Factions
AddHtmlLocalized(55, 350, 100, 20, 1011447); // BACK
AddButton(20, 350, 4005, 4007, 0, GumpButtonType.Page, 1);
#endregion
#region Statistics
AddPage(4);
AddHtmlLocalized(20, 30, 150, 20, 1011444); // STATISTICS
@ -139,10 +128,6 @@ namespace Server.Factions
AddHtmlLocalized(55, 250, 100, 20, 1011447); // BACK
AddButton(20, 250, 4005, 4007, 0, GumpButtonType.Page, 1);
#endregion
#region Merchant Options
if ((pl == null || pl.MerchantTitle == MerchantTitle.None) && isMerchantQualified)
{
AddPage(5);
@ -169,14 +154,8 @@ namespace Server.Factions
AddButton(20, 340, 4005, 4007, 0, GumpButtonType.Page, 1);
}
#endregion
#region Commander Options
if (faction.IsCommander(from))
{
#region General
AddPage(6);
AddHtmlLocalized(20, 30, 200, 20, 1011461); // COMMANDER OPTIONS
@ -202,10 +181,6 @@ namespace Server.Factions
AddHtmlLocalized(55, 310, 100, 20, 1011447); // BACK
AddButton(20, 310, 4005, 4007, 0, GumpButtonType.Page, 1);
#endregion
#region Town Finance
if (faction.Silver >= 10000)
{
AddPage(7);
@ -230,10 +205,6 @@ namespace Server.Factions
AddButton(20, 310, 4005, 4007, 0, GumpButtonType.Page, 1);
}
#endregion
#region Change Tithe Rate
AddPage(8);
AddHtmlLocalized(20, 30, 400, 20, 1011479); // Select the % for the new tithe rate
@ -256,11 +227,7 @@ namespace Server.Factions
AddHtmlLocalized(55, 310, 300, 20, 1011447); // BACK
AddButton(20, 310, 4005, 4007, 0, GumpButtonType.Page, 1);
#endregion
}
#endregion
}
public override int ButtonTypes => 4;
@ -273,84 +240,84 @@ namespace Server.Factions
switch (type)
{
case 0: // general
{
switch (index)
{
case 0: // vote
switch (index)
{
m_From.SendGump(new ElectionGump(m_From, m_Faction.Election));
break;
case 0: // vote
{
m_From.SendGump(new ElectionGump(m_From, m_Faction.Election));
break;
}
case 1: // leave
{
m_From.SendGump(new LeaveFactionGump(m_From, m_Faction));
break;
}
}
case 1: // leave
{
m_From.SendGump(new LeaveFactionGump(m_From, m_Faction));
break;
}
}
break;
}
break;
}
case 1: // merchant title
{
if (index >= 0 && index <= MerchantTitles.Info.Length)
{
PlayerState pl = PlayerState.Find(m_From);
MerchantTitle newTitle = (MerchantTitle)index;
MerchantTitleInfo mti = MerchantTitles.GetInfo(newTitle);
if (mti == null)
if (index >= 0 && index <= MerchantTitles.Info.Length)
{
m_From.SendLocalizedMessage(1010120); // Your merchant title has been removed
PlayerState pl = PlayerState.Find(m_From);
if (pl != null)
pl.MerchantTitle = newTitle;
}
else if (MerchantTitles.IsQualified(m_From, mti))
{
m_From.SendLocalizedMessage(mti.Assigned);
MerchantTitle newTitle = (MerchantTitle)index;
MerchantTitleInfo mti = MerchantTitles.GetInfo(newTitle);
if (pl != null)
pl.MerchantTitle = newTitle;
}
}
break;
}
case 2: // transfer silver
{
if (!m_Faction.IsCommander(m_From))
return;
List<Town> towns = Town.Towns;
if (index >= 0 && index < towns.Count)
{
Town town = towns[index];
if (town.Owner == m_Faction)
if (m_Faction.Silver >= 10000)
if (mti == null)
{
m_Faction.Silver -= 10000;
town.Silver += 10000;
m_From.SendLocalizedMessage(1010120); // Your merchant title has been removed
// 10k in silver has been received by:
m_From.SendLocalizedMessage(1042726, true, $" {town.Definition.FriendlyName}");
if (pl != null)
pl.MerchantTitle = newTitle;
}
else if (MerchantTitles.IsQualified(m_From, mti))
{
m_From.SendLocalizedMessage(mti.Assigned);
if (pl != null)
pl.MerchantTitle = newTitle;
}
}
break;
}
case 2: // transfer silver
{
if (!m_Faction.IsCommander(m_From))
return;
break;
}
List<Town> towns = Town.Towns;
if (index >= 0 && index < towns.Count)
{
Town town = towns[index];
if (town.Owner == m_Faction)
if (m_Faction.Silver >= 10000)
{
m_Faction.Silver -= 10000;
town.Silver += 10000;
// 10k in silver has been received by:
m_From.SendLocalizedMessage(1042726, true, $" {town.Definition.FriendlyName}");
}
}
break;
}
case 3: // change tithe
{
if (!m_Faction.IsCommander(m_From))
return;
{
if (!m_Faction.IsCommander(m_From))
return;
if (index >= 0 && index <= 10)
m_Faction.Tithe = index * 10;
if (index >= 0 && index <= 10)
m_Faction.Tithe = index * 10;
break;
}
break;
}
}
}
}

View file

@ -9,15 +9,15 @@ namespace Server.Factions
{
public class FinanceGump : FactionGump
{
private static int[] m_PriceOffsets =
private static readonly int[] m_PriceOffsets =
{
-30, -25, -20, -15, -10, -5,
+50, +100, +150, +200, +250, +300
};
private Faction m_Faction;
private PlayerMobile m_From;
private Town m_Town;
private readonly Faction m_Faction;
private readonly PlayerMobile m_From;
private readonly Town m_Town;
public FinanceGump(PlayerMobile from, Faction faction, Town town) : base(50, 50)
{
@ -25,19 +25,15 @@ namespace Server.Factions
m_Faction = faction;
m_Town = town;
AddPage(0);
AddBackground(0, 0, 320, 410, 5054);
AddBackground(10, 10, 300, 390, 3000);
#region General
AddPage(1);
AddHtmlLocalized(20, 30, 260, 25, 1011541); // FINANCE MINISTER
AddHtmlLocalized(55, 90, 200, 25, 1011539); // CHANGE PRICES
AddButton(20, 90, 4005, 4007, 0, GumpButtonType.Page, 2);
@ -50,10 +46,6 @@ namespace Server.Factions
AddHtmlLocalized(55, 360, 200, 25, 1011441); // EXIT
AddButton(20, 360, 4005, 4007, 0);
#endregion
#region Change Prices
AddPage(2);
AddHtmlLocalized(20, 30, 200, 25, 1011539); // CHANGE PRICES
@ -82,10 +74,6 @@ namespace Server.Factions
AddHtmlLocalized(55, 360, 200, 25, 1011067); // Previous page
AddButton(20, 360, 4005, 4007, 0, GumpButtonType.Page, 1);
#endregion
#region Buy Shopkeepers
AddPage(3);
AddHtmlLocalized(20, 30, 200, 25, 1011540); // BUY SHOPKEEPERS
@ -101,13 +89,9 @@ namespace Server.Factions
AddHtmlText(100, 90 + i * 40, 200, 25, list.Definition.Label, false, false);
}
AddHtmlLocalized(55, 360, 200, 25, 1011067); // Previous page
AddHtmlLocalized(55, 360, 200, 25, 1011067); // Previous page
AddButton(20, 360, 4005, 4007, 0, GumpButtonType.Page, 1);
#endregion
#region View Finances
AddPage(4);
int financeUpkeep = town.FinanceUpkeep;
@ -115,7 +99,6 @@ namespace Server.Factions
int dailyIncome = town.DailyIncome;
int netCashFlow = town.NetCashFlow;
AddHtmlLocalized(20, 30, 300, 25, 1011524); // FINANCE STATEMENT
AddHtmlLocalized(20, 80, 300, 25, 1011538); // Current total money for town :
@ -136,10 +119,6 @@ namespace Server.Factions
AddHtmlLocalized(55, 360, 200, 25, 1011067); // Previous page
AddButton(20, 360, 4005, 4007, 0, GumpButtonType.Page, 1);
#endregion
#region Shopkeeper Pages
for (int i = 0; i < vendorLists.Count; ++i)
{
VendorList vendorList = vendorLists[i];
@ -176,8 +155,6 @@ namespace Server.Factions
AddHtmlLocalized(55, 360, 200, 25, 1011067); // Previous page
AddButton(20, 360, 4005, 4007, 0, GumpButtonType.Page, 3);
}
#endregion
}
public override int ButtonTypes => 2;
@ -196,96 +173,96 @@ namespace Server.Factions
switch (type)
{
case 0: // general
{
switch (index)
{
case 0: // set price
switch (index)
{
int[] switches = info.Switches;
case 0: // set price
{
int[] switches = info.Switches;
if (switches.Length == 0)
break;
if (switches.Length == 0)
break;
int opt = switches[0];
int newTax = 0;
int opt = switches[0];
int newTax = 0;
if (opt >= 1 && opt <= m_PriceOffsets.Length)
newTax = m_PriceOffsets[opt - 1];
if (opt >= 1 && opt <= m_PriceOffsets.Length)
newTax = m_PriceOffsets[opt - 1];
if (m_Town.Tax == newTax)
break;
if (m_Town.Tax == newTax)
break;
if (m_From.AccessLevel == AccessLevel.Player && !m_Town.TaxChangeReady)
{
TimeSpan remaining = DateTime.UtcNow - (m_Town.LastTaxChange + Town.TaxChangePeriod);
if (m_From.AccessLevel == AccessLevel.Player && !m_Town.TaxChangeReady)
{
TimeSpan remaining = DateTime.UtcNow - (m_Town.LastTaxChange + Town.TaxChangePeriod);
if (remaining.TotalMinutes < 4)
m_From.SendLocalizedMessage(
1042165); // You must wait a short while before changing prices again.
else if (remaining.TotalMinutes < 10)
m_From.SendLocalizedMessage(
1042166); // You must wait several minutes before changing prices again.
else if (remaining.TotalHours < 1)
m_From.SendLocalizedMessage(
1042167); // You must wait up to an hour before changing prices again.
else if (remaining.TotalHours < 4)
m_From.SendLocalizedMessage(
1042168); // You must wait a few hours before changing prices again.
else
m_From.SendLocalizedMessage(
1042169); // You must wait several hours before changing prices again.
}
else
{
m_Town.Tax = newTax;
if (remaining.TotalMinutes < 4)
m_From.SendLocalizedMessage(
1042165); // You must wait a short while before changing prices again.
else if (remaining.TotalMinutes < 10)
m_From.SendLocalizedMessage(
1042166); // You must wait several minutes before changing prices again.
else if (remaining.TotalHours < 1)
m_From.SendLocalizedMessage(
1042167); // You must wait up to an hour before changing prices again.
else if (remaining.TotalHours < 4)
m_From.SendLocalizedMessage(
1042168); // You must wait a few hours before changing prices again.
else
m_From.SendLocalizedMessage(
1042169); // You must wait several hours before changing prices again.
}
else
{
m_Town.Tax = newTax;
if (m_From.AccessLevel == AccessLevel.Player)
m_Town.LastTaxChange = DateTime.UtcNow;
}
if (m_From.AccessLevel == AccessLevel.Player)
m_Town.LastTaxChange = DateTime.UtcNow;
}
break;
break;
}
}
}
break;
}
break;
}
case 1: // make vendor
{
List<VendorList> vendorLists = m_Town.VendorLists;
if (index >= 0 && index < vendorLists.Count)
{
VendorList vendorList = vendorLists[index];
List<VendorList> vendorLists = m_Town.VendorLists;
if (Town.FromRegion(m_From.Region) != m_Town)
if (index >= 0 && index < vendorLists.Count)
{
m_From.SendLocalizedMessage(1010305); // You must be in your controlled city to buy Items
}
else if (vendorList.Vendors.Count >= vendorList.Definition.Maximum)
{
m_From.SendLocalizedMessage(
1010306); // You currently have too many of this enhancement type to place another
}
else if (BaseBoat.FindBoatAt(m_From.Location, m_From.Map) != null)
{
m_From.SendMessage("You cannot place a vendor here");
}
else if (m_Town.Silver >= vendorList.Definition.Price)
{
BaseFactionVendor vendor = vendorList.Construct(m_Town, m_Faction);
VendorList vendorList = vendorLists[index];
if (vendor != null)
if (Town.FromRegion(m_From.Region) != m_Town)
{
m_Town.Silver -= vendorList.Definition.Price;
m_From.SendLocalizedMessage(1010305); // You must be in your controlled city to buy Items
}
else if (vendorList.Vendors.Count >= vendorList.Definition.Maximum)
{
m_From.SendLocalizedMessage(
1010306); // You currently have too many of this enhancement type to place another
}
else if (BaseBoat.FindBoatAt(m_From.Location, m_From.Map) != null)
{
m_From.SendMessage("You cannot place a vendor here");
}
else if (m_Town.Silver >= vendorList.Definition.Price)
{
BaseFactionVendor vendor = vendorList.Construct(m_Town, m_Faction);
vendor.MoveToWorld(m_From.Location, m_From.Map);
vendor.Home = vendor.Location;
if (vendor != null)
{
m_Town.Silver -= vendorList.Definition.Price;
vendor.MoveToWorld(m_From.Location, m_From.Map);
vendor.Home = vendor.Location;
}
}
}
}
break;
}
break;
}
}
}
}

View file

@ -7,8 +7,8 @@ namespace Server.Factions
{
public class HorseBreederGump : FactionGump
{
private Faction m_Faction;
private PlayerMobile m_From;
private readonly Faction m_Faction;
private readonly PlayerMobile m_From;
public HorseBreederGump(PlayerMobile from, Faction faction) : base(20, 30)
{

View file

@ -6,8 +6,8 @@ namespace Server.Factions
{
public class JoinStoneGump : FactionGump
{
private Faction m_Faction;
private PlayerMobile m_From;
private readonly Faction m_Faction;
private readonly PlayerMobile m_From;
public JoinStoneGump(PlayerMobile from, Faction faction) : base(20, 30)
{
@ -19,11 +19,9 @@ namespace Server.Factions
AddBackground(0, 0, 550, 440, 5054);
AddBackground(10, 10, 530, 420, 3000);
AddHtmlText(20, 30, 510, 20, faction.Definition.Header, false, false);
AddHtmlText(20, 130, 510, 100, faction.Definition.About, true, true);
AddHtmlLocalized(20, 60, 100, 20, 1011429); // Led By :
AddHtml(125, 60, 200, 20, faction.Commander != null ? faction.Commander.Name : "Nobody");
@ -33,7 +31,6 @@ namespace Server.Factions
else
AddHtml(125, 80, 350, 20, $"{faction.Tithe}%");
AddButton(20, 400, 4005, 4007, 1);
AddHtmlLocalized(55, 400, 200, 20, 1011425); // JOIN THIS FACTION

View file

@ -9,7 +9,7 @@ namespace Server.Factions
public class LeaveFactionGump : FactionGump
{
private Faction m_Faction;
private PlayerMobile m_From;
private readonly PlayerMobile m_From;
public LeaveFactionGump(PlayerMobile from, Faction faction) : base(20, 30)
{
@ -37,56 +37,56 @@ namespace Server.Factions
switch (info.ButtonID)
{
case 1: // continue
{
if (!(m_From.Guild is Guild guild))
{
PlayerState pl = PlayerState.Find(m_From);
if (pl != null)
if (!(m_From.Guild is Guild guild))
{
pl.Leaving = DateTime.UtcNow;
if (Faction.LeavePeriod == TimeSpan.FromDays(3.0))
m_From.SendLocalizedMessage(1005065); // You will be removed from the faction in 3 days
else
m_From.SendMessage("You will be removed from the faction in {0} days.",
Faction.LeavePeriod.TotalDays);
}
}
else if (guild.Leader != m_From)
{
m_From.SendLocalizedMessage(
1005061); // You cannot quit the faction because you are not the guild master
}
else
{
m_From.SendLocalizedMessage(1042285); // Your guild is now quitting the faction.
for (int i = 0; i < guild.Members.Count; ++i)
{
Mobile mob = guild.Members[i];
PlayerState pl = PlayerState.Find(mob);
PlayerState pl = PlayerState.Find(m_From);
if (pl != null)
{
pl.Leaving = DateTime.UtcNow;
if (Faction.LeavePeriod == TimeSpan.FromDays(3.0))
mob.SendLocalizedMessage(1005060); // Your guild will quit the faction in 3 days
if (TimeSpan.FromDays(3.0) == Faction.LeavePeriod)
m_From.SendLocalizedMessage(1005065); // You will be removed from the faction in 3 days
else
mob.SendMessage("Your guild will quit the faction in {0} days.",
m_From.SendMessage("You will be removed from the faction in {0} days.",
Faction.LeavePeriod.TotalDays);
}
}
}
else if (guild.Leader != m_From)
{
m_From.SendLocalizedMessage(
1005061); // You cannot quit the faction because you are not the guild master
}
else
{
m_From.SendLocalizedMessage(1042285); // Your guild is now quitting the faction.
break;
}
for (int i = 0; i < guild.Members.Count; ++i)
{
Mobile mob = guild.Members[i];
PlayerState pl = PlayerState.Find(mob);
if (pl != null)
{
pl.Leaving = DateTime.UtcNow;
if (TimeSpan.FromDays(3.0) == Faction.LeavePeriod)
mob.SendLocalizedMessage(1005060); // Your guild will quit the faction in 3 days
else
mob.SendMessage("Your guild will quit the faction in {0} days.",
Faction.LeavePeriod.TotalDays);
}
}
}
break;
}
case 2: // cancel
{
m_From.SendLocalizedMessage(500737); // Canceled resignation.
break;
}
{
m_From.SendLocalizedMessage(500737); // Canceled resignation.
break;
}
}
}
}

View file

@ -8,9 +8,9 @@ namespace Server.Factions
{
public class SheriffGump : FactionGump
{
private Faction m_Faction;
private PlayerMobile m_From;
private Town m_Town;
private readonly Faction m_Faction;
private readonly PlayerMobile m_From;
private readonly Town m_Town;
public SheriffGump(PlayerMobile from, Faction faction, Town town) : base(50, 50)
{
@ -18,14 +18,11 @@ namespace Server.Factions
m_Faction = faction;
m_Town = town;
AddPage(0);
AddBackground(0, 0, 320, 410, 5054);
AddBackground(10, 10, 300, 390, 3000);
#region General
AddPage(1);
AddHtmlLocalized(20, 30, 260, 25, 1011431); // Sheriff
@ -39,10 +36,6 @@ namespace Server.Factions
AddHtmlLocalized(55, 360, 200, 25, 1011441); // Exit
AddButton(20, 360, 4005, 4007, 0);
#endregion
#region Finances
AddPage(2);
int financeUpkeep = town.FinanceUpkeep;
@ -70,10 +63,6 @@ namespace Server.Factions
AddHtmlLocalized(55, 360, 200, 25, 1011067); // Previous page
AddButton(20, 360, 4005, 4007, 0, GumpButtonType.Page, 1);
#endregion
#region Hire Guards
AddPage(3);
AddHtmlLocalized(20, 30, 300, 25, 1011494); // HIRE GUARDS
@ -93,10 +82,6 @@ namespace Server.Factions
AddHtmlLocalized(55, 360, 200, 25, 1011067); // Previous page
AddButton(20, 360, 4005, 4007, 0, GumpButtonType.Page, 1);
#endregion
#region Guard Pages
for (int i = 0; i < guardLists.Count; ++i)
{
GuardList guardList = guardLists[i];
@ -130,8 +115,6 @@ namespace Server.Factions
AddHtmlLocalized(55, 360, 200, 25, 1011067); // Previous page
AddButton(20, 360, 4005, 4007, 0, GumpButtonType.Page, 3);
}
#endregion
}
private void CenterItem(int itemID, int x, int y, int w, int h)

View file

@ -7,9 +7,9 @@ namespace Server.Factions
{
public class TownStoneGump : FactionGump
{
private Faction m_Faction;
private PlayerMobile m_From;
private Town m_Town;
private readonly Faction m_Faction;
private readonly PlayerMobile m_From;
private readonly Town m_Town;
public TownStoneGump(PlayerMobile from, Faction faction, Town town) : base(50, 50)
{
@ -51,65 +51,65 @@ namespace Server.Factions
switch (info.ButtonID)
{
case 1: // hire sheriff
{
if (m_Town.Sheriff != null)
{
m_From.SendLocalizedMessage(1010342); // You must fire your Sheriff before you can elect a new one
}
else
{
m_From.SendLocalizedMessage(1010347); // Who shall be your new sheriff
m_From.BeginTarget(12, false, TargetFlags.None, HireSheriff_OnTarget);
}
if (m_Town.Sheriff != null)
{
m_From.SendLocalizedMessage(1010342); // You must fire your Sheriff before you can elect a new one
}
else
{
m_From.SendLocalizedMessage(1010347); // Who shall be your new sheriff
m_From.BeginTarget(12, false, TargetFlags.None, HireSheriff_OnTarget);
}
break;
}
break;
}
case 2: // hire finance minister
{
if (m_Town.Finance != null)
{
m_From.SendLocalizedMessage(
1010345); // You must fire your finance minister before you can elect a new one
}
else
{
m_From.SendLocalizedMessage(1010348); // Who shall be your new Minister of Finances?
m_From.BeginTarget(12, false, TargetFlags.None, HireFinanceMinister_OnTarget);
}
if (m_Town.Finance != null)
{
m_From.SendLocalizedMessage(
1010345); // You must fire your finance minister before you can elect a new one
}
else
{
m_From.SendLocalizedMessage(1010348); // Who shall be your new Minister of Finances?
m_From.BeginTarget(12, false, TargetFlags.None, HireFinanceMinister_OnTarget);
}
break;
}
break;
}
case 3: // fire sheriff
{
if (m_Town.Sheriff == null)
{
m_From.SendLocalizedMessage(1010350); // You need to elect a sheriff before you can fire one
}
else
{
m_From.SendLocalizedMessage(1010349); // You have fired your sheriff
m_Town.Sheriff.SendLocalizedMessage(1010270); // You have been fired as Sheriff
m_Town.Sheriff = null;
}
if (m_Town.Sheriff == null)
{
m_From.SendLocalizedMessage(1010350); // You need to elect a sheriff before you can fire one
}
else
{
m_From.SendLocalizedMessage(1010349); // You have fired your sheriff
m_Town.Sheriff.SendLocalizedMessage(1010270); // You have been fired as Sheriff
m_Town.Sheriff = null;
}
break;
}
break;
}
case 4: // fire finance minister
{
if (m_Town.Finance == null)
{
m_From.SendLocalizedMessage(
1010352); // You need to elect a financial minister before you can fire one
}
else
{
m_From.SendLocalizedMessage(1010351); // You have fired your financial Minister
m_Town.Finance.SendLocalizedMessage(1010151); // You have been fired as Finance Minister
m_Town.Finance = null;
}
if (m_Town.Finance == null)
{
m_From.SendLocalizedMessage(
1010352); // You need to elect a financial minister before you can fire one
}
else
{
m_From.SendLocalizedMessage(1010351); // You have fired your financial Minister
m_Town.Finance.SendLocalizedMessage(1010151); // You have been fired as Finance Minister
m_Town.Finance = null;
}
break;
}
break;
}
}
}

View file

@ -6,8 +6,8 @@ namespace Server.Factions
{
public class VoteGump : FactionGump
{
private Election m_Election;
private PlayerMobile m_From;
private readonly Election m_Election;
private readonly PlayerMobile m_From;
public VoteGump(PlayerMobile from, Election election) : base(50, 50)
{

View file

@ -97,10 +97,9 @@ namespace Server.Factions
new TextDefinition(1011507, "SORCERESS"), new TextDefinition(1011501, "Hire Sorceress")),
new GuardDefinition(typeof(FactionWizard), 0x13F8, 8000, 4000, 10,
new TextDefinition(1011508, "ELDER WIZARD"), new TextDefinition(1011502, "Hire Elder Wizard"))
}
);
});
}
public static Faction Instance{ get; private set; }
public static Faction Instance { get; private set; }
}
}

View file

@ -74,10 +74,9 @@ namespace Server.Factions
new TextDefinition(1011505, "BERSERKER"), new TextDefinition(1011499, "Hire Berserker")),
new GuardDefinition(typeof(FactionDragoon), 0x1439, 8000, 4000, 10,
new TextDefinition(1011506, "DRAGOON"), new TextDefinition(1011500, "Hire Dragoon"))
}
);
});
}
public static Faction Instance{ get; private set; }
public static Faction Instance { get; private set; }
}
}

View file

@ -74,10 +74,9 @@ namespace Server.Factions
new TextDefinition(1011512, "DEATH KNIGHT"), new TextDefinition(1011503, "Hire Death Knight")),
new GuardDefinition(typeof(FactionNecromancer), 0x13F8, 8000, 4000, 10,
new TextDefinition(1011513, "SHADOW MAGE"), new TextDefinition(1011504, "Hire Shadow Mage"))
}
);
});
}
public static Faction Instance{ get; private set; }
public static Faction Instance { get; private set; }
}
}

View file

@ -79,10 +79,9 @@ namespace Server.Factions
new TextDefinition(1011528, "KNIGHT"), new TextDefinition(1011497, "Hire Knight")),
new GuardDefinition(typeof(FactionPaladin), 0x143F, 8000, 4000, 10,
new TextDefinition(1011529, "PALADIN"), new TextDefinition(1011498, "Hire Paladin"))
}
);
});
}
public static Faction Instance{ get; private set; }
public static Faction Instance { get; private set; }
}
}

View file

@ -64,7 +64,7 @@ namespace Server.Factions
}
}
public static List<BaseMonolith> Monoliths{ get; set; } = new List<BaseMonolith>();
public static List<BaseMonolith> Monoliths { get; set; } = new List<BaseMonolith>();
public override void OnLocationChange(Point3D oldLocation)
{
@ -117,12 +117,12 @@ namespace Server.Factions
switch (version)
{
case 0:
{
Town = Town.ReadReference(reader);
Faction = Faction.ReadReference(reader);
m_Sigil = reader.ReadItem() as Sigil;
break;
}
{
Town = Town.ReadReference(reader);
Faction = Faction.ReadReference(reader);
m_Sigil = reader.ReadItem() as Sigil;
break;
}
}
}
}

View file

@ -89,10 +89,10 @@ namespace Server.Factions
switch (version)
{
case 0:
{
Faction = Faction.ReadReference(reader);
break;
}
{
Faction = Faction.ReadReference(reader);
break;
}
}
}
}

View file

@ -64,10 +64,10 @@ namespace Server.Factions
switch (version)
{
case 0:
{
Faction = Faction.ReadReference(reader);
break;
}
{
Faction = Faction.ReadReference(reader);
break;
}
}
}
}

View file

@ -40,7 +40,7 @@ namespace Server
from.PlaySound(0x1EE);
from.AddStatMod(new StatMod(StatType.Int, "clarity-potion", amount, TimeSpan.FromMinutes(time)));
Timer.DelayCall(TimeSpan.FromMinutes(time), delegate { from.EndAction<ClarityPotion>(); });
Timer.DelayCall(TimeSpan.FromMinutes(time), from.EndAction<ClarityPotion>);
return true;
}
@ -62,4 +62,4 @@ namespace Server
int version = reader.ReadEncodedInt();
}
}
}
}

View file

@ -9,7 +9,7 @@ namespace Server
{
public abstract class PowerFactionItem : Item
{
private static WeightedItem[] _items =
private static readonly WeightedItem[] _items =
{
new WeightedItem(30, typeof(GemOfEmpowerment)),
new WeightedItem(25, typeof(BloodRose)),
@ -61,8 +61,7 @@ namespace Server
killer.SendSound(1470);
killer.LocalOverheadMessage(
MessageType.Regular, 2119, false,
"You notice a strange item on the corpse, and decide to pick it up."
);
"You notice a strange item on the corpse, and decide to pick it up.");
try
{
@ -101,19 +100,16 @@ namespace Server
"The object vanishes from your hands as you touch it.");
Timer.DelayCall(TimeSpan.FromSeconds(1.0),
delegate
{
from.LocalOverheadMessage(MessageType.Regular, 2118, false,
"You feel a strange tingling sensation throughout your body.");
});
() => from.LocalOverheadMessage(MessageType.Regular, 2118, false,
"You feel a strange tingling sensation throughout your body."));
Timer.DelayCall(TimeSpan.FromSeconds(4.0),
delegate { from.LocalOverheadMessage(MessageType.Regular, 2118, false, "Your skin begins to burn."); });
() => { from.LocalOverheadMessage(MessageType.Regular, 2118, false, "Your skin begins to burn."); });
new DestructionTimer(from).Start();
Delete();
//from.SendMessage( "You must be in a faction to use this item." );
// from.SendMessage( "You must be in a faction to use this item." );
}
else if (Use(from))
{
@ -138,7 +134,7 @@ namespace Server
private sealed class DestructionTimer : Timer
{
private Mobile _mobile;
private readonly Mobile _mobile;
private bool _screamed;
@ -171,9 +167,9 @@ namespace Server
Type = type;
}
public int Weight{ get; }
public int Weight { get; }
public Type Type{ get; }
public Type Type { get; }
public Item Construct() => ActivatorUtil.CreateInstance(Type) as Item;
}

View file

@ -23,7 +23,7 @@ namespace Server
public override bool Use(Mobile user)
{
if (Movable)
user.BeginTarget(12, true, TargetFlags.None, delegate(Mobile from, object obj)
user.BeginTarget(12, true, TargetFlags.None, (from, obj) =>
{
if (Movable && !Deleted)
if (obj is IPoint3D pt)
@ -40,10 +40,9 @@ namespace Server
Effects.SendMovingEffect(
from, new Entity(Serial.Zero, origin, facet),
ItemID & 0x3FFF, 7, 0, false, false, Hue - 1
);
ItemID & 0x3FFF, 7, 0, false, false, Hue - 1);
Timer.DelayCall(TimeSpan.FromSeconds(0.5), delegate
Timer.DelayCall(TimeSpan.FromSeconds(0.5), () =>
{
Delete();
@ -52,10 +51,9 @@ namespace Server
Effects.SendLocationEffect(
origin, facet,
14284, 96, 1, 0, 2
);
14284, 96, 1, 0, 2);
Timer.DelayCall(TimeSpan.FromSeconds(1.0), delegate
Timer.DelayCall(TimeSpan.FromSeconds(1.0), () =>
{
List<Mobile> targets = facet.GetMobilesInRange(origin, 12).Where(mob =>
from.CanBeHarmful(mob, false) && mob.InLOS(new Point3D(origin, origin.Z + 1)) &&
@ -72,8 +70,7 @@ namespace Server
Effects.SendMovingEffect(
new Entity(Serial.Zero, new Point3D(origin, origin.Z + 4), facet), mob,
14068, 1, 32, false, false, 1111, 2
);
14068, 1, 32, false, false, 1111, 2);
from.DoHarmful(mob);
@ -84,7 +81,7 @@ namespace Server
SpellHelper.Damage(TimeSpan.FromSeconds(1.00), mob, from, damage / 3.0, 0, 0, 0, 0,
100);
Timer.DelayCall(TimeSpan.FromSeconds(0.50), delegate { mob.PlaySound(0x1FB); });
Timer.DelayCall(TimeSpan.FromSeconds(0.50), mob.PlaySound, 0x1FB);
}
});
});

View file

@ -41,16 +41,16 @@ namespace Server.Factions
}
[CommandProperty(AccessLevel.Counselor, AccessLevel.Administrator)]
public DateTime LastStolen{ get; set; }
public DateTime LastStolen { get; set; }
[CommandProperty(AccessLevel.Counselor, AccessLevel.Administrator)]
public DateTime GraceStart{ get; set; }
public DateTime GraceStart { get; set; }
[CommandProperty(AccessLevel.Counselor, AccessLevel.Administrator)]
public DateTime CorruptionStart{ get; set; }
public DateTime CorruptionStart { get; set; }
[CommandProperty(AccessLevel.Counselor, AccessLevel.Administrator)]
public DateTime PurificationStart{ get; set; }
public DateTime PurificationStart { get; set; }
[CommandProperty(AccessLevel.Counselor, AccessLevel.Administrator)]
public Town Town
@ -86,7 +86,7 @@ namespace Server.Factions
}
[CommandProperty(AccessLevel.Counselor, AccessLevel.Administrator)]
public BaseMonolith LastMonolith{ get; set; }
public BaseMonolith LastMonolith { get; set; }
[CommandProperty(AccessLevel.Counselor)]
public bool IsBeingCorrupted => LastMonolith is StrongholdMonolith && LastMonolith.Faction == m_Corrupting &&
@ -118,7 +118,7 @@ namespace Server.Factions
}
}
public static List<Sigil> Sigils{ get; } = new List<Sigil>();
public static List<Sigil> Sigils { get; } = new List<Sigil>();
public void Update()
{
@ -240,8 +240,6 @@ namespace Server.Factions
if (Deleted || !IsChildOf(from.Backpack))
return;
#region Give To Mobile
if (obj is Mobile)
{
if (obj is PlayerMobile targ)
@ -274,16 +272,11 @@ namespace Server.Factions
}
else
{
from.SendLocalizedMessage(1005221); //You cannot give the sigil to them
from.SendLocalizedMessage(1005221); // You cannot give the sigil to them
}
}
#endregion
else if (obj is BaseMonolith)
{
#region Put in Stronghold
if (obj is StrongholdMonolith sm)
{
if (sm.Faction == null || sm.Faction != Faction.Find(from))
@ -327,11 +320,6 @@ namespace Server.Factions
PurificationStart = DateTime.MinValue;
}
}
#endregion
#region Put in Town
else if (obj is TownMonolith tm)
{
if (tm.Town == null || tm.Town != m_Town)
@ -355,12 +343,10 @@ namespace Server.Factions
m_Corrupted = null;
}
}
#endregion
}
else
{
from.SendLocalizedMessage(1005224); // You can't use the sigil on that
from.SendLocalizedMessage(1005224); // You can't use the sigil on that
}
Update();
@ -393,25 +379,25 @@ namespace Server.Factions
switch (version)
{
case 0:
{
m_Town = Town.ReadReference(reader);
m_Corrupted = Faction.ReadReference(reader);
m_Corrupting = Faction.ReadReference(reader);
{
m_Town = Town.ReadReference(reader);
m_Corrupted = Faction.ReadReference(reader);
m_Corrupting = Faction.ReadReference(reader);
LastMonolith = reader.ReadItem() as BaseMonolith;
LastMonolith = reader.ReadItem() as BaseMonolith;
LastStolen = reader.ReadDateTime();
GraceStart = reader.ReadDateTime();
CorruptionStart = reader.ReadDateTime();
PurificationStart = reader.ReadDateTime();
LastStolen = reader.ReadDateTime();
GraceStart = reader.ReadDateTime();
CorruptionStart = reader.ReadDateTime();
PurificationStart = reader.ReadDateTime();
Update();
Update();
if (RootParent is Mobile mob)
mob.SolidHueOverride = OwnershipHue;
if (RootParent is Mobile mob)
mob.SolidHueOverride = OwnershipHue;
break;
}
break;
}
}
}

View file

@ -4,7 +4,6 @@ namespace Server.Factions
{
public StrongholdMonolith(Town town = null, Faction faction = null) : base(town, faction)
{
}
public StrongholdMonolith(Serial serial) : base(serial)

View file

@ -41,7 +41,7 @@ namespace Server.Factions
if (faction == null && from.AccessLevel < AccessLevel.GameMaster)
return; // TODO: Message?
if (m_Town.Owner == null || from.AccessLevel < AccessLevel.GameMaster && faction != m_Town.Owner)
if (m_Town.Owner == null || (from.AccessLevel < AccessLevel.GameMaster && faction != m_Town.Owner))
from.SendLocalizedMessage(1010332); // Your faction does not control this town
else if (!m_Town.Owner.IsCommander(from))
from.SendLocalizedMessage(1005242); // Only faction Leaders can use townstones
@ -69,10 +69,10 @@ namespace Server.Factions
switch (version)
{
case 0:
{
Town = Town.ReadReference(reader);
break;
}
{
Town = Town.ReadReference(reader);
break;
}
}
}
}

View file

@ -31,13 +31,13 @@ namespace Server.Factions
}
[CommandProperty(AccessLevel.GameMaster)]
public Faction Faction{ get; set; }
public Faction Faction { get; set; }
[CommandProperty(AccessLevel.GameMaster)]
public Mobile Placer{ get; set; }
public Mobile Placer { get; set; }
[CommandProperty(AccessLevel.GameMaster)]
public DateTime TimeOfPlacement{ get; set; }
public DateTime TimeOfPlacement { get; set; }
public virtual int EffectSound => 0;
@ -120,32 +120,32 @@ namespace Server.Factions
switch (AllowedPlacing)
{
case AllowedPlacing.FactionStronghold:
{
StrongholdRegion region = Region.Find(p, m).GetRegion<StrongholdRegion>();
{
StrongholdRegion region = Region.Find(p, m).GetRegion<StrongholdRegion>();
if (region != null && region.Faction == Faction)
return 0;
if (region != null && region.Faction == Faction)
return 0;
return 1010355; // This trap can only be placed in your stronghold
}
return 1010355; // This trap can only be placed in your stronghold
}
case AllowedPlacing.AnyFactionTown:
{
Town town = Town.FromRegion(Region.Find(p, m));
{
Town town = Town.FromRegion(Region.Find(p, m));
if (town != null)
return 0;
if (town != null)
return 0;
return 1010356; // This trap can only be placed in a faction town
}
return 1010356; // This trap can only be placed in a faction town
}
case AllowedPlacing.ControlledFactionTown:
{
Town town = Town.FromRegion(Region.Find(p, m));
{
Town town = Town.FromRegion(Region.Find(p, m));
if (town != null && town.Owner == Faction)
return 0;
if (town != null && town.Owner == Faction)
return 0;
return 1010357; // This trap can only be placed in a town your faction controls
}
return 1010357; // This trap can only be placed in a town your faction controls
}
}
return 0;

View file

@ -9,7 +9,7 @@ namespace Server.Factions
{
private Faction m_Faction;
public BaseFactionTrapDeed(int itemID= 0x14F0) : base(itemID)
public BaseFactionTrapDeed(int itemID = 0x14F0) : base(itemID)
{
Weight = 1.0;
LootType = LootType.Blessed;
@ -19,7 +19,7 @@ namespace Server.Factions
{
}
public abstract Type TrapType{ get; }
public abstract Type TrapType { get; }
[CommandProperty(AccessLevel.GameMaster)]
public Faction Faction
@ -34,8 +34,6 @@ namespace Server.Factions
}
}
#region ICraftable Members
public int OnCraft(int quality, bool makersMark, Mobile from, CraftSystem craftSystem, Type typeRes, BaseTool tool,
CraftItem craftItem, int resHue)
{
@ -45,8 +43,6 @@ namespace Server.Factions
return 1;
}
#endregion
public virtual BaseFactionTrap Construct(Mobile from)
{
try

View file

@ -14,7 +14,7 @@ namespace Server.Factions
}
[CommandProperty(AccessLevel.GameMaster)]
public int Charges{ get; set; }
public int Charges { get; set; }
public override int LabelNumber => 1041508; // a faction trap removal kit
@ -56,15 +56,15 @@ namespace Server.Factions
switch (version)
{
case 1:
{
Charges = reader.ReadEncodedInt();
break;
}
{
Charges = reader.ReadEncodedInt();
break;
}
case 0:
{
Charges = 25;
break;
}
{
Charges = 25;
break;
}
}
}
}

View file

@ -98,10 +98,10 @@ namespace Server.Factions
switch (version)
{
case 0:
{
Faction = Faction.ReadReference(reader);
break;
}
{
Faction = Faction.ReadReference(reader);
break;
}
}
}
}

View file

@ -11,7 +11,7 @@ namespace Server.Factions
{
private const int ListenRange = 12;
private static Type[] m_StrongPotions =
private static readonly Type[] m_StrongPotions =
{
typeof(GreaterHealPotion), typeof(GreaterHealPotion), typeof(GreaterHealPotion),
typeof(GreaterCurePotion), typeof(GreaterCurePotion), typeof(GreaterCurePotion),
@ -21,7 +21,7 @@ namespace Server.Factions
typeof(GreaterExplosionPotion)
};
private static Type[] m_WeakPotions =
private static readonly Type[] m_WeakPotions =
{
typeof(HealPotion), typeof(HealPotion), typeof(HealPotion),
typeof(CurePotion), typeof(CurePotion), typeof(CurePotion),
@ -62,7 +62,7 @@ namespace Server.Factions
}
}
public Orders Orders{ get; private set; }
public Orders Orders { get; private set; }
[CommandProperty(AccessLevel.GameMaster, AccessLevel.Administrator)]
public Town Town
@ -76,7 +76,7 @@ namespace Server.Factions
}
}
public abstract GuardAI GuardAI{ get; }
public abstract GuardAI GuardAI { get; }
protected override BaseAI ForcedAI => new FactionGuardAI(this);
@ -443,7 +443,7 @@ namespace Server.Factions
public class VirtualMount : IMount
{
private VirtualMountItem m_Item;
private readonly VirtualMountItem m_Item;
public VirtualMount(VirtualMountItem item) => m_Item = item;
@ -460,7 +460,7 @@ namespace Server.Factions
public class VirtualMountItem : Item, IMountItem
{
private VirtualMount m_Mount;
private readonly VirtualMount m_Mount;
public VirtualMountItem(Mobile mob) : base(0x3EA0)
{
@ -472,7 +472,7 @@ namespace Server.Factions
public VirtualMountItem(Serial serial) : base(serial) => m_Mount = new VirtualMount(this);
public Mobile Rider{ get; private set; }
public Mobile Rider { get; private set; }
public IMount Mount => m_Mount;

View file

@ -39,11 +39,11 @@ namespace Server.Factions
Hold = hold;
}
public Type Spell{ get; }
public Type Spell { get; }
public TimeSpan Hold{ get; }
public TimeSpan Hold { get; }
public int Chance{ get; }
public int Chance { get; }
}
public class SpellCombo
@ -52,8 +52,7 @@ namespace Server.Factions
new ComboEntry(typeof(ParalyzeSpell), 20),
new ComboEntry(typeof(ExplosionSpell), 100, TimeSpan.FromSeconds(2.8)),
new ComboEntry(typeof(PoisonSpell), 30),
new ComboEntry(typeof(EnergyBoltSpell))
);
new ComboEntry(typeof(EnergyBoltSpell)));
public static readonly SpellCombo Strong = new SpellCombo(90,
new ComboEntry(typeof(ParalyzeSpell), 20),
@ -62,8 +61,7 @@ namespace Server.Factions
new ComboEntry(typeof(ExplosionSpell), 100, TimeSpan.FromSeconds(2.8)),
new ComboEntry(typeof(EnergyBoltSpell)),
new ComboEntry(typeof(PoisonSpell), 30),
new ComboEntry(typeof(EnergyBoltSpell))
);
new ComboEntry(typeof(EnergyBoltSpell)));
public SpellCombo(int mana, params ComboEntry[] entries)
{
@ -71,9 +69,9 @@ namespace Server.Factions
Entries = entries;
}
public int Mana{ get; }
public int Mana { get; }
public ComboEntry[] Entries{ get; }
public ComboEntry[] Entries { get; }
public static Spell Process(Mobile mob, Mobile targ, ref SpellCombo combo, ref int index, ref DateTime releaseTime)
{
@ -106,7 +104,7 @@ namespace Server.Factions
private SpellCombo m_Combo;
private int m_ComboIndex = -1;
private BaseFactionGuard m_Guard;
private readonly BaseFactionGuard m_Guard;
private DateTime m_ReleaseTarget;
public FactionGuardAI(BaseFactionGuard guard) : base(guard) => m_Guard = guard;
@ -344,11 +342,11 @@ namespace Server.Factions
public void RunTo(Mobile m)
{
/*if ( m.Paralyzed || m.Frozen )
/*if (m.Paralyzed || m.Frozen)
{
if ( m_Mobile.InRange( m, 1 ) )
if (m_Mobile.InRange( m, 1 ))
RunFrom( m );
else if ( !m_Mobile.InRange( m, m_Mobile.RangeFight > 2 ? m_Mobile.RangeFight : 2 ) && !MoveTo( m, true, 1 ) )
else if (!m_Mobile.InRange( m, m_Mobile.RangeFight > 2 ? m_Mobile.RangeFight : 2 ) && !MoveTo( m, true, 1 ))
OnFailedMove();
}
else
@ -373,9 +371,9 @@ namespace Server.Factions
public void OnFailedMove()
{
/*if ( !m_Mobile.DisallowAllMoves && 20 > Utility.Random( 100 ) && IsAllowed( GuardAI.Magic ) )
/*if (!m_Mobile.DisallowAllMoves && 20 > Utility.Random( 100 ) && IsAllowed( GuardAI.Magic ))
{
if ( m_Mobile.Target != null )
if (m_Mobile.Target != null)
m_Mobile.Target.Cancel( m_Mobile, TargetCancelType.Canceled );
new TeleportSpell( m_Mobile, null ).Cast();
@ -590,7 +588,7 @@ namespace Server.Factions
else if (dispelTarget != null &&
(IsAllowed(GuardAI.Magic) || IsAllowed(GuardAI.Bless) || IsAllowed(GuardAI.Curse)))
{
if (!dispelTarget.Paralyzed && m_Guard.Mana > ManaReserve + 20 && 40 > Utility.Random(100))
if (!dispelTarget.Paralyzed && m_Guard.Mana > ManaReserve + 20 && Utility.Random(100) < 40)
spell = new ParalyzeSpell(m_Guard);
else
spell = new DispelSpell(m_Guard);
@ -610,9 +608,9 @@ namespace Server.Factions
m_ComboIndex = -1;
}
}
else if (20 > Utility.Random(100) && IsAllowed(GuardAI.Magic))
else if (Utility.Random(100) < 20 && IsAllowed(GuardAI.Magic))
{
if (80 > Utility.Random(100))
if (Utility.Random(100) < 80)
{
m_Combo = IsAllowed(GuardAI.Smart) ? SpellCombo.Simple : SpellCombo.Strong;
m_ComboIndex = -1;
@ -635,7 +633,7 @@ namespace Server.Factions
}
}
if (spell == null && 2 > Utility.Random(100) && m_Guard.Mana >= ManaReserve + 10)
if (spell == null && Utility.Random(100) < 2 && m_Guard.Mana >= ManaReserve + 10)
{
int strMod = GetStatMod(m_Guard, StatType.Str);
int dexMod = GetStatMod(m_Guard, StatType.Dex);
@ -668,10 +666,10 @@ namespace Server.Factions
}
}
if (spell == null && 2 > Utility.Random(100) && m_Guard.Mana >= ManaReserve + 10 &&
if (spell == null && Utility.Random(100) < 2 && m_Guard.Mana >= ManaReserve + 10 &&
IsAllowed(GuardAI.Curse))
{
if (!combatant.Poisoned && 40 > Utility.Random(100))
if (!combatant.Poisoned && Utility.Random(100) < 40)
{
spell = new PoisonSpell(m_Guard);
}

View file

@ -31,18 +31,18 @@ namespace Server.Factions.AI
switch (version)
{
case 0:
{
Faction = Faction.ReadReference(reader);
Type = (ReactionType)reader.ReadEncodedInt();
{
Faction = Faction.ReadReference(reader);
Type = (ReactionType)reader.ReadEncodedInt();
break;
}
break;
}
}
}
public Faction Faction{ get; }
public Faction Faction { get; }
public ReactionType Type{ get; set; }
public ReactionType Type { get; set; }
public void Serialize(IGenericWriter writer)
{
@ -55,7 +55,7 @@ namespace Server.Factions.AI
public class Orders
{
private List<Reaction> m_Reactions;
private readonly List<Reaction> m_Reactions;
public Orders(BaseFactionGuard guard)
{
@ -73,30 +73,30 @@ namespace Server.Factions.AI
switch (version)
{
case 1:
{
Follow = reader.ReadMobile();
goto case 0;
}
{
Follow = reader.ReadMobile();
goto case 0;
}
case 0:
{
int count = reader.ReadEncodedInt();
m_Reactions = new List<Reaction>(count);
{
int count = reader.ReadEncodedInt();
m_Reactions = new List<Reaction>(count);
for (int i = 0; i < count; ++i)
m_Reactions.Add(new Reaction(reader));
for (int i = 0; i < count; ++i)
m_Reactions.Add(new Reaction(reader));
Movement = (MovementType)reader.ReadEncodedInt();
Movement = (MovementType)reader.ReadEncodedInt();
break;
}
break;
}
}
}
public BaseFactionGuard Guard{ get; }
public BaseFactionGuard Guard { get; }
public MovementType Movement{ get; set; }
public MovementType Movement { get; set; }
public Mobile Follow{ get; set; }
public Mobile Follow { get; set; }
public Reaction GetReaction(Faction faction)
{

View file

@ -51,7 +51,7 @@ namespace Server.Factions
}
}
protected override List<SBInfo> SBInfos{ get; } = new List<SBInfo>();
protected override List<SBInfo> SBInfos { get; } = new List<SBInfo>();
public void Register()
{
@ -104,12 +104,12 @@ namespace Server.Factions
switch (version)
{
case 0:
{
m_Town = Town.ReadReference(reader);
m_Faction = Faction.ReadReference(reader);
Register();
break;
}
{
m_Town = Town.ReadReference(reader);
m_Faction = Faction.ReadReference(reader);
Register();
break;
}
}
Frozen = true;

View file

@ -6,8 +6,7 @@ namespace Server.Factions
{
public class FactionBoardVendor : BaseFactionVendor
{
public FactionBoardVendor(Town town, Faction faction) :
base(town, faction, "the LumberMan") // NOTE: title inconsistant, as OSI
public FactionBoardVendor(Town town, Faction faction) : base(town, faction, "the LumberMan") // NOTE: title inconsistant, as OSI
{
SetSkill(SkillName.Carpentry, 85.0, 100.0);
SetSkill(SkillName.Lumberjacking, 60.0, 83.0);
@ -46,9 +45,9 @@ namespace Server.Factions
public class SBFactionBoard : SBInfo
{
public override IShopSellInfo SellInfo{ get; } = new InternalSellInfo();
public override IShopSellInfo SellInfo { get; } = new InternalSellInfo();
public override List<GenericBuyInfo> BuyInfo{ get; } = new InternalBuyInfo();
public override List<GenericBuyInfo> BuyInfo { get; } = new InternalBuyInfo();
public class InternalBuyInfo : List<GenericBuyInfo>
{

View file

@ -47,9 +47,9 @@ namespace Server.Factions
public class SBFactionBottle : SBInfo
{
public override IShopSellInfo SellInfo{ get; } = new InternalSellInfo();
public override IShopSellInfo SellInfo { get; } = new InternalSellInfo();
public override List<GenericBuyInfo> BuyInfo{ get; } = new InternalBuyInfo();
public override List<GenericBuyInfo> BuyInfo { get; } = new InternalBuyInfo();
public class InternalBuyInfo : List<GenericBuyInfo>
{

View file

@ -48,9 +48,9 @@ namespace Server.Factions
{
private static readonly object[] m_FixedSizeArgs = { true };
public override IShopSellInfo SellInfo{ get; } = new InternalSellInfo();
public override IShopSellInfo SellInfo { get; } = new InternalSellInfo();
public override List<GenericBuyInfo> BuyInfo{ get; } = new InternalBuyInfo();
public override List<GenericBuyInfo> BuyInfo { get; } = new InternalBuyInfo();
public class InternalBuyInfo : List<GenericBuyInfo>
{

View file

@ -52,9 +52,9 @@ namespace Server.Factions
public class SBFactionReagent : SBInfo
{
public override IShopSellInfo SellInfo{ get; } = new InternalSellInfo();
public override IShopSellInfo SellInfo { get; } = new InternalSellInfo();
public override List<GenericBuyInfo> BuyInfo{ get; } = new InternalBuyInfo();
public override List<GenericBuyInfo> BuyInfo { get; } = new InternalBuyInfo();
public class InternalBuyInfo : List<GenericBuyInfo>
{