Esempio n. 1
0
 public Game(bool? enableLogging = false, bool? autoFinish = false)
 {
     EnableLogging = enableLogging.HasValue && enableLogging.Value;
     AutoFinish = autoFinish.HasValue && autoFinish.Value;
     Tournament = new Tournament.Tournament(EnableLogging);
     CurrentBattleDetails = new BattleDetails();
 }
Esempio n. 2
0
 public void ProcessBattleResult(BattleDetails battleDetails)
 {
     var winningParticipant = Participants.First(i => i.Character.Name == battleDetails.WinnerName);
     winningParticipant.Battles++;
     winningParticipant.Status = ParticipantStatus.Active;
     var losingParticipant = Participants.First(i => i.Character.Name == battleDetails.LoserName);
     losingParticipant.Battles++;
     losingParticipant.Status = ParticipantStatus.KnockedOut;
     UpdateTournamentStatus();
     if (EnableLogging)
     {
         Logger.WriteBattleResult(
             winningParticipant.Character.SkillTree.Get().Where(i => i.IsActive).OrderByDescending(i => i.Level).First().Path
             + " defeated "
             + losingParticipant.Character.SkillTree.Get().Where(i => i.IsActive).OrderByDescending(i => i.Level).First().Path );
     }
 }
Esempio n. 3
0
 private void PopulateFights()
 {
     BattlesByRound.Add(Round, new List<BattleDetails>());
     var takenParticipants = 0;
     var validParticipants = Participants.Where(p => p.Status == ParticipantStatus.Active).ToList();
     if (validParticipants.Count < 2)
     {
         throw new Exception("Not enough valid participants to fight bro");
     }
     while (takenParticipants < Participants.Count)
     {
         var battleDetails = new BattleDetails();
         battleDetails.Participants.Add(validParticipants.ElementAt(takenParticipants));
         takenParticipants++;
         battleDetails.Participants.Add(validParticipants.ElementAt(takenParticipants));
         takenParticipants++;
         battleDetails.BattleMode = battleDetails.Participants.Any(p => p.Character is Player)
             ? BattleMode.PlayerVsComputer
             : BattleMode.ComputerVsComputer;
         BattlesByRound[Round].Add(battleDetails);
     }
 }
Esempio n. 4
0
 public void SimulateBattle(BattleDetails battleDetails)
 {
 }
Esempio n. 5
0
 public BattleReport BuildBattleReport(BattleDetails battleDetails)
 {
     var br = new BattleReport
     {
         BattleStatus = battleDetails.BattleStatus,
         PlayerWins = battleDetails.BattleStatus == BattleStatus.BattleOver && Player.Health > 0
     };
     return br;
 }
Esempio n. 6
0
 private void EndComputerVsComputerBattle()
 {
     if (Tournament.TournamentStatus == TournamentStatus.InProgress && AutoFinish)
     {
         CurrentBattleDetails = Tournament.GetNextBattleDetails();
         if (CurrentBattleDetails != null)
         {
             StartBattle();
         }
     }
 }
Esempio n. 7
0
 public void StartPlayerVsComputerTournament()
 {
     Tournament.TournamentMode = TournamentMode.PlayerVsComputer;
     Tournament.AddCharacterToTournament(Player);
     Tournament.Populate();
     Tournament.Start();
     CurrentBattleDetails = Tournament.GetNextBattleDetails();
     StartBattle();
 }
Esempio n. 8
0
 public void StartComputerVsComputerGame()
 {
     Tournament.TournamentMode = TournamentMode.ComputerVsComputer;
     Tournament.Populate();
     Tournament.Start();
     CurrentBattleDetails = Tournament.GetNextBattleDetails();
     StartBattle();
 }
Esempio n. 9
0
 public void SimulateComputerVsComputerBattle(Guid battleGuid)
 {
     CurrentBattleDetails = Tournament.GetBattleByGuid(battleGuid);
     StartBattle();
 }
Esempio n. 10
0
 public void SimulateAllComputerBattles()
 {
     Tournament.BattlesByRound[Tournament.Round]
         .Where(b => b.BattleMode == BattleMode.ComputerVsComputer && b.BattleStatus == BattleStatus.NotStarted)
         .ToList()
         .ForEach(b =>
         {
             CurrentBattleDetails = b;
             StartBattle();
         });
 }