Esempio n. 1
0
        //If player attended most recent Monday game
        public Game FindMondayGameOfSameLevelInSameWeek(Pool fridayPool, DateTime fridayGameDate)
        {
            Pool mondayPool = Pools.Find(p => p.DayOfWeek != fridayPool.DayOfWeek && p.IsLowPool == fridayPool.IsLowPool);
            Game mondayGame = mondayPool.Games.OrderByDescending(game => game.Date).ToList <Game>().Find(game => game.Date < fridayGameDate);

            if (mondayGame == null || mondayGame.Date.AddDays(7) < fridayGameDate.Date)
            {
                return(null);
            }
            return(mondayGame);
        }
Esempio n. 2
0
        //

        /*     public bool IsPlayerAttendedThisMondayGameWithPowerReserveFactor(Pool fridayPool, DateTime fridayGameDate, Player player)
         *   {
         *       if (fridayPool.Dropins.FindByPlayerId(player.Id).WaiveBenefit || !IsPlayerAttendedThisWeekMondayGame(fridayGameDate, player)) return false;
         *       Pool mondayPool = Pools.Find(p => p.DayOfWeek != fridayPool.DayOfWeek && p.IsLowPool == fridayPool.IsLowPool);
         *       Game mostRecentGame = mondayPool.Games.Find(game => game.Date.AddDays(4) == fridayGameDate.Date);
         *       return mostRecentGame != null && mostRecentGame.Factor >= mondayPool.FactorForPowerReserve;
         *   }
         */
        //Calculate factor for current moment
        public void ReCalculateFactor(Pool pool, DateTime gameDate)
        {
            Pool anotherDayPoolWithSameLevel      = Pools.Find(p => p.DayOfWeek != pool.DayOfWeek && p.IsLowPool == pool.IsLowPool);
            Pool anotherDayPoolWithDifferentLevel = Pools.Find(p => p.DayOfWeek != pool.DayOfWeek && p.IsLowPool != pool.IsLowPool);
            Game game = pool.FindGameByDate(gameDate);
            int  currentPoolNumberOfPlayer = game.NumberOfReservedPlayers;
            Pool sameDayPool                = Pools.Find(p => p.DayOfWeek == pool.DayOfWeek && p.Name != pool.Name);
            Game sameDayPoolGame            = sameDayPool.FindGameByDate(gameDate);
            int  sameDayPoolNumberOfPlayers = sameDayPoolGame.NumberOfReservedPlayers;

            if (pool.IsLowPool)
            {
                int    coopNumberOfPlayers = sameDayPool.FindGameByDate(gameDate).Dropins.Items.FindAll(pickup => pickup.IsCoop && pickup.Status == InOutNoshow.In).Count;
                Factor factor = Factors.Find(f => f.PoolName == anotherDayPoolWithSameLevel.Name && f.LowPoolName == pool.Name && f.LowPoolNumberFrom <= currentPoolNumberOfPlayer && currentPoolNumberOfPlayer <= f.LowPoolNumberTo && //
                                             f.CoopNumberFrom <= coopNumberOfPlayers && coopNumberOfPlayers <= f.CoopNumberTo && f.HighPoolName == sameDayPool.Name && f.HighPoolNumberFrom <= sameDayPoolNumberOfPlayers &&            //
                                             sameDayPoolNumberOfPlayers <= f.HighPoolNumberTo);
                if (factor != null)
                {
                    game.Factor = factor.Value;
                }
                factor = Factors.Find(f => f.PoolName == anotherDayPoolWithDifferentLevel.Name && f.LowPoolName == pool.Name && f.LowPoolNumberFrom <= currentPoolNumberOfPlayer && currentPoolNumberOfPlayer <= f.LowPoolNumberTo && //
                                      f.CoopNumberFrom <= coopNumberOfPlayers && coopNumberOfPlayers <= f.CoopNumberTo && f.HighPoolName == sameDayPool.Name && f.HighPoolNumberFrom <= sameDayPoolNumberOfPlayers &&                 //
                                      sameDayPoolNumberOfPlayers <= f.HighPoolNumberTo);
                if (factor != null)
                {
                    sameDayPoolGame.Factor = factor.Value;
                }
            }
            else
            {
                int    coopNumberOfPlayers = pool.FindGameByDate(gameDate).Dropins.Items.FindAll(pickup => pickup.IsCoop && pickup.Status == InOutNoshow.In).Count;
                Factor factor = Factors.Find(f => f.PoolName == anotherDayPoolWithSameLevel.Name && f.LowPoolName == sameDayPool.Name && f.LowPoolNumberFrom <= sameDayPoolNumberOfPlayers && sameDayPoolNumberOfPlayers <= f.LowPoolNumberTo && //
                                             f.CoopNumberFrom <= coopNumberOfPlayers && coopNumberOfPlayers <= f.CoopNumberTo && f.HighPoolName == pool.Name && f.HighPoolNumberFrom <= currentPoolNumberOfPlayer &&                             //
                                             currentPoolNumberOfPlayer <= f.HighPoolNumberTo);
                if (factor != null)
                {
                    game.Factor = factor.Value;
                }
                factor = Factors.Find(f => f.PoolName == anotherDayPoolWithDifferentLevel.Name && f.LowPoolName == sameDayPool.Name && f.LowPoolNumberFrom <= sameDayPoolNumberOfPlayers && sameDayPoolNumberOfPlayers <= f.LowPoolNumberTo && //
                                      f.CoopNumberFrom <= coopNumberOfPlayers && coopNumberOfPlayers <= f.CoopNumberTo && f.HighPoolName == pool.Name && f.HighPoolNumberFrom <= currentPoolNumberOfPlayer &&                                  //
                                      currentPoolNumberOfPlayer <= f.HighPoolNumberTo);
                if (factor != null)
                {
                    sameDayPoolGame.Factor = factor.Value;
                }
            }
        }
Esempio n. 3
0
 public Pool FindSameLevelPool(Pool pool)
 {
     return(Pools.Find(p => p.DayOfWeek != pool.DayOfWeek && pool.IsLowPool == p.IsLowPool));
 }
Esempio n. 4
0
 public Pool FindSameDayPool(Pool pool)
 {
     return(Pools.Find(p => p.DayOfWeek == pool.DayOfWeek && pool.IsLowPool != p.IsLowPool));
 }