Esempio n. 1
0
        public Task <bool> HostGame(HostedGame hostedGame, HostedGameSource source, string username, string password)
        {
            DebugValidate(hostedGame, true);

            var args = "-h ";

            if (CommandLineHandler.Instance.DevMode)
            {
                args += "-x ";
            }

            if (source == HostedGameSource.Lan)
            {
                new HostedGameProcess(
                    hostedGame,
                    X.Instance.Debug,
                    true
                    ).Start();
            }

            args += $"-u \"{username}\" ";
            args += "-k \"" + HostedGame.Serialize(hostedGame) + "\"";

            return(LaunchJodsEngine(args));
        }
Esempio n. 2
0
        public Task <bool> JoinGame(DataGameViewModel game, IPAddress host, int port, string username, string password, bool spectate)
        {
            var user = new User(Guid.NewGuid().ToString(), username);

            var hostedGame = new HostedGame()
            {
                Id           = Guid.NewGuid(),
                GameId       = game.Id,
                GameName     = game.Name,
                OctgnVersion = Const.OctgnVersion.ToString(),
                GameVersion  = game.Version.ToString(),
                HostAddress  = $"{host}:{port}",
                Password     = password,
                DateCreated  = DateTime.UtcNow
            };

            DebugValidate(hostedGame, false);

            var args = "-j ";

            if (CommandLineHandler.Instance.DevMode)
            {
                args += "-x ";
            }

            args += $"-u \"{username}\" ";
            if (spectate)
            {
                args += "-s ";
            }

            args += "-k \"" + HostedGame.Serialize(hostedGame) + "\"";

            return(LaunchJodsEngine(args));
        }
Esempio n. 3
0
        public Task <bool> HostGame(HostedGame hostedGame, HostedGameSource source, string username, string password)
        {
            DebugValidate(hostedGame, true);

            //duct-tape fix for a game server bug where online-hosted games lose the chosen password
            //TODO: remove this check when the bug is fixed server-side (see git issue ticket #2109)
            if (!password.Equals(hostedGame.Password))
            {
                hostedGame.Password = password;
            }

            var args = "-h ";

            if (CommandLineHandler.Instance.DevMode)
            {
                args += "-x ";
            }

            if (source == HostedGameSource.Lan)
            {
                new HostedGameProcess(
                    hostedGame,
                    X.Instance.Debug,
                    true
                    ).Start();
            }

            args += $"-u \"{username}\" ";
            args += "-k \"" + HostedGame.Serialize(hostedGame) + "\"";

            return(LaunchJodsEngine(args));
        }
Esempio n. 4
0
        public async Task StartSinglePlayer()
        {
            DbContext.SetContext(new DesktopDbContext());

            var configLoader = new ConfigLoader();

            await configLoader.Load(null);

            var octgnVersion = typeof(Server.Server).Assembly.GetName().Version;

            var username = Prefs.Username;

            if (string.IsNullOrWhiteSpace(username))
            {
                username = Library.Randomness.GrabRandomNounWord() + Library.Randomness.GrabRandomJargonWord();
            }

            var user = new User(Guid.NewGuid().ToString(), username);

            var name = Prefs.LastRoomName;

            if (string.IsNullOrWhiteSpace(name))
            {
                name = Library.Randomness.RandomRoomName();
            }

            var gameId = GetGameId();

            var gameName    = Details.Name;
            var gameVersion = Package.Record.Version;

            var hostedGame = new HostedGame()
            {
                Id           = Guid.NewGuid(),
                Name         = name,
                HostUser     = user,
                GameName     = gameName,
                GameId       = gameId,
                GameVersion  = gameVersion,
                HostAddress  = $"0.0.0.0:{Prefs.LastLocalHostedGamePort}",
                OctgnVersion = octgnVersion.ToString(),
                Spectators   = true,
            };

            var args = "-h ";

            new HostedGameProcess(
                hostedGame,
                X.Instance.Debug,
                true
                ).Start();

            args += $"-u \"{username}\" ";
            args += "-p ";
            args += "-k \"" + HostedGame.Serialize(hostedGame) + "\"";

            await LaunchEngine(args);
        }
Esempio n. 5
0
        public Task <bool> JoinGame(HostedGameViewModel hostedGameViewModel, string username, bool spectate)
        {
            User user;

            if (Program.LobbyClient.User != null)
            {
                user = Program.LobbyClient.User;
            }
            else
            {
                user = new User(Guid.NewGuid().ToString(), Prefs.Username);
            }

            var hostedGame = hostedGameViewModel.HostedGame;

            DebugValidate(hostedGame, false);

            var args = "-j ";

            if (CommandLineHandler.Instance.DevMode)
            {
                args += "-x ";
            }

            new HostedGameProcess(
                hostedGame,
                X.Instance.Debug,
                true
                ).Start();

            args += $"-u \"{username}\" ";
            if (spectate)
            {
                args += "-s ";
            }
            args += "-k \"" + HostedGame.Serialize(hostedGame) + "\"";

            return(LaunchJodsEngine(args));
        }