Глобальный рефакторинг пространств имён
This commit is contained in:
+197
@@ -0,0 +1,197 @@
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Pf2e.Scrapper.Processors;
|
||||
using Pf2e.Database.Model.Enum;
|
||||
|
||||
namespace Pf2e.Scrapper.Importers.Implementations.Aonprd.Helpers;
|
||||
|
||||
internal static class AonprdProcessorInputExtension
|
||||
{
|
||||
/// <summary>
|
||||
/// Обработать строку, содержащую информацию о количестве действий.
|
||||
/// </summary>
|
||||
/// <param name="_"></param>
|
||||
/// <param name="input">Входная строка с данными.</param>
|
||||
/// <returns>Структура, хранящая информацию о количетсве действий.</returns>
|
||||
public static ActionStruct ResolveActionString(this ProcessorInput _, string input)
|
||||
{
|
||||
ActionStruct result = new();
|
||||
|
||||
switch (input)
|
||||
{
|
||||
case "Single Action":
|
||||
result.Actions = result.MaxActions = 1;
|
||||
break;
|
||||
|
||||
case "Two Actions":
|
||||
result.Actions = result.MaxActions = 2;
|
||||
break;
|
||||
|
||||
case "Three Actions":
|
||||
result.Actions = result.MaxActions = 3;
|
||||
break;
|
||||
|
||||
case "Reaction":
|
||||
result.IsReaction = true;
|
||||
break;
|
||||
|
||||
case "Free Action":
|
||||
result.IsFreeAction = false;
|
||||
break;
|
||||
|
||||
case "Single Action to Three Actions":
|
||||
case "Single Action or more Actions":
|
||||
result.Actions = 1;
|
||||
result.MaxActions = 3;
|
||||
break;
|
||||
|
||||
case "Single Action or Two Actions":
|
||||
case "Single Action to Two Actions":
|
||||
result.Actions = 1;
|
||||
result.MaxActions = 2;
|
||||
break;
|
||||
|
||||
case "Two Actions or Three Actions":
|
||||
result.Actions = 2;
|
||||
result.MaxActions = 3;
|
||||
break;
|
||||
|
||||
case "Two Actions to 2 rounds":
|
||||
result.Actions = 2;
|
||||
result.MaxActions = 3;
|
||||
result.TwoRounds = true;
|
||||
break;
|
||||
|
||||
case "Reaction or One Action":
|
||||
result.IsReaction = true;
|
||||
result.Actions = result.MaxActions = 1;
|
||||
break;
|
||||
|
||||
case "Reaction or Two Actions":
|
||||
result.IsReaction = true;
|
||||
result.Actions = result.MaxActions = 2;
|
||||
break;
|
||||
|
||||
case "Free Action or One Action":
|
||||
result.IsFreeAction = false;
|
||||
result.Actions = result.MaxActions = 1;
|
||||
break;
|
||||
|
||||
default:
|
||||
result.IsPassive = true;
|
||||
break;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Класс структуры, хранящей информацию о количетсве действий.
|
||||
/// </summary>
|
||||
public class ActionStruct
|
||||
{
|
||||
/// <summary>
|
||||
/// Количество действий
|
||||
/// </summary>
|
||||
public int Actions { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Максимальное количество действий
|
||||
/// </summary>
|
||||
public int MaxActions { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Флаг, указывающий, что действия не требуются.
|
||||
/// </summary>
|
||||
public bool IsPassive { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Флаг, указывающий, что действие может быть использовано как реакция.
|
||||
/// </summary>
|
||||
public bool IsReaction { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Флаг, указывающий, что можно использовать свободное действие.
|
||||
/// </summary>
|
||||
public bool IsFreeAction { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Флаг, указывающий, что действие может быть продлено до 2 раундов.
|
||||
/// </summary>
|
||||
public bool TwoRounds { get; set; }
|
||||
}
|
||||
|
||||
public class SourceCategorySolver : EnumSolver<SourceCategory>
|
||||
{
|
||||
public override Dictionary<string, SourceCategory> Data { get; } =
|
||||
new()
|
||||
{
|
||||
{ "Rulebooks", SourceCategory.Rulebooks },
|
||||
{ "Adventure Paths", SourceCategory.AdventurePaths },
|
||||
{ "Lost Omens", SourceCategory.LostOmens },
|
||||
{ "Adventures", SourceCategory.Adventures },
|
||||
{ "Comics", SourceCategory.Comics },
|
||||
{ "Blog Posts", SourceCategory.BlogPosts },
|
||||
{ "Society", SourceCategory.Society },
|
||||
};
|
||||
}
|
||||
|
||||
public class VisionEnumSolver : EnumSolver<VisionEnum>
|
||||
{
|
||||
public override Dictionary<string, VisionEnum> Data { get; } =
|
||||
new()
|
||||
{
|
||||
{ "Low-Light VisionEnum", VisionEnum.LowLightVision },
|
||||
{ "Darkvision", VisionEnum.DarkVision },
|
||||
};
|
||||
}
|
||||
|
||||
public class AttributeValuesSolver : EnumSolver<AttributeValues>
|
||||
{
|
||||
public override Dictionary<string, AttributeValues> Data { get; } =
|
||||
new()
|
||||
{
|
||||
{ "Consitution", AttributeValues.Constitution },
|
||||
{ "Other", AttributeValues.Free },
|
||||
{ "other", AttributeValues.Free },
|
||||
};
|
||||
}
|
||||
|
||||
public class ActionEnumSolver : EnumSolver<ActionEnum>
|
||||
{
|
||||
public override Dictionary<string, ActionEnum> Data { get; } =
|
||||
new()
|
||||
{
|
||||
{ "Single Action", ActionEnum.SingleAction },
|
||||
{ "Two Actions", ActionEnum.TwoActions },
|
||||
{ "Three Actions", ActionEnum.ThreeActions },
|
||||
{ "Reaction", ActionEnum.Reaction },
|
||||
{ "Free Action", ActionEnum.FreeAction },
|
||||
{ "Single Action to Three Actions", ActionEnum.SingleActionToThreeActions },
|
||||
{ "Single Action or more Actions", ActionEnum.SingleActionToThreeActions },
|
||||
{ "Single Action or Two Actions", ActionEnum.SingleActionToTwoActions },
|
||||
{ "Single Action to Two Actions", ActionEnum.SingleActionToTwoActions },
|
||||
{ "Two Actions or Three Actions", ActionEnum.TwoActionsToThreeActions },
|
||||
{ "Two Actions to 2 rounds", ActionEnum.TwoActionsToTwoRounds },
|
||||
{ "Reaction or One Action", ActionEnum.ReactionOrOneAction },
|
||||
{ "Reaction or Two Actions", ActionEnum.ReactionOrTwoAction },
|
||||
{ "Reaction or Three Actions", ActionEnum.ReactionOrThreeAction },
|
||||
{ "Free Action or One Action", ActionEnum.FreeActionOrOneAction },
|
||||
{ "1 Minute", ActionEnum.OneMinute },
|
||||
{ "1 minute", ActionEnum.OneMinute },
|
||||
{ "5 minutes", ActionEnum.FiveMinutes },
|
||||
{ "10 minutes", ActionEnum.TenMinutes },
|
||||
{ "30 minutes", ActionEnum.ThirtyMinutes },
|
||||
{ "1 hour", ActionEnum.OneHour },
|
||||
{ "<i>Nethys Note: No cast time was printed</i>", ActionEnum.Unknown },
|
||||
};
|
||||
}
|
||||
|
||||
public static void RegisterServices(IServiceCollection serviceCollection)
|
||||
{
|
||||
serviceCollection.AddTransient<IEnumSolver, SourceCategorySolver>();
|
||||
serviceCollection.AddTransient<IEnumSolver, VisionEnumSolver>();
|
||||
serviceCollection.AddTransient<IEnumSolver, AttributeValuesSolver>();
|
||||
serviceCollection.AddTransient<IEnumSolver, ActionEnumSolver>();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user