Skip to content

Commit

Permalink
Npc Daily routines, better exporting, bugfixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Steffen Nörtershäuser committed Jul 16, 2019
1 parent 8c7b8bb commit 32e79de
Show file tree
Hide file tree
Showing 722 changed files with 88,438 additions and 15,546 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -310,4 +310,6 @@ ItemImages/**
MapImages/*/**
TaskImages/**
SkillImages/**
dbdata/**
dbdata/**

xunit.xml
7 changes: 7 additions & 0 deletions Controllers/Api/AikaApiController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1131,6 +1131,13 @@ public async Task<IActionResult> DeleteQuest(string id)
return StatusCode((int)HttpStatusCode.BadRequest, _localizer["CanNotDeleteQuestReferencedInTaleDialog", referencedInDialogs].Value);
}

List<KortistoNpc> referencedInDailyRoutines = await _kortistoNpcDbAccess.GetNpcsObjectIsReferencedInDailyRoutine(id);
if(referencedInDailyRoutines.Count > 0)
{
string usedInDailyRoutines = string.Join(", ", referencedInDailyRoutines.Select(m => m.Name));
return StatusCode((int)HttpStatusCode.BadRequest, _localizer["CanNotDeleteQuestUsedInDailyRoutine", usedInDailyRoutines].Value);
}

// Delete Quest
AikaQuest deletedQuest = await _questDbAccess.GetQuestById(id);
await _questDbAccess.DeleteQuest(deletedQuest);
Expand Down
7 changes: 7 additions & 0 deletions Controllers/Api/EvneApiController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,13 @@ protected override async Task<string> CheckObjectReferences(string id)
return _localizer["CanNotDeleteSkillLearnedByNpc", learnedByNpcsString].Value;
}

List<KortistoNpc> referencedInDailyRoutines = await _kortistoNpcDbAccess.GetNpcsObjectIsReferencedInDailyRoutine(id);
if(referencedInDailyRoutines.Count > 0)
{
string usedInDailyRoutines = string.Join(", ", referencedInDailyRoutines.Select(m => m.Name));
return _localizer["CanNotDeleteSkillUsedInDailyRoutine", usedInDailyRoutines].Value;
}

return string.Empty;
}

Expand Down
8 changes: 5 additions & 3 deletions Controllers/Api/ExportApiController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
using Microsoft.Extensions.Localization;
using Microsoft.Extensions.Logging;
using GoNorth.Services.Export.LanguageExport;
using GoNorth.Services.Export.LanguageKeyGeneration;

namespace GoNorth.Controllers.Api
{
Expand Down Expand Up @@ -250,15 +251,16 @@ private class ExportTemplateByObjectIdResult
/// <param name="dialogFunctionDbAccess">Dialog Function Db Access</param>
/// <param name="dialogFunctionGenerationConditionProvider">Dialog Function Generation Condition Provider</param>
/// <param name="languageKeyDbAccess">Language Key Db Access</param>
/// <param name="languageKeyReferenceCollector">Language key reference collector</param>
/// <param name="timelineService">Timeline Service</param>
/// <param name="userManager">User Manager</param>
/// <param name="logger">Logger</param>
/// <param name="localizerFactory">Localizer Factory</param>
public ExportApiController(IExportDefaultTemplateProvider defaultTemplateProvider, IExportTemplateDbAccess exportTemplateDbAccess, IExportSettingsDbAccess exportSettingsDbAccess, IProjectDbAccess projectDbAccess,
IKortistoNpcDbAccess npcDbAccess, IKortistoNpcTemplateDbAccess npcTemplateDbAccess, ITaleDbAccess dialogDbAccess, IStyrItemDbAccess itemDbAccess, IStyrItemTemplateDbAccess itemTemplateDbAccess,
IEvneSkillDbAccess skillDbAccess, IEvneSkillTemplateDbAccess skillTemplateDbAccess, IExportTemplatePlaceholderResolver templatePlaceholderResolver, IDialogFunctionGenerationConditionDbAccess dialogFunctionDbAccess,
IDialogFunctionGenerationConditionProvider dialogFunctionGenerationConditionProvider, ILanguageKeyDbAccess languageKeyDbAccess, ITimelineService timelineService, UserManager<GoNorthUser> userManager, ILogger<ExportApiController> logger,
IStringLocalizerFactory localizerFactory)
IDialogFunctionGenerationConditionProvider dialogFunctionGenerationConditionProvider, ILanguageKeyDbAccess languageKeyDbAccess, ILanguageKeyReferenceCollector languageKeyReferenceCollector, ITimelineService timelineService,
UserManager<GoNorthUser> userManager, ILogger<ExportApiController> logger, IStringLocalizerFactory localizerFactory)
{
_defaultTemplateProvider = defaultTemplateProvider;
_exportTemplateDbAccess = exportTemplateDbAccess;
Expand All @@ -283,7 +285,7 @@ public ExportApiController(IExportDefaultTemplateProvider defaultTemplateProvide
_exporters = new Dictionary<string, IObjectExporter>();
_exporters.Add("script", new ScriptExporter(templatePlaceholderResolver, projectDbAccess, exportSettingsDbAccess));
_exporters.Add("json", new JsonExporter());
_exporters.Add("languagefile", new LanguageExporter(templatePlaceholderResolver, defaultTemplateProvider, projectDbAccess, exportSettingsDbAccess));
_exporters.Add("languagefile", new LanguageExporter(templatePlaceholderResolver, defaultTemplateProvider, projectDbAccess, exportSettingsDbAccess, languageKeyReferenceCollector));
}

/// <summary>
Expand Down
31 changes: 26 additions & 5 deletions Controllers/Api/FlexFieldBaseApiController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -212,12 +212,12 @@ public class FlexFieldObjectQueryResult
/// <summary>
/// Timeline Service
/// </summary>
private readonly ITimelineService _timelineService;
protected readonly ITimelineService _timelineService;

/// <summary>
/// User Manager
/// </summary>
private readonly UserManager<GoNorthUser> _userManager;
protected readonly UserManager<GoNorthUser> _userManager;

/// <summary>
/// Xss Checker
Expand Down Expand Up @@ -938,6 +938,14 @@ public async Task<IActionResult> DeleteFlexFieldObject(string id)
/// <returns>Updated flex field object</returns>
protected abstract Task<T> RunAdditionalUpdates(T flexFieldObject, T loadedFlexFieldObject);

/// <summary>
/// Checks if an update is valid
/// </summary>
/// <param name="flexFieldObject">Flex Field Object</param>
/// <param name="loadedFlexFieldObject">Loaded Flex Field Object</param>
/// <returns>Empty string if update is valid, error string if update is not valid</returns>
protected virtual Task<string> CheckUpdateValid(T flexFieldObject, T loadedFlexFieldObject) { return Task.FromResult(string.Empty); }

/// <summary>
/// Runs updates on markers
/// </summary>
Expand All @@ -956,7 +964,7 @@ public async Task<IActionResult> DeleteFlexFieldObject(string id)
/// Sets the not implemented flag for an object on a relevant change
/// </summary>
/// <param name="newState">New State of the object</param>
private async Task SetNotImplementedFlagOnChange(T newState)
protected async Task SetNotImplementedFlagOnChange(T newState)
{
if(!newState.IsImplemented)
{
Expand Down Expand Up @@ -984,6 +992,12 @@ public async Task<IActionResult> UpdateFlexFieldObject(string id, [FromBody]T fl

T loadedFlexFieldObject = await _objectDbAccess.GetFlexFieldObjectById(id);

string updateErrorMessage = await CheckUpdateValid(flexFieldObject, loadedFlexFieldObject);
if(!string.IsNullOrEmpty(updateErrorMessage))
{
return StatusCode((int)HttpStatusCode.BadRequest, updateErrorMessage);
}

List<string> oldTags = loadedFlexFieldObject.Tags;
if(oldTags == null)
{
Expand Down Expand Up @@ -1144,8 +1158,15 @@ public IActionResult FlexFieldObjectImage(string imageFile)
return StatusCode((int)HttpStatusCode.InternalServerError);
}

Stream imageStream = _imageAccess.OpenFlexFieldObjectImage(imageFile);
return File(imageStream, mimeType);
try
{
Stream imageStream = _imageAccess.OpenFlexFieldObjectImage(imageFile);
return File(imageStream, mimeType);
}
catch(FileNotFoundException)
{
return NotFound();
}
}


Expand Down
Loading

0 comments on commit 32e79de

Please sign in to comment.