Example #1
0
        public void InheritFrom(MVersion parentVersion)
        {
            // Inherit list
            // Overload : AssetId, AssetUrl, AssetHash, ClientDownloadUrl, ClientHash, MainClass, MinecraftArguments
            // Combine : Libraries, GameArguments, JvmArguments

            // Overloads

            if (nc(AssetId))
            {
                AssetId = parentVersion.AssetId;
            }

            if (nc(AssetUrl))
            {
                AssetUrl = parentVersion.AssetUrl;
            }

            if (nc(AssetHash))
            {
                AssetHash = parentVersion.AssetHash;
            }

            if (nc(ClientDownloadUrl))
            {
                ClientDownloadUrl = parentVersion.ClientDownloadUrl;
            }

            if (nc(ClientHash))
            {
                ClientHash = parentVersion.ClientHash;
            }

            if (nc(MainClass))
            {
                MainClass = parentVersion.MainClass;
            }

            if (nc(MinecraftArguments))
            {
                MinecraftArguments = parentVersion.MinecraftArguments;
            }

            Jar = parentVersion.Jar;

            // Combine

            if (parentVersion.Libraries != null)
            {
                if (Libraries != null)
                {
                    Libraries = Libraries.Concat(parentVersion.Libraries).ToArray();
                }
                else
                {
                    Libraries = parentVersion.Libraries;
                }
            }

            if (parentVersion.GameArguments != null)
            {
                if (GameArguments != null)
                {
                    GameArguments = GameArguments.Concat(parentVersion.GameArguments).ToArray();
                }
                else
                {
                    GameArguments = parentVersion.GameArguments;
                }
            }


            if (parentVersion.JvmArguments != null)
            {
                if (JvmArguments != null)
                {
                    JvmArguments = JvmArguments.Concat(parentVersion.JvmArguments).ToArray();
                }
                else
                {
                    JvmArguments = parentVersion.JvmArguments;
                }
            }
        }
Example #2
0
 private void GameOnMineFound(object sender, GameArguments e)
 {
     ReportTextRepresentation(e.TextRepresentation);
     Console.WriteLine($"Mine Found {e.LastKnownBoardPosition.GetChessNotation()}");
 }
Example #3
0
 private void GameOnMoveNotAvailable(object sender, GameArguments e)
 {
     ReportTextRepresentation(e.TextRepresentation);
     Console.WriteLine("Move not available.");
 }
Example #4
0
 private void GameOnMoveReported(object sender, GameArguments e)
 {
     Report(e, "Move");
 }
Example #5
0
 private void GameOnLivesRunOut(object sender, GameArguments e)
 {
     Report(e, "Lives run  out");
     _gameIsOn = false;
 }
Example #6
0
 private static void Report(GameArguments gameArguments, string status)
 {
     ReportTextRepresentation(gameArguments.TextRepresentation);
     Console.WriteLine(
         $"{status} - lives left {gameArguments.LivesLeft} , moves elapsed {gameArguments.MovesElapsed}, last position {gameArguments.LastKnownBoardPosition.GetChessNotation()} ");
 }
Example #7
0
 private void GameOnGameGoalReached(object sender, GameArguments e)
 {
     _gameIsOn = false;
     Report(e, "Game goal reached");
     Console.WriteLine($"Final score {e.MovesElapsed}");
 }
        public static async Task WriteScripts(Config cfg, TransformedTarget[] tv, MCDownload downloader)
        {
            foreach (var t in tv)
            {
                MCVersion       v  = downloader.GetRemoteVersion(t.VersionID);
                VersionManifest vm = await v.GetManifest();

                GameArguments combined = new GameArguments(t.From.JVMArguments)
                                         + vm.JavaArguments
                                         //  (vm.LoggingSettings.ContainsKey("client") ? vm.LoggingSettings["client"].GameArgument : new GameArguments("")) +
                                         + new GameArguments("me.basiqueevangelist.launchergenerator.authhelper.MinecraftAuthHelper")
                                         + new GameArguments(vm.MainClass)
                                         + new GameArguments(cfg.Username)
                                         + new GameArguments(t.From.NewGameArguments)
                                         + vm.MinecraftArguments;
                AssetGroupIndex ai = await vm.AssetGroup.GetIndex();

                Dictionary <string, string> variables = new Dictionary <string, string>
                {
                    ["auth_player_name"]  = "@USERNAME",
                    ["version_name"]      = t.VersionID,
                    ["game_directory"]    = ".",
                    ["assets_root"]       = "../../assets",
                    ["game_assets"]       = "../../assets" + (ai.IsVirtual ? "/virtual/" + vm.AssetGroup.ID : ""),
                    ["assets_index_name"] = vm.AssetGroup.ID,
                    ["auth_uuid"]         = "@UUID",
                    ["auth_access_token"] = "@ACCESSTOKEN",
                    ["user_type"]         = "mojang",
                    ["version_type"]      = v.Type.ToString(),
                    ["classpath"]         = Classpath(vm),
                    ["natives_directory"] = "../../versions/" + t.VersionID + "/natives",
                    ["launcher_name"]     = "LauncherGenerator",
                    ["launcher_version"]  = "0.1a",
                    ["path"] = vm.LoggingSettings.ContainsKey("client") ? "../../assets/log_configs/" + ((RemoteFile)vm.LoggingSettings["client"].File).Name : ""
                };
                string[] cargs = combined.Process(variables, Array.Empty <string>());
                string   fname = "data/" + t.From.Name + (Environment.OSVersion.Platform == PlatformID.Win32NT ? ".bat" : ".sh");
                using (FileStream fs = File.Open(fname, System.IO.FileMode.Create, FileAccess.Write, FileShare.Read))
                    using (StreamWriter sw = new StreamWriter(fs))
                    {
                        if (Environment.OSVersion.Platform == PlatformID.Win32NT)
                        {
                            sw.WriteLine("title Minecraft " + t.VersionID + " launch script");
                            sw.WriteLine("cd %~dp0");
                        }
                        else
                        {
                            sw.WriteLine("#!/bin/sh");
                            sw.WriteLine("printf \"\\033]0;Minecraft " + t.VersionID + " launch script\\007\"");
                            sw.WriteLine("cd $(cd `dirname $0` && pwd)");
                        }
                        sw.WriteLine("cd profiles/" + t.From.Profile);
                        sw.WriteLine(t.From.JavaPath.Replace("\\", "\\\\") + " " + GameArguments.FoldArgs(cargs));
                        // sw.WriteLine("pause");
                    }
                Log.FileNew(fname);
                if (Environment.OSVersion.Platform != PlatformID.Win32NT)
                {
                    UnixFileInfo ufi = new UnixFileInfo(fname);
                    ufi.FileAccessPermissions |= FileAccessPermissions.UserExecute | FileAccessPermissions.GroupRead | FileAccessPermissions.OtherExecute;
                }
            }

            var assembly = typeof(Program).Assembly;

            using (Stream jarIn = assembly.GetManifestResourceStream("LauncherGenerator.MCAuthHelper.jar") ?? throw new NotImplementedException())
                using (FileStream jarOut = File.Open("data/MCAuthHelper.jar", FileMode.Create, FileAccess.Write, FileShare.Delete))
                    await jarIn.CopyToAsync(jarOut);
        }