mirror of
https://github.com/JogmansonReal/Radicade.git
synced 2026-10-26 23:49:02 -07:00
Radicade Public Code
This commit is contained in:
@@ -0,0 +1,69 @@
|
||||
using System.Text;
|
||||
|
||||
namespace RadicadeServer.RecNet.Avatar;
|
||||
|
||||
public static class AvatarItemDescription
|
||||
{
|
||||
public static string Normalize(string? description)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(description))
|
||||
{
|
||||
return description?.Trim() ?? string.Empty;
|
||||
}
|
||||
|
||||
var trimmed = description.Trim();
|
||||
var segments = trimmed.Split(',');
|
||||
if (segments[0].Length == 0)
|
||||
{
|
||||
return trimmed;
|
||||
}
|
||||
|
||||
var hasEmptySlot = false;
|
||||
for (var index = 1; index < segments.Length - 1; index++)
|
||||
{
|
||||
if (segments[index].Length == 0)
|
||||
{
|
||||
hasEmptySlot = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!hasEmptySlot)
|
||||
{
|
||||
return trimmed;
|
||||
}
|
||||
|
||||
var builder = new StringBuilder(segments[0]).Append(',');
|
||||
for (var index = 1; index < segments.Length; index++)
|
||||
{
|
||||
var material = segments[index].Trim();
|
||||
if (material.Length == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
builder.Append(material).Append(',');
|
||||
}
|
||||
|
||||
return builder.ToString();
|
||||
}
|
||||
|
||||
public static bool HasEmptyMaterialSlot(string? description)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(description))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var segments = description.Trim().Split(',');
|
||||
for (var index = 1; index < segments.Length - 1; index++)
|
||||
{
|
||||
if (segments[index].Length == 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user