public static void UpdateMoralePoints() { try { if (!fpwEnable || MatchMain.inst.isInterruptedMatch || promotion == null) { return; } MatchEvaluation evaluation = global::MatchEvaluation.inst; //Variables for Match Details String titleMatch = ""; bool winnerLogged = false; bool loserLogged = false; bool isFinals = IsTourneyFinals(); MatchSetting matchSetting = GlobalWork.inst.MatchSetting; //Get Loser int rating = evaluation.EvaluateMatch(); bool isDraw = false; //Update Morale Points for (int i = 0; i < 8; i++) { Employee employee = employeeData[i]; if (employee == null) { continue; } int moralePoints = 0; Player player = PlayerMan.inst.GetPlObj(i); //Verify that employee and player match employee = VerifyEmployeeMatch(employee, DataBase.GetWrestlerFullName(player.WresParam), promotion); //This occurs if an invalid employee is selected. //Handles cases where ModPack Royal Rumbles could include a winner from another promotion. if (employee == null) { continue; } //Ensure intruders are exempt if (player.isIntruder) { continue; } bool isWinner = true; //Check Match Rating moralePoints += EvaluateMatchRating(rating); //Check Win Condition //Losers only checked if the match IS NOT a Battle Royal if (CheckWinCondition(evaluation)) { if (evaluation.PlResult[i].resultPosition == ResultPosition.Loser && matchSetting.BattleRoyalKind == BattleRoyalKindEnum.Off) { moralePoints -= 1; //Determine Skill rank of the winner Player winner = GetPlayer(ResultPosition.Winner); int rankPoints = CompareRank(winner, player, ResultPosition.Loser); moralePoints += rankPoints; isWinner = false; //Record if this was an upset victory if (rankPoints != 0) { promotion.AddHistory(DateTime.Now.ToString("MM/dd/yyyy HH:mm") + "-" + DataBase.GetWrestlerFullName(winner.WresParam) + " has scored an upset victory against " + DataBase.GetWrestlerFullName(player.WresParam) + "."); } } else if (evaluation.PlResult[i].resultPosition == ResultPosition.Winner) { moralePoints += 1; //Determine Skill rank of loser Player loser = GetPlayer(ResultPosition.Loser); int rankPoints = CompareRank(player, loser, ResultPosition.Winner); moralePoints += rankPoints; //Additional points for winning a Battle Royal if (matchSetting.BattleRoyalKind != BattleRoyalKindEnum.Off) { L.D("Adding points for Battle Royal win to " + DataBase.GetWrestlerFullName(player.WresParam)); //Determine how many points the employee receives //Based on Employee Morale Rank and Number of Opponents int points = 0; if (playerNum <= 3) { points = 2; } else if (playerNum <= 7) { points = 3; } else { points = 4; } if (employee.MoraleRank == 1) { points *= 2; } else if (employee.MoraleRank == 0) { points *= 3; } L.D("Morale Rank: " + employee.MoraleRank + "\nParticipant Number: " + playerNum); moralePoints += points; } } else if (evaluation.PlResult[i].resultPosition == ResultPosition.Winner_Partner && matchSetting.BattleRoyalKind == BattleRoyalKindEnum.Off) { moralePoints += 1; } else if (evaluation.PlResult[i].resultPosition == ResultPosition.Loser_Partner && matchSetting.BattleRoyalKind == BattleRoyalKindEnum.Off) { moralePoints -= 1; isWinner = false; } } else { isDraw = true; } //Check For Title Match if (GlobalParam.TitleMatch_BeltData != null && isFinals) { titleMatch = GlobalParam.TitleMatch_BeltData.titleName.ToUpper() + " - "; String champion = GlobalParam.TitleMatch_BeltData.GetCurrentTitleHolderName(); if (evaluation.ResultType == MatchResultEnum.RingOutDraw || evaluation.ResultType == MatchResultEnum.TimeOutDraw) { moralePoints += 1; } //Removing belt from previous champion else if ((evaluation.PlResult[i].resultPosition == ResultPosition.Loser || evaluation.PlResult[i].resultPosition == ResultPosition.Loser_Partner) && i >= 4) { //Ensure that we aren't logging information in Event History multiple times. if (!loserLogged) { promotion.AddHistory(DateTime.Now.ToString("MM/dd/yyyy HH:mm") + "-" + GetTeamName(ResultPosition.Loser) + " has lost the " + GlobalParam.TitleMatch_BeltData.titleName.ToUpper() + "."); loserLogged = true; } moralePoints -= 3; } //Awarding a new champion else if ((evaluation.PlResult[i].resultPosition == ResultPosition.Winner || evaluation.PlResult[i].resultPosition == ResultPosition.Winner_Partner) && i < 4) { int championNumber = GlobalParam.TitleMatch_BeltData.titleMatch_Record_Data.Count + 1; string ordinalNumber = global::TitleMatch_Data.GetOrdinalNumberString(championNumber); //Ensure that we aren't logging information in Event History multiple times. if (!winnerLogged) { promotion.AddHistory(DateTime.Now.ToString("MM/dd/yyyy HH:mm") + "-" + GetTeamName(ResultPosition.Winner) + " has gained the " + GlobalParam.TitleMatch_BeltData.titleName.ToUpper() + " and becomes the " + ordinalNumber + "."); winnerLogged = true; } moralePoints += (6 - employee.MoraleRank); } //Logging record for a successful defense else if (evaluation.PlResult[i].resultPosition == ResultPosition.Winner || evaluation.PlResult[i].resultPosition == ResultPosition.Winner_Partner && i >= 4) { int defenseNumber = GlobalParam.TitleMatch_BeltData.GetLatestMatchRecord().DefenseCount; string ordinalNumber = global::TitleMatch_Data.GetOrdinalNumberString(defenseNumber); Player loser = GetPlayer(ResultPosition.Loser); //Ensure that we aren't logging information in Event History multiple times. if (!winnerLogged) { promotion.AddHistory(DateTime.Now.ToString("MM/dd/yyyy HH:mm") + "-" + GetTeamName(ResultPosition.Winner) + " successfully defend(s) the " + GlobalParam.TitleMatch_BeltData.titleName.ToUpper() + " (" + ordinalNumber + " defense) against " + GetTeamName(ResultPosition.Loser) + "."); winnerLogged = true; } } } //Check for the defeat of champions in a non-title match if (hasChamp) { TitleMatch_Data data = titleData[GetPlayer(ResultPosition.Loser).PlIdx]; if (data != null) { //Singles match details if (GetPlayer(ResultPosition.Winner).PlIdx == i) { moralePoints += 3; promotion.AddHistory(DateTime.Now.ToString("MM/dd/yyyy HH:mm") + "-" + DataBase.GetWrestlerFullName(GetPlayer(ResultPosition.Winner) .WresParam) + " has defeated " + DataBase.GetWrestlerFullName(GetPlayer(ResultPosition.Loser) .WresParam) + " (" + data.titleName.ToUpper() + " champion) in a non-title match."); } } } //Determine whether the player won a league or tournament if ((GlobalParam.m_BattleMode == GlobalParam.BattleMode.Tournament) && isFinals) { if (evaluation.PlResult[i].resultPosition == ResultPosition.Winner || evaluation.PlResult[i].resultPosition == ResultPosition.Winner_Partner && !player.isSecond && !player.isIntruder) { String eventType = "tournament"; //Ensure that we aren't logging information in Event History multiple times. if (!winnerLogged) { promotion.AddHistory(DateTime.Now.ToString("MM/dd/yyyy HH:mm") + "-" + GetTeamName(ResultPosition.Winner) + " has recently won a " + eventType.ToUpper() + "."); winnerLogged = true; } moralePoints += (6 - employee.MoraleRank); } } //Check Employee Health if (player.isKO) { moralePoints -= 1; promotion.AddHistory(DateTime.Now.ToString("MM/dd/yyyy HH:mm") + "-" + employee.Name + " has been knocked out."); } String injury = ""; if (player.HP_Arm <= 0) { moralePoints -= 1; if (War_Form.form.fpw_armInjuries.Items.Count == 0) { injury = "extreme arm damage"; } else { injury = (String)War_Form.form.fpw_armInjuries.Items[UnityEngine.Random.Range(0, War_Form.form.fpw_armInjuries.Items.Count)]; } promotion.AddHistory(DateTime.Now.ToString("MM/dd/yyyy HH:mm") + "-" + employee.Name + " has suffered " + injury + "."); } if (player.HP_Neck <= 0) { moralePoints -= 1; if (War_Form.form.fpw_neckInjuries.Items.Count == 0) { injury = "extreme neck damage"; } else { injury = (String)War_Form.form.fpw_neckInjuries.Items[UnityEngine.Random.Range(0, War_Form.form.fpw_neckInjuries.Items.Count)]; } promotion.AddHistory(DateTime.Now.ToString("MM/dd/yyyy HH:mm") + "-" + employee.Name + " has suffered " + injury + "."); } if (player.HP_Waist <= 0) { moralePoints -= 1; if (War_Form.form.fpw_waistInjuries.Items.Count == 0) { injury = "extreme waist damage"; } else { injury = (String)War_Form.form.fpw_waistInjuries.Items[UnityEngine.Random.Range(0, War_Form.form.fpw_waistInjuries.Items.Count)]; } promotion.AddHistory(DateTime.Now.ToString("MM/dd/yyyy HH:mm") + "-" + employee.Name + " has suffered " + injury + "."); } if (player.HP_Leg <= 0) { moralePoints -= 1; if (War_Form.form.fpw_legInjuries.Items.Count == 0) { injury = "extreme leg damage"; } else { injury = (String)War_Form.form.fpw_legInjuries.Items[UnityEngine.Random.Range(0, War_Form.form.fpw_legInjuries.Items.Count)]; } promotion.AddHistory(DateTime.Now.ToString("MM/dd/yyyy HH:mm") + "-" + employee.Name + " has suffered " + injury + "."); } //Update Employee Details employee.MoralePoints += moralePoints; //Ensure that Seconds do not gain a record update if (!player.isSecond) { employee.MatchCount += 1; if (isDraw) { employee.Draws += 1; } else if (isWinner) { employee.Wins += 1; } else if (!isWinner) { employee.Losses += 1; } if (employee.MatchCount == 1) { employee.AverageRating = rating; } else { employee.AverageRating = (employee.AverageRating + rating) / 2; } } War_Form.form.UpdateEmployeeMorale(employee, isWinner); } //Update Promotion Details if (CheckWinCondition(evaluation) || isDraw) { promotion.MatchCount += 1; if (promotion.AverageRating == 0) { promotion.AverageRating = rating; } else { promotion.AverageRating = (promotion.AverageRating + rating) / 2; } String matchDetails = ""; //Ensure that we're tracking Battle Royale Results if (matchSetting.BattleRoyalKind != BattleRoyalKindEnum.Off) { matchDetails = promotion.MatchDetails.Count + 1 + ") " + DateTime.Now.ToString("MM/dd/yyyy HH:mm") + " - " + titleMatch + GetTeamName(ResultPosition.Winner) + " has won a Battle Royal Match!"; try { //Adding Rumble Statistics Employee emp = new Employee { Name = String.Empty }; string mostElims = RumbleForm.GetMatchStat(MatchStatEnum.MostEliminations); string longest = RumbleForm.GetMatchStat(MatchStatEnum.LongestTime); string shortest = RumbleForm.GetMatchStat(MatchStatEnum.ShortestTime); if (mostElims != "NONE") { Employee statElim = VerifyEmployeeMatch(emp, mostElims, promotion); if (statElim != null) { statElim.MoralePoints += 3; War_Form.form.UpdateEmployeeMorale(statElim, true); L.D("Most Eliminations: " + statElim.Name); matchDetails += " - Most Eliminations: " + mostElims; } } if (longest != "NONE") { Employee statlong = VerifyEmployeeMatch(emp, longest, promotion); if (statlong != null) { statlong.MoralePoints += 3; War_Form.form.UpdateEmployeeMorale(statlong, true); L.D("Longest Time: " + statlong.Name); matchDetails += " - Longest Time: " + longest; } } if (shortest != "NONE") { Employee statshort = VerifyEmployeeMatch(emp, shortest, promotion); if (statshort != null) { statshort.MoralePoints -= 3; War_Form.form.UpdateEmployeeMorale(statshort, false); L.D("Shortest Time: " + statshort.Name); matchDetails += " - Shortest Time: " + shortest; } } } catch (Exception e) { L.D("Error while attempting to add ModPack Rumble stats: " + e); } } else if (isDraw) { matchDetails = promotion.MatchDetails.Count + 1 + ") " + DateTime.Now.ToString("MM/dd/yyyy HH:mm") + " - " + titleMatch + "Draw between " + GetTeamName(ResultPosition.Draw) + " (" + rating + "%)."; } else { matchDetails = promotion.MatchDetails.Count + 1 + ") " + DateTime.Now.ToString("MM/dd/yyyy HH:mm") + " - " + titleMatch + GetTeamName(ResultPosition.Winner) + " defeat(s) " + GetTeamName(ResultPosition.Loser) + " (" + rating + "%) in " + MatchEvaluation.inst.PlResult[GetPlayer(ResultPosition.Loser).PlIdx].finishTime.min + " minutes."; } promotion.AddMatchDetails(matchDetails); War_Form.form.UpdatePromotionData(promotion); } } catch (Exception ex) { L.D("UpdateMoralePointException: " + ex); } }