Example #1
0
        private List <List <string> > LoadStats()
        {
            var data = YamlParser
                       .ParseFile <List <RogueskivGameStats> >(AppConfig.GameStatsFilePath);

            if (data == null)
            {
                return(new List <List <string> >());
            }

            return(data
                   .AsEnumerable()
                   .Reverse()
                   .Select(gameStat => new List <string>
            {
                gameStat.GetResult(),
                gameStat.GetDateTime(),
                RogueskivMenu.CleanGameModeText(gameStat.GameMode),
                gameStat.Floors.ToString(),
                gameStat.DiedOnFloor.ToString(),
                gameStat.FinalHealth.ToString(),
                gameStat.GetRealTimeFormatted(),
                gameStat.GetInGameTimeFormatted(),
            })
                   .ToList());
        }
Example #2
0
        public OsTest()
        {
            var path = $"{Utils.CurrentDirectory()}\\{@"Parser\fixtures\oss.yml"}";

            var parser = new YamlParser <List <OsFixture> >();

            _fixtureData = parser.ParseFile(path);

            //replace null
            _fixtureData = _fixtureData.Select(f =>
            {
                f.os.version = f.os.version ?? "";
                return(f);
            }).ToList();
        }
Example #3
0
        public LibraryTest()
        {
            var path = $"{Utils.CurrentDirectory()}\\{@"Parser\Client\fixtures\library.yml"}";

            var parser = new YamlParser <List <ClientFixture> >();

            _fixtureData = parser.ParseFile(path);

            //replace null
            _fixtureData = _fixtureData.Select(f =>
            {
                f.client.version = f.client.version ?? "";
                return(f);
            }).ToList();
        }
Example #4
0
        public CarBrowserTest()
        {
            var path = $"{Utils.CurrentDirectory()}\\{@"Parser\Devices\fixtures\car_browser.yml"}";

            var parser = new YamlParser <List <DeviceModelFixture> >();

            _fixtureData = parser.ParseFile(path);

            //replace null
            //_fixtureData = _fixtureData.Select(f =>
            //{
            //    f.client.version = f.client.version ?? "";
            //    return f;
            //}).ToList();
        }
Example #5
0
        public VendorFragmentTest()
        {
            var path = $"{Utils.CurrentDirectory()}\\{@"Parser\fixtures\vendorfragments.yml"}";

            var parser = new YamlParser <List <VendorFragmentFixture> >();

            _fixtureData = parser.ParseFile(path);

            //replace null
            _fixtureData = _fixtureData.Select(f =>
            {
                f.vendor = f.vendor ?? "";
                return(f);
            }).ToList();
        }
Example #6
0
        public BrowserTest()
        {
            var path = $"{Utils.CurrentDirectory()}\\{@"Parser\Client\fixtures\browser.yml"}";

            var parser = new YamlParser <List <BrowserFixture> >();

            _fixtureData = parser.ParseFile(path);

            //replace null
            _fixtureData = _fixtureData.Select(f =>
            {
                f.client.version        = f.client.version ?? "";
                f.client.engine         = f.client.engine ?? "";
                f.client.engine_version = f.client.engine_version ?? "";
                return(f);
            }).ToList();
        }
Example #7
0
        private static RogueskivAppConfig GetRogueskivAppConfig()
        {
            var dataFilePath = Path.Combine(
                Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
                APP_DATA_FOLDER
                );

            CheckApplicationDataFolder(dataFilePath);

            var rogueskivConfig = YamlParser.ParseFile <RogueskivAppConfig>(dataFilePath, CONFIG_FILE_NAME);

            rogueskivConfig.GlobalConfigFilePath = Path.Combine(dataFilePath, $"{CONFIG_FILE_NAME}.yaml");
            rogueskivConfig.GameStatsFilePath    = Path.Combine(dataFilePath, $"{GAME_STATS_FILE_NAME}.yaml");
            rogueskivConfig.GameModeFilesPath    = Path.Combine(dataFilePath, GAME_MODE_FILES_PATH);
            rogueskivConfig.GameModes            = GetGameModes(rogueskivConfig);
            rogueskivConfig.CheckGameModeIndexBounds();

            return(rogueskivConfig);
        }
Example #8
0
        public void TestParse(string fileNme)
        {
            //DeviceDetectorSettings.RegexesDirectory = @"D:\WorkSpaces\GitHubVisualStudio\DeviceDetector.Net\src\DeviceDetector.NET\";
            var parser       = new YamlParser <List <DeviceDetectorFixture> >();
            var _fixtureData = parser.ParseFile($"{Utils.CurrentDirectory()}\\fixtures\\{fileNme}.yml");

            foreach (var expected in _fixtureData)
            {
                var dd = DeviceDetector.GetInfoFromUserAgent(expected.user_agent);
                dd.Success.Should().BeTrue();
                dd.Match.OsFamily.Should().BeEquivalentTo(expected.os_family);
                dd.Match.BrowserFamily.Should().BeEquivalentTo(expected.browser_family);
                if (expected.os != null)
                {
                    if (expected.os is Dictionary <object, object> dicOs && dicOs.Count > 0)
                    {
                        var osName = dicOs["name"];
                        dd.Match.Os.Name.Should().BeEquivalentTo(osName.ToString());
                    }
                    else
                    {
                        if (expected.os is List <object> listOs && listOs.Count > 0)
                        {
                            throw new Exception();
                            //var osName = dicOs["name"];
                            //dd.Match.Os.Name.Should().BeEquivalentTo(osName.ToString());
                        }
                    }
                }

                if (expected.client != null)
                {
                    dd.Match.Client.Type.Should().BeEquivalentTo(expected.client.type);
                    dd.Match.Client.Name.Should().BeEquivalentTo(expected.client.name);
                }
                if (expected.device != null)
                {
                    dd.Match.DeviceType?.Should().BeEquivalentTo(expected.device.type);
                    dd.Match.DeviceBrand?.Should().BeEquivalentTo((expected.device.brand ?? ""));
                    dd.Match.DeviceModel?.Should().BeEquivalentTo((expected.device.model ?? ""));
                }
            }
Example #9
0
        private GameEngine <EntityList> CreateGameStage(
            IGameResult <EntityList> result = null,
            int?gameSeed = null
            )
        {
            LoadingScreenRenderer.Render();

            var isFirstStage = result == null;

            if (isFirstStage)
            {
                SaveGlobalConfig();
            }

            if (gameSeed.HasValue)
            {
                GameContext.SetSeed(gameSeed.Value);
            }

            var gameConfig = YamlParser.ParseFile <RogueskivGameConfig>(AppConfig.GameModeFilesPath, AppConfig.GameMode);

            gameConfig.GameFPS    = GameContext.GameFPS;
            gameConfig.GameSeed   = GameContext.GameSeed;
            gameConfig.FloorCount = AppConfig.FloorCount;

            if (FloorEngines.Count == 0)
            {
                UxContext.PlayMusic(gameConfig.GameMusicFilePath, gameConfig.GameMusicVolume);
            }

            CurrentFloor = FloorEngines.Count + 1;
            var game      = new RogueskivGame(GameStageCodes.Game, gameConfig, CurrentFloor, result, OnGameEnd);
            var renderer  = new RogueskivRenderer(UxContext, GameContext, game, AppConfig, gameConfig);
            var userInput = new RogueskivInputHandler(UxContext, game, renderer);
            var engine    = new GameEngine <EntityList>(GameContext, userInput, game, renderer);

            FloorEngines.Add(engine);

            return(engine);
        }