Fixes code according to modern code style. Fixes a few expression bugs.

This commit is contained in:
Kamron Batman 2018-09-15 09:58:51 -07:00
parent 89eea25e5f
commit 970fd563b2
3324 changed files with 441118 additions and 433755 deletions

View file

@ -18,113 +18,106 @@
*
***************************************************************************/
using System;
using System.Collections.Generic;
namespace Server.Guilds
{
public enum GuildType
{
Regular,
Chaos,
Order
}
public enum GuildType
{
Regular,
Chaos,
Order
}
public abstract class BaseGuild : ISerializable
{
protected BaseGuild( int Id )//serialization ctor
{
this.Id = Id;
List.Add( this.Id, this );
if ( this.Id+1 > m_NextID )
m_NextID = this.Id + 1;
}
public abstract class BaseGuild : ISerializable
{
private static int m_NextID = 1;
protected BaseGuild()
{
Id = m_NextID++;
List.Add( Id, this );
}
protected BaseGuild(int Id) //serialization ctor
{
this.Id = Id;
List.Add(this.Id, this);
if (this.Id + 1 > m_NextID)
m_NextID = this.Id + 1;
}
[CommandProperty( AccessLevel.Counselor )]
public int Id { get; }
protected BaseGuild()
{
Id = m_NextID++;
List.Add(Id, this);
}
int ISerializable.TypeReference => 0;
[CommandProperty(AccessLevel.Counselor)]
public int Id{ get; }
int ISerializable.SerialIdentity => Id;
public abstract string Abbreviation{ get; set; }
public abstract string Name{ get; set; }
public abstract GuildType Type{ get; set; }
public abstract bool Disbanded{ get; }
public abstract void Deserialize( GenericReader reader );
public abstract void Serialize( GenericWriter writer );
public static Dictionary<int, BaseGuild> List{ get; } = new Dictionary<int, BaseGuild>();
public abstract string Abbreviation { get; set; }
public abstract string Name { get; set; }
public abstract GuildType Type { get; set; }
public abstract bool Disbanded{ get; }
public abstract void OnDelete( Mobile mob );
int ISerializable.TypeReference => 0;
private static int m_NextID = 1;
int ISerializable.SerialIdentity => Id;
public abstract void Serialize(GenericWriter writer);
public static Dictionary<int, BaseGuild> List { get; } = new Dictionary<int, BaseGuild>();
public abstract void Deserialize(GenericReader reader);
public abstract void OnDelete(Mobile mob);
public static BaseGuild Find( int id )
{
BaseGuild g;
public static BaseGuild Find(int id)
{
BaseGuild g;
List.TryGetValue( id, out g );
List.TryGetValue(id, out g);
return g;
}
return g;
}
public static BaseGuild FindByName( string name )
{
foreach ( BaseGuild g in List.Values )
{
if ( g.Name == name )
return g;
}
public static BaseGuild FindByName(string name)
{
foreach (BaseGuild g in List.Values)
if (g.Name == name)
return g;
return null;
}
return null;
}
public static BaseGuild FindByAbbrev( string abbr )
{
foreach ( BaseGuild g in List.Values )
{
if ( g.Abbreviation == abbr )
return g;
}
public static BaseGuild FindByAbbrev(string abbr)
{
foreach (BaseGuild g in List.Values)
if (g.Abbreviation == abbr)
return g;
return null;
}
return null;
}
public static List<BaseGuild> Search( string find )
{
string[] words = find.ToLower().Split( ' ' );
List<BaseGuild> results = new List<BaseGuild>();
public static List<BaseGuild> Search(string find)
{
string[] words = find.ToLower().Split(' ');
List<BaseGuild> results = new List<BaseGuild>();
foreach ( BaseGuild g in List.Values )
{
bool match = true;
string name = g.Name.ToLower();
for (int i=0;i<words.Length;i++)
{
if ( name.IndexOf( words[i] ) == -1 )
{
match = false;
break;
}
}
foreach (BaseGuild g in List.Values)
{
bool match = true;
string name = g.Name.ToLower();
for (int i = 0; i < words.Length; i++)
if (name.IndexOf(words[i]) == -1)
{
match = false;
break;
}
if ( match )
results.Add( g );
}
if (match)
results.Add(g);
}
return results;
}
return results;
}
public override string ToString()
{
return $"0x{Id:X} \"{Name} [{Abbreviation}]\"";
}
}
}
public override string ToString()
{
return $"0x{Id:X} \"{Name} [{Abbreviation}]\"";
}
}
}