Skip to content

Commit

Permalink
Guilds v1 (#689)
Browse files Browse the repository at this point in the history
* Guilds V1

* Removed partial guild classes and merged with existing base engine classes.

* Make the lowest rank Newbie instead of Probationary so it fits in the guild guild ui

* Fix demotion options showing up for users

* Fixed a bug where clients would crash trying to pickup/gather items when inventories were full
  • Loading branch information
jcsnider committed May 10, 2021
1 parent 901e3f5 commit d476afb
Show file tree
Hide file tree
Showing 66 changed files with 5,012 additions and 363 deletions.
138 changes: 138 additions & 0 deletions Intersect (Core)/Config/Guilds/GuildOptions.cs
@@ -0,0 +1,138 @@
using System;
using System.Linq;
using System.Runtime.Serialization;

namespace Intersect.Config.Guilds
{
/// <summary>
/// Contains all options pertaining to guilds
/// </summary>
public class GuildOptions
{
/// <summary>
/// Denotes the minimum amount of characters a guild name must contain before being accepted.
/// </summary>
public int MinimumGuildNameSize { get; set; } = 3;

/// <summary>
/// Denotes the maximum amount of characters a guild name can contain before being rejected.
/// </summary>
public int MaximumGuildNameSize { get; set; } = 25;

/// <summary>
/// Configures whether or not to allow guild members to attack eachother.
/// </summary>
public bool AllowGuildMemberPvp { get; set; } = false;

/// <summary>
/// Configured whether the guild name should be rendered above player sprites as a tag
/// </summary>
public bool ShowGuildNameTagsOverMembers { get; set; } = true;

/// <summary>
/// How often to send guild updates to members, these updates are alongside updates whenever people log in or out
/// </summary>
public int GuildUpdateInterval = 10000;

/// <summary>
/// If set to a value > 0 then upon server boot any guilds with only 1 member that hasn't played in this number of days will be deleted
/// </summary>
public int DeleteStaleGuildsAfterDays { get; set; } = -1;

/// <summary>
/// Default number of storage slots in guild banks
/// </summary>
public int GuildBankSlots { get; set; } = 50;

/// <summary>
/// Array of guild ranks that are available in this game
/// </summary>
public GuildRank[] Ranks { get; set; } = new GuildRank[]
{
new GuildRank()
{
Title = "Master",
Limit = 1,
Permissions = new GuildPermissions()
{
Invite = true,
Kick = true,
Demote = true,
Promote = true,
BankDeposit = true,
BankMove = true,
BankRetrieve = true
}
},
new GuildRank()
{
Title = "Officer",
Limit = 10,
Permissions = new GuildPermissions()
{
Invite = true,
Kick = true,
Demote = true,
Promote = true,
BankDeposit = true,
BankMove = true,
BankRetrieve = true
}
},
new GuildRank()
{
Title = "Member",
Limit = -1,
Permissions = new GuildPermissions()
{
Invite = false,
Kick = false,
Demote = false,
Promote = false,
BankDeposit = true,
BankMove = false,
BankRetrieve = false
}
},
new GuildRank()
{
Title = "Newbie",
Limit = -1,
Permissions = new GuildPermissions()
{
Invite = false,
Kick = false,
Demote = false,
Promote = false,
BankDeposit = false,
BankMove = false,
BankRetrieve = false
}
}

};

[OnDeserialized]
internal void OnDeserializedMethod(StreamingContext context)
{
Validate();
}

public void Validate()
{
if (Ranks.Length < 2)
{
throw new Exception("Must have at least 2 guild ranks defined!");
}

if (Ranks[0].Limit != 1)
{
throw new Exception(Ranks[0].Title + " is considered a guild leader (first rank) so the limit should be 1.");
}

//Leader is always going to be the first rank, just make sure they can invite or kick
Ranks[0].Permissions.Invite = true;
Ranks[0].Permissions.Kick = true;
}
}
}
40 changes: 40 additions & 0 deletions Intersect (Core)/Config/Guilds/GuildPermissions.cs
@@ -0,0 +1,40 @@
namespace Intersect.Config.Guilds
{
public class GuildPermissions
{
/// <summary>
/// Defines whether or not this guild member can invite new members
/// </summary>
public bool Invite { get; set; }

/// <summary>
/// Defines whether or not this guild member can kick members (under their rank of course)
/// </summary>
public bool Kick { get; set; }

/// <summary>
/// Defines whether or not this guild member can promote other guilds members to ranks below this one
/// </summary>
public bool Promote { get; set; }

/// <summary>
/// Defined whether or not this guild member can demote other members who are below this rank
/// </summary>
public bool Demote { get; set; }

/// <summary>
/// Determines whether or not guild members of this rank can withdraw items from the guild bank
/// </summary>
public bool BankRetrieve { get; set; }

/// <summary>
/// Determines whether or not guild members of this rank can deposit items into the guild bank
/// </summary>
public bool BankDeposit { get; set; }

/// <summary>
/// Determines whether or not guild members of this rank can move items around within the guild bank
/// </summary>
public bool BankMove { get; set; }
}
}
24 changes: 24 additions & 0 deletions Intersect (Core)/Config/Guilds/GuildRank.cs
@@ -0,0 +1,24 @@
namespace Intersect.Config.Guilds
{
/// <summary>
/// Name and options for individual guild ranks
/// </summary>
public class GuildRank
{
/// <summary>
/// Name of this rank
/// </summary>
public string Title { get; set; }

/// <summary>
/// Maximum number of guild members with this title
/// </summary>
public int Limit { get; set; }

/// <summary>
/// Permissions that this rank holds for the guild and the actions they can take
/// </summary>
public GuildPermissions Permissions { get; set; } = new GuildPermissions();

}
}
4 changes: 3 additions & 1 deletion Intersect (Core)/Config/Options.cs
Expand Up @@ -2,7 +2,7 @@
using System.IO;

using Intersect.Config;

using Intersect.Config.Guilds;
using Newtonsoft.Json;

namespace Intersect
Expand Down Expand Up @@ -72,6 +72,8 @@ public class Options

public SmtpSettings SmtpSettings = new SmtpSettings();

public GuildOptions Guild = new GuildOptions();

public static Options Instance { get; private set; }

[JsonIgnore]
Expand Down
2 changes: 2 additions & 0 deletions Intersect (Core)/CustomColors.cs
Expand Up @@ -119,6 +119,8 @@ public sealed class ChatNamespace

public Color ProximityMsg = new Color(255, 220, 220, 220);

public Color GuildChat = new Color(255, 255, 165, 0);

}

public sealed class QuestsNamespace
Expand Down
2 changes: 2 additions & 0 deletions Intersect (Core)/Enums/ChatMessageType.cs
Expand Up @@ -17,6 +17,8 @@ public enum ChatMessageType

Admin,

Guild,

// Player Messages
Experience = 20,

Expand Down
2 changes: 2 additions & 0 deletions Intersect (Core)/Enums/ChatboxTab.cs
Expand Up @@ -11,6 +11,8 @@ public enum ChatboxTab

Party,

Guild,

Global,

System,
Expand Down
6 changes: 6 additions & 0 deletions Intersect (Core)/Enums/CommonEventTrigger.cs
Expand Up @@ -28,6 +28,12 @@ public enum CommonEventTrigger

ServerVariableChange,

GuildMemberJoined,

GuildMemberLeft,

GuildMemberKicked

}

}
17 changes: 17 additions & 0 deletions Intersect (Core)/Enums/GuildMemberUpdateActions.cs
@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Intersect.Enums
{
public enum GuildMemberUpdateActions
{
Invite = 0,
Remove,
Promote,
Demote,
Transfer
}
}

0 comments on commit d476afb

Please sign in to comment.