## MAJOR CHANGE Added a champion title system to facilitate the existing champion titles. This should make it easier to extend or create other related game content. Champion titles will be saved in a folder called _ChampionTitles_. ### Motivation The motivation to refactor was two-folder, but mostly related to performance in two ways. First, every player had a ChampionTitleInfo object with an array of ChamptionTitleInfo. We want to eliminate the need for this information unless a player actually uses it. This should save a considerable amount of memory. Second, to facilitate the atrophy mechanic, the champion titles would run atrophy post-world save, adding to the time that the server is frozen. Eliminating this post-world save side effect unlocks our ability to further optimize the world save process since there are no direct side effects. ### Bugs fixed - [X] Fixed titles getting cut off on the paperdoll - [X] Fixed champion title not displaying overhead (OPL) ### Screenshots <img width="216" alt="image" src="https://github.com/modernuo/ModernUO/assets/3953314/8916f895-8d68-4fb0-892e-108a0c43be90">
122 lines
3.4 KiB
C#
122 lines
3.4 KiB
C#
/*************************************************************************
|
|
* ModernUO *
|
|
* Copyright 2019-2022 - ModernUO Development Team *
|
|
* Email: hi@modernuo.com *
|
|
* File: Guild.cs *
|
|
* *
|
|
* This program is free software: you can redistribute it and/or modify *
|
|
* it under the terms of the GNU General Public License as published by *
|
|
* the Free Software Foundation, either version 3 of the License, or *
|
|
* (at your option) any later version. *
|
|
* *
|
|
* You should have received a copy of the GNU General Public License *
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
|
*************************************************************************/
|
|
|
|
using System;
|
|
using System.Collections.Generic;
|
|
|
|
namespace Server.Guilds;
|
|
|
|
public enum GuildType
|
|
{
|
|
Regular,
|
|
Chaos,
|
|
Order
|
|
}
|
|
|
|
public abstract class BaseGuild : ISerializable
|
|
{
|
|
protected BaseGuild()
|
|
{
|
|
Serial = World.NewGuild;
|
|
World.AddGuild(this);
|
|
}
|
|
|
|
protected BaseGuild(Serial serial) => Serial = serial;
|
|
|
|
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 Delete();
|
|
|
|
public bool Deleted => Disbanded;
|
|
|
|
[CommandProperty(AccessLevel.Counselor)]
|
|
public Serial Serial { get; }
|
|
|
|
[CommandProperty(AccessLevel.GameMaster, readOnly: true)]
|
|
public DateTime Created { get; set; } = Core.Now;
|
|
|
|
[CommandProperty(AccessLevel.GameMaster)]
|
|
DateTime ISerializable.LastSerialized { get; set; } = Core.Now;
|
|
|
|
long ISerializable.SavePosition { get; set; } = -1;
|
|
|
|
BufferWriter ISerializable.SaveBuffer { get; set; }
|
|
|
|
public int TypeRef { get; private set; }
|
|
|
|
public abstract void Serialize(IGenericWriter writer);
|
|
|
|
public abstract void Deserialize(IGenericReader reader);
|
|
public abstract void OnDelete(Mobile mob);
|
|
|
|
public static BaseGuild FindByName(string name)
|
|
{
|
|
foreach (var g in World.Guilds.Values)
|
|
{
|
|
if (g.Name.InsensitiveEquals(name))
|
|
{
|
|
return g;
|
|
}
|
|
}
|
|
|
|
return null;
|
|
}
|
|
|
|
public static BaseGuild FindByAbbrev(string abbr)
|
|
{
|
|
foreach (var g in World.Guilds.Values)
|
|
{
|
|
if (g.Abbreviation.InsensitiveEquals(abbr))
|
|
{
|
|
return g;
|
|
}
|
|
}
|
|
|
|
return null;
|
|
}
|
|
|
|
public static HashSet<BaseGuild> Search(string find)
|
|
{
|
|
var words = find.ToLower().Split(' ');
|
|
var results = new HashSet<BaseGuild>();
|
|
|
|
foreach (var g in World.Guilds.Values)
|
|
{
|
|
var name = g.Name;
|
|
|
|
bool all = true;
|
|
foreach (var t in words)
|
|
{
|
|
if (name.InsensitiveIndexOf(t) == -1)
|
|
{
|
|
all = false;
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (all)
|
|
{
|
|
results.Add(g);
|
|
}
|
|
}
|
|
|
|
return results;
|
|
}
|
|
|
|
public override string ToString() => $"{Serial} \"{Name} [{Abbreviation}]\"";
|
|
}
|