public FightOutcome SimulateFight(Main.Fight fight) { Random rand = new Random(Guid.NewGuid().GetHashCode()); Fighter winner; int f1 = int.Parse(String.Join("", fight.Fighter0().Name.Where(char.IsDigit))); int f2 = int.Parse(String.Join("", fight.Fighter1().Name.Where(char.IsDigit))); if (f1 > f2) { // fighter 1 won updateElo(fight.Fighter0(), fight.Fighter1()); winner = fight.Fighter0(); fight.Fighter0().Record.Wins++; fight.Fighter1().Record.Losses++; } else { updateElo(fight.Fighter1(), fight.Fighter0()); winner = fight.Fighter1(); fight.Fighter1().Record.Wins++; fight.Fighter0().Record.Losses++; } FightOutcome fo = new FightOutcome(0, FightSim.MethodOfResult.NC, winner, null, fight.Fighers); fo.Viewership = getNetworkViewers(fight.Fighter0().Record.Rank, fight.Fighter1().Record.Rank); fight.Outcome = fo; return(fo); }
private FightOutcome DetermineFightResult() { Fighter winner = null; FightOutcome outcome; MethodOfResult method = MethodOfResult.UD; if (TimeOfStoppage != -1) { winner = F1.Health <= 0 ? Boxer2() : Boxer1(); outcome = new FightOutcome(TimeOfStoppage, MethodOfResult.KO, winner, Scorecards, Fight); } else { int[] cardsWon = { 0, 0 }; for (int card = 0; card < Scorecards.GetLength(0); ++card) { if (Scorecards[card, 0] > Scorecards[card, 1]) { ++cardsWon[0]; } else if (Scorecards[card, 0] < Scorecards[card, 1]) { ++cardsWon[1]; } } if (cardsWon[0] > cardsWon[1]) { winner = Boxer1(); } else if (cardsWon[0] < cardsWon[1]) { winner = Boxer2(); } if (Math.Abs(cardsWon[0] - cardsWon[1]) < 3) { method = MethodOfResult.MD; } outcome = new FightOutcome(-1, method, winner, Scorecards, Fight); } return(outcome); }
public void UpdateRecord(FightSim.FightOutcome outcome) { if (outcome.IsDraw()) { ++Record.Draws; } else if (outcome.Winner == this) { ++Record.Wins; if (outcome.IsKO()) { ++Record.KOs; } } else { ++Record.Losses; } }
public void EndOfRound() { int round = CurrentRound(); for (int j = 0; j < Fight.Judges.Length; ++j) //Score Round { int[] roundScore = Fight.Judges[j].ScoreRound(Punches[round], FightStats[round]); Scorecards[j, 0] += roundScore[0]; Scorecards[j, 1] += roundScore[1]; } ; if (Concluded) //If not concluded, set up the next round { Outcome = DetermineFightResult(); } else { F1.RecoverFor(60); F2.RecoverFor(60); InitNextRound(); } }