public void AddPickToHistory(PlayerDatabase.PlayerData playerData, int currentRound, int currentPick) { // Skip pick grades for defenses and kickers (they don't work well) if (playerData.position != PlayerDatabase.Position.DEF && playerData.position != PlayerDatabase.Position.K) { // Check pick grade int expectedPlayerRank = (currentRound + 3) * (int)DrafterEnum.TotalDrafters + currentPick + 1; int pickGrade = expectedPlayerRank - (int)playerData.overallRank; // Draft Steal! if (pickGrade > 30) { this.breakingNews.AddNewsToTicker(timerScript.GetCurrentDrafter(), playerData.playerName, true); print("Draft Steal!: " + playerData.playerName + " : " + pickGrade); } // Draft Reach! else if (pickGrade < -24) { this.breakingNews.AddNewsToTicker(timerScript.GetCurrentDrafter(), playerData.playerName, false); print("Reach Pick: " + playerData.playerName + " : " + pickGrade); } } this.pickHistory.Insert(0, playerData); // Keep history to max of 5 names. if (this.pickHistory.Count > 5) { this.pickHistory.RemoveAt(this.pickHistory.Count - 1); } }
private void SetBestAvailableNames() { // Go to the next display option, and loop around if needed currentDisplayOption += 1; if (currentDisplayOption > BestAvailableOption.TopDEFs) { currentDisplayOption = BestAvailableOption.TopAvailable; } // Best available overall PlayerDatabase.PlayerData[] bestPlayers = new PlayerDatabase.PlayerData[5]; switch (currentDisplayOption) { case BestAvailableOption.TopAvailable: headerObject.GetComponentInChildren <TextMeshPro>().text = "Best Available"; bestPlayers = timerScript.playerDatabase.GetBestAvailablePlayers(); break; case BestAvailableOption.TopQBs: headerObject.GetComponentInChildren <TextMeshPro>().text = "Best Available QBs"; bestPlayers = timerScript.playerDatabase.GetBestPositionPlayers(PlayerDatabase.Position.QB); break; case BestAvailableOption.TopRBs: headerObject.GetComponentInChildren <TextMeshPro>().text = "Best Available RBs"; bestPlayers = timerScript.playerDatabase.GetBestPositionPlayers(PlayerDatabase.Position.RB); break; case BestAvailableOption.TopWRs: headerObject.GetComponentInChildren <TextMeshPro>().text = "Best Available WRs"; bestPlayers = timerScript.playerDatabase.GetBestPositionPlayers(PlayerDatabase.Position.WR); break; case BestAvailableOption.TopTEs: headerObject.GetComponentInChildren <TextMeshPro>().text = "Best Available TEs"; bestPlayers = timerScript.playerDatabase.GetBestPositionPlayers(PlayerDatabase.Position.TE); break; case BestAvailableOption.TopKs: headerObject.GetComponentInChildren <TextMeshPro>().text = "Best Available Ks"; bestPlayers = timerScript.playerDatabase.GetBestPositionPlayers(PlayerDatabase.Position.K); break; case BestAvailableOption.TopDEFs: headerObject.GetComponentInChildren <TextMeshPro>().text = "Best Available DEFs"; bestPlayers = timerScript.playerDatabase.GetBestPositionPlayers(PlayerDatabase.Position.DEF); break; } // Assign best players to the correct location for (int i = 0; i < 5; ++i) { GameObject backdrop; if (bestPlayers[i] == null) { backdrop = dataBackdrops[i]; backdrop.GetComponentInChildren <TextMeshPro>().text = string.Empty; backdrop.GetComponent <SpriteRenderer>().sprite = teamBackgroundSprites[(int)PlayerDatabase.NFLTeam.FA]; continue; } backdrop = dataBackdrops[i]; backdrop.GetComponentInChildren <TextMeshPro>().text = bestPlayers[i].playerName; backdrop.GetComponent <SpriteRenderer>().sprite = teamBackgroundSprites[(int)bestPlayers[i].nflTeam]; } }
private void SetAutoPickPlayer() { string autopickPlayer = string.Empty; // No RBs on roster if (rosterSlots[(int)PositionImportance.RB] == 0) { // Get the top RB autopickPlayer = timerScript.playerDatabase.GetBestPositionPlayers(PlayerDatabase.Position.RB)[0].playerName; } // 0 or 1 WRs on roster else if (rosterSlots[(int)PositionImportance.WR] <= 1) { // Get the top WR autopickPlayer = timerScript.playerDatabase.GetBestPositionPlayers(PlayerDatabase.Position.WR)[0].playerName; } // No QBs on roster else if (rosterSlots[(int)PositionImportance.QB] == 0) { // Get the top QB autopickPlayer = timerScript.playerDatabase.GetBestPositionPlayers(PlayerDatabase.Position.QB)[0].playerName; } // No Flex1 starters on roster else if (rosterSlots[(int)PositionImportance.Flex1] <= 1) { // Get the top flex PlayerDatabase.PlayerData WR = timerScript.playerDatabase.GetBestPositionPlayers(PlayerDatabase.Position.WR)[0]; PlayerDatabase.PlayerData RB = timerScript.playerDatabase.GetBestPositionPlayers(PlayerDatabase.Position.RB)[0]; PlayerDatabase.PlayerData TE = timerScript.playerDatabase.GetBestPositionPlayers(PlayerDatabase.Position.TE)[0]; // WR is better ranked if (WR.overallRank < RB.overallRank && WR.overallRank < TE.overallRank) { autopickPlayer = WR.playerName; } // RB is better ranked else if (RB.overallRank < WR.overallRank && RB.overallRank < TE.overallRank) { autopickPlayer = RB.playerName; } // TE is better ranked else { autopickPlayer = TE.playerName; } } // No RB backups on roster else if (rosterSlots[(int)PositionImportance.RBBackup] == 0) { // Get the top RB autopickPlayer = timerScript.playerDatabase.GetBestPositionPlayers(PlayerDatabase.Position.RB)[0].playerName; } // No WR backups on roster else if (rosterSlots[(int)PositionImportance.WRBackup] == 0) { // Get the top WR autopickPlayer = timerScript.playerDatabase.GetBestPositionPlayers(PlayerDatabase.Position.WR)[0].playerName; } // No DEF starters on roster else if (rosterSlots[(int)PositionImportance.DEF] == 0) { // Get the top DEF autopickPlayer = timerScript.playerDatabase.GetBestPositionPlayers(PlayerDatabase.Position.DEF)[0].playerName; } // No QB backups on roster else if (rosterSlots[(int)PositionImportance.QBBackup] == 0) { // Get the top QB autopickPlayer = timerScript.playerDatabase.GetBestPositionPlayers(PlayerDatabase.Position.QB)[0].playerName; } // No Flex backups on roster else if (rosterSlots[(int)PositionImportance.FlexBackup] <= 1) { // Get the top flex PlayerDatabase.PlayerData WR = timerScript.playerDatabase.GetBestPositionPlayers(PlayerDatabase.Position.WR)[0]; PlayerDatabase.PlayerData RB = timerScript.playerDatabase.GetBestPositionPlayers(PlayerDatabase.Position.RB)[0]; PlayerDatabase.PlayerData TE = timerScript.playerDatabase.GetBestPositionPlayers(PlayerDatabase.Position.TE)[0]; // WR is better ranked if (WR.overallRank < RB.overallRank && WR.overallRank < TE.overallRank) { autopickPlayer = WR.playerName; } // RB is better ranked else if (RB.overallRank < WR.overallRank && RB.overallRank < TE.overallRank) { autopickPlayer = RB.playerName; } // TE is better ranked else { autopickPlayer = TE.playerName; } } // No K on roster else if (rosterSlots[(int)PositionImportance.K] == 0) { // Get the top K autopickPlayer = timerScript.playerDatabase.GetBestPositionPlayers(PlayerDatabase.Position.K)[0].playerName; } else { // Get the top player autopickPlayer = timerScript.playerDatabase.GetBestAvailablePlayers()[0].playerName; } GameObject.Find("AutoPickButton").GetComponent <AutoPickButton>().SetAutoPickPlayer(autopickPlayer); }
// Pick has been confirmed with button press public void PickConfirmed() { // Don't activate if not in pick is in state if (currentDraftState != DraftState.ThePickIsIn) { return; } // Contract data is not written int currentDrafter = (int)pickInfo[currentRound][currentPick].drafterID; PlayerDatabase.PlayerData currentPickedPlayer = playerDatabase.PickPlayerFromDatabase(textBoxObject.GetComponent <InputField>().text); if (!playerProfiles[currentDrafter].contractDataWritten) { // Count all the contracts (everyone always has a 3year contract) int contracts = 1; // Add up all the contracts contracts += playerProfiles[currentDrafter].twoYearContracts.Count; contracts += playerProfiles[currentDrafter].oneYearContracts.Count; // Already have 3 contracts if (contracts >= 3) { SerializeContractData(pickInfo[currentRound][currentPick].drafterID); playerProfiles[currentDrafter].contractDataWritten = true; pickInfo[currentRound][currentPick].playerPicked = currentPickedPlayer; playerProfiles[(int)pickInfo[currentRound][currentPick].drafterID].allPlayerPicks.Add(pickInfo[currentRound][currentPick].playerPicked); } else { // Two year contract slot is open if (playerProfiles[currentDrafter].twoYearContracts.Count == 0) { // Add player as 2 year contract playerProfiles[currentDrafter].twoYearContracts.Add(currentPickedPlayer); ++contracts; } // One year contract slot is open else if (playerProfiles[currentDrafter].oneYearContracts.Count == 0) { // Add player as 1 year contract playerProfiles[currentDrafter].oneYearContracts.Add(currentPickedPlayer); ++contracts; } // Done getting contracts so write this out if (contracts >= 3) { SerializeContractData(pickInfo[currentRound][currentPick].drafterID); playerProfiles[currentDrafter].contractDataWritten = true; } } } else { pickInfo[currentRound][currentPick].playerPicked = currentPickedPlayer; pickInfo[currentRound][currentPick].roundNumber = currentRound; pickInfo[currentRound][currentPick].pickNumber = currentPick; playerProfiles[(int)pickInfo[currentRound][currentPick].drafterID].allPlayerPicks.Add(pickInfo[currentRound][currentPick].playerPicked); } // Grab the pick text and clear the textbox. GameObject.Find("AlreadyPickedController").GetComponent <AlreadyPickedController>().AddPickToHistory(currentPickedPlayer, currentRound, currentPick); textBoxObject.GetComponent <InputField>().text = ""; textBoxObject.GetComponent <InputPickScript>().Hide(); confirmPickButton.GetComponent <ConfirmPickButton>().Hide(); makePickButton.GetComponent <MakePickButton>().Show(); // Cycle the pick now if (CycleToNextPick()) { return; } // Start next pick animation GoToDraftState(DraftState.AnimateToNextDrafter); }