Beispiel #1
0
        /// <summary>
        /// Searches the database (specifically, just the batting team) for a player
        /// with the matching name in the regex, and returns them, or null if not found
        /// </summary>
        /// <returns>The reference to the player, or null if failed</returns>
        public BBPlayer Stealer()
        {
            string playerName = recordedRegexMatch.Groups[0].Value;
            string playerTeam = gameState.topOfInning ? gameState.awayTeam : gameState.homeTeam;

            BBTeam team = database.GetTeam(playerTeam);

            if (team != null)
            {
                foreach (string playerID in team.lineup)
                {
                    BBPlayer player = database.GetPlayer(playerID);
                    if (player == null)
                    {
                        continue;
                    }
                    if (player.name == playerName)
                    {
                        return(player);
                    }
                }
            }

            return(database.FindPlayerByName(playerName));
        }
Beispiel #2
0
    private void BatterUp(BBBatterAtPlatePlay play)
    {
        cameraGraphicsMasterControl.ResetPlate(play);

        BBPlayer batter       = play.Batter();
        BBTeam   battingTeam  = Database.GetTeam(play.gameState.topOfInning ? play.gameState.awayTeam : play.gameState.homeTeam);
        BBTeam   fieldingTeam = Database.GetTeam(!play.gameState.topOfInning ? play.gameState.awayTeam : play.gameState.homeTeam);

        SetupBatter(play.Batter(), battingTeam?.id ?? "-1");
        SetupCatcher(Database.GetPlayer(fieldingTeam?.lineup[8] ?? "-1"), fieldingTeam?.id ?? "-1");

        SetupAndPlay(GetRandomAnimation(newBatterAnimations, play.playIndex));
        cameraGraphicsMasterControl.ShowBatter(batter, battingTeam);
        cameraGraphicsMasterControl.UpdateScores(play.gameState);
    }
Beispiel #3
0
        public BBPlayer GetPlayerByName(string playerName, string teamID)
        {
            BBTeam team = database.GetTeam(teamID);

            if (team != null)
            {
                foreach (string playerID in team.lineup)
                {
                    BBPlayer player = database.GetPlayer(playerID);
                    if (player == null)
                    {
                        continue;
                    }
                    if (player.name == playerName)
                    {
                        return(player);
                    }
                }
            }

            return(database.FindPlayerByName(playerName));
        }
Beispiel #4
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);
            }
        }