private string generate()
        {
            string fileString = "";

            List <string> interludesFiles = MusicFolder.getMusicFiles(interludesPath);

            // interlude exceptions
            if (interludesUsage && (
                    (!interludeUsageSame && interludesFiles.Count < actsQuantity - 1) ||
                    (interludeUsageSame && interludesFiles.Count == 0 && actsQuantity != 1)))
            {
                int    interludesNeeded = interludeUsageSame ? 1 : actsQuantity - 1;
                string aux = interludesNeeded == 1 ? "pieza" : "piezas";

                throw new Exception($"La carpeta de cortinas {interludesPath} necesita tener al menos {interludesNeeded} {aux}");
            }

            // act exceptions
            foreach (Act act in acts)
            {
                // check if all the acts have enough songs
                if (MusicFolder.getMusicFiles(act.path).Count < actsLength)
                {
                    string aux = actsLength == 1 ? "pieza" : "piezas";
                    throw new Exception($"La carpeta {act.path} necesita tener al menos {actsLength} {aux}");
                }
            }

            // sort the acts and interludes
            List <Act>    actsSorted       = sortRandom(acts);
            List <string> interludesSorted = interludesUsage ? sortRandom(interludesFiles) : new List <string>();

            for (int i = 0; i < actsQuantity; i++)
            {
                Act           current     = actsSorted[i];
                List <string> filesSorted = sortRandom(MusicFolder.getMusicFiles(current.path));

                // header
                fileString += $"{(i == 0 ? "" : "\n\n")}# Tanda: {current.name}";

                // songs
                for (int j = 0; j < actsLength; j++)
                {
                    fileString += $"\n{filesSorted[j]}";
                }

                if (interludesUsage && i != actsQuantity - 1)
                {
                    fileString += $"\n\n# Cortina {i + 1}";

                    int interludeIndex = interludeUsageSame ? 0 : i;
                    fileString += $"\n{interludesSorted[interludeIndex]}";
                }
            }

            return(fileString);
        }
Esempio n. 2
0
 public Act(string _path)
 {
     path = _path;
     name = MusicFolder.getLastFolderName(_path);
 }