Ejemplo n.º 1
0
 private void AddJammer(JammerGateway jammerGateway, Dictionary<string, Player> playerMap, Jam jam, ScoreModel scoreModel, bool passedStar, bool receivedStar)
 {
     if (scoreModel != null && !string.IsNullOrWhiteSpace(scoreModel.PlayerNumber))
     {
         jammerGateway.AddJammer(jam.ID, playerMap[scoreModel.PlayerNumber].ID, scoreModel.JamTotal,
             scoreModel.Lost, scoreModel.Lead, scoreModel.Called, scoreModel.Injury, scoreModel.NoPass, passedStar, receivedStar);
     }
 }
Ejemplo n.º 2
0
 public PenaltyProcessor(IList<Jam> jams, Dictionary<string, Player> homePlayers, Dictionary<string, Player> awayPlayers)
 {
     _jams = jams;
     _players = homePlayers.Values.ToDictionary(p => p.ID);
     foreach(Player player in awayPlayers.Values)
     {
         _players[player.ID] = player;
     }
     _lastJam = _jams.Last();
 }
Ejemplo n.º 3
0
 private List<JamPlayer> AddJamPlayers(Dictionary<string, Player> playerMap, Jam jam, IList<PlayerLineupModel> lineups, JamPlayerGateway gateway)
 {
     List<JamPlayer> list = new List<JamPlayer>();
     foreach (PlayerLineupModel lineup in lineups)
     {
         if(lineup == null)
         {
             // TODO: handle null players
             Console.WriteLine(jam.ToString() + ": empty player spot");
             continue;
         }
         Player player = playerMap[lineup.PlayerNumber];
         list.Add(gateway.AddJamPlayer(jam.ID, player.ID, player.TeamID, lineup.IsJammer, lineup.IsPivot));
     }
     return list;
 }
Ejemplo n.º 4
0
        private List<JamPlayer> AddJamPlayers(Dictionary<string, Player> playerMap, Jam jam, IList<PlayerLineupModel> lineups, JamPlayerGateway gateway)
        {
            List<JamPlayer> list = new List<JamPlayer>();
            List<string> duplicateCheckList = new List<string>();
            foreach (PlayerLineupModel lineup in lineups)
            {
                if(lineup == null)
                {
                    // TODO: handle null players
                    Console.WriteLine(jam.ToString() + ": empty player spot");
                    continue;
                }
                if (duplicateCheckList.Contains(lineup.PlayerNumber))
                {
                    throw new InvalidOperationException(string.Format("{0}: #{1} in lineup multiple times.", jam, lineup.PlayerNumber));
                }

                duplicateCheckList.Add(lineup.PlayerNumber);
                Player player = playerMap[lineup.PlayerNumber];
                list.Add(gateway.AddJamPlayer(jam.ID, player.ID, player.TeamID, lineup.IsJammer, lineup.IsPivot));
            }
            return list;
        }
Ejemplo n.º 5
0
 private bool IsBoxTimePossibleForPenalty(Jam penaltyJam, Jam boxTimeJam)
 {
     return CompareJams(penaltyJam, boxTimeJam) >= 0;
 }
Ejemplo n.º 6
0
 private int CompareJams(Jam jam1, Jam jam2)
 {
     if (jam1.IsFirstHalf && !jam2.IsFirstHalf)
     {
         return -1;
     }
     else if (jam2.IsFirstHalf && !jam1.IsFirstHalf)
     {
         return 1;
     }
     else if (jam1.JamNumber < jam2.JamNumber)
     {
         return -1;
     }
     else if (jam2.JamNumber < jam1.JamNumber)
     {
         return 1;
     }
     else return 0;
 }
Ejemplo n.º 7
0
 internal Jam ReadData(SqlDataReader reader)
 {
     Jam jam = new Jam();
     jam.BoutID = reader.GetInt32(reader.GetOrdinal("BoutID"));
     jam.ID = reader.GetInt32(reader.GetOrdinal("ID"));
     jam.IsFirstHalf = reader.GetBoolean(reader.GetOrdinal("IsFirstHalf"));
     jam.JamNumber = reader.GetInt32(reader.GetOrdinal("JamNum"));
     return jam;
 }