Ejemplo n.º 1
0
    private void StrikeOut(BBStrikeOutPlay play)
    {
        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);

        BBPlayer batter  = play.Batter();
        BBPlayer pitcher = play.Pitcher();


        SetupBatter(batter, battingTeam.id);
        SetupPitcher(pitcher, fieldingTeam.id);

        switch (play.TypeOfStrikeOut)
        {
        case BBStrikeOutPlay.StrikeOut.LOOKING:
            SetupAndPlay(GetRandomAnimation(strikeOutLookingAnimations, play.playIndex));
            break;

        case BBStrikeOutPlay.StrikeOut.SWINGING:
            SetupAndPlay(GetRandomAnimation(strikeOutSwingingAnimations, play.playIndex));
            break;

        default:
            HandleTechnicalDifficulties(play);
            break;
        }

        cameraGraphicsMasterControl.UpdateScores(play.gameState);
    }
Ejemplo n.º 2
0
    private IEnumerator LoadTloppsCard(BBPlayer player)
    {
        if (player == null)
        {
            TloppsCardContainer.gameObject.SetActive(false);
            yield return(true);
        }
        else
        {
            UnityWebRequest www = new UnityWebRequest(fileLoader.GetPlayerTloppsCard(player.id));
            www.downloadHandler = new DownloadHandlerTexture();
            yield return(www.SendWebRequest());

            if (www.isNetworkError || www.isHttpError)
            {
                TloppsCardContainer.gameObject.SetActive(false);
            }
            else
            {
                TloppsCardContainer.gameObject.SetActive(true);
                Texture2D c = ((DownloadHandlerTexture)www.downloadHandler).texture;
                TloppsCardImage.sprite = Sprite.Create(
                    c,
                    new Rect(0, 0, c.width, c.height),
                    new Vector2(0.5f, 0.5f),
                    100
                    );
            }
        }
    }
Ejemplo n.º 3
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));
        }
Ejemplo n.º 4
0
        public bool UpdatePlayer(string playerID)
        {
            string playerInformation = Download($"https://blaseball.com/database/players?ids={playerID}");

            if (playerInformation == "")
            {
                return(false);
            }
            BBPlayer player = JsonUtility.FromJson <BBPlayer>(playerInformation);

            Database.SetPlayer(player);
            Logger.Log($"Player: {player.name}");
            return(true);
        }
Ejemplo n.º 5
0
    /// <summary>
    /// Todo, get the batter catcher model if one is available
    /// </summary>
    /// <param name="batterID"></param>
    /// <param name="teamID"></param>
    private void SetupCatcher(BBPlayer player, string teamID)
    {
        BBTeam team = Database.GetTeam(teamID);

        Color teamColorMain   = Color.white;
        Color teamColorSecond = Color.white;

        ColorUtility.TryParseHtmlString(team?.mainColor ?? "#999999", out teamColorMain);
        ColorUtility.TryParseHtmlString(team?.secondaryColor ?? "#dddddd", out teamColorSecond);

        GetCatcher(player).SetPlayerName(player?.name ?? "Unknown Player");
        GetCatcher(player).SetPrimaryColor(teamColorMain);
        GetCatcher(player).SetSecondaryColor(teamColorSecond);
    }
Ejemplo n.º 6
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);
    }
Ejemplo n.º 7
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);
    }
Ejemplo n.º 8
0
    private CharacterCutsceneControl GetPitcher(BBPlayer player)
    {
        if (Pitcher != null)
        {
            return(Pitcher);
        }

        if (player != null)
        {
            Pitcher = LoadCharacter(player);
        }
        if (Pitcher == null)
        {
            Pitcher = Instantiate(DefaultCharacterPrefab).GetComponent <CharacterCutsceneControl>();
        }
        return(Pitcher);
    }
Ejemplo n.º 9
0
    /// <summary>
    /// Todo, get the batter custom model if one is available
    /// </summary>
    /// <param name="batterID"></param>
    /// <param name="teamID"></param>
    private void SetupBatter(BBPlayer player, string teamID)
    {
        BBTeam team = Database.GetTeam(teamID);

        Color teamColorMain   = Color.white;
        Color teamColorSecond = Color.white;

        ColorUtility.TryParseHtmlString(team?.mainColor ?? "#999999", out teamColorMain);
        ColorUtility.TryParseHtmlString(team?.secondaryColor ?? "#dddddd", out teamColorSecond);

        Debug.Log($"Setting Up Batter: {player}");
        Bat.gameObject.SetActive(true);

        Bat.SetParent(GetBatter(player).LeftHandAttachmentReference, false);

        GetBatter(player).SetPlayerName(player?.name ?? "Unknown Player");
        GetBatter(player).SetPrimaryColor(teamColorMain);
        GetBatter(player).SetSecondaryColor(teamColorSecond);
    }
Ejemplo n.º 10
0
    private CharacterCutsceneControl LoadCharacter(BBPlayer player)
    {
        try {
            var myLoadedAssetBundle = AssetBundle.LoadFromFile(Loader.GetPlayerCustomModelPath(player.id));
            if (myLoadedAssetBundle == null)
            {
                Debug.Log("Failed to load AssetBundle!");
                return(null);
            }

            var        prefab      = myLoadedAssetBundle.LoadAsset <GameObject>("Body");
            GameObject playerModel = (GameObject)Instantiate(prefab);

            myLoadedAssetBundle.Unload(false);

            return(playerModel.GetComponent <CharacterCutsceneControl>());
        } catch (Exception e) {
            return(null);
        }
    }
Ejemplo n.º 11
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));
        }
Ejemplo n.º 12
0
 public void SetPlayer(BBPlayer player)
 {
     Players[player.id] = player;
 }
Ejemplo n.º 13
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);
            }
        }
Ejemplo n.º 14
0
 public void ShowFielder(BBPlayer player, BBTeam team)
 {
 }
Ejemplo n.º 15
0
 public void ShowPitcher(BBPlayer player, BBTeam team)
 {
 }
Ejemplo n.º 16
0
 public void ShowBatter(BBPlayer player, BBTeam team)
 {
     ClearAllGraphics();
     playerInformationChiron.Show();
     playerInformationChiron.ShowBatter(player, team);
 }