Ejemplo n.º 1
0
        public object ToObjectModel()
        {
            ICollection <User> users = new List <User>();

            if (ParticipantsId != null && (Participants == null || Participants.Count() <= 0))
            {
                foreach (long joueur in ParticipantsId)
                {
                    users.Add(new User()
                    {
                        Id = joueur
                    });
                }
            }
            else
            {
                users = Participants;
            }
            return(new Tournament()
            {
                Id = Id,
                NameTournament = Name,
                BeginDate = BeginDate,
                EndDate = EndDate,
                Etat = Etat,
                Participants = users,
                Address = Address
            });
        }
        protected void Page_Init(object sender, EventArgs e)
        {
            Participants           = AttendRegistrationEngine.GetParticipants(CurrentPage.ContentLink).ToList();
            NoParticipants.Visible = !(Participants.Count <IParticipant>() > 0);
            Sessions = AttendSessionEngine.GetSessions(CurrentPage.ContentLink).ToList();

            PopulateStatusDropDown();
            PopulateEMailDropDown();
            PopulateSessionDropDown();

            DeleteParticipantsCopy.OnClientClick = "return confirm('" + DeleteConfirmation() + "');";

            NoParticipants.DataBind();
        }
Ejemplo n.º 3
0
        private void updateVal()
        {
            // TODO REMOVE
            int numofusers = Participants.Count();

            for (int i = 0; i < numofusers; i++)
            {
                Participant p      = Participants[i];
                BandEntry   latest = GenerateBandEntry(p.BandEntry);
                var         member = participants[i];
                member.BandEntry = latest;
                Participants[i]  = new Participant(member.RowNumber, member.user, member.BandEntry, member.dehydrateTicks, member.BandEntryHistory, member.notified);
            }
        }
Ejemplo n.º 4
0
        public bool AddParticipant(Member participant)
        {
            string[] str = RangeOfAge.Split('-');
            int      minAge = int.Parse(str[0]), maxAge = int.Parse(str[1]);

            if (Participants.Count() < MaxParticipants && participant.Age >= minAge && participant.Age <= maxAge && participant.HasCompetitionPass() && (participant.Subscription.Cast <Subscription>().Any(s => s.PassType.Equals(PassType.Competition)) ? participant.Subscription.Cast <Subscription>().First(s => s.PassType.Equals(PassType.Competition)).IsValid() : false))
            {
                Participants.Add(participant);
                participant.Competitions.Add(this);
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 5
0
 public virtual int?AvailablePlaces()
 {
     return(MaxPlaces - Participants.Count());
 }
        /// <summary>
        /// A game can be played according to a set of Game rules to generate a Game Result
        /// </summary>
        /// <param name="rules"></param>
        /// <returns></returns>
        public override IContestResult Play(IGameRules rules)
        {
            var result = new GameResult(ContestOutcome.None, Id, Moves, null);

            //Display Message to User: Game<Id>: Commence...
            Controller.Output(CommencementMessage);

            //Request Moves from Each Player
            foreach (var player in Participants)
            {
                var playerMove = player.SelectMove();
                Moves.Add(playerMove);
            }

            //Display Message to User: Player 2: <name> Plays <Move.Action>
            //  if this is a game against a non Human Player
            var countHumans = Participants.Count(p => p.GetType() == typeof(HumanPlayer));

            switch (countHumans)
            {
            case 1:
                //  if this is a game against a non Human Player
                //  Display Message: Player 2: <name> Played <Move.Action>
                var player2MoveMessage = Moves.First(m => m.Owner.GetType() != typeof(HumanPlayer)).ToString();
                Controller.Output(player2MoveMessage);
                break;

            case 0:
                //If neither Player is a Human
                // Display Message:
                // Player 1: <name> Played <Move.Action>
                // Player 2: <name> Played <Move.Action>
                foreach (var move in Moves)
                {
                    var playermoveMessage = move.ToString();
                    Controller.Output(playermoveMessage);
                }
                break;
            }

            //Use Game Rules to Play each Players selected Moves against each other
            //  Check for a Draw: Player 1 Move action is the same as Player 2 move action: player1Move.Action == player2Move.Action :Draw
            if (Moves[0].Action == Moves[1].Action)
            {
                //Draw
                Outcome = ContestOutcome.Draw;
                Winner  = null;
                result  = new GameResult(Outcome, Id, Moves, null);
            }

            //Get losing actions for the Moves that were played by each player
            //  A losing action is the action that a Players Move beats based on the mappings in the GameRules dictionary: rules
            var move0Losingactions = rules.Rules[Moves[0].Action];
            var move1Losingactions = rules.Rules[Moves[1].Action];

            //Figure out which Move wins and who played the winning Move
            //  Moves[0] wins: If Moves[1] Action IN Moves[0] losing actions:
            if (move0Losingactions.Contains(Moves[1].Action))
            {
                //Moves[0] wins
                Outcome = ContestOutcome.Win;
                Winner  = Moves[0].Owner;
                result  = new GameResult(Outcome, Id, Moves, Moves[0]);
            }

            //  Moves[1] wins: If Moves[0] Action IN Moves[1] losing actions:
            if (move1Losingactions.Contains(Moves[0].Action))
            {
                //Moves[1] wins
                Outcome = ContestOutcome.Win;
                Winner  = Moves[1].Owner;
                result  = new GameResult(Outcome, Id, Moves, Moves[1]);
            }

            return(result);
        }