Example #1
0
        public VisualizationSystemContext(DbContextOptions <VisualizationSystemContext> options)
            : base(options)
        {
            Database.EnsureCreated();

            if (!Teams.Any())
            {
                var team1 = new Teams()
                {
                    Id         = Guid.NewGuid().ToString(),
                    Name       = "営業1課",
                    Department = 1,
                };
                Teams.Add(team1);
                Users.Add(new Users()
                {
                    Id          = Guid.NewGuid().ToString(),
                    Name        = "Test User",
                    AccountName = "testuser",
                    Password    = "******",
                    Rank        = 1,
                    Department  = team1.Department,
                    TeamId      = team1.Id,
                    Theme       = 0,
                    Obsolete    = false,
                });
                SaveChanges();
            }
        }
Example #2
0
File: CTF.cs Project: LordEnigma/UO
        public override bool Validate(Mobile viewer, List <string> errors, bool pop = true)
        {
            if (!base.Validate(viewer, errors, pop) && pop)
            {
                return(false);
            }

            if (CapsToWin < 1)
            {
                errors.Add("CapsToWin value must be equal to or greater than 1.");
                errors.Add("[Options] -> [Edit Options]");
            }

            if (Teams.Any(t => !(t is CTFTeam)))
            {
                errors.Add("One or more teams are not of the CTFTeam type.");
                errors.Add("[Options] -> [View Teams]");

                if (pop)
                {
                    return(false);
                }
            }

            return(true);
        }
Example #3
0
        public int PointsFor(TeamName teamName)
        {
            if (!Teams.Any(teamName.Matches))
            {
                throw new ArgumentException("£");
            }

            return(teamName.Matches(Winner) ? (Date.Year < 1981) ? 2 : 3 : teamName.Matches(Loser) ? 0 : 1);
        }
Example #4
0
        public double SquaredDistanceTo(IGeographical other)
        {
            if (!Teams.Any())
            {
                return(0.0);
            }

            return((Latitude - other.Latitude) * (Latitude - other.Latitude) + (Longitude - other.Longitude) * (Longitude - other.Longitude));
        }
Example #5
0
        public static void AddTeam(Team team)
        {
            if (Teams.Any(t => t.Name.Equals(team.Name)))
            {
                throw new Exception("Team " + team.Name + " already exists");
            }

            teams.Add(team);
            Console.WriteLine("Successfully added Team {0}", team.Name);
        }
Example #6
0
    public void UpdateNotify()
    {
        if (IsUpdateNotify == false || Teams == null)
        {
            return;
        }

        IsUpdateNotify = false;

        IsNotify = Teams.Any(t => t.IsNotify);
    }
Example #7
0
        public void DeleteTeam(Guid teamId)
        {
            if (Teams.Any(team => team.Id != teamId && team.State != State.Active))
            {
                throw new Exception();
            }

            Teams
            .First(team => team.Id == teamId)
            .Delete();
        }
Example #8
0
        public bool IsOver()
        {
            var multipleTypes = Teams.Any(team => team.IsDouble) && Teams.Any(team => !team.IsDouble);
            var result        = Winner.Any();

            if (multipleTypes && Winner.Count != 2)
            {
                result = false;
            }
            return(result);
        }
Example #9
0
 public DomainResult AddTeam(TeamReadModel teamId)
 {
     if (SeasonIsStarted)
     {
         return(DomainResult.Error(new SeasonAllreadyStarted()));
     }
     if (Teams.Any(t => t == teamId.TeamId))
     {
         return(DomainResult.Error(new CanNotAddTeamTwice(teamId.TeamId)));
     }
     return(DomainResult.Ok(new TeamAddedToSeason(SeasonId, teamId.TeamId)));
 }
 public TeamListing ToTeamListing()
 {
     return(new TeamListing
     {
         TeamListingId = ClubId,
         ClubOrTeamName = ClubName,
         ClubOrTeamRoute = ClubRoute,
         Active = Teams.Any(x => !x.UntilYear.HasValue),
         PlayerTypes = Teams.Select(x => x.PlayerType).Distinct().ToList(),
         MatchLocations = Teams.SelectMany(x => x.MatchLocations).Distinct(new MatchLocationEqualityComparer()).ToList()
     });
 }
Example #11
0
        public bool UpdateTeamName(Guid teamId, string name)
        {
            if (Teams.Any(team => team.Id != teamId))
            {
                throw new Exception();
            }

            Teams
            .First(team => team.Id == teamId)
            .UpdateName(name);

            return(true);
        }
Example #12
0
        public bool UpdateTeamDescription(Guid teamId, string description)
        {
            if (Teams.Any(team => team.Id != teamId))
            {
                throw new Exception();
            }

            Teams
            .First(team => team.Id == teamId)
            .UpdateDescription(description);

            return(true);
        }
Example #13
0
        public bool UpdateTeamPoints(Guid teamId, int points)
        {
            if (Teams.Any(team => team.Id != teamId))
            {
                throw new Exception();
            }

            Teams
            .First(team => team.Id == teamId)
            .UpdatePoints(points);

            return(true);
        }
Example #14
0
        public Team GetTeamByNameOrCreate(string teamName)
        {
            if (Teams.Any(team => team.Name == teamName))
            {
                return(Teams.Where(team => team.Name == teamName).FirstOrDefault());
            }

            Team team = new Team();

            team.Name = teamName;
            Teams.Add(team);
            return(team);
        }
Example #15
0
        public bool UpdateTeamOwner(Guid teamId, Guid teamOwnerId)
        {
            if (Teams.Any(team => team.Id != teamId))
            {
                throw new Exception();
            }

            Teams
            .First(team => team.Id == teamId)
            .UpdateTeamOwner(teamOwnerId);

            return(true);
        }
Example #16
0
        public void AddTeam(string teamName,
                            Guid teamOwnerId,
                            string description)
        {
            if (Teams.Any(team => team.Name == teamName))
            {
                throw new Exception();
            }

            var team = TeamFactory.Create(teamName, teamOwnerId, Id, description);

            Teams.Add(team);
        }
Example #17
0
        public Match PlayMatch(Team home, Team away, int gameWeek)
        {
            if (!(Teams.Any(x => x.Name == home.Name) && Teams.Any(x => x.Name == away.Name)))
            {
                throw new TeamNotInLeagueException();
            }

            var match = new Match(home, away, gameWeek);

            AddMatch(match, gameWeek);

            return(match);
        }
Example #18
0
        public async Task OnGet()
        {
            var members = (await _repository.GetAllAsync <TeamMember>())
                          .OrderBy(m => m.TeamName);

            AllTeams = members.Select(m => m.TeamName)
                       .Distinct();

            if (Teams == null || !Teams.Any())
            {
                Teams       = Enumerable.Empty <string>();
                TeamMembers = members;
            }
            else
            {
                TeamMembers = members.Where(m => Teams.Contains(m.TeamName));
            }
        }
Example #19
0
        public override bool Validate(Mobile viewer, List <string> errors, bool pop = true)
        {
            if (!base.Validate(viewer, errors, pop) && pop)
            {
                return(false);
            }

            if (Teams.Any(t => !(t is UOF_PvPTeam)))
            {
                errors.Add("One or more teams are not of the UOF_PvPTeam type.");
                errors.Add("[Options] -> [View Teams]");

                if (pop)
                {
                    return(false);
                }
            }

            return(true);
        }
Example #20
0
        public override int[] GetBestTeams()
        {
            if (!Teams.Any())
            {
                return(new int[] { 0, 0 });
            }

            var orderedQueueTeams = new Queue <ITeam>(Teams.OrderByDescending(x => x.TeamScore));

            var maxScore = orderedQueueTeams.First().TeamScore;

            int bestTeamsCount = 0;

            while (orderedQueueTeams.First().TeamScore == maxScore)
            {
                orderedQueueTeams.Dequeue();
                bestTeamsCount++;
            }

            return(new int[] { maxScore, bestTeamsCount });
        }
Example #21
0
        public virtual bool Validate(Mobile viewer, List <string> errors, bool pop = true)
        {
            if (Deleted)
            {
                errors.Add("This battle has been deleted.");
                return(false);
            }

            if (String.IsNullOrWhiteSpace(Name))
            {
                errors.Add("Select a valid Name.");
                errors.Add("[Options] -> [Edit Options]");

                if (pop)
                {
                    return(false);
                }
            }

            if (String.IsNullOrWhiteSpace(Description))
            {
                errors.Add("Select a valid Description.");
                errors.Add("[Options] -> [Edit Options]");

                if (pop)
                {
                    return(false);
                }
            }

            if (SpectateAllowed)
            {
                if (SpectateRegion == null)
                {
                    errors.Add("Select a valid Spectate Region.");
                    errors.Add("[Options] -> [Edit Spectage Region]");

                    if (pop)
                    {
                        return(false);
                    }
                }
                else if (Options.Locations.SpectateBounds.Count == 0)
                {
                    errors.Add("The Spectate Region has no zones.");
                    errors.Add("[Options] -> [Edit Spectage Region]");

                    if (pop)
                    {
                        return(false);
                    }
                }
            }

            if (BattleRegion == null)
            {
                errors.Add("Select a valid Battle Region.");
                errors.Add("[Options] -> [Edit Battle Region]");

                if (pop)
                {
                    return(false);
                }
            }
            else if (Options.Locations.BattleBounds.Count == 0)
            {
                errors.Add("The Battle Region has no zones.");
                errors.Add("[Options] -> [Edit Battle Region]");

                if (pop)
                {
                    return(false);
                }
            }

            if (Options.Locations.Map == Map.Internal)
            {
                errors.Add("The Battle Map must not be Internal.");
                errors.Add("[Options] -> [Edit Advanced Options] -> [Locations]");

                if (pop)
                {
                    return(false);
                }
            }

            if (Options.Locations.Eject.Internal)
            {
                errors.Add("The Eject Map must not be Internal.");
                errors.Add("[Options] -> [Edit Advanced Options] -> [Locations]");

                if (pop)
                {
                    return(false);
                }
            }

            if (Options.Locations.Eject == Point3D.Zero)
            {
                errors.Add("Select a valid Eject Location.");
                errors.Add("[Options] -> [Edit Advanced Options] -> [Locations]");

                if (pop)
                {
                    return(false);
                }
            }
            else if (BattleRegion != null && BattleRegion.Contains(Options.Locations.Eject.Location, Options.Locations.Eject.Map))
            {
                errors.Add("Eject Location must be outside the Battle Region.");
                errors.Add("[Options] -> [Edit Advanced Options] -> [Locations]");

                if (pop)
                {
                    return(false);
                }
            }

            if (SpectateAllowed)
            {
                if (Options.Locations.SpectateJoin == Point3D.Zero)
                {
                    errors.Add("Select a valid Spectator Join location.");
                    errors.Add("[Options] -> [Edit Advanced Options] -> [Locations]");

                    if (pop)
                    {
                        return(false);
                    }
                }
                else if (SpectateRegion != null && !SpectateRegion.Contains(Options.Locations.SpectateJoin))
                {
                    errors.Add("Spectate Join Location must be within the Spectate Region.");
                    errors.Add("[Options] -> [Edit Advanced Options] -> [Locations]");

                    if (pop)
                    {
                        return(false);
                    }
                }
            }

            if (Schedule == null)
            {
                errors.Add("No Schedule has been set for this battle.");
                errors.Add("[Options] -> [View Schedule]");

                if (pop)
                {
                    return(false);
                }
            }
            else if (Schedule.Enabled && Schedule.NextGlobalTick == null)
            {
                errors.Add("The Schedule has no more future dates.");
                errors.Add("[Options] -> [View Schedule]");

                if (pop)
                {
                    return(false);
                }
            }

            if (IdleKick && IdleThreshold.TotalSeconds < 10.0)
            {
                errors.Add("The Idle Threshold must be greater than, or equal to 10 seconds.");
                errors.Add("[Options] -> [Edit Options]");

                if (pop)
                {
                    return(false);
                }
            }

            if (Teams.Count == 0)
            {
                errors.Add("There are no teams available for this Battle.");
                errors.Add("[Options] -> [View Teams]");

                if (pop)
                {
                    return(false);
                }
            }
            else if (Teams.Any(team => !team.Validate(viewer)))
            {
                errors.Add("One or more teams did not pass validation.");
                errors.Add("[Options] -> [View Teams]");

                if (pop)
                {
                    return(false);
                }
            }

            return(errors.Count == 0);
        }
Example #22
0
 public bool HasTeams()
 {
     return(Teams != null && Teams.Any() && Teams.All(t => t.Team != null));
 }