Exemplo n.º 1
0
    public void ShowBatter(BBPlayer player, BBTeam team)
    {
        StartCoroutine(LoadTloppsCard(player));

        PlayerNameText.text       = $"{player.name}";
        PlayerSecondLineText.text = $"Batting for the {team.nickname}";
        PlayerThirdLineText.text  = "$???";

        Debug.Log($"Player Stats for {player.name} were {Helper.GetStarRating(BBPlayer.BatterRating(player))} and {Helper.GetStarRating(BBPlayer.BaserunningRating(player))}");

        FirstStatText.text  = "Batting";
        SecondStatText.text = "Baserunning";
        ShowStars(BBPlayer.BatterRating(player), firstStarContainer);
        ShowStars(BBPlayer.BaserunningRating(player), secondStarContainer);
    }
Exemplo n.º 2
0
        public void SetupStreamingAssets()
        {
            // Setup basics...
            if (!Directory.Exists(applicationConfig.RootDirectory))
            {
                Directory.CreateDirectory(applicationConfig.RootDirectory);
            }

            string OSPath = $"{applicationConfig.RootDirectory}/blaseball";

            if (!Directory.Exists(OSPath))
            {
                Directory.CreateDirectory(OSPath);
            }

            BBLeague league = database.GetLeague();

            string leaguePath    = $"{OSPath}/{league.id}";
            string subleaguePath = $"{leaguePath}/subleague";
            string divisionPath  = $"{leaguePath}/division";
            string teamPath      = $"{leaguePath}/team";
            string playerPath    = $"{leaguePath}/player";

            if (!Directory.Exists(leaguePath))
            {
                Directory.CreateDirectory(leaguePath);
            }
            if (!Directory.Exists(subleaguePath))
            {
                Directory.CreateDirectory(subleaguePath);
            }
            if (!Directory.Exists(divisionPath))
            {
                Directory.CreateDirectory(divisionPath);
            }
            if (!Directory.Exists(teamPath))
            {
                Directory.CreateDirectory(teamPath);
            }
            if (!Directory.Exists(playerPath))
            {
                Directory.CreateDirectory(playerPath);
            }

            // Subleagues
            List <string> textFileContents = new List <string>();

            foreach (string subleague in database.GetSubleagueIDs())
            {
                string path = $"{subleaguePath}/{subleague}";
                if (!Directory.Exists(path))
                {
                    Directory.CreateDirectory(path);
                }

                BBSubleague subleagueVO = database.GetSubleague(subleague);
                textFileContents.Add($"{subleagueVO.name}\t{subleagueVO.id}");
            }
            CreateTextFile(textFileContents, subleaguePath);

            // Divisions
            textFileContents = new List <string>();
            foreach (string division in database.GetDivisionIDs())
            {
                string path = $"{divisionPath}/{division}";
                if (!Directory.Exists(path))
                {
                    Directory.CreateDirectory(path);
                }

                BBDivision divisionVO = database.GetDivision(division);
                textFileContents.Add($"{divisionVO.name}\t{divisionVO.id}");
            }
            CreateTextFile(textFileContents, divisionPath);

            // Teams
            textFileContents = new List <string>();
            foreach (string team in database.GetTeamIDs())
            {
                string path = $"{teamPath}/{team}";
                if (!Directory.Exists(path))
                {
                    Directory.CreateDirectory(path);
                }

                BBTeam teamVO = database.GetTeam(team);
                textFileContents.Add($"{teamVO.fullName}\t{teamVO.id}");

                string teamText = $"{teamVO.fullName}\n\"{teamVO.slogan}\"";
                File.WriteAllText($"{path}/info.txt", teamText);
            }
            CreateTextFile(textFileContents, teamPath);

            // Players
            textFileContents = new List <string>();
            foreach (string player in database.GetPlayerIDs())
            {
                string path = $"{playerPath}/{player}";
                if (!Directory.Exists(path))
                {
                    Directory.CreateDirectory(path);
                }

                BBPlayer playerVO = database.GetPlayer(player);
                textFileContents.Add($"{playerVO.name}\t{playerVO.id}");

                string playerText = $"{playerVO.name}\nBatting\t\t{StarRating(BBPlayer.BatterRating(playerVO))}\nPitching\t{StarRating(BBPlayer.PitcherRating(playerVO))}\n";
                playerText += $"Baserunning\t{StarRating(BBPlayer.BaserunningRating(playerVO))}\nDefense\t\t{StarRating(BBPlayer.DefenseRating(playerVO))}";
                File.WriteAllText($"{path}/info.txt", playerText);
            }
            CreateTextFile(textFileContents, playerPath);

            void CreateTextFile(List <string> content, string directory)
            {
                content.Sort();
                string fileContents = "";

                for (int i = 0; i < content.Count; i++)
                {
                    fileContents += content[i] + "\n";
                }

                File.WriteAllText($"{directory}/index.tsv", fileContents);
            }

            string StarRating(float v)
            {
                string txt       = "";
                int    halfstars = Mathf.RoundToInt(v * 10);

                while (halfstars >= 2)
                {
                    txt       += "\u2605";
                    halfstars -= 2;
                }
                if (halfstars == 1)
                {
                    txt += "\u00BD";
                }
                return(txt);
            }
        }