Example #1
0
File: Team.cs Project: fossabot/A3S
 /// <summary>
 /// Gets the hash code
 /// </summary>
 /// <returns>Hash code</returns>
 public override int GetHashCode()
 {
     unchecked // Overflow is fine, just wrap
     {
         var hashCode = 41;
         // Suitable nullity checks etc, of course :)
         if (Uuid != null)
         {
             hashCode = hashCode * 59 + Uuid.GetHashCode();
         }
         if (Name != null)
         {
             hashCode = hashCode * 59 + Name.GetHashCode();
         }
         if (Description != null)
         {
             hashCode = hashCode * 59 + Description.GetHashCode();
         }
         if (TeamIds != null)
         {
             hashCode = hashCode * 59 + TeamIds.GetHashCode();
         }
         if (UserIds != null)
         {
             hashCode = hashCode * 59 + UserIds.GetHashCode();
         }
         if (DataPolicies != null)
         {
             hashCode = hashCode * 59 + DataPolicies.GetHashCode();
         }
         return(hashCode);
     }
 }
 /// <summary>
 /// Gets the hash code
 /// </summary>
 /// <returns>Hash code</returns>
 public override int GetHashCode()
 {
     unchecked // Overflow is fine, just wrap
     {
         var hashCode = 41;
         // Suitable nullity checks etc, of course :)
         if (Uuid != null)
         {
             hashCode = hashCode * 59 + Uuid.GetHashCode();
         }
         if (AgreementName != null)
         {
             hashCode = hashCode * 59 + AgreementName.GetHashCode();
         }
         if (Version != null)
         {
             hashCode = hashCode * 59 + Version.GetHashCode();
         }
         if (TeamIds != null)
         {
             hashCode = hashCode * 59 + TeamIds.GetHashCode();
         }
         if (AcceptedUserIds != null)
         {
             hashCode = hashCode * 59 + AcceptedUserIds.GetHashCode();
         }
         if (SubRealmId != null)
         {
             hashCode = hashCode * 59 + SubRealmId.GetHashCode();
         }
         return(hashCode);
     }
 }
Example #3
0
        public async Task <ScheduleResponse> GetLastMatchupAsync(TeamIds mainTeamId, TeamIds secondTeamId)
        {
            var team = await _owlApiService.GetTeamAsync((int)mainTeamId);

            var lastMatchup = team.GetLastMatchup((int)secondTeamId);

            return(lastMatchup);
        }
Example #4
0
        public async Task <ScheduleResponse[]> GetFutureMatchesAsync(TeamIds teamId)
        {
            var team = await _owlApiService.GetTeamAsync((int)teamId);

            var futureMatches = team.GetFutureMatches();

            return(futureMatches);
        }
Example #5
0
        public async Task <ScheduleResponse> GetNextMatchAsync(TeamIds teamId)
        {
            var team = await _owlApiService.GetTeamAsync((int)teamId);

            var futureMatches = team.GetFutureMatches();
            var nextMatch     = futureMatches.FirstOrDefault();

            return(nextMatch);
        }
Example #6
0
 /// <summary>
 /// Gets the hash code
 /// </summary>
 /// <returns>Hash code</returns>
 public override int GetHashCode()
 {
     unchecked // Overflow is fine, just wrap
     {
         var hashCode = 41;
         // Suitable nullity checks etc, of course :)
         if (Uuid != null)
         {
             hashCode = hashCode * 59 + Uuid.GetHashCode();
         }
         if (Name != null)
         {
             hashCode = hashCode * 59 + Name.GetHashCode();
         }
         if (Surname != null)
         {
             hashCode = hashCode * 59 + Surname.GetHashCode();
         }
         if (Username != null)
         {
             hashCode = hashCode * 59 + Username.GetHashCode();
         }
         if (Password != null)
         {
             hashCode = hashCode * 59 + Password.GetHashCode();
         }
         if (Email != null)
         {
             hashCode = hashCode * 59 + Email.GetHashCode();
         }
         if (PhoneNumber != null)
         {
             hashCode = hashCode * 59 + PhoneNumber.GetHashCode();
         }
         if (Avatar != null)
         {
             hashCode = hashCode * 59 + Avatar.GetHashCode();
         }
         if (LdapAuthenticationModeId != null)
         {
             hashCode = hashCode * 59 + LdapAuthenticationModeId.GetHashCode();
         }
         if (RoleIds != null)
         {
             hashCode = hashCode * 59 + RoleIds.GetHashCode();
         }
         if (TeamIds != null)
         {
             hashCode = hashCode * 59 + TeamIds.GetHashCode();
         }
         if (CustomAttributes != null)
         {
             hashCode = hashCode * 59 + CustomAttributes.GetHashCode();
         }
         return(hashCode);
     }
 }
        private static Node GetListFromTeamId(TeamIds t, Settings settings)
        {
            var suffix = string.Empty;

            switch (t)
            {
            case TeamIds.BostonUprising:
                suffix = "BOS";
                break;

            case TeamIds.DallasFuel:
                suffix = "DAL";
                break;

            case TeamIds.FloridaMayhem:
                suffix = "FLA";
                break;

            case TeamIds.HoustonOutlaws:
                suffix = "HOU";
                break;

            case TeamIds.LondonSpitfire:
                suffix = "LON";
                break;

            case TeamIds.LosAngelesGladiators:
                suffix = "GLA";
                break;

            case TeamIds.LosAngelesValiant:
                suffix = "VAL";
                break;

            case TeamIds.NewYorkExcelsior:
                suffix = "NYE";
                break;

            case TeamIds.PhiladelphiaFusion:
                suffix = "PHI";
                break;

            case TeamIds.SanFranciscoShock:
                suffix = "SFS";
                break;

            case TeamIds.SeoulDynasty:
                suffix = "SEO";
                break;

            case TeamIds.ShanghaiDragons:
            default:
                suffix = "SHD";
                break;
            }
            return(Node.Parse($"Alert_{suffix}{settings.BroadcastDomain}"));
        }
Example #8
0
        /// <summary>
        /// Returns true if Team instances are equal
        /// </summary>
        /// <param name="other">Instance of Team to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(Team other)
        {
            if (other is null)
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     Uuid == other.Uuid ||
                     Uuid != null &&
                     Uuid.Equals(other.Uuid)
                     ) &&
                 (
                     Name == other.Name ||
                     Name != null &&
                     Name.Equals(other.Name)
                 ) &&
                 (
                     Description == other.Description ||
                     Description != null &&
                     Description.Equals(other.Description)
                 ) &&
                 (
                     TeamIds == other.TeamIds ||
                     TeamIds != null &&
                     other.TeamIds != null &&
                     TeamIds.SequenceEqual(other.TeamIds)
                 ) &&
                 (
                     UserIds == other.UserIds ||
                     UserIds != null &&
                     other.UserIds != null &&
                     UserIds.SequenceEqual(other.UserIds)
                 ) &&
                 (
                     DataPolicyIds == other.DataPolicyIds ||
                     DataPolicyIds != null &&
                     other.DataPolicyIds != null &&
                     DataPolicyIds.SequenceEqual(other.DataPolicyIds)
                 ) &&
                 (
                     TermsOfServiceId == other.TermsOfServiceId ||
                     TermsOfServiceId != null &&
                     TermsOfServiceId.Equals(other.TermsOfServiceId)
                 ) &&
                 (
                     SubRealmId == other.SubRealmId ||
                     SubRealmId != null &&
                     SubRealmId.Equals(other.SubRealmId)
                 ));
        }
        private static Message BuildBroadcastMessage(TeamIds t, ScheduleResponse s, Settings settings)
        {
            var message = new Message($"{settings.BroadcastMessageIdPrefix}{s.Id.ToString()}")
            {
                To      = GetListFromTeamId(t, settings),
                Content = GetMessageFromScheduledEvent(s, t, settings)
            };

            return(message);
        }
        public async Task GetFutureMatchesAsync(TeamIds teamId)
        {
            // Arrange

            // Act
            var result = await _service.GetFutureMatchesAsync(teamId);

            // Assert
            result.ShouldNotBeNull();
        }
Example #11
0
        /// <summary>
        /// Returns true if TermsOfService instances are equal
        /// </summary>
        /// <param name="other">Instance of TermsOfService to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(TermsOfService other)
        {
            if (other is null)
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     Uuid == other.Uuid ||
                     Uuid != null &&
                     Uuid.Equals(other.Uuid)
                     ) &&
                 (
                     AgreementName == other.AgreementName ||
                     AgreementName != null &&
                     AgreementName.Equals(other.AgreementName)
                 ) &&
                 (
                     Version == other.Version ||
                     Version != null &&
                     Version.Equals(other.Version)
                 ) &&
                 (
                     AgreementFileData == other.AgreementFileData ||
                     AgreementFileData != null &&
                     AgreementFileData.Equals(other.AgreementFileData)
                 ) &&
                 (
                     TeamIds == other.TeamIds ||
                     TeamIds != null &&
                     other.TeamIds != null &&
                     TeamIds.SequenceEqual(other.TeamIds)
                 ) &&
                 (
                     AcceptedUserIds == other.AcceptedUserIds ||
                     AcceptedUserIds != null &&
                     other.AcceptedUserIds != null &&
                     AcceptedUserIds.SequenceEqual(other.AcceptedUserIds)
                 ) &&
                 (
                     SubRealmId == other.SubRealmId ||
                     SubRealmId != null &&
                     SubRealmId.Equals(other.SubRealmId)
                 ));
        }
        public async Task GetLastMatchupAsync(TeamIds mainTeamId)
        {
            foreach (TeamIds team in MyConstants.AllTeams)
            {
                // Arrange
                var query = new MatchupRequest()
                {
                    firstTeamId  = (int)mainTeamId,
                    secondTeamId = (int)team
                };

                // Act
                var result = await _service.GetLastMatchupAsync((TeamIds)query.firstTeamId, (TeamIds)query.secondTeamId);

                // Assert
                result.ShouldNotBeNull();
            }
        }
        public async Task GetNextMatchAsync(TeamIds teamId)
        {
            //Arrange
            var query = new MatchRequest()
            {
                teamId = (int)teamId
            };

            // Act
            var result = await _service.GetNextMatchAsync((TeamIds)query.teamId);

            //Assert
            result.ShouldNotBeNull();
            result.Competitors.Length.ShouldBe(2);
            result.Id.ShouldNotBeNull();
            result.Games.Length.ShouldBeGreaterThan(3);
            result.State.ShouldBe("PENDING");
            result.Winner.ShouldBeNull();
            result.ConclusionStrategy.ShouldNotBeNull();
            result.ConclusionStrategy.ShouldBeOfType(typeof(string));
        }
Example #14
0
        protected override void ProcessRecord()
        {
            //TraceControlSettings.TraceLevel = System.Diagnostics.SourceLevels.All;
            //TraceControlSettings.AddTraceListener(new TextWriterTraceListener("XrmTooling.txt"));

            try
            {
                var service = ConnectToCrm();

                WriteDebug("Instantiating logic...");
                var logic = new ExportLogic(service);

                WriteDebug("Retrieving teams...");
                var teams = logic.RetrieveTeams();

                if (ExportAll.IsPresent)
                {
                    WriteDebug("Exporting ALL teams...");
                    logic.Export(FileName, teams);
                }
                else if (TeamNames != null && TeamNames.Length > 0)
                {
                    WriteDebug("Exporting teams: " + string.Join(", ", TeamNames));
                    logic.Export(FileName, teams.Where(t => TeamNames.Contains(t.Name)));
                }
                else if (TeamIds != null && TeamIds.Length > 0)
                {
                    WriteDebug("Exporting teams with Ids: " + string.Join(", ", TeamIds));
                    logic.Export(FileName, teams.Where(t => TeamIds.Contains(t.TeamId)));
                }
                else
                {
                    throw new ArgumentException("Encountered unexpected combination of arguments. Please review documentation and try again.");
                }
            }
            catch (Exception ex)
            {
                ThrowTerminatingError(new ErrorRecord(ex, ex.GetType().Name, ErrorCategory.NotSpecified, null));
            }
        }
Example #15
0
        /// <summary>
        /// Returns true if TeamSubmit instances are equal
        /// </summary>
        /// <param name="other">Instance of TeamSubmit to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(TeamSubmit other)
        {
            if (other is null)
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     Uuid == other.Uuid ||
                     Uuid != null &&
                     Uuid.Equals(other.Uuid)
                     ) &&
                 (
                     Name == other.Name ||
                     Name != null &&
                     Name.Equals(other.Name)
                 ) &&
                 (
                     Description == other.Description ||
                     Description != null &&
                     Description.Equals(other.Description)
                 ) &&
                 (
                     TeamIds == other.TeamIds ||
                     TeamIds != null &&
                     other.TeamIds != null &&
                     TeamIds.SequenceEqual(other.TeamIds)
                 ) &&
                 (
                     DataPolicies == other.DataPolicies ||
                     DataPolicies != null &&
                     other.DataPolicies != null &&
                     DataPolicies.SequenceEqual(other.DataPolicies)
                 ));
        }
        private static Document GetMessageFromScheduledEvent(ScheduleResponse s, TeamIds t, Settings settings)
        {
            var carousel = new DocumentCollection()
            {
                ItemType = DocumentSelect.MediaType,
                Items    = new DocumentSelect[]
                {
                    new DocumentSelect
                    {
                        Header = new DocumentContainer
                        {
                            Value = new MediaLink
                            {
                                AspectRatio = MyConstants.FacebookCarouselAspectRatio,
                                Uri         = new Uri(settings.OWLLogo),
                                Title       = s.Competitors[0].Name + " X " + s.Competitors[1].Name,
                                Text        = $"{s.StartDate.ConvertLongIntoDateTime().ToShortDateString()} - {s.StartDate.ConvertLongIntoDateTime().ToShortTimeString()} (GMT)"
                            }
                        },
                        Options = new DocumentSelectOption[]
                        {
                            new DocumentSelectOption
                            {
                                Label = new DocumentContainer
                                {
                                    Value = new WebLink
                                    {
                                        Uri   = new Uri(settings.OWLTwitch),
                                        Title = "💻Watch!"
                                    }
                                }
                            }
                        }
                    }
                }
            };

            return(carousel);
        }
Example #17
0
        /// <summary>
        /// Returns true if UserSubmit instances are equal
        /// </summary>
        /// <param name="other">Instance of UserSubmit to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(UserSubmit other)
        {
            if (other is null)
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     Uuid == other.Uuid ||
                     Uuid != null &&
                     Uuid.Equals(other.Uuid)
                     ) &&
                 (
                     Name == other.Name ||
                     Name != null &&
                     Name.Equals(other.Name)
                 ) &&
                 (
                     Surname == other.Surname ||
                     Surname != null &&
                     Surname.Equals(other.Surname)
                 ) &&
                 (
                     Username == other.Username ||
                     Username != null &&
                     Username.Equals(other.Username)
                 ) &&
                 (
                     Password == other.Password ||
                     Password != null &&
                     Password.Equals(other.Password)
                 ) &&
                 (
                     Email == other.Email ||
                     Email != null &&
                     Email.Equals(other.Email)
                 ) &&
                 (
                     PhoneNumber == other.PhoneNumber ||
                     PhoneNumber != null &&
                     PhoneNumber.Equals(other.PhoneNumber)
                 ) &&
                 (
                     Avatar == other.Avatar ||
                     Avatar != null &&
                     Avatar.Equals(other.Avatar)
                 ) &&
                 (
                     LdapAuthenticationModeId == other.LdapAuthenticationModeId ||
                     LdapAuthenticationModeId != null &&
                     LdapAuthenticationModeId.Equals(other.LdapAuthenticationModeId)
                 ) &&
                 (
                     RoleIds == other.RoleIds ||
                     RoleIds != null &&
                     other.RoleIds != null &&
                     RoleIds.SequenceEqual(other.RoleIds)
                 ) &&
                 (
                     TeamIds == other.TeamIds ||
                     TeamIds != null &&
                     other.TeamIds != null &&
                     TeamIds.SequenceEqual(other.TeamIds)
                 ) &&
                 (
                     CustomAttributes == other.CustomAttributes ||
                     CustomAttributes != null &&
                     other.CustomAttributes != null &&
                     CustomAttributes.SequenceEqual(other.CustomAttributes)
                 ));
        }
Example #18
0
        public void Draft(int i)
        {
            iteration++;
            try
            {
                //i will be -1 when no available players are left, i will be >= count if fair team is impossible
                if (i >= 0 && i < Players.Count)
                {
                    if (isPromisingTeam(i))
                    {
                        //Assign player to team
                        Players[i].isDrafted = true;
                        FinalTeam.Add(Players[i]);

                        //Draft next available
                        Draft(lowestAvail());

                        //Drafting is complete
                        if (FinalTeam.Count == Players.Count)
                        {
                            if (completeTeams >= sentinel || deviation > maxDeviation)
                            {
                                return;
                            }
                            String teamId = GetTotalTeamId(FinalTeam);
                            if (!TeamIds.Contains(teamId))
                            {
                                //TeamSet finalSet =  new TeamSet(FinalTeam, playersPerTeam, averageRank, teamId);
                                //String teamId = GetTotalTeamId(finalSet.TeamList);
                                //finalSet.teamId = teamId;

                                try
                                {
                                    TeamIds.Add(teamId);
                                    //@TA NOTE using a dictionary slows the process exponentially
                                    //team id is key, this will not allow duplicates
                                    CompletedSets.Add(new TeamSet(FinalTeam, playersPerTeam, averageRank, teamId));
                                    //CompletedSets.Add(teamId, finalSet);
                                    completeTeams++;
                                    // PrintTeams();
                                }
                                catch (Exception ex)
                                {
                                }
                            }

                            //PrintTeams();
                            //PrintTeamsOdds();
                        }

                        //Keep back tracking to get all possible combinations draft next
                        Players[i].isDrafted = false;
                        FinalTeam.Remove(FinalTeam[FinalTeam.Count - 1]);
                    }

                    //Player did not fit on team or we back tracked, draft next player
                    Draft(i + 1);
                }
            }
            catch (Exception ex)
            {
            }
        }
        public void GetTeamIdFromTagTest(string tag, TeamIds returns)
        {
            var team = GetTeamIdFromTag(tag);

            team.ShouldBe(returns);
        }