Skip to content

Commit

Permalink
Merge pull request #176 from Quaver/automod-cmd
Browse files Browse the repository at this point in the history
Add AutoMod command
  • Loading branch information
Swan authored Aug 1, 2024
2 parents 3c5da6e + e88c5c2 commit c5f0e7f
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 1 deletion.
43 changes: 43 additions & 0 deletions Quaver.Tools/Commands/AutoModComand.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
using System;
using System.IO;
using System.Linq;
using Newtonsoft.Json.Linq;
using Quaver.API.Maps;
using Quaver.API.Maps.AutoMod;

namespace Quaver.Tools.Commands
{
public class AutoModCommand : Command
{
private string Dir { get; }

public AutoModCommand(string[] args) : base(args)
{
var list = args.ToList();
list.RemoveAt(0);
Dir = string.Join(' ', list);
}

public override void Execute()
{
var totalIssues = 0;

foreach (var file in Directory.GetFiles(Dir))
{
if (Path.GetExtension(file) != ".qua")
continue;

var qua = Qua.Parse(file);
var automod = new AutoMod(qua);
automod.Run();

totalIssues += automod.Issues.Count;
}

Console.WriteLine(JObject.FromObject(new
{
HasIssues = totalIssues > 0
}));
}
}
}
6 changes: 5 additions & 1 deletion Quaver.Tools/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ internal static void Main(string[] args)
$"-convertosu <file_path.osu> <output.qua>\n" +
$"-convertsm <file_path.sm> <output directory>\n" +
$"-changequaids <file_path.qua> <output_path.qua> <map_id> <mapset_id>\n" +
$"-recalculate <user_id> <mode> Recalculates a given user's top 50 scores for a game mode.");
$"-recalculate <user_id> <mode> Recalculates a given user's top 50 scores for a game mode.\n" +
$"-automod <directory> Runs AutoMod on all files in a .qua directory and returns if there are any issues.");
return;
}

Expand Down Expand Up @@ -64,6 +65,9 @@ internal static void Main(string[] args)
case "-recalculate":
new RecalculateCommand(args).Execute();
break;
case "-automod":
new AutoModCommand(args).Execute();
break;
default:
throw new ArgumentException();
}
Expand Down

0 comments on commit c5f0e7f

Please sign in to comment.