/ArcaeaChartNoteCounterLibrary

A really simple Arcaea chart note counter library.

Primary LanguageC#BSD 3-Clause "New" or "Revised" LicenseBSD-3-Clause

Arcaea Chart Note Counter Library

A really simple Arcaea chart note counter library written in C#.

Last updated for Arcaea v6.0.3.

How to use

Simply call one of the following two static methods:

static int Moe.Lowiro.Arcaea.Chart.CountNote(string path);
static int Moe.Lowiro.Arcaea.Chart.CountNote(System.IO.Stream stream);

Notes about compiling

Do NOT check "Code Optimization" in the Project Properties. It will affect floating point errors.

Example

This is an example of using this library to count the notes of all charts and saving the results as CSV.

Note that we do not offer Arcaea charts due to copyright reasons. Please get them yourself.

using static Moe.Lowiro.Arcaea.Chart;
using System;
using System.IO;
using System.Text;

namespace Moe.Lowiro.Arcaea.Csv
{
    internal class Program
    {
        private const int FileNotExist = -2;
        private const int ChartError = -1;
        private static string CurrentPath;

        private static void Main(string[] args)
        {
            CurrentPath = Directory.GetCurrentDirectory();
            StringBuilder text = new StringBuilder("ID,PST,PRS,FTR,BYD,ETR");
            int[] counts = new int[5];
            foreach (DirectoryInfo folder in new DirectoryInfo(CurrentPath).GetDirectories())
            {
                string id = folder.Name;
                bool ok = false;
                for (int i = 0; i < 5; ++i)
                {
                    int count = Count(id, i);
                    counts[i] = count;
                    if (count != FileNotExist)
                    {
                        ok = true;
                    }
                }
                if (ok)
                {
                    text.AppendLine();
                    text.Append(id);
                    for (int i = 0; i < 5; ++i)
                    {
                        Append(text, counts[i]);
                    }
                }
            }
            text.AppendLine();
            text.AppendLine(",,,,,");
            text.AppendLine("Generated by Arcaea Chart Note Counter,,,,,");
            File.WriteAllText($@"{CurrentPath}\result.csv", text.ToString(), new UTF8Encoding(false));
        }

        private static int Count(string id, int level)
        {
            string path = $@"{CurrentPath}\{id}\{level}.aff";
            if (File.Exists(path))
            {
                try
                {
                    return CountNote(path);
                }
                catch (Exception e)
                {
                    Console.WriteLine($"{id}/{level}.aff: {e.Message}");
                    return ChartError;
                }
            }
            return FileNotExist;
        }

        private static void Append(StringBuilder builder, int value)
        {
            builder.Append(',');
            switch (value)
            {
            case FileNotExist: break;
            case ChartError: builder.Append("ERROR"); break;
            default: builder.Append(value); break;
            }
        }
    }
}