Fixes code according to modern code style. Fixes a few expression bugs.
This commit is contained in:
parent
89eea25e5f
commit
970fd563b2
3324 changed files with 441118 additions and 433755 deletions
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
|
@ -2,142 +2,142 @@ using System;
|
|||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public interface IFactionItem
|
||||
{
|
||||
FactionItem FactionItemState{ get; set; }
|
||||
}
|
||||
public interface IFactionItem
|
||||
{
|
||||
FactionItem FactionItemState{ get; set; }
|
||||
}
|
||||
|
||||
public class FactionItem
|
||||
{
|
||||
public static readonly TimeSpan ExpirationPeriod = TimeSpan.FromDays( 21.0 );
|
||||
public class FactionItem
|
||||
{
|
||||
public static readonly TimeSpan ExpirationPeriod = TimeSpan.FromDays(21.0);
|
||||
|
||||
public Item Item { get; }
|
||||
public FactionItem(Item item, Faction faction)
|
||||
{
|
||||
Item = item;
|
||||
Faction = faction;
|
||||
}
|
||||
|
||||
public Faction Faction { get; }
|
||||
public FactionItem(GenericReader reader, Faction faction)
|
||||
{
|
||||
int version = reader.ReadEncodedInt();
|
||||
|
||||
public DateTime Expiration { get; private set; }
|
||||
switch (version)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
Item = reader.ReadItem();
|
||||
Expiration = reader.ReadDateTime();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public bool HasExpired
|
||||
{
|
||||
get
|
||||
{
|
||||
if ( Item == null || Item.Deleted )
|
||||
return true;
|
||||
Faction = faction;
|
||||
}
|
||||
|
||||
return ( Expiration != DateTime.MinValue && DateTime.UtcNow >= Expiration );
|
||||
}
|
||||
}
|
||||
public Item Item{ get; }
|
||||
|
||||
public void StartExpiration()
|
||||
{
|
||||
Expiration = DateTime.UtcNow + ExpirationPeriod;
|
||||
}
|
||||
public Faction Faction{ get; }
|
||||
|
||||
public void CheckAttach()
|
||||
{
|
||||
if ( !HasExpired )
|
||||
Attach();
|
||||
else
|
||||
Detach();
|
||||
}
|
||||
public DateTime Expiration{ get; private set; }
|
||||
|
||||
public void Attach()
|
||||
{
|
||||
if ( Item is IFactionItem item )
|
||||
item.FactionItemState = this;
|
||||
public bool HasExpired
|
||||
{
|
||||
get
|
||||
{
|
||||
if (Item == null || Item.Deleted)
|
||||
return true;
|
||||
|
||||
Faction?.State.FactionItems.Add( this );
|
||||
}
|
||||
return Expiration != DateTime.MinValue && DateTime.UtcNow >= Expiration;
|
||||
}
|
||||
}
|
||||
|
||||
public void Detach()
|
||||
{
|
||||
if ( Item is IFactionItem item )
|
||||
item.FactionItemState = null;
|
||||
public void StartExpiration()
|
||||
{
|
||||
Expiration = DateTime.UtcNow + ExpirationPeriod;
|
||||
}
|
||||
|
||||
if ( Faction != null && Faction.State.FactionItems.Contains( this ) )
|
||||
Faction.State.FactionItems.Remove( this );
|
||||
}
|
||||
public void CheckAttach()
|
||||
{
|
||||
if (!HasExpired)
|
||||
Attach();
|
||||
else
|
||||
Detach();
|
||||
}
|
||||
|
||||
public FactionItem( Item item, Faction faction )
|
||||
{
|
||||
Item = item;
|
||||
Faction = faction;
|
||||
}
|
||||
public void Attach()
|
||||
{
|
||||
if (Item is IFactionItem item)
|
||||
item.FactionItemState = this;
|
||||
|
||||
public FactionItem( GenericReader reader, Faction faction )
|
||||
{
|
||||
int version = reader.ReadEncodedInt();
|
||||
Faction?.State.FactionItems.Add(this);
|
||||
}
|
||||
|
||||
switch ( version )
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
Item = reader.ReadItem();
|
||||
Expiration = reader.ReadDateTime();
|
||||
break;
|
||||
}
|
||||
}
|
||||
public void Detach()
|
||||
{
|
||||
if (Item is IFactionItem item)
|
||||
item.FactionItemState = null;
|
||||
|
||||
Faction = faction;
|
||||
}
|
||||
if (Faction != null && Faction.State.FactionItems.Contains(this))
|
||||
Faction.State.FactionItems.Remove(this);
|
||||
}
|
||||
|
||||
public void Serialize( GenericWriter writer )
|
||||
{
|
||||
writer.WriteEncodedInt( (int) 0 );
|
||||
public void Serialize(GenericWriter writer)
|
||||
{
|
||||
writer.WriteEncodedInt(0);
|
||||
|
||||
writer.Write( (Item) Item );
|
||||
writer.Write( (DateTime) Expiration );
|
||||
}
|
||||
writer.Write(Item);
|
||||
writer.Write(Expiration);
|
||||
}
|
||||
|
||||
public static int GetMaxWearables( Mobile mob )
|
||||
{
|
||||
PlayerState pl = PlayerState.Find( mob );
|
||||
public static int GetMaxWearables(Mobile mob)
|
||||
{
|
||||
PlayerState pl = PlayerState.Find(mob);
|
||||
|
||||
if ( pl == null )
|
||||
return 0;
|
||||
if (pl == null)
|
||||
return 0;
|
||||
|
||||
if ( pl.Faction.IsCommander( mob ) )
|
||||
return 9;
|
||||
if (pl.Faction.IsCommander(mob))
|
||||
return 9;
|
||||
|
||||
return pl.Rank.MaxWearables;
|
||||
}
|
||||
return pl.Rank.MaxWearables;
|
||||
}
|
||||
|
||||
public static FactionItem Find( Item item )
|
||||
{
|
||||
if ( item is IFactionItem factionItem )
|
||||
{
|
||||
FactionItem state = factionItem.FactionItemState;
|
||||
public static FactionItem Find(Item item)
|
||||
{
|
||||
if (item is IFactionItem factionItem)
|
||||
{
|
||||
FactionItem state = factionItem.FactionItemState;
|
||||
|
||||
if ( state?.HasExpired == true )
|
||||
{
|
||||
state.Detach();
|
||||
state = null;
|
||||
}
|
||||
if (state?.HasExpired == true)
|
||||
{
|
||||
state.Detach();
|
||||
state = null;
|
||||
}
|
||||
|
||||
return state;
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Item Imbue( Item item, Faction faction, bool expire, int hue )
|
||||
{
|
||||
if ( !(item is IFactionItem) )
|
||||
return item;
|
||||
public static Item Imbue(Item item, Faction faction, bool expire, int hue)
|
||||
{
|
||||
if (!(item is IFactionItem))
|
||||
return item;
|
||||
|
||||
FactionItem state = Find( item );
|
||||
FactionItem state = Find(item);
|
||||
|
||||
if ( state == null )
|
||||
{
|
||||
state = new FactionItem( item, faction );
|
||||
state.Attach();
|
||||
}
|
||||
if (state == null)
|
||||
{
|
||||
state = new FactionItem(item, faction);
|
||||
state.Attach();
|
||||
}
|
||||
|
||||
if ( expire )
|
||||
state.StartExpiration();
|
||||
if (expire)
|
||||
state.StartExpiration();
|
||||
|
||||
item.Hue = hue;
|
||||
return item;
|
||||
}
|
||||
}
|
||||
}
|
||||
item.Hue = hue;
|
||||
return item;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -3,277 +3,271 @@ using System.Collections.Generic;
|
|||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class FactionState
|
||||
{
|
||||
private Faction m_Faction;
|
||||
private Mobile m_Commander;
|
||||
public class FactionState
|
||||
{
|
||||
private const int BroadcastsPerPeriod = 2;
|
||||
private static readonly TimeSpan BroadcastPeriod = TimeSpan.FromHours(1.0);
|
||||
private Mobile m_Commander;
|
||||
private Faction m_Faction;
|
||||
|
||||
private DateTime[] m_LastBroadcasts = new DateTime[BroadcastsPerPeriod];
|
||||
|
||||
public FactionState(Faction faction)
|
||||
{
|
||||
m_Faction = faction;
|
||||
Tithe = 50;
|
||||
Members = new List<PlayerState>();
|
||||
Election = new Election(faction);
|
||||
FactionItems = new List<FactionItem>();
|
||||
Traps = new List<BaseFactionTrap>();
|
||||
}
|
||||
|
||||
public FactionState(GenericReader reader)
|
||||
{
|
||||
int version = reader.ReadEncodedInt();
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
goto case 3;
|
||||
}
|
||||
case 3:
|
||||
case 2:
|
||||
case 1:
|
||||
{
|
||||
Election = new Election(reader);
|
||||
|
||||
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();
|
||||
|
||||
if (m_LastBroadcasts.Length > 0)
|
||||
m_LastBroadcasts[0] = time;
|
||||
}
|
||||
|
||||
private const int BroadcastsPerPeriod = 2;
|
||||
private static readonly TimeSpan BroadcastPeriod = TimeSpan.FromHours( 1.0 );
|
||||
Tithe = reader.ReadEncodedInt();
|
||||
Silver = reader.ReadEncodedInt();
|
||||
|
||||
private DateTime[] m_LastBroadcasts = new DateTime[BroadcastsPerPeriod];
|
||||
int memberCount = reader.ReadEncodedInt();
|
||||
|
||||
public DateTime LastAtrophy { get; set; }
|
||||
Members = new List<PlayerState>();
|
||||
|
||||
public bool FactionMessageReady
|
||||
{
|
||||
get
|
||||
{
|
||||
for ( int i = 0; i < m_LastBroadcasts.Length; ++i )
|
||||
{
|
||||
if ( DateTime.UtcNow >= (m_LastBroadcasts[i] + BroadcastPeriod) )
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsAtrophyReady => DateTime.UtcNow >= (LastAtrophy + TimeSpan.FromHours( 47.0 ));
|
||||
|
||||
public int CheckAtrophy()
|
||||
{
|
||||
if ( DateTime.UtcNow < (LastAtrophy + TimeSpan.FromHours( 47.0 )) )
|
||||
return 0;
|
||||
|
||||
int distrib = 0;
|
||||
LastAtrophy = DateTime.UtcNow;
|
||||
|
||||
List<PlayerState> members = new List<PlayerState>( Members );
|
||||
|
||||
for ( int i = 0; i < members.Count; ++i )
|
||||
{
|
||||
PlayerState ps = members[i];
|
||||
|
||||
if ( ps.IsActive )
|
||||
{
|
||||
ps.IsActive = false;
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( ps.KillPoints > 0 )
|
||||
{
|
||||
int atrophy = ( ps.KillPoints + 9 ) / 10;
|
||||
ps.KillPoints -= atrophy;
|
||||
distrib += atrophy;
|
||||
}
|
||||
}
|
||||
|
||||
return distrib;
|
||||
}
|
||||
|
||||
public void RegisterBroadcast()
|
||||
{
|
||||
for ( int i = 0; i < m_LastBroadcasts.Length; ++i )
|
||||
{
|
||||
if ( DateTime.UtcNow >= (m_LastBroadcasts[i] + BroadcastPeriod) )
|
||||
{
|
||||
m_LastBroadcasts[i] = DateTime.UtcNow;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public List<FactionItem> FactionItems { get; set; }
|
||||
|
||||
public List<BaseFactionTrap> Traps { get; set; }
|
||||
|
||||
public Election Election { get; set; }
|
||||
|
||||
public Mobile Commander
|
||||
{
|
||||
get => m_Commander;
|
||||
set
|
||||
{
|
||||
m_Commander?.InvalidateProperties();
|
||||
|
||||
m_Commander = value;
|
||||
|
||||
if ( m_Commander != null )
|
||||
{
|
||||
m_Commander.SendLocalizedMessage( 1042227 ); // You have been elected Commander of your faction
|
||||
|
||||
m_Commander.InvalidateProperties();
|
||||
|
||||
PlayerState pl = PlayerState.Find( m_Commander );
|
||||
|
||||
if ( pl?.Finance != null )
|
||||
pl.Finance.Finance = null;
|
||||
|
||||
if ( pl?.Sheriff != null )
|
||||
pl.Sheriff.Sheriff = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int Tithe { get; set; }
|
||||
for (int i = 0; i < memberCount; ++i)
|
||||
{
|
||||
PlayerState pl = new PlayerState(reader, m_Faction, Members);
|
||||
|
||||
public int Silver { get; set; }
|
||||
|
||||
public List<PlayerState> Members { get; set; }
|
||||
|
||||
public FactionState( Faction faction )
|
||||
{
|
||||
m_Faction = faction;
|
||||
Tithe = 50;
|
||||
Members = new List<PlayerState>();
|
||||
Election = new Election( faction );
|
||||
FactionItems = new List<FactionItem>();
|
||||
Traps = new List<BaseFactionTrap>();
|
||||
}
|
||||
if (pl.Mobile != null)
|
||||
Members.Add(pl);
|
||||
}
|
||||
|
||||
public FactionState( GenericReader reader )
|
||||
{
|
||||
int version = reader.ReadEncodedInt();
|
||||
|
||||
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;
|
||||
}
|
||||
m_Faction.State = this;
|
||||
|
||||
goto case 3;
|
||||
}
|
||||
case 3:
|
||||
case 2:
|
||||
case 1:
|
||||
{
|
||||
Election = new Election( reader );
|
||||
m_Faction.ZeroRankOffset = Members.Count;
|
||||
Members.Sort();
|
||||
|
||||
goto case 0;
|
||||
}
|
||||
case 0:
|
||||
{
|
||||
m_Faction = Faction.ReadReference( reader );
|
||||
for (int i = Members.Count - 1; i >= 0; i--)
|
||||
{
|
||||
PlayerState player = Members[i];
|
||||
|
||||
m_Commander = reader.ReadMobile();
|
||||
if (player.KillPoints <= 0)
|
||||
m_Faction.ZeroRankOffset = i;
|
||||
else
|
||||
player.RankIndex = i;
|
||||
}
|
||||
|
||||
if ( version < 5 )
|
||||
LastAtrophy = DateTime.UtcNow;
|
||||
FactionItems = new List<FactionItem>();
|
||||
|
||||
if ( version < 4 )
|
||||
{
|
||||
DateTime time = reader.ReadDateTime();
|
||||
if (version >= 2)
|
||||
{
|
||||
int factionItemCount = reader.ReadEncodedInt();
|
||||
|
||||
if ( m_LastBroadcasts.Length > 0 )
|
||||
m_LastBroadcasts[0] = time;
|
||||
}
|
||||
for (int i = 0; i < factionItemCount; ++i)
|
||||
{
|
||||
FactionItem factionItem = new FactionItem(reader, m_Faction);
|
||||
|
||||
Tithe = reader.ReadEncodedInt();
|
||||
Silver = reader.ReadEncodedInt();
|
||||
Timer.DelayCall(TimeSpan.Zero, factionItem.CheckAttach); // sandbox attachment
|
||||
}
|
||||
}
|
||||
|
||||
int memberCount = reader.ReadEncodedInt();
|
||||
Traps = new List<BaseFactionTrap>();
|
||||
|
||||
Members = new List<PlayerState>();
|
||||
if (version >= 3)
|
||||
{
|
||||
int factionTrapCount = reader.ReadEncodedInt();
|
||||
|
||||
for ( int i = 0; i < memberCount; ++i )
|
||||
{
|
||||
PlayerState pl = new PlayerState( reader, m_Faction, Members );
|
||||
for (int i = 0; i < factionTrapCount; ++i)
|
||||
if (reader.ReadItem() is BaseFactionTrap trap && !trap.CheckDecay())
|
||||
Traps.Add(trap);
|
||||
}
|
||||
|
||||
if ( pl.Mobile != null )
|
||||
Members.Add( pl );
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
m_Faction.State = this;
|
||||
if (version < 1)
|
||||
Election = new Election(m_Faction);
|
||||
}
|
||||
|
||||
m_Faction.ZeroRankOffset = Members.Count;
|
||||
Members.Sort();
|
||||
public DateTime LastAtrophy{ get; set; }
|
||||
|
||||
for ( int i = Members.Count - 1; i >= 0; i-- ) {
|
||||
PlayerState player = Members[i];
|
||||
public bool FactionMessageReady
|
||||
{
|
||||
get
|
||||
{
|
||||
for (int i = 0; i < m_LastBroadcasts.Length; ++i)
|
||||
if (DateTime.UtcNow >= m_LastBroadcasts[i] + BroadcastPeriod)
|
||||
return true;
|
||||
|
||||
if ( player.KillPoints <= 0 )
|
||||
m_Faction.ZeroRankOffset = i;
|
||||
else
|
||||
player.RankIndex = i;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
FactionItems = new List<FactionItem>();
|
||||
public bool IsAtrophyReady => DateTime.UtcNow >= LastAtrophy + TimeSpan.FromHours(47.0);
|
||||
|
||||
if ( version >= 2 )
|
||||
{
|
||||
int factionItemCount = reader.ReadEncodedInt();
|
||||
public List<FactionItem> FactionItems{ get; set; }
|
||||
|
||||
for ( int i = 0; i < factionItemCount; ++i )
|
||||
{
|
||||
FactionItem factionItem = new FactionItem( reader, m_Faction );
|
||||
public List<BaseFactionTrap> Traps{ get; set; }
|
||||
|
||||
Timer.DelayCall( TimeSpan.Zero, factionItem.CheckAttach ); // sandbox attachment
|
||||
}
|
||||
}
|
||||
public Election Election{ get; set; }
|
||||
|
||||
Traps = new List<BaseFactionTrap>();
|
||||
public Mobile Commander
|
||||
{
|
||||
get => m_Commander;
|
||||
set
|
||||
{
|
||||
m_Commander?.InvalidateProperties();
|
||||
|
||||
if ( version >= 3 )
|
||||
{
|
||||
int factionTrapCount = reader.ReadEncodedInt();
|
||||
m_Commander = value;
|
||||
|
||||
for ( int i = 0; i < factionTrapCount; ++i )
|
||||
{
|
||||
if ( reader.ReadItem() is BaseFactionTrap trap && !trap.CheckDecay() )
|
||||
Traps.Add( trap );
|
||||
}
|
||||
}
|
||||
if (m_Commander != null)
|
||||
{
|
||||
m_Commander.SendLocalizedMessage(1042227); // You have been elected Commander of your faction
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
m_Commander.InvalidateProperties();
|
||||
|
||||
if ( version < 1 )
|
||||
Election = new Election( m_Faction );
|
||||
}
|
||||
PlayerState pl = PlayerState.Find(m_Commander);
|
||||
|
||||
public void Serialize( GenericWriter writer )
|
||||
{
|
||||
writer.WriteEncodedInt( (int) 5 ); // version
|
||||
if (pl?.Finance != null)
|
||||
pl.Finance.Finance = null;
|
||||
|
||||
writer.Write( LastAtrophy );
|
||||
if (pl?.Sheriff != null)
|
||||
pl.Sheriff.Sheriff = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
writer.WriteEncodedInt( (int) m_LastBroadcasts.Length );
|
||||
public int Tithe{ get; set; }
|
||||
|
||||
for ( int i = 0; i < m_LastBroadcasts.Length; ++i )
|
||||
writer.Write( (DateTime) m_LastBroadcasts[i] );
|
||||
public int Silver{ get; set; }
|
||||
|
||||
Election.Serialize( writer );
|
||||
public List<PlayerState> Members{ get; set; }
|
||||
|
||||
Faction.WriteReference( writer, m_Faction );
|
||||
public int CheckAtrophy()
|
||||
{
|
||||
if (DateTime.UtcNow < LastAtrophy + TimeSpan.FromHours(47.0))
|
||||
return 0;
|
||||
|
||||
writer.Write( (Mobile) m_Commander );
|
||||
int distrib = 0;
|
||||
LastAtrophy = DateTime.UtcNow;
|
||||
|
||||
writer.WriteEncodedInt( (int) Tithe );
|
||||
writer.WriteEncodedInt( (int) Silver );
|
||||
List<PlayerState> members = new List<PlayerState>(Members);
|
||||
|
||||
writer.WriteEncodedInt( (int) Members.Count );
|
||||
for (int i = 0; i < members.Count; ++i)
|
||||
{
|
||||
PlayerState ps = members[i];
|
||||
|
||||
for ( int i = 0; i < Members.Count; ++i )
|
||||
{
|
||||
PlayerState pl = (PlayerState) Members[i];
|
||||
if (ps.IsActive)
|
||||
{
|
||||
ps.IsActive = false;
|
||||
continue;
|
||||
}
|
||||
|
||||
pl.Serialize( writer );
|
||||
}
|
||||
if (ps.KillPoints > 0)
|
||||
{
|
||||
int atrophy = (ps.KillPoints + 9) / 10;
|
||||
ps.KillPoints -= atrophy;
|
||||
distrib += atrophy;
|
||||
}
|
||||
}
|
||||
|
||||
writer.WriteEncodedInt( (int) FactionItems.Count );
|
||||
return distrib;
|
||||
}
|
||||
|
||||
for ( int i = 0; i < FactionItems.Count; ++i )
|
||||
FactionItems[i].Serialize( writer );
|
||||
public void RegisterBroadcast()
|
||||
{
|
||||
for (int i = 0; i < m_LastBroadcasts.Length; ++i)
|
||||
if (DateTime.UtcNow >= m_LastBroadcasts[i] + BroadcastPeriod)
|
||||
{
|
||||
m_LastBroadcasts[i] = DateTime.UtcNow;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
writer.WriteEncodedInt( (int) Traps.Count );
|
||||
public void Serialize(GenericWriter writer)
|
||||
{
|
||||
writer.WriteEncodedInt(5); // version
|
||||
|
||||
for ( int i = 0; i < Traps.Count; ++i )
|
||||
writer.Write( (Item) Traps[i] );
|
||||
}
|
||||
}
|
||||
}
|
||||
writer.Write(LastAtrophy);
|
||||
|
||||
writer.WriteEncodedInt(m_LastBroadcasts.Length);
|
||||
|
||||
for (int i = 0; i < m_LastBroadcasts.Length; ++i)
|
||||
writer.Write(m_LastBroadcasts[i]);
|
||||
|
||||
Election.Serialize(writer);
|
||||
|
||||
Faction.WriteReference(writer, m_Faction);
|
||||
|
||||
writer.Write(m_Commander);
|
||||
|
||||
writer.WriteEncodedInt(Tithe);
|
||||
writer.WriteEncodedInt(Silver);
|
||||
|
||||
writer.WriteEncodedInt(Members.Count);
|
||||
|
||||
for (int i = 0; i < Members.Count; ++i)
|
||||
{
|
||||
PlayerState pl = Members[i];
|
||||
|
||||
pl.Serialize(writer);
|
||||
}
|
||||
|
||||
writer.WriteEncodedInt(FactionItems.Count);
|
||||
|
||||
for (int i = 0; i < FactionItems.Count; ++i)
|
||||
FactionItems[i].Serialize(writer);
|
||||
|
||||
writer.WriteEncodedInt(Traps.Count);
|
||||
|
||||
for (int i = 0; i < Traps.Count; ++i)
|
||||
writer.Write(Traps[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,80 +1,78 @@
|
|||
using System;
|
||||
using Server.Commands;
|
||||
using System.Collections.Generic;
|
||||
using Server.Commands;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class Generator
|
||||
{
|
||||
public static void Initialize()
|
||||
{
|
||||
CommandSystem.Register( "GenerateFactions", AccessLevel.Administrator, GenerateFactions_OnCommand );
|
||||
}
|
||||
public class Generator
|
||||
{
|
||||
public static void Initialize()
|
||||
{
|
||||
CommandSystem.Register("GenerateFactions", AccessLevel.Administrator, GenerateFactions_OnCommand);
|
||||
}
|
||||
|
||||
public static void GenerateFactions_OnCommand( CommandEventArgs e )
|
||||
{
|
||||
new FactionPersistance();
|
||||
public static void GenerateFactions_OnCommand(CommandEventArgs e)
|
||||
{
|
||||
new FactionPersistance();
|
||||
|
||||
List<Faction> factions = Faction.Factions;
|
||||
List<Faction> factions = Faction.Factions;
|
||||
|
||||
foreach ( Faction faction in factions )
|
||||
Generate( faction );
|
||||
foreach (Faction faction in factions)
|
||||
Generate(faction);
|
||||
|
||||
List<Town> towns = Town.Towns;
|
||||
List<Town> towns = Town.Towns;
|
||||
|
||||
foreach ( Town town in towns )
|
||||
Generate( town );
|
||||
}
|
||||
foreach (Town town in towns)
|
||||
Generate(town);
|
||||
}
|
||||
|
||||
public static void Generate( Town town )
|
||||
{
|
||||
Map facet = Faction.Facet;
|
||||
public static void Generate(Town town)
|
||||
{
|
||||
Map facet = Faction.Facet;
|
||||
|
||||
TownDefinition def = town.Definition;
|
||||
TownDefinition def = town.Definition;
|
||||
|
||||
if ( !CheckExistance( def.Monolith, facet, typeof( TownMonolith ) ) )
|
||||
{
|
||||
TownMonolith mono = new TownMonolith( town );
|
||||
mono.MoveToWorld( def.Monolith, facet );
|
||||
mono.Sigil = new Sigil( town );
|
||||
}
|
||||
if (!CheckExistance(def.Monolith, facet, typeof(TownMonolith)))
|
||||
{
|
||||
TownMonolith mono = new TownMonolith(town);
|
||||
mono.MoveToWorld(def.Monolith, facet);
|
||||
mono.Sigil = new Sigil(town);
|
||||
}
|
||||
|
||||
if ( !CheckExistance( def.TownStone, facet, typeof( TownStone ) ) )
|
||||
new TownStone( town ).MoveToWorld( def.TownStone, facet );
|
||||
}
|
||||
if (!CheckExistance(def.TownStone, facet, typeof(TownStone)))
|
||||
new TownStone(town).MoveToWorld(def.TownStone, facet);
|
||||
}
|
||||
|
||||
public static void Generate( Faction faction )
|
||||
{
|
||||
Map facet = Faction.Facet;
|
||||
public static void Generate(Faction faction)
|
||||
{
|
||||
Map facet = Faction.Facet;
|
||||
|
||||
List<Town> towns = Town.Towns;
|
||||
List<Town> towns = Town.Towns;
|
||||
|
||||
StrongholdDefinition stronghold = faction.Definition.Stronghold;
|
||||
StrongholdDefinition stronghold = faction.Definition.Stronghold;
|
||||
|
||||
if ( !CheckExistance( stronghold.JoinStone, facet, typeof( JoinStone ) ) )
|
||||
new JoinStone( faction ).MoveToWorld( stronghold.JoinStone, facet );
|
||||
if (!CheckExistance(stronghold.JoinStone, facet, typeof(JoinStone)))
|
||||
new JoinStone(faction).MoveToWorld(stronghold.JoinStone, facet);
|
||||
|
||||
if ( !CheckExistance( stronghold.FactionStone, facet, typeof( FactionStone ) ) )
|
||||
new FactionStone( faction ).MoveToWorld( stronghold.FactionStone, facet );
|
||||
if (!CheckExistance(stronghold.FactionStone, facet, typeof(FactionStone)))
|
||||
new FactionStone(faction).MoveToWorld(stronghold.FactionStone, facet);
|
||||
|
||||
for ( int i = 0; i < stronghold.Monoliths.Length; ++i )
|
||||
{
|
||||
Point3D monolith = stronghold.Monoliths[i];
|
||||
for (int i = 0; i < stronghold.Monoliths.Length; ++i)
|
||||
{
|
||||
Point3D monolith = stronghold.Monoliths[i];
|
||||
|
||||
if ( !CheckExistance( monolith, facet, typeof( StrongholdMonolith ) ) )
|
||||
new StrongholdMonolith( towns[i], faction ).MoveToWorld( monolith, facet );
|
||||
}
|
||||
}
|
||||
if (!CheckExistance(monolith, facet, typeof(StrongholdMonolith)))
|
||||
new StrongholdMonolith(towns[i], faction).MoveToWorld(monolith, facet);
|
||||
}
|
||||
}
|
||||
|
||||
private static bool CheckExistance( Point3D loc, Map facet, Type type )
|
||||
{
|
||||
foreach ( Item item in facet.GetItemsInRange( loc, 0 ) )
|
||||
{
|
||||
if ( type.IsAssignableFrom( item.GetType() ) )
|
||||
return true;
|
||||
}
|
||||
private static bool CheckExistance(Point3D loc, Map facet, Type type)
|
||||
{
|
||||
foreach (Item item in facet.GetItemsInRange(loc, 0))
|
||||
if (type.IsAssignableFrom(item.GetType()))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -3,22 +3,28 @@ using System.Collections.Generic;
|
|||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class GuardList
|
||||
{
|
||||
public GuardDefinition Definition { get; }
|
||||
public class GuardList
|
||||
{
|
||||
public GuardList(GuardDefinition definition)
|
||||
{
|
||||
Definition = definition;
|
||||
Guards = new List<BaseFactionGuard>();
|
||||
}
|
||||
|
||||
public List<BaseFactionGuard> Guards { get; }
|
||||
public GuardDefinition Definition{ get; }
|
||||
|
||||
public BaseFactionGuard Construct()
|
||||
{
|
||||
try{ return Activator.CreateInstance( Definition.Type ) as BaseFactionGuard; }
|
||||
catch{ return null; }
|
||||
}
|
||||
public List<BaseFactionGuard> Guards{ get; }
|
||||
|
||||
public GuardList( GuardDefinition definition )
|
||||
{
|
||||
Definition = definition;
|
||||
Guards = new List<BaseFactionGuard>();
|
||||
}
|
||||
}
|
||||
public BaseFactionGuard Construct()
|
||||
{
|
||||
try
|
||||
{
|
||||
return Activator.CreateInstance(Definition.Type) as BaseFactionGuard;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,154 +1,159 @@
|
|||
using System;
|
||||
using Server.Network;
|
||||
using Server.Mobiles;
|
||||
using Server.Network;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class Keywords
|
||||
{
|
||||
public static void Initialize()
|
||||
{
|
||||
EventSink.Speech += EventSink_Speech;
|
||||
}
|
||||
public class Keywords
|
||||
{
|
||||
public static void Initialize()
|
||||
{
|
||||
EventSink.Speech += EventSink_Speech;
|
||||
}
|
||||
|
||||
private static void ShowScore_Sandbox( object state )
|
||||
{
|
||||
PlayerState pl = (PlayerState)state;
|
||||
private static void ShowScore_Sandbox(object state)
|
||||
{
|
||||
PlayerState pl = (PlayerState)state;
|
||||
|
||||
pl?.Mobile.PublicOverheadMessage( MessageType.Regular, pl.Mobile.SpeechHue, true, pl.KillPoints.ToString( "N0" ) ); // NOTE: Added 'N0'
|
||||
}
|
||||
pl?.Mobile.PublicOverheadMessage(MessageType.Regular, pl.Mobile.SpeechHue, true,
|
||||
pl.KillPoints.ToString("N0")); // NOTE: Added 'N0'
|
||||
}
|
||||
|
||||
private static void EventSink_Speech( SpeechEventArgs e )
|
||||
{
|
||||
Mobile from = e.Mobile;
|
||||
int[] keywords = e.Keywords;
|
||||
private static void EventSink_Speech(SpeechEventArgs e)
|
||||
{
|
||||
Mobile from = e.Mobile;
|
||||
int[] keywords = e.Keywords;
|
||||
|
||||
for ( int i = 0; i < keywords.Length; ++i )
|
||||
{
|
||||
switch ( keywords[i] )
|
||||
{
|
||||
case 0x00E4: // *i wish to access the city treasury*
|
||||
{
|
||||
Town town = Town.FromRegion( from.Region );
|
||||
for (int i = 0; i < keywords.Length; ++i)
|
||||
switch (keywords[i])
|
||||
{
|
||||
case 0x00E4: // *i wish to access the city treasury*
|
||||
{
|
||||
Town town = Town.FromRegion(from.Region);
|
||||
|
||||
if ( town == null || !town.IsFinance( from ) || !from.Alive )
|
||||
break;
|
||||
if (town == null || !town.IsFinance(from) || !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 ) );
|
||||
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 );
|
||||
break;
|
||||
}
|
||||
case 0x0ED: // *i am sheriff*
|
||||
{
|
||||
Town town = Town.FromRegion(from.Region);
|
||||
|
||||
if ( town == null || !town.IsSheriff( from ) || !from.Alive )
|
||||
break;
|
||||
if (town == null || !town.IsSheriff(from) || !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 ) );
|
||||
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 );
|
||||
break;
|
||||
}
|
||||
case 0x00EF: // *you are fired*
|
||||
{
|
||||
Town town = Town.FromRegion(from.Region);
|
||||
|
||||
if ( town == null )
|
||||
break;
|
||||
if (town == null)
|
||||
break;
|
||||
|
||||
if ( town.IsFinance( from ) || town.IsSheriff( from ) )
|
||||
town.BeginOrderFiring( from );
|
||||
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 );
|
||||
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
|
||||
}
|
||||
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 );
|
||||
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
|
||||
}
|
||||
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 );
|
||||
break;
|
||||
}
|
||||
case 0x00E9: // *what is my faction term status*
|
||||
{
|
||||
PlayerState pl = PlayerState.Find(from);
|
||||
|
||||
if ( pl?.IsLeaving == true )
|
||||
{
|
||||
if ( Faction.CheckLeaveTimer( from ) )
|
||||
break;
|
||||
if (pl?.IsLeaving == true)
|
||||
{
|
||||
if (Faction.CheckLeaveTimer(from))
|
||||
break;
|
||||
|
||||
TimeSpan remaining = ( pl.Leaving + Faction.LeavePeriod ) - DateTime.UtcNow;
|
||||
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.
|
||||
}
|
||||
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 );
|
||||
break;
|
||||
}
|
||||
case 0x00EA: // *message faction*
|
||||
{
|
||||
Faction faction = Faction.Find(from);
|
||||
|
||||
if ( faction == null || !faction.IsCommander( from ) )
|
||||
break;
|
||||
if (faction == null || !faction.IsCommander(from))
|
||||
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 );
|
||||
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 );
|
||||
break;
|
||||
}
|
||||
case 0x00EC: // *showscore*
|
||||
{
|
||||
PlayerState pl = PlayerState.Find(from);
|
||||
|
||||
if ( pl != null )
|
||||
Timer.DelayCall( TimeSpan.Zero, new TimerStateCallback( ShowScore_Sandbox ), pl );
|
||||
if (pl != null)
|
||||
Timer.DelayCall(TimeSpan.Zero, new TimerStateCallback(ShowScore_Sandbox), pl);
|
||||
|
||||
break;
|
||||
}
|
||||
case 0x0178: // i honor your leadership
|
||||
{
|
||||
Faction faction = Faction.Find( from );
|
||||
break;
|
||||
}
|
||||
case 0x0178: // i honor your leadership
|
||||
{
|
||||
Faction faction = Faction.Find(from);
|
||||
|
||||
faction?.BeginHonorLeadership( from );
|
||||
faction?.BeginHonorLeadership(from);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,81 +1,92 @@
|
|||
namespace Server.Factions
|
||||
{
|
||||
public enum MerchantTitle
|
||||
{
|
||||
None,
|
||||
Scribe,
|
||||
Carpenter,
|
||||
Blacksmith,
|
||||
Bowyer,
|
||||
Tialor
|
||||
}
|
||||
public enum MerchantTitle
|
||||
{
|
||||
None,
|
||||
Scribe,
|
||||
Carpenter,
|
||||
Blacksmith,
|
||||
Bowyer,
|
||||
Tialor
|
||||
}
|
||||
|
||||
public class MerchantTitleInfo
|
||||
{
|
||||
public SkillName Skill { get; }
|
||||
public class MerchantTitleInfo
|
||||
{
|
||||
public MerchantTitleInfo(SkillName skill, double requirement, TextDefinition title, TextDefinition label,
|
||||
TextDefinition assigned)
|
||||
{
|
||||
Skill = skill;
|
||||
Requirement = requirement;
|
||||
Title = title;
|
||||
Label = label;
|
||||
Assigned = assigned;
|
||||
}
|
||||
|
||||
public double Requirement { get; }
|
||||
public SkillName Skill{ get; }
|
||||
|
||||
public TextDefinition Title { get; }
|
||||
public double Requirement{ get; }
|
||||
|
||||
public TextDefinition Label { get; }
|
||||
public TextDefinition Title{ get; }
|
||||
|
||||
public TextDefinition Assigned { get; }
|
||||
public TextDefinition Label{ get; }
|
||||
|
||||
public MerchantTitleInfo( SkillName skill, double requirement, TextDefinition title, TextDefinition label, TextDefinition assigned )
|
||||
{
|
||||
Skill = skill;
|
||||
Requirement = requirement;
|
||||
Title = title;
|
||||
Label = label;
|
||||
Assigned = assigned;
|
||||
}
|
||||
}
|
||||
public TextDefinition Assigned{ get; }
|
||||
}
|
||||
|
||||
public class MerchantTitles
|
||||
{
|
||||
public static MerchantTitleInfo[] Info { get; } =
|
||||
{
|
||||
new MerchantTitleInfo( SkillName.Inscribe, 90.0, new TextDefinition( 1060773, "Scribe" ), new TextDefinition( 1011468, "SCRIBE" ), new TextDefinition( 1010121, "You now have the faction title of scribe" ) ),
|
||||
new MerchantTitleInfo( SkillName.Carpentry, 90.0, new TextDefinition( 1060774, "Carpenter" ), new TextDefinition( 1011469, "CARPENTER" ), new TextDefinition( 1010122, "You now have the faction title of carpenter" ) ),
|
||||
new MerchantTitleInfo( SkillName.Tinkering, 90.0, new TextDefinition( 1022984, "Tinker" ), new TextDefinition( 1011470, "TINKER" ), new TextDefinition( 1010123, "You now have the faction title of tinker" ) ),
|
||||
new MerchantTitleInfo( SkillName.Blacksmith, 90.0, new TextDefinition( 1023016, "Blacksmith" ), new TextDefinition( 1011471, "BLACKSMITH" ), new TextDefinition( 1010124, "You now have the faction title of blacksmith" ) ),
|
||||
new MerchantTitleInfo( SkillName.Fletching, 90.0, new TextDefinition( 1023022, "Bowyer" ), new TextDefinition( 1011472, "BOWYER" ), new TextDefinition( 1010125, "You now have the faction title of Bowyer" ) ),
|
||||
new MerchantTitleInfo( SkillName.Tailoring, 90.0, new TextDefinition( 1022982, "Tailor" ), new TextDefinition( 1018300, "TAILOR" ), new TextDefinition( 1042162, "You now have the faction title of Tailor" ) ),
|
||||
};
|
||||
public class MerchantTitles
|
||||
{
|
||||
public static MerchantTitleInfo[] Info{ get; } =
|
||||
{
|
||||
new MerchantTitleInfo(SkillName.Inscribe, 90.0, new TextDefinition(1060773, "Scribe"),
|
||||
new TextDefinition(1011468, "SCRIBE"),
|
||||
new TextDefinition(1010121, "You now have the faction title of scribe")),
|
||||
new MerchantTitleInfo(SkillName.Carpentry, 90.0, new TextDefinition(1060774, "Carpenter"),
|
||||
new TextDefinition(1011469, "CARPENTER"),
|
||||
new TextDefinition(1010122, "You now have the faction title of carpenter")),
|
||||
new MerchantTitleInfo(SkillName.Tinkering, 90.0, new TextDefinition(1022984, "Tinker"),
|
||||
new TextDefinition(1011470, "TINKER"),
|
||||
new TextDefinition(1010123, "You now have the faction title of tinker")),
|
||||
new MerchantTitleInfo(SkillName.Blacksmith, 90.0, new TextDefinition(1023016, "Blacksmith"),
|
||||
new TextDefinition(1011471, "BLACKSMITH"),
|
||||
new TextDefinition(1010124, "You now have the faction title of blacksmith")),
|
||||
new MerchantTitleInfo(SkillName.Fletching, 90.0, new TextDefinition(1023022, "Bowyer"),
|
||||
new TextDefinition(1011472, "BOWYER"),
|
||||
new TextDefinition(1010125, "You now have the faction title of Bowyer")),
|
||||
new MerchantTitleInfo(SkillName.Tailoring, 90.0, new TextDefinition(1022982, "Tailor"),
|
||||
new TextDefinition(1018300, "TAILOR"),
|
||||
new TextDefinition(1042162, "You now have the faction title of Tailor"))
|
||||
};
|
||||
|
||||
public static MerchantTitleInfo GetInfo( MerchantTitle title )
|
||||
{
|
||||
int idx = (int)title - 1;
|
||||
public static MerchantTitleInfo GetInfo(MerchantTitle title)
|
||||
{
|
||||
int idx = (int)title - 1;
|
||||
|
||||
if ( idx >= 0 && idx < Info.Length )
|
||||
return Info[idx];
|
||||
if (idx >= 0 && idx < Info.Length)
|
||||
return Info[idx];
|
||||
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static bool HasMerchantQualifications( Mobile mob )
|
||||
{
|
||||
for ( int i = 0; i < Info.Length; ++i )
|
||||
{
|
||||
if ( IsQualified( mob, Info[i] ) )
|
||||
return true;
|
||||
}
|
||||
public static bool HasMerchantQualifications(Mobile mob)
|
||||
{
|
||||
for (int i = 0; i < Info.Length; ++i)
|
||||
if (IsQualified(mob, Info[i]))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static bool IsQualified( Mobile mob, MerchantTitle title )
|
||||
{
|
||||
return IsQualified( mob, GetInfo( title ) );
|
||||
}
|
||||
public static bool IsQualified(Mobile mob, MerchantTitle title)
|
||||
{
|
||||
return IsQualified(mob, GetInfo(title));
|
||||
}
|
||||
|
||||
public static bool IsQualified( Mobile mob, MerchantTitleInfo info )
|
||||
{
|
||||
if ( mob == null || info == null )
|
||||
return false;
|
||||
public static bool IsQualified(Mobile mob, MerchantTitleInfo info)
|
||||
{
|
||||
if (mob == null || info == null)
|
||||
return false;
|
||||
|
||||
return ( mob.Skills[info.Skill].Value >= info.Requirement );
|
||||
}
|
||||
}
|
||||
return mob.Skills[info.Skill].Value >= info.Requirement;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2,87 +2,89 @@ using System.Collections.Generic;
|
|||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class FactionPersistance : Item
|
||||
{
|
||||
public static FactionPersistance Instance { get; private set; }
|
||||
public class FactionPersistance : Item
|
||||
{
|
||||
public FactionPersistance() : base(1)
|
||||
{
|
||||
Movable = false;
|
||||
|
||||
public override string DefaultName => "Faction Persistance - Internal";
|
||||
if (Instance == null || Instance.Deleted)
|
||||
Instance = this;
|
||||
else
|
||||
base.Delete();
|
||||
}
|
||||
|
||||
public FactionPersistance() : base( 1 )
|
||||
{
|
||||
Movable = false;
|
||||
public FactionPersistance(Serial serial) : base(serial)
|
||||
{
|
||||
Instance = this;
|
||||
}
|
||||
|
||||
if ( Instance == null || Instance.Deleted )
|
||||
Instance = this;
|
||||
else
|
||||
base.Delete();
|
||||
}
|
||||
public static FactionPersistance Instance{ get; private set; }
|
||||
|
||||
private enum PersistedType
|
||||
{
|
||||
Terminator,
|
||||
Faction,
|
||||
Town
|
||||
}
|
||||
public override string DefaultName => "Faction Persistance - Internal";
|
||||
|
||||
public FactionPersistance( Serial serial ) : base( serial )
|
||||
{
|
||||
Instance = this;
|
||||
}
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
public override void Serialize( GenericWriter writer )
|
||||
{
|
||||
base.Serialize( writer );
|
||||
writer.Write(0); // version
|
||||
|
||||
writer.Write( (int) 0 ); // version
|
||||
List<Faction> factions = Faction.Factions;
|
||||
|
||||
List<Faction> factions = Faction.Factions;
|
||||
for (int i = 0; i < factions.Count; ++i)
|
||||
{
|
||||
writer.WriteEncodedInt((int)PersistedType.Faction);
|
||||
factions[i].State.Serialize(writer);
|
||||
}
|
||||
|
||||
for ( int i = 0; i < factions.Count; ++i )
|
||||
{
|
||||
writer.WriteEncodedInt( (int) PersistedType.Faction );
|
||||
factions[i].State.Serialize( writer );
|
||||
}
|
||||
List<Town> towns = Town.Towns;
|
||||
|
||||
List<Town> towns = Town.Towns;
|
||||
for (int i = 0; i < towns.Count; ++i)
|
||||
{
|
||||
writer.WriteEncodedInt((int)PersistedType.Town);
|
||||
towns[i].State.Serialize(writer);
|
||||
}
|
||||
|
||||
for ( int i = 0; i < towns.Count; ++i )
|
||||
{
|
||||
writer.WriteEncodedInt( (int) PersistedType.Town );
|
||||
towns[i].State.Serialize( writer );
|
||||
}
|
||||
writer.WriteEncodedInt((int)PersistedType.Terminator);
|
||||
}
|
||||
|
||||
writer.WriteEncodedInt( (int) PersistedType.Terminator );
|
||||
}
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize( reader );
|
||||
int version = reader.ReadInt();
|
||||
|
||||
int version = reader.ReadInt();
|
||||
switch (version)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
PersistedType type;
|
||||
|
||||
switch ( version )
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
public override void Delete()
|
||||
{
|
||||
}
|
||||
|
||||
public override void Delete()
|
||||
{
|
||||
}
|
||||
}
|
||||
private enum PersistedType
|
||||
{
|
||||
Terminator,
|
||||
Faction,
|
||||
Town
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,251 +1,310 @@
|
|||
using System;
|
||||
using Server.Mobiles;
|
||||
using System.Collections.Generic;
|
||||
using Server.Mobiles;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class PlayerState : IComparable
|
||||
{
|
||||
private int m_KillPoints;
|
||||
private MerchantTitle m_MerchantTitle;
|
||||
private RankDefinition m_Rank;
|
||||
public class PlayerState : IComparable
|
||||
{
|
||||
private Town m_Finance;
|
||||
|
||||
private Town m_Sheriff;
|
||||
private Town m_Finance;
|
||||
private bool m_InvalidateRank = true;
|
||||
private int m_KillPoints;
|
||||
private MerchantTitle m_MerchantTitle;
|
||||
private RankDefinition m_Rank;
|
||||
private int m_RankIndex = -1;
|
||||
|
||||
public Mobile Mobile { get; }
|
||||
private Town m_Sheriff;
|
||||
|
||||
public Faction Faction { get; }
|
||||
public PlayerState(Mobile mob, Faction faction, List<PlayerState> owner)
|
||||
{
|
||||
Mobile = mob;
|
||||
Faction = faction;
|
||||
Owner = owner;
|
||||
|
||||
public List<PlayerState> Owner { get; }
|
||||
Attach();
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
public MerchantTitle MerchantTitle{ get => m_MerchantTitle;
|
||||
set{ m_MerchantTitle = value; Invalidate(); } }
|
||||
public Town Sheriff{ get => m_Sheriff;
|
||||
set{ m_Sheriff = value; Invalidate(); } }
|
||||
public Town Finance{ get => m_Finance;
|
||||
set{ m_Finance = value; Invalidate(); } }
|
||||
public List<SilverGivenEntry> SilverGiven { get; private set; }
|
||||
public PlayerState(GenericReader reader, Faction faction, List<PlayerState> owner)
|
||||
{
|
||||
Faction = faction;
|
||||
Owner = owner;
|
||||
|
||||
public int KillPoints {
|
||||
get => m_KillPoints;
|
||||
set {
|
||||
if ( m_KillPoints != value ) {
|
||||
if ( value > m_KillPoints ) {
|
||||
if ( m_KillPoints <= 0 ) {
|
||||
if ( value <= 0 ) {
|
||||
m_KillPoints = value;
|
||||
Invalidate();
|
||||
return;
|
||||
}
|
||||
int version = reader.ReadEncodedInt();
|
||||
|
||||
Owner.Remove( this );
|
||||
Owner.Insert( Faction.ZeroRankOffset, this );
|
||||
switch (version)
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
IsActive = reader.ReadBool();
|
||||
LastHonorTime = reader.ReadDateTime();
|
||||
goto case 0;
|
||||
}
|
||||
case 0:
|
||||
{
|
||||
Mobile = reader.ReadMobile();
|
||||
|
||||
m_RankIndex = Faction.ZeroRankOffset;
|
||||
Faction.ZeroRankOffset++;
|
||||
}
|
||||
while ( ( m_RankIndex - 1 ) >= 0 ) {
|
||||
PlayerState p = Owner[m_RankIndex-1] as PlayerState;
|
||||
if ( value > p.KillPoints ) {
|
||||
Owner[m_RankIndex] = p;
|
||||
Owner[m_RankIndex-1] = this;
|
||||
RankIndex--;
|
||||
p.RankIndex++;
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ( value <= 0 ) {
|
||||
if ( m_KillPoints <= 0 ) {
|
||||
m_KillPoints = value;
|
||||
Invalidate();
|
||||
return;
|
||||
}
|
||||
m_KillPoints = reader.ReadEncodedInt();
|
||||
m_MerchantTitle = (MerchantTitle)reader.ReadEncodedInt();
|
||||
|
||||
while ( ( m_RankIndex + 1 ) < Faction.ZeroRankOffset ) {
|
||||
PlayerState p = Owner[m_RankIndex+1] as PlayerState;
|
||||
Owner[m_RankIndex+1] = this;
|
||||
Owner[m_RankIndex] = p;
|
||||
RankIndex++;
|
||||
p.RankIndex--;
|
||||
}
|
||||
Leaving = reader.ReadDateTime();
|
||||
|
||||
m_RankIndex = -1;
|
||||
Faction.ZeroRankOffset--;
|
||||
}
|
||||
else {
|
||||
while ( ( m_RankIndex + 1 ) < Faction.ZeroRankOffset ) {
|
||||
PlayerState p = Owner[m_RankIndex+1] as PlayerState;
|
||||
if ( value < p.KillPoints ) {
|
||||
Owner[m_RankIndex+1] = this;
|
||||
Owner[m_RankIndex] = p;
|
||||
RankIndex++;
|
||||
p.RankIndex--;
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
m_KillPoints = value;
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
}
|
||||
Attach();
|
||||
}
|
||||
|
||||
private bool m_InvalidateRank = true;
|
||||
private int m_RankIndex = -1;
|
||||
public Mobile Mobile{ get; }
|
||||
|
||||
public int RankIndex { get => m_RankIndex;
|
||||
set { if ( m_RankIndex != value ) { m_RankIndex = value; m_InvalidateRank = true; } } }
|
||||
public Faction Faction{ get; }
|
||||
|
||||
public RankDefinition Rank {
|
||||
get {
|
||||
if ( m_InvalidateRank ) {
|
||||
RankDefinition[] ranks = Faction.Definition.Ranks;
|
||||
int percent;
|
||||
public List<PlayerState> Owner{ get; }
|
||||
|
||||
if ( Owner.Count == 1 )
|
||||
percent = 1000;
|
||||
else if ( m_RankIndex == -1 )
|
||||
percent = 0;
|
||||
else
|
||||
percent = ( ( Faction.ZeroRankOffset - m_RankIndex ) * 1000 ) / Faction.ZeroRankOffset;
|
||||
public MerchantTitle MerchantTitle
|
||||
{
|
||||
get => m_MerchantTitle;
|
||||
set
|
||||
{
|
||||
m_MerchantTitle = value;
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
for ( int i = 0; i < ranks.Length; i++ ) {
|
||||
RankDefinition check = ranks[i];
|
||||
public Town Sheriff
|
||||
{
|
||||
get => m_Sheriff;
|
||||
set
|
||||
{
|
||||
m_Sheriff = value;
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
if ( percent >= check.Required ) {
|
||||
m_Rank = check;
|
||||
m_InvalidateRank = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
public Town Finance
|
||||
{
|
||||
get => m_Finance;
|
||||
set
|
||||
{
|
||||
m_Finance = value;
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
Invalidate();
|
||||
}
|
||||
public List<SilverGivenEntry> SilverGiven{ get; private set; }
|
||||
|
||||
return m_Rank;
|
||||
}
|
||||
}
|
||||
public int KillPoints
|
||||
{
|
||||
get => m_KillPoints;
|
||||
set
|
||||
{
|
||||
if (m_KillPoints != value)
|
||||
{
|
||||
if (value > m_KillPoints)
|
||||
{
|
||||
if (m_KillPoints <= 0)
|
||||
{
|
||||
if (value <= 0)
|
||||
{
|
||||
m_KillPoints = value;
|
||||
Invalidate();
|
||||
return;
|
||||
}
|
||||
|
||||
public DateTime LastHonorTime { get; set; }
|
||||
Owner.Remove(this);
|
||||
Owner.Insert(Faction.ZeroRankOffset, this);
|
||||
|
||||
public DateTime Leaving { get; set; }
|
||||
m_RankIndex = Faction.ZeroRankOffset;
|
||||
Faction.ZeroRankOffset++;
|
||||
}
|
||||
|
||||
public bool IsLeaving => ( Leaving > DateTime.MinValue );
|
||||
while (m_RankIndex - 1 >= 0)
|
||||
{
|
||||
PlayerState p = Owner[m_RankIndex - 1];
|
||||
if (value > p.KillPoints)
|
||||
{
|
||||
Owner[m_RankIndex] = p;
|
||||
Owner[m_RankIndex - 1] = this;
|
||||
RankIndex--;
|
||||
p.RankIndex++;
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (value <= 0)
|
||||
{
|
||||
if (m_KillPoints <= 0)
|
||||
{
|
||||
m_KillPoints = value;
|
||||
Invalidate();
|
||||
return;
|
||||
}
|
||||
|
||||
public bool IsActive { get; set; }
|
||||
while (m_RankIndex + 1 < Faction.ZeroRankOffset)
|
||||
{
|
||||
PlayerState p = Owner[m_RankIndex + 1];
|
||||
Owner[m_RankIndex + 1] = this;
|
||||
Owner[m_RankIndex] = p;
|
||||
RankIndex++;
|
||||
p.RankIndex--;
|
||||
}
|
||||
|
||||
public bool CanGiveSilverTo( Mobile mob )
|
||||
{
|
||||
if ( SilverGiven == null )
|
||||
return true;
|
||||
m_RankIndex = -1;
|
||||
Faction.ZeroRankOffset--;
|
||||
}
|
||||
else
|
||||
{
|
||||
while (m_RankIndex + 1 < Faction.ZeroRankOffset)
|
||||
{
|
||||
PlayerState p = Owner[m_RankIndex + 1];
|
||||
if (value < p.KillPoints)
|
||||
{
|
||||
Owner[m_RankIndex + 1] = this;
|
||||
Owner[m_RankIndex] = p;
|
||||
RankIndex++;
|
||||
p.RankIndex--;
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for ( int i = 0; i < SilverGiven.Count; ++i )
|
||||
{
|
||||
SilverGivenEntry sge = SilverGiven[i];
|
||||
m_KillPoints = value;
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( sge.IsExpired )
|
||||
SilverGiven.RemoveAt( i-- );
|
||||
else if ( sge.GivenTo == mob )
|
||||
return false;
|
||||
}
|
||||
public int RankIndex
|
||||
{
|
||||
get => m_RankIndex;
|
||||
set
|
||||
{
|
||||
if (m_RankIndex != value)
|
||||
{
|
||||
m_RankIndex = value;
|
||||
m_InvalidateRank = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
public RankDefinition Rank
|
||||
{
|
||||
get
|
||||
{
|
||||
if (m_InvalidateRank)
|
||||
{
|
||||
RankDefinition[] ranks = Faction.Definition.Ranks;
|
||||
int percent;
|
||||
|
||||
public void OnGivenSilverTo( Mobile mob )
|
||||
{
|
||||
if ( SilverGiven == null )
|
||||
SilverGiven = new List<SilverGivenEntry>();
|
||||
if (Owner.Count == 1)
|
||||
percent = 1000;
|
||||
else if (m_RankIndex == -1)
|
||||
percent = 0;
|
||||
else
|
||||
percent = (Faction.ZeroRankOffset - m_RankIndex) * 1000 / Faction.ZeroRankOffset;
|
||||
|
||||
SilverGiven.Add( new SilverGivenEntry( mob ) );
|
||||
}
|
||||
for (int i = 0; i < ranks.Length; i++)
|
||||
{
|
||||
RankDefinition check = ranks[i];
|
||||
|
||||
public void Invalidate()
|
||||
{
|
||||
if ( Mobile is PlayerMobile pm )
|
||||
{
|
||||
pm.InvalidateProperties();
|
||||
pm.InvalidateMyRunUO();
|
||||
}
|
||||
}
|
||||
if (percent >= check.Required)
|
||||
{
|
||||
m_Rank = check;
|
||||
m_InvalidateRank = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void Attach()
|
||||
{
|
||||
if ( Mobile is PlayerMobile mobile )
|
||||
mobile.FactionPlayerState = this;
|
||||
}
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
public PlayerState( Mobile mob, Faction faction, List<PlayerState> owner )
|
||||
{
|
||||
Mobile = mob;
|
||||
Faction = faction;
|
||||
Owner = owner;
|
||||
return m_Rank;
|
||||
}
|
||||
}
|
||||
|
||||
Attach();
|
||||
Invalidate();
|
||||
}
|
||||
public DateTime LastHonorTime{ get; set; }
|
||||
|
||||
public PlayerState( GenericReader reader, Faction faction, List<PlayerState> owner )
|
||||
{
|
||||
Faction = faction;
|
||||
Owner = owner;
|
||||
public DateTime Leaving{ get; set; }
|
||||
|
||||
int version = reader.ReadEncodedInt();
|
||||
public bool IsLeaving => Leaving > DateTime.MinValue;
|
||||
|
||||
switch ( version )
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
IsActive = reader.ReadBool();
|
||||
LastHonorTime = reader.ReadDateTime();
|
||||
goto case 0;
|
||||
}
|
||||
case 0:
|
||||
{
|
||||
Mobile = reader.ReadMobile();
|
||||
public bool IsActive{ get; set; }
|
||||
|
||||
m_KillPoints = reader.ReadEncodedInt();
|
||||
m_MerchantTitle = (MerchantTitle)reader.ReadEncodedInt();
|
||||
public int CompareTo(object obj)
|
||||
{
|
||||
return ((PlayerState)obj).m_KillPoints - m_KillPoints;
|
||||
}
|
||||
|
||||
Leaving = reader.ReadDateTime();
|
||||
public bool CanGiveSilverTo(Mobile mob)
|
||||
{
|
||||
if (SilverGiven == null)
|
||||
return true;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < SilverGiven.Count; ++i)
|
||||
{
|
||||
SilverGivenEntry sge = SilverGiven[i];
|
||||
|
||||
Attach();
|
||||
}
|
||||
if (sge.IsExpired)
|
||||
SilverGiven.RemoveAt(i--);
|
||||
else if (sge.GivenTo == mob)
|
||||
return false;
|
||||
}
|
||||
|
||||
public void Serialize( GenericWriter writer )
|
||||
{
|
||||
writer.WriteEncodedInt( (int) 1 ); // version
|
||||
return true;
|
||||
}
|
||||
|
||||
writer.Write( IsActive );
|
||||
writer.Write( LastHonorTime );
|
||||
public void OnGivenSilverTo(Mobile mob)
|
||||
{
|
||||
if (SilverGiven == null)
|
||||
SilverGiven = new List<SilverGivenEntry>();
|
||||
|
||||
writer.Write( (Mobile) Mobile );
|
||||
SilverGiven.Add(new SilverGivenEntry(mob));
|
||||
}
|
||||
|
||||
writer.WriteEncodedInt( (int) m_KillPoints );
|
||||
writer.WriteEncodedInt( (int) m_MerchantTitle );
|
||||
public void Invalidate()
|
||||
{
|
||||
if (Mobile is PlayerMobile pm)
|
||||
{
|
||||
pm.InvalidateProperties();
|
||||
pm.InvalidateMyRunUO();
|
||||
}
|
||||
}
|
||||
|
||||
writer.Write( (DateTime) Leaving );
|
||||
}
|
||||
public void Attach()
|
||||
{
|
||||
if (Mobile is PlayerMobile mobile)
|
||||
mobile.FactionPlayerState = this;
|
||||
}
|
||||
|
||||
public static PlayerState Find( Mobile mob )
|
||||
{
|
||||
return mob is PlayerMobile mobile ? mobile.FactionPlayerState : null;
|
||||
}
|
||||
public void Serialize(GenericWriter writer)
|
||||
{
|
||||
writer.WriteEncodedInt(1); // version
|
||||
|
||||
public int CompareTo( object obj )
|
||||
{
|
||||
return ((PlayerState)obj).m_KillPoints - m_KillPoints;
|
||||
}
|
||||
}
|
||||
}
|
||||
writer.Write(IsActive);
|
||||
writer.Write(LastHonorTime);
|
||||
|
||||
writer.Write(Mobile);
|
||||
|
||||
writer.WriteEncodedInt(m_KillPoints);
|
||||
writer.WriteEncodedInt((int)m_MerchantTitle);
|
||||
|
||||
writer.Write(Leaving);
|
||||
}
|
||||
|
||||
public static PlayerState Find(Mobile mob)
|
||||
{
|
||||
return mob is PlayerMobile mobile ? mobile.FactionPlayerState : null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,72 +1,78 @@
|
|||
using System;
|
||||
using System.Reflection;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class Reflector
|
||||
{
|
||||
private static List<Town> m_Towns;
|
||||
public class Reflector
|
||||
{
|
||||
private static List<Town> m_Towns;
|
||||
|
||||
public static List<Town> Towns
|
||||
{
|
||||
get
|
||||
{
|
||||
if ( m_Towns == null )
|
||||
ProcessTypes();
|
||||
private static List<Faction> m_Factions;
|
||||
|
||||
return m_Towns;
|
||||
}
|
||||
}
|
||||
public static List<Town> Towns
|
||||
{
|
||||
get
|
||||
{
|
||||
if (m_Towns == null)
|
||||
ProcessTypes();
|
||||
|
||||
private static List<Faction> m_Factions;
|
||||
return m_Towns;
|
||||
}
|
||||
}
|
||||
|
||||
public static List<Faction> Factions
|
||||
{
|
||||
get
|
||||
{
|
||||
if ( m_Factions == null )
|
||||
ProcessTypes();
|
||||
public static List<Faction> Factions
|
||||
{
|
||||
get
|
||||
{
|
||||
if (m_Factions == null)
|
||||
ProcessTypes();
|
||||
|
||||
return m_Factions;
|
||||
}
|
||||
}
|
||||
return m_Factions;
|
||||
}
|
||||
}
|
||||
|
||||
private static object Construct( Type type )
|
||||
{
|
||||
try{ return Activator.CreateInstance( type ); }
|
||||
catch{ return null; }
|
||||
}
|
||||
private static object Construct(Type type)
|
||||
{
|
||||
try
|
||||
{
|
||||
return Activator.CreateInstance(type);
|
||||
}
|
||||
catch
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static void ProcessTypes()
|
||||
{
|
||||
m_Factions = new List<Faction>();
|
||||
m_Towns = new List<Town>();
|
||||
private static void ProcessTypes()
|
||||
{
|
||||
m_Factions = new List<Faction>();
|
||||
m_Towns = new List<Town>();
|
||||
|
||||
Assembly[] asms = ScriptCompiler.Assemblies;
|
||||
Assembly[] asms = ScriptCompiler.Assemblies;
|
||||
|
||||
for ( int i = 0; i < asms.Length; ++i )
|
||||
{
|
||||
Assembly asm = asms[i];
|
||||
TypeCache tc = ScriptCompiler.GetTypeCache( asm );
|
||||
Type[] types = tc.Types;
|
||||
for (int i = 0; i < asms.Length; ++i)
|
||||
{
|
||||
Assembly asm = asms[i];
|
||||
TypeCache tc = ScriptCompiler.GetTypeCache(asm);
|
||||
Type[] types = tc.Types;
|
||||
|
||||
for ( int j = 0; j < types.Length; ++j )
|
||||
{
|
||||
Type type = types[j];
|
||||
for (int j = 0; j < types.Length; ++j)
|
||||
{
|
||||
Type type = types[j];
|
||||
|
||||
if ( type.IsSubclassOf( typeof( Faction ) ) )
|
||||
{
|
||||
if ( Construct( type ) is Faction faction )
|
||||
Faction.Factions.Add( faction );
|
||||
}
|
||||
else if ( type.IsSubclassOf( typeof( Town ) ) )
|
||||
{
|
||||
if ( Construct( type ) is Town town )
|
||||
Town.Towns.Add( town );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (type.IsSubclassOf(typeof(Faction)))
|
||||
{
|
||||
if (Construct(type) is Faction faction)
|
||||
Faction.Factions.Add(faction);
|
||||
}
|
||||
else if (type.IsSubclassOf(typeof(Town)))
|
||||
{
|
||||
if (Construct(type) is Town town)
|
||||
Town.Towns.Add(town);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2,20 +2,20 @@ using System;
|
|||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class SilverGivenEntry
|
||||
{
|
||||
public static readonly TimeSpan ExpirePeriod = TimeSpan.FromHours( 3.0 );
|
||||
public class SilverGivenEntry
|
||||
{
|
||||
public static readonly TimeSpan ExpirePeriod = TimeSpan.FromHours(3.0);
|
||||
|
||||
public Mobile GivenTo { get; }
|
||||
public SilverGivenEntry(Mobile givenTo)
|
||||
{
|
||||
GivenTo = givenTo;
|
||||
TimeOfGift = DateTime.UtcNow;
|
||||
}
|
||||
|
||||
public DateTime TimeOfGift { get; }
|
||||
public Mobile GivenTo{ get; }
|
||||
|
||||
public bool IsExpired => ( TimeOfGift + ExpirePeriod ) < DateTime.UtcNow;
|
||||
public DateTime TimeOfGift{ get; }
|
||||
|
||||
public SilverGivenEntry( Mobile givenTo )
|
||||
{
|
||||
GivenTo = givenTo;
|
||||
TimeOfGift = DateTime.UtcNow;
|
||||
}
|
||||
}
|
||||
public bool IsExpired => TimeOfGift + ExpirePeriod < DateTime.UtcNow;
|
||||
}
|
||||
}
|
||||
|
|
@ -3,36 +3,38 @@ using Server.Regions;
|
|||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class StrongholdRegion : BaseRegion
|
||||
{
|
||||
public Faction Faction { get; set; }
|
||||
public class StrongholdRegion : BaseRegion
|
||||
{
|
||||
public StrongholdRegion(Faction faction) : base(faction.Definition.FriendlyName, Faction.Facet, DefaultPriority,
|
||||
faction.Definition.Stronghold.Area)
|
||||
{
|
||||
Faction = faction;
|
||||
|
||||
public StrongholdRegion( Faction faction ) : base( faction.Definition.FriendlyName, Faction.Facet, DefaultPriority, faction.Definition.Stronghold.Area )
|
||||
{
|
||||
Faction = faction;
|
||||
Register();
|
||||
}
|
||||
|
||||
Register();
|
||||
}
|
||||
public Faction Faction{ get; set; }
|
||||
|
||||
public override bool OnMoveInto( Mobile m, Direction d, Point3D newLocation, Point3D oldLocation )
|
||||
{
|
||||
if ( !base.OnMoveInto( m, d, newLocation, oldLocation ) )
|
||||
return false;
|
||||
public override bool OnMoveInto(Mobile m, Direction d, Point3D newLocation, Point3D oldLocation)
|
||||
{
|
||||
if (!base.OnMoveInto(m, d, newLocation, oldLocation))
|
||||
return false;
|
||||
|
||||
if ( m.AccessLevel >= AccessLevel.Counselor || Contains( oldLocation ) )
|
||||
return true;
|
||||
if (m.AccessLevel >= AccessLevel.Counselor || Contains(oldLocation))
|
||||
return true;
|
||||
|
||||
if ( m is PlayerMobile pm && pm.DuelContext != null) {
|
||||
pm.SendMessage( "You may not enter this area while participating in a duel or a tournament." );
|
||||
return false;
|
||||
}
|
||||
if (m is PlayerMobile pm && pm.DuelContext != null)
|
||||
{
|
||||
pm.SendMessage("You may not enter this area while participating in a duel or a tournament.");
|
||||
return false;
|
||||
}
|
||||
|
||||
return ( Faction.Find( m, true, true ) != null );
|
||||
}
|
||||
return Faction.Find(m, true, true) != null;
|
||||
}
|
||||
|
||||
public override bool AllowHousing( Mobile from, Point3D p )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
public override bool AllowHousing(Mobile from, Point3D p)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,510 +1,514 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using Server.Targeting;
|
||||
using Server.Commands;
|
||||
using System.Collections.Generic;
|
||||
using Server.Commands;
|
||||
using Server.Targeting;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
[CustomEnum( new[]{ "Britain", "Magincia", "Minoc", "Moonglow", "Skara Brae", "Trinsic", "Vesper", "Yew" } )]
|
||||
public abstract class Town : IComparable
|
||||
{
|
||||
private TownState m_State;
|
||||
|
||||
public TownDefinition Definition { get; set; }
|
||||
|
||||
public TownState State
|
||||
{
|
||||
get => m_State;
|
||||
set{ m_State = value; ConstructGuardLists(); }
|
||||
}
|
||||
|
||||
public int Silver
|
||||
{
|
||||
get => m_State.Silver;
|
||||
set => m_State.Silver = value;
|
||||
}
|
||||
|
||||
public Faction Owner
|
||||
{
|
||||
get => m_State.Owner;
|
||||
set => Capture( value );
|
||||
}
|
||||
|
||||
public Mobile Sheriff
|
||||
{
|
||||
get => m_State.Sheriff;
|
||||
set => m_State.Sheriff = value;
|
||||
}
|
||||
|
||||
public Mobile Finance
|
||||
{
|
||||
get => m_State.Finance;
|
||||
set => m_State.Finance = value;
|
||||
}
|
||||
|
||||
public int Tax
|
||||
{
|
||||
get => m_State.Tax;
|
||||
set => m_State.Tax = value;
|
||||
}
|
||||
|
||||
public DateTime LastTaxChange
|
||||
{
|
||||
get => m_State.LastTaxChange;
|
||||
set => m_State.LastTaxChange = value;
|
||||
}
|
||||
|
||||
public static readonly TimeSpan TaxChangePeriod = TimeSpan.FromHours( 12.0 );
|
||||
public static readonly TimeSpan IncomePeriod = TimeSpan.FromDays( 1.0 );
|
||||
|
||||
public bool TaxChangeReady => ( m_State.LastTaxChange + TaxChangePeriod ) < DateTime.UtcNow;
|
||||
|
||||
public static Town FromRegion( Region reg )
|
||||
{
|
||||
if ( reg.Map != Faction.Facet )
|
||||
return null;
|
||||
|
||||
List<Town> towns = Towns;
|
||||
|
||||
for ( int i = 0; i < towns.Count; ++i )
|
||||
{
|
||||
Town town = towns[i];
|
||||
|
||||
if ( reg.IsPartOf( town.Definition.Region ) )
|
||||
return town;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public int FinanceUpkeep
|
||||
{
|
||||
get
|
||||
{
|
||||
List<VendorList> vendorLists = VendorLists;
|
||||
int upkeep = 0;
|
||||
|
||||
for ( int i = 0; i < vendorLists.Count; ++i )
|
||||
upkeep += vendorLists[i].Vendors.Count * vendorLists[i].Definition.Upkeep;
|
||||
|
||||
return upkeep;
|
||||
}
|
||||
}
|
||||
|
||||
public int SheriffUpkeep
|
||||
{
|
||||
get
|
||||
{
|
||||
List<GuardList> guardLists = GuardLists;
|
||||
int upkeep = 0;
|
||||
|
||||
for ( int i = 0; i < guardLists.Count; ++i )
|
||||
upkeep += guardLists[i].Guards.Count * guardLists[i].Definition.Upkeep;
|
||||
|
||||
return upkeep;
|
||||
}
|
||||
}
|
||||
|
||||
public int DailyIncome => (10000 * (100 + m_State.Tax)) / 100;
|
||||
|
||||
public int NetCashFlow => DailyIncome - FinanceUpkeep - SheriffUpkeep;
|
||||
|
||||
public TownMonolith Monolith
|
||||
{
|
||||
get
|
||||
{
|
||||
List<BaseMonolith> monoliths = BaseMonolith.Monoliths;
|
||||
|
||||
foreach ( BaseMonolith monolith in monoliths )
|
||||
{
|
||||
if ( monolith is TownMonolith townMonolith && townMonolith.Town == this )
|
||||
return townMonolith;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public DateTime LastIncome
|
||||
{
|
||||
get => m_State.LastIncome;
|
||||
set => m_State.LastIncome = value;
|
||||
}
|
||||
|
||||
public void BeginOrderFiring( Mobile from )
|
||||
{
|
||||
bool isFinance = IsFinance( from );
|
||||
bool isSheriff = IsSheriff( from );
|
||||
string type = null;
|
||||
|
||||
// NOTE: Messages not OSI-accurate, intentional
|
||||
if ( isFinance && isSheriff ) // GM only
|
||||
type = "vendor or guard";
|
||||
else if ( isFinance )
|
||||
type = "vendor";
|
||||
else if ( isSheriff )
|
||||
type = "guard";
|
||||
|
||||
from.SendMessage( "Target the {0} you wish to dismiss.", type );
|
||||
from.BeginTarget( 12, false, TargetFlags.None, EndOrderFiring );
|
||||
}
|
||||
[CustomEnum(new[] { "Britain", "Magincia", "Minoc", "Moonglow", "Skara Brae", "Trinsic", "Vesper", "Yew" })]
|
||||
public abstract class Town : IComparable
|
||||
{
|
||||
public const int SilverCaptureBonus = 10000;
|
||||
|
||||
public static readonly TimeSpan TaxChangePeriod = TimeSpan.FromHours(12.0);
|
||||
public static readonly TimeSpan IncomePeriod = TimeSpan.FromDays(1.0);
|
||||
|
||||
private Timer m_IncomeTimer;
|
||||
private TownState m_State;
|
||||
|
||||
public Town()
|
||||
{
|
||||
m_State = new TownState(this);
|
||||
ConstructVendorLists();
|
||||
ConstructGuardLists();
|
||||
StartIncomeTimer();
|
||||
}
|
||||
|
||||
public TownDefinition Definition{ get; set; }
|
||||
|
||||
public TownState State
|
||||
{
|
||||
get => m_State;
|
||||
set
|
||||
{
|
||||
m_State = value;
|
||||
ConstructGuardLists();
|
||||
}
|
||||
}
|
||||
|
||||
public int Silver
|
||||
{
|
||||
get => m_State.Silver;
|
||||
set => m_State.Silver = value;
|
||||
}
|
||||
|
||||
public Faction Owner
|
||||
{
|
||||
get => m_State.Owner;
|
||||
set => Capture(value);
|
||||
}
|
||||
|
||||
public Mobile Sheriff
|
||||
{
|
||||
get => m_State.Sheriff;
|
||||
set => m_State.Sheriff = value;
|
||||
}
|
||||
|
||||
public Mobile Finance
|
||||
{
|
||||
get => m_State.Finance;
|
||||
set => m_State.Finance = value;
|
||||
}
|
||||
|
||||
public int Tax
|
||||
{
|
||||
get => m_State.Tax;
|
||||
set => m_State.Tax = value;
|
||||
}
|
||||
|
||||
public DateTime LastTaxChange
|
||||
{
|
||||
get => m_State.LastTaxChange;
|
||||
set => m_State.LastTaxChange = value;
|
||||
}
|
||||
|
||||
public bool TaxChangeReady => m_State.LastTaxChange + TaxChangePeriod < DateTime.UtcNow;
|
||||
|
||||
public int FinanceUpkeep
|
||||
{
|
||||
get
|
||||
{
|
||||
List<VendorList> vendorLists = VendorLists;
|
||||
int upkeep = 0;
|
||||
|
||||
for (int i = 0; i < vendorLists.Count; ++i)
|
||||
upkeep += vendorLists[i].Vendors.Count * vendorLists[i].Definition.Upkeep;
|
||||
|
||||
return upkeep;
|
||||
}
|
||||
}
|
||||
|
||||
public int SheriffUpkeep
|
||||
{
|
||||
get
|
||||
{
|
||||
List<GuardList> guardLists = GuardLists;
|
||||
int upkeep = 0;
|
||||
|
||||
for (int i = 0; i < guardLists.Count; ++i)
|
||||
upkeep += guardLists[i].Guards.Count * guardLists[i].Definition.Upkeep;
|
||||
|
||||
return upkeep;
|
||||
}
|
||||
}
|
||||
|
||||
public int DailyIncome => 10000 * (100 + m_State.Tax) / 100;
|
||||
|
||||
public int NetCashFlow => DailyIncome - FinanceUpkeep - SheriffUpkeep;
|
||||
|
||||
public TownMonolith Monolith
|
||||
{
|
||||
get
|
||||
{
|
||||
List<BaseMonolith> monoliths = BaseMonolith.Monoliths;
|
||||
|
||||
foreach (BaseMonolith monolith in monoliths)
|
||||
if (monolith is TownMonolith townMonolith && townMonolith.Town == this)
|
||||
return townMonolith;
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public DateTime LastIncome
|
||||
{
|
||||
get => m_State.LastIncome;
|
||||
set => m_State.LastIncome = value;
|
||||
}
|
||||
|
||||
public List<VendorList> VendorLists{ get; set; }
|
||||
|
||||
public List<GuardList> GuardLists{ get; set; }
|
||||
|
||||
public static List<Town> Towns => Reflector.Towns;
|
||||
|
||||
public int CompareTo(object obj)
|
||||
{
|
||||
return Definition.Sort - ((Town)obj).Definition.Sort;
|
||||
}
|
||||
|
||||
public static Town FromRegion(Region reg)
|
||||
{
|
||||
if (reg.Map != Faction.Facet)
|
||||
return null;
|
||||
|
||||
List<Town> towns = Towns;
|
||||
|
||||
for (int i = 0; i < towns.Count; ++i)
|
||||
{
|
||||
Town town = towns[i];
|
||||
|
||||
if (reg.IsPartOf(town.Definition.Region))
|
||||
return town;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public void BeginOrderFiring(Mobile from)
|
||||
{
|
||||
bool isFinance = IsFinance(from);
|
||||
bool isSheriff = IsSheriff(from);
|
||||
string type = null;
|
||||
|
||||
// NOTE: Messages not OSI-accurate, intentional
|
||||
if (isFinance && isSheriff) // GM only
|
||||
type = "vendor or guard";
|
||||
else if (isFinance)
|
||||
type = "vendor";
|
||||
else if (isSheriff)
|
||||
type = "guard";
|
||||
|
||||
public void EndOrderFiring( Mobile from, object obj )
|
||||
{
|
||||
bool isFinance = IsFinance( from );
|
||||
bool isSheriff = IsSheriff( from );
|
||||
string type = null;
|
||||
from.SendMessage("Target the {0} you wish to dismiss.", type);
|
||||
from.BeginTarget(12, false, TargetFlags.None, EndOrderFiring);
|
||||
}
|
||||
|
||||
if ( isFinance && isSheriff ) // GM only
|
||||
type = "vendor or guard";
|
||||
else if ( isFinance )
|
||||
type = "vendor";
|
||||
else if ( isSheriff )
|
||||
type = "guard";
|
||||
public void EndOrderFiring(Mobile from, object obj)
|
||||
{
|
||||
bool isFinance = IsFinance(from);
|
||||
bool isSheriff = IsSheriff(from);
|
||||
string type = null;
|
||||
|
||||
if ( obj is BaseFactionVendor vendor && vendor.Town == this && isFinance )
|
||||
vendor.Delete();
|
||||
else if ( obj is BaseFactionGuard guard && guard.Town == this && isSheriff )
|
||||
guard.Delete();
|
||||
else
|
||||
{
|
||||
from.SendMessage( "That is not a {0}!", type );
|
||||
}
|
||||
}
|
||||
if (isFinance && isSheriff) // GM only
|
||||
type = "vendor or guard";
|
||||
else if (isFinance)
|
||||
type = "vendor";
|
||||
else if (isSheriff)
|
||||
type = "guard";
|
||||
|
||||
private Timer m_IncomeTimer;
|
||||
if (obj is BaseFactionVendor vendor && vendor.Town == this && isFinance)
|
||||
vendor.Delete();
|
||||
else if (obj is BaseFactionGuard guard && guard.Town == this && isSheriff)
|
||||
guard.Delete();
|
||||
else
|
||||
from.SendMessage("That is not a {0}!", type);
|
||||
}
|
||||
|
||||
public void StartIncomeTimer()
|
||||
{
|
||||
m_IncomeTimer?.Stop();
|
||||
public void StartIncomeTimer()
|
||||
{
|
||||
m_IncomeTimer?.Stop();
|
||||
|
||||
m_IncomeTimer = Timer.DelayCall( TimeSpan.FromMinutes( 1.0 ), TimeSpan.FromMinutes( 1.0 ), CheckIncome );
|
||||
}
|
||||
m_IncomeTimer = Timer.DelayCall(TimeSpan.FromMinutes(1.0), TimeSpan.FromMinutes(1.0), CheckIncome);
|
||||
}
|
||||
|
||||
public void StopIncomeTimer()
|
||||
{
|
||||
m_IncomeTimer?.Stop();
|
||||
public void StopIncomeTimer()
|
||||
{
|
||||
m_IncomeTimer?.Stop();
|
||||
|
||||
m_IncomeTimer = null;
|
||||
}
|
||||
m_IncomeTimer = null;
|
||||
}
|
||||
|
||||
public void CheckIncome()
|
||||
{
|
||||
if ( (LastIncome + IncomePeriod) > DateTime.UtcNow || Owner == null )
|
||||
return;
|
||||
public void CheckIncome()
|
||||
{
|
||||
if (LastIncome + IncomePeriod > DateTime.UtcNow || Owner == null)
|
||||
return;
|
||||
|
||||
ProcessIncome();
|
||||
}
|
||||
ProcessIncome();
|
||||
}
|
||||
|
||||
public void ProcessIncome()
|
||||
{
|
||||
LastIncome = DateTime.UtcNow;
|
||||
public void ProcessIncome()
|
||||
{
|
||||
LastIncome = DateTime.UtcNow;
|
||||
|
||||
int flow = NetCashFlow;
|
||||
int flow = NetCashFlow;
|
||||
|
||||
if ( (Silver + flow) < 0 )
|
||||
{
|
||||
ArrayList toDelete = BuildFinanceList();
|
||||
if (Silver + flow < 0)
|
||||
{
|
||||
ArrayList toDelete = BuildFinanceList();
|
||||
|
||||
while ( (Silver + flow) < 0 && toDelete.Count > 0 )
|
||||
{
|
||||
int index = Utility.Random( toDelete.Count );
|
||||
Mobile mob = (Mobile)toDelete[index];
|
||||
while (Silver + flow < 0 && toDelete.Count > 0)
|
||||
{
|
||||
int index = Utility.Random(toDelete.Count);
|
||||
Mobile mob = (Mobile)toDelete[index];
|
||||
|
||||
mob.Delete();
|
||||
mob.Delete();
|
||||
|
||||
toDelete.RemoveAt( index );
|
||||
flow = NetCashFlow;
|
||||
}
|
||||
}
|
||||
toDelete.RemoveAt(index);
|
||||
flow = NetCashFlow;
|
||||
}
|
||||
}
|
||||
|
||||
Silver += flow;
|
||||
}
|
||||
Silver += flow;
|
||||
}
|
||||
|
||||
public ArrayList BuildFinanceList()
|
||||
{
|
||||
ArrayList list = new ArrayList();
|
||||
public ArrayList BuildFinanceList()
|
||||
{
|
||||
ArrayList list = new ArrayList();
|
||||
|
||||
List<VendorList> vendorLists = VendorLists;
|
||||
List<VendorList> vendorLists = VendorLists;
|
||||
|
||||
for ( int i = 0; i < vendorLists.Count; ++i )
|
||||
list.AddRange( vendorLists[i].Vendors );
|
||||
for (int i = 0; i < vendorLists.Count; ++i)
|
||||
list.AddRange(vendorLists[i].Vendors);
|
||||
|
||||
List<GuardList> guardLists = GuardLists;
|
||||
List<GuardList> guardLists = GuardLists;
|
||||
|
||||
for ( int i = 0; i < guardLists.Count; ++i )
|
||||
list.AddRange( guardLists[i].Guards );
|
||||
for (int i = 0; i < guardLists.Count; ++i)
|
||||
list.AddRange(guardLists[i].Guards);
|
||||
|
||||
return list;
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public List<VendorList> VendorLists { get; set; }
|
||||
public void ConstructGuardLists()
|
||||
{
|
||||
GuardDefinition[] defs = Owner == null ? new GuardDefinition[0] : Owner.Definition.Guards;
|
||||
|
||||
public List<GuardList> GuardLists { get; set; }
|
||||
GuardLists = new List<GuardList>();
|
||||
|
||||
public void ConstructGuardLists()
|
||||
{
|
||||
GuardDefinition[] defs = ( Owner == null ? new GuardDefinition[0] : Owner.Definition.Guards );
|
||||
for (int i = 0; i < defs.Length; ++i)
|
||||
GuardLists.Add(new GuardList(defs[i]));
|
||||
}
|
||||
|
||||
GuardLists = new List<GuardList>();
|
||||
public GuardList FindGuardList(Type type)
|
||||
{
|
||||
List<GuardList> guardLists = GuardLists;
|
||||
|
||||
for ( int i = 0; i < defs.Length; ++i )
|
||||
GuardLists.Add( new GuardList( defs[i] ) );
|
||||
}
|
||||
for (int i = 0; i < guardLists.Count; ++i)
|
||||
{
|
||||
GuardList guardList = guardLists[i];
|
||||
|
||||
public GuardList FindGuardList( Type type )
|
||||
{
|
||||
List<GuardList> guardLists = GuardLists;
|
||||
if (guardList.Definition.Type == type)
|
||||
return guardList;
|
||||
}
|
||||
|
||||
for ( int i = 0; i < guardLists.Count; ++i )
|
||||
{
|
||||
GuardList guardList = guardLists[i];
|
||||
return null;
|
||||
}
|
||||
|
||||
if ( guardList.Definition.Type == type )
|
||||
return guardList;
|
||||
}
|
||||
public void ConstructVendorLists()
|
||||
{
|
||||
VendorDefinition[] defs = VendorDefinition.Definitions;
|
||||
|
||||
return null;
|
||||
}
|
||||
VendorLists = new List<VendorList>();
|
||||
|
||||
public void ConstructVendorLists()
|
||||
{
|
||||
VendorDefinition[] defs = VendorDefinition.Definitions;
|
||||
for (int i = 0; i < defs.Length; ++i)
|
||||
VendorLists.Add(new VendorList(defs[i]));
|
||||
}
|
||||
|
||||
VendorLists = new List<VendorList>();
|
||||
public VendorList FindVendorList(Type type)
|
||||
{
|
||||
List<VendorList> vendorLists = VendorLists;
|
||||
|
||||
for ( int i = 0; i < defs.Length; ++i )
|
||||
VendorLists.Add( new VendorList( defs[i] ) );
|
||||
}
|
||||
for (int i = 0; i < vendorLists.Count; ++i)
|
||||
{
|
||||
VendorList vendorList = vendorLists[i];
|
||||
|
||||
public VendorList FindVendorList( Type type )
|
||||
{
|
||||
List<VendorList> vendorLists = VendorLists;
|
||||
if (vendorList.Definition.Type == type)
|
||||
return vendorList;
|
||||
}
|
||||
|
||||
for ( int i = 0; i < vendorLists.Count; ++i )
|
||||
{
|
||||
VendorList vendorList = vendorLists[i];
|
||||
return null;
|
||||
}
|
||||
|
||||
if ( vendorList.Definition.Type == type )
|
||||
return vendorList;
|
||||
}
|
||||
public bool RegisterGuard(BaseFactionGuard guard)
|
||||
{
|
||||
if (guard == null)
|
||||
return false;
|
||||
|
||||
return null;
|
||||
}
|
||||
GuardList guardList = FindGuardList(guard.GetType());
|
||||
|
||||
public bool RegisterGuard( BaseFactionGuard guard )
|
||||
{
|
||||
if ( guard == null )
|
||||
return false;
|
||||
if (guardList == null)
|
||||
return false;
|
||||
|
||||
GuardList guardList = FindGuardList( guard.GetType() );
|
||||
guardList.Guards.Add(guard);
|
||||
return true;
|
||||
}
|
||||
|
||||
if ( guardList == null )
|
||||
return false;
|
||||
public bool UnregisterGuard(BaseFactionGuard guard)
|
||||
{
|
||||
if (guard == null)
|
||||
return false;
|
||||
|
||||
guardList.Guards.Add( guard );
|
||||
return true;
|
||||
}
|
||||
GuardList guardList = FindGuardList(guard.GetType());
|
||||
|
||||
public bool UnregisterGuard( BaseFactionGuard guard )
|
||||
{
|
||||
if ( guard == null )
|
||||
return false;
|
||||
if (guardList == null)
|
||||
return false;
|
||||
|
||||
GuardList guardList = FindGuardList( guard.GetType() );
|
||||
if (!guardList.Guards.Contains(guard))
|
||||
return false;
|
||||
|
||||
if ( guardList == null )
|
||||
return false;
|
||||
guardList.Guards.Remove(guard);
|
||||
return true;
|
||||
}
|
||||
|
||||
if ( !guardList.Guards.Contains( guard ) )
|
||||
return false;
|
||||
public bool RegisterVendor(BaseFactionVendor vendor)
|
||||
{
|
||||
if (vendor == null)
|
||||
return false;
|
||||
|
||||
guardList.Guards.Remove( guard );
|
||||
return true;
|
||||
}
|
||||
VendorList vendorList = FindVendorList(vendor.GetType());
|
||||
|
||||
public bool RegisterVendor( BaseFactionVendor vendor )
|
||||
{
|
||||
if ( vendor == null )
|
||||
return false;
|
||||
if (vendorList == null)
|
||||
return false;
|
||||
|
||||
VendorList vendorList = FindVendorList( vendor.GetType() );
|
||||
vendorList.Vendors.Add(vendor);
|
||||
return true;
|
||||
}
|
||||
|
||||
if ( vendorList == null )
|
||||
return false;
|
||||
public bool UnregisterVendor(BaseFactionVendor vendor)
|
||||
{
|
||||
if (vendor == null)
|
||||
return false;
|
||||
|
||||
vendorList.Vendors.Add( vendor );
|
||||
return true;
|
||||
}
|
||||
VendorList vendorList = FindVendorList(vendor.GetType());
|
||||
|
||||
public bool UnregisterVendor( BaseFactionVendor vendor )
|
||||
{
|
||||
if ( vendor == null )
|
||||
return false;
|
||||
if (vendorList == null)
|
||||
return false;
|
||||
|
||||
VendorList vendorList = FindVendorList( vendor.GetType() );
|
||||
if (!vendorList.Vendors.Contains(vendor))
|
||||
return false;
|
||||
|
||||
if ( vendorList == null )
|
||||
return false;
|
||||
vendorList.Vendors.Remove(vendor);
|
||||
return true;
|
||||
}
|
||||
|
||||
if ( !vendorList.Vendors.Contains( vendor ) )
|
||||
return false;
|
||||
public static void Initialize()
|
||||
{
|
||||
List<Town> towns = Towns;
|
||||
|
||||
vendorList.Vendors.Remove( vendor );
|
||||
return true;
|
||||
}
|
||||
for (int i = 0; i < towns.Count; ++i)
|
||||
{
|
||||
towns[i].Sheriff = towns[i].Sheriff;
|
||||
towns[i].Finance = towns[i].Finance;
|
||||
}
|
||||
|
||||
public static void Initialize()
|
||||
{
|
||||
List<Town> towns = Towns;
|
||||
CommandSystem.Register("GrantTownSilver", AccessLevel.Administrator, GrantTownSilver_OnCommand);
|
||||
}
|
||||
|
||||
for ( int i = 0; i < towns.Count; ++i )
|
||||
{
|
||||
towns[i].Sheriff = towns[i].Sheriff;
|
||||
towns[i].Finance = towns[i].Finance;
|
||||
}
|
||||
public bool IsSheriff(Mobile mob)
|
||||
{
|
||||
if (mob == null || mob.Deleted)
|
||||
return false;
|
||||
|
||||
CommandSystem.Register( "GrantTownSilver", AccessLevel.Administrator, GrantTownSilver_OnCommand );
|
||||
}
|
||||
return mob.AccessLevel >= AccessLevel.GameMaster || mob == Sheriff;
|
||||
}
|
||||
|
||||
public Town()
|
||||
{
|
||||
m_State = new TownState( this );
|
||||
ConstructVendorLists();
|
||||
ConstructGuardLists();
|
||||
StartIncomeTimer();
|
||||
}
|
||||
public bool IsFinance(Mobile mob)
|
||||
{
|
||||
if (mob == null || mob.Deleted)
|
||||
return false;
|
||||
|
||||
public bool IsSheriff( Mobile mob )
|
||||
{
|
||||
if ( mob == null || mob.Deleted )
|
||||
return false;
|
||||
return mob.AccessLevel >= AccessLevel.GameMaster || mob == Finance;
|
||||
}
|
||||
|
||||
return ( mob.AccessLevel >= AccessLevel.GameMaster || mob == Sheriff );
|
||||
}
|
||||
public void Capture(Faction f)
|
||||
{
|
||||
if (m_State.Owner == f)
|
||||
return;
|
||||
|
||||
public bool IsFinance( Mobile mob )
|
||||
{
|
||||
if ( mob == null || mob.Deleted )
|
||||
return false;
|
||||
|
||||
return ( mob.AccessLevel >= AccessLevel.GameMaster || mob == Finance );
|
||||
}
|
||||
|
||||
public static List<Town> Towns => Reflector.Towns;
|
||||
|
||||
public const int SilverCaptureBonus = 10000;
|
||||
|
||||
public void Capture( Faction f )
|
||||
{
|
||||
if ( m_State.Owner == f )
|
||||
return;
|
||||
|
||||
if ( m_State.Owner == null ) // going from unowned to owned
|
||||
{
|
||||
LastIncome = DateTime.UtcNow;
|
||||
f.Silver += SilverCaptureBonus;
|
||||
}
|
||||
else if ( f == null ) // going from owned to unowned
|
||||
{
|
||||
LastIncome = DateTime.MinValue;
|
||||
}
|
||||
else // otherwise changing hands, income timer doesn't change
|
||||
{
|
||||
f.Silver += SilverCaptureBonus;
|
||||
}
|
||||
|
||||
m_State.Owner = f;
|
||||
|
||||
Sheriff = null;
|
||||
Finance = null;
|
||||
|
||||
TownMonolith monolith = Monolith;
|
||||
|
||||
if ( monolith != null )
|
||||
monolith.Faction = f;
|
||||
|
||||
List<VendorList> vendorLists = VendorLists;
|
||||
|
||||
for ( int i = 0; i < vendorLists.Count; ++i )
|
||||
{
|
||||
VendorList vendorList = vendorLists[i];
|
||||
List<BaseFactionVendor> vendors = vendorList.Vendors;
|
||||
|
||||
for ( int j = vendors.Count - 1; j >= 0; --j )
|
||||
vendors[j].Delete();
|
||||
}
|
||||
|
||||
List<GuardList> guardLists = GuardLists;
|
||||
|
||||
for ( int i = 0; i < guardLists.Count; ++i )
|
||||
{
|
||||
GuardList guardList = guardLists[i];
|
||||
List<BaseFactionGuard> guards = guardList.Guards;
|
||||
|
||||
for ( int j = guards.Count - 1; j >= 0; --j )
|
||||
guards[j].Delete();
|
||||
}
|
||||
|
||||
ConstructGuardLists();
|
||||
}
|
||||
|
||||
public int CompareTo( object obj )
|
||||
{
|
||||
return Definition.Sort - ((Town)obj).Definition.Sort;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return Definition.FriendlyName;
|
||||
}
|
||||
|
||||
public static void WriteReference( GenericWriter writer, Town town )
|
||||
{
|
||||
int idx = Towns.IndexOf( town );
|
||||
|
||||
writer.WriteEncodedInt( (int) (idx + 1) );
|
||||
}
|
||||
|
||||
public static Town ReadReference( GenericReader reader )
|
||||
{
|
||||
int idx = reader.ReadEncodedInt() - 1;
|
||||
|
||||
if ( idx >= 0 && idx < Towns.Count )
|
||||
return Towns[idx];
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Town Parse( string name )
|
||||
{
|
||||
List<Town> towns = Towns;
|
||||
|
||||
for ( int i = 0; i < towns.Count; ++i )
|
||||
{
|
||||
Town town = towns[i];
|
||||
|
||||
if ( Insensitive.Equals( town.Definition.FriendlyName, name ) )
|
||||
return town;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void GrantTownSilver_OnCommand( CommandEventArgs e )
|
||||
{
|
||||
Town town = FromRegion( e.Mobile.Region );
|
||||
|
||||
if ( town == null )
|
||||
e.Mobile.SendMessage( "You are not in a faction town." );
|
||||
else if ( e.Length == 0 )
|
||||
e.Mobile.SendMessage( "Format: GrantTownSilver <amount>" );
|
||||
else
|
||||
{
|
||||
town.Silver += e.GetInt32( 0 );
|
||||
e.Mobile.SendMessage( "You have granted {0:N0} silver to the town. It now has {1:N0} silver.", e.GetInt32( 0 ), town.Silver );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (m_State.Owner == null) // going from unowned to owned
|
||||
{
|
||||
LastIncome = DateTime.UtcNow;
|
||||
f.Silver += SilverCaptureBonus;
|
||||
}
|
||||
else if (f == null) // going from owned to unowned
|
||||
{
|
||||
LastIncome = DateTime.MinValue;
|
||||
}
|
||||
else // otherwise changing hands, income timer doesn't change
|
||||
{
|
||||
f.Silver += SilverCaptureBonus;
|
||||
}
|
||||
|
||||
m_State.Owner = f;
|
||||
|
||||
Sheriff = null;
|
||||
Finance = null;
|
||||
|
||||
TownMonolith monolith = Monolith;
|
||||
|
||||
if (monolith != null)
|
||||
monolith.Faction = f;
|
||||
|
||||
List<VendorList> vendorLists = VendorLists;
|
||||
|
||||
for (int i = 0; i < vendorLists.Count; ++i)
|
||||
{
|
||||
VendorList vendorList = vendorLists[i];
|
||||
List<BaseFactionVendor> vendors = vendorList.Vendors;
|
||||
|
||||
for (int j = vendors.Count - 1; j >= 0; --j)
|
||||
vendors[j].Delete();
|
||||
}
|
||||
|
||||
List<GuardList> guardLists = GuardLists;
|
||||
|
||||
for (int i = 0; i < guardLists.Count; ++i)
|
||||
{
|
||||
GuardList guardList = guardLists[i];
|
||||
List<BaseFactionGuard> guards = guardList.Guards;
|
||||
|
||||
for (int j = guards.Count - 1; j >= 0; --j)
|
||||
guards[j].Delete();
|
||||
}
|
||||
|
||||
ConstructGuardLists();
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return Definition.FriendlyName;
|
||||
}
|
||||
|
||||
public static void WriteReference(GenericWriter writer, Town town)
|
||||
{
|
||||
int idx = Towns.IndexOf(town);
|
||||
|
||||
writer.WriteEncodedInt(idx + 1);
|
||||
}
|
||||
|
||||
public static Town ReadReference(GenericReader reader)
|
||||
{
|
||||
int idx = reader.ReadEncodedInt() - 1;
|
||||
|
||||
if (idx >= 0 && idx < Towns.Count)
|
||||
return Towns[idx];
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Town Parse(string name)
|
||||
{
|
||||
List<Town> towns = Towns;
|
||||
|
||||
for (int i = 0; i < towns.Count; ++i)
|
||||
{
|
||||
Town town = towns[i];
|
||||
|
||||
if (Insensitive.Equals(town.Definition.FriendlyName, name))
|
||||
return town;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void GrantTownSilver_OnCommand(CommandEventArgs e)
|
||||
{
|
||||
Town town = FromRegion(e.Mobile.Region);
|
||||
|
||||
if (town == null)
|
||||
{
|
||||
e.Mobile.SendMessage("You are not in a faction town.");
|
||||
}
|
||||
else if (e.Length == 0)
|
||||
{
|
||||
e.Mobile.SendMessage("Format: GrantTownSilver <amount>");
|
||||
}
|
||||
else
|
||||
{
|
||||
town.Silver += e.GetInt32(0);
|
||||
e.Mobile.SendMessage("You have granted {0:N0} silver to the town. It now has {1:N0} silver.", e.GetInt32(0),
|
||||
town.Silver);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2,134 +2,134 @@ using System;
|
|||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class TownState
|
||||
{
|
||||
private Mobile m_Sheriff;
|
||||
private Mobile m_Finance;
|
||||
public class TownState
|
||||
{
|
||||
private Mobile m_Finance;
|
||||
private Mobile m_Sheriff;
|
||||
|
||||
public Town Town { get; set; }
|
||||
public TownState(Town town)
|
||||
{
|
||||
Town = town;
|
||||
}
|
||||
|
||||
public Faction Owner { get; set; }
|
||||
public TownState(GenericReader reader)
|
||||
{
|
||||
int version = reader.ReadEncodedInt();
|
||||
|
||||
public Mobile Sheriff
|
||||
{
|
||||
get => m_Sheriff;
|
||||
set
|
||||
{
|
||||
if ( m_Sheriff != null )
|
||||
{
|
||||
PlayerState pl = PlayerState.Find( m_Sheriff );
|
||||
switch (version)
|
||||
{
|
||||
case 3:
|
||||
{
|
||||
LastIncome = reader.ReadDateTime();
|
||||
|
||||
if ( pl != null )
|
||||
pl.Sheriff = null;
|
||||
}
|
||||
goto case 2;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
Tax = reader.ReadEncodedInt();
|
||||
LastTaxChange = reader.ReadDateTime();
|
||||
|
||||
m_Sheriff = value;
|
||||
goto case 1;
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
Silver = reader.ReadEncodedInt();
|
||||
|
||||
if ( m_Sheriff != null )
|
||||
{
|
||||
PlayerState pl = PlayerState.Find( m_Sheriff );
|
||||
goto case 0;
|
||||
}
|
||||
case 0:
|
||||
{
|
||||
Town = Town.ReadReference(reader);
|
||||
Owner = Faction.ReadReference(reader);
|
||||
|
||||
if ( pl != null )
|
||||
pl.Sheriff = Town;
|
||||
}
|
||||
}
|
||||
}
|
||||
m_Sheriff = reader.ReadMobile();
|
||||
m_Finance = reader.ReadMobile();
|
||||
|
||||
public Mobile Finance
|
||||
{
|
||||
get => m_Finance;
|
||||
set
|
||||
{
|
||||
if ( m_Finance != null )
|
||||
{
|
||||
PlayerState pl = PlayerState.Find( m_Finance );
|
||||
Town.State = this;
|
||||
|
||||
if ( pl != null )
|
||||
pl.Finance = null;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_Finance = value;
|
||||
public Town Town{ get; set; }
|
||||
|
||||
if ( m_Finance != null )
|
||||
{
|
||||
PlayerState pl = PlayerState.Find( m_Finance );
|
||||
public Faction Owner{ get; set; }
|
||||
|
||||
if ( pl != null )
|
||||
pl.Finance = Town;
|
||||
}
|
||||
}
|
||||
}
|
||||
public Mobile Sheriff
|
||||
{
|
||||
get => m_Sheriff;
|
||||
set
|
||||
{
|
||||
if (m_Sheriff != null)
|
||||
{
|
||||
PlayerState pl = PlayerState.Find(m_Sheriff);
|
||||
|
||||
public int Silver { get; set; }
|
||||
if (pl != null)
|
||||
pl.Sheriff = null;
|
||||
}
|
||||
|
||||
public int Tax { get; set; }
|
||||
m_Sheriff = value;
|
||||
|
||||
public DateTime LastTaxChange { get; set; }
|
||||
if (m_Sheriff != null)
|
||||
{
|
||||
PlayerState pl = PlayerState.Find(m_Sheriff);
|
||||
|
||||
public DateTime LastIncome { get; set; }
|
||||
if (pl != null)
|
||||
pl.Sheriff = Town;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public TownState( Town town )
|
||||
{
|
||||
Town = town;
|
||||
}
|
||||
public Mobile Finance
|
||||
{
|
||||
get => m_Finance;
|
||||
set
|
||||
{
|
||||
if (m_Finance != null)
|
||||
{
|
||||
PlayerState pl = PlayerState.Find(m_Finance);
|
||||
|
||||
public TownState( GenericReader reader )
|
||||
{
|
||||
int version = reader.ReadEncodedInt();
|
||||
if (pl != null)
|
||||
pl.Finance = null;
|
||||
}
|
||||
|
||||
switch ( version )
|
||||
{
|
||||
case 3:
|
||||
{
|
||||
LastIncome = reader.ReadDateTime();
|
||||
m_Finance = value;
|
||||
|
||||
goto case 2;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
Tax = reader.ReadEncodedInt();
|
||||
LastTaxChange = reader.ReadDateTime();
|
||||
if (m_Finance != null)
|
||||
{
|
||||
PlayerState pl = PlayerState.Find(m_Finance);
|
||||
|
||||
goto case 1;
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
Silver = reader.ReadEncodedInt();
|
||||
if (pl != null)
|
||||
pl.Finance = Town;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
goto case 0;
|
||||
}
|
||||
case 0:
|
||||
{
|
||||
Town = Town.ReadReference( reader );
|
||||
Owner = Faction.ReadReference( reader );
|
||||
public int Silver{ get; set; }
|
||||
|
||||
m_Sheriff = reader.ReadMobile();
|
||||
m_Finance = reader.ReadMobile();
|
||||
public int Tax{ get; set; }
|
||||
|
||||
Town.State = this;
|
||||
public DateTime LastTaxChange{ get; set; }
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
public DateTime LastIncome{ get; set; }
|
||||
|
||||
public void Serialize( GenericWriter writer )
|
||||
{
|
||||
writer.WriteEncodedInt( (int) 3 ); // version
|
||||
public void Serialize(GenericWriter writer)
|
||||
{
|
||||
writer.WriteEncodedInt(3); // version
|
||||
|
||||
writer.Write( (DateTime) LastIncome );
|
||||
writer.Write(LastIncome);
|
||||
|
||||
writer.WriteEncodedInt( (int) Tax );
|
||||
writer.Write( (DateTime) LastTaxChange );
|
||||
writer.WriteEncodedInt(Tax);
|
||||
writer.Write(LastTaxChange);
|
||||
|
||||
writer.WriteEncodedInt( (int) Silver );
|
||||
writer.WriteEncodedInt(Silver);
|
||||
|
||||
Town.WriteReference( writer, Town );
|
||||
Faction.WriteReference( writer, Owner );
|
||||
Town.WriteReference(writer, Town);
|
||||
Faction.WriteReference(writer, Owner);
|
||||
|
||||
writer.Write( (Mobile) m_Sheriff );
|
||||
writer.Write( (Mobile) m_Finance );
|
||||
}
|
||||
}
|
||||
writer.Write(m_Sheriff);
|
||||
writer.Write(m_Finance);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -3,22 +3,28 @@ using System.Collections.Generic;
|
|||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class VendorList
|
||||
{
|
||||
public VendorDefinition Definition { get; }
|
||||
public class VendorList
|
||||
{
|
||||
public VendorList(VendorDefinition definition)
|
||||
{
|
||||
Definition = definition;
|
||||
Vendors = new List<BaseFactionVendor>();
|
||||
}
|
||||
|
||||
public List<BaseFactionVendor> Vendors { get; }
|
||||
public VendorDefinition Definition{ get; }
|
||||
|
||||
public BaseFactionVendor Construct( Town town, Faction faction )
|
||||
{
|
||||
try{ return Activator.CreateInstance( Definition.Type, new object[]{ town, faction } ) as BaseFactionVendor; }
|
||||
catch{ return null; }
|
||||
}
|
||||
public List<BaseFactionVendor> Vendors{ get; }
|
||||
|
||||
public VendorList( VendorDefinition definition )
|
||||
{
|
||||
Definition = definition;
|
||||
Vendors = new List<BaseFactionVendor>();
|
||||
}
|
||||
}
|
||||
}
|
||||
public BaseFactionVendor Construct(Town town, Faction faction)
|
||||
{
|
||||
try
|
||||
{
|
||||
return Activator.CreateInstance(Definition.Type, town, faction) as BaseFactionVendor;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue