public GamePlayViewModel(GamePlay gamePlay)
 {
     GamePlay = gamePlay;
     TeamRotation[] currentRotation = gamePlay.Sets[gamePlay.CurrentSetNumber].TeamRotations;
     int[] teamARotation = currentRotation[0].ShirtNumbers;
     int[] teamBRotation = currentRotation[1].ShirtNumbers;
     RotationForView = new TeamRotation[2]
     {
         new TeamRotation()
         {
             ShirtNumbers = new int[6]
             {
                 teamARotation[4],
                 teamARotation[5],
                 teamARotation[0],
                 teamARotation[3],
                 teamARotation[2],
                 teamARotation[1]
             }
         } ,
         new TeamRotation()
         {
             ShirtNumbers = new int[6]
             {
                 teamBRotation[1],
                 teamBRotation[2],
                 teamBRotation[3],
                 teamBRotation[0],
                 teamBRotation[5],
                 teamBRotation[4]
             }
         }
     };
 }
Beispiel #2
0
 //!! remove all refrences to use input data
 public static TeamRotation[] GetRandomTeamRotationModels()
 {
     var teamRotations = new TeamRotation[2];
     teamRotations[0] = new TeamRotation() { ShirtNumbers = GetRandomShirtNumbers(true) };
     teamRotations[1] = new TeamRotation() { ShirtNumbers = GetRandomShirtNumbers(false) };
     return teamRotations;
 }
Beispiel #3
0
        private TeamRotation Rotate(TeamRotation model)
        {
            if (model == null || model.ShirtNumbers == null || model.ShirtNumbers.Length != 6)
                throw new ArgumentException("Invalid team rotation model");

            TeamRotation rotatedModel = new TeamRotation();
            rotatedModel.ShirtNumbers = new int[6];
            rotatedModel.ShirtNumbers[0] = model.ShirtNumbers[1];
            rotatedModel.ShirtNumbers[1] = model.ShirtNumbers[2];
            rotatedModel.ShirtNumbers[2] = model.ShirtNumbers[3];
            rotatedModel.ShirtNumbers[3] = model.ShirtNumbers[4];
            rotatedModel.ShirtNumbers[4] = model.ShirtNumbers[5];
            rotatedModel.ShirtNumbers[5] = model.ShirtNumbers[0];
            return rotatedModel;
        }
Beispiel #4
0
 public Game StartGame(int bestOfNumberOfSets, TeamRotation[] teamRotations, int firstServe)
 {
     if (bestOfNumberOfSets % 2 == 0)
         throw new ArgumentException("Best of number of sets must be odd", "bestOfNumberOfSets");
     Guid gameId = Guid.NewGuid();
     var game = new Game
     {
         UniqueId = gameId,
         GamePlay = new GamePlay
         {
             GameId = gameId,
             Sets = new Set[bestOfNumberOfSets],
             SetWins = new int[2]
         },
         StartedAt = DateTime.Now
     };
     game.GamePlay = StartNewSet(game.GamePlay, teamRotations, firstServe);
     Save(game);
     return game;
 }
Beispiel #5
0
 public GamePlay StartNewSet(GamePlay game, TeamRotation[] teamRotations, int firstServe)
 {
     var highestActivatedSetNumber = game.GetHighestActivatedSetNumber();
     game.Sets[highestActivatedSetNumber + 1] = new Set
     {
         TeamRotations = teamRotations,
         Score = new int[2],
         FirstServer = firstServe,
         StartedAt = DateTime.Now,
         Information = new TeamInSetInformation[2]
                                                         {
                                                             new TeamInSetInformation() {  Substitutions = new Substitution[Constants.MaximumNumberOfSubstitutionsPerTeamPerSet], TimeOuts = new TimeOut[Constants.MaximumNumberOfTimeOutsPerTeamPerSet] },
                                                             new TeamInSetInformation() { Substitutions = new Substitution[Constants.MaximumNumberOfSubstitutionsPerTeamPerSet], TimeOuts = new TimeOut[Constants.MaximumNumberOfTimeOutsPerTeamPerSet] }
                                                         },
     };
     return game;
 }