Esempio n. 1
0
        static void Main(string[] args)
        {
            ILuptator mag1 = new Magician("Gigi");
            ILuptator mag2 = new Razboinic("Zizi");

            Arcas magg = new Arcas("zzzz");

            magg.Test(mag2);

            ILupta    lupta      = new Lupta1vs1(mag1, mag2);
            ILuptator castigator = lupta.Desfasurare();

            Console.WriteLine($"Meciul a fost castigat de {castigator.Rasa} {castigator.Nume}");

            ILupta    turnament           = new Turnament(mag1, mag2, mag1, mag2);
            ILuptator castigatorturnament = turnament.Desfasurare();

            Console.WriteLine($"Meciul a fost castigat de {castigatorturnament.Rasa} {castigatorturnament.Nume}");

            ILupta    turnament16           = new Turnament(new List <ILuptator>(), TipTurnament.Luptatori16);
            ILuptator castigatorturnament16 = turnament16.Desfasurare();

            Console.WriteLine($"Meciul a fost castigat de {castigatorturnament16.Rasa} {castigatorturnament16.Nume}");
        }
        public static GetTurnamentsForUserResponse Execute(string accountId)
        {
            var turnaments = DbHelper.GetTurnamentsForUser(Guid.Parse(accountId));

            var response = new GetTurnamentsForUserResponse {
                Turnaments = new List <Turnament>()
            };

            foreach (var item in turnaments)
            {
                var positionCommands = item.type == 1 ? GetPositionCommandBLL.Execute(item.id_turnament) : new List <PositionCommand>();
                var groupTourNumber  = item.type == 1 ? GetGroupTourNumberBLL.Execute(item.id_turnament, false) : new List <GroupTourNumber>();
                var turnamentGroups  = item.type == 2 ? GetTurnamentGroupsBLL.Execute(item.id_turnament, false) : new List <TurnamentGroups>();
                var turnamentPlayOff = new List <TurnamentPlayOff>();
                var positionPlayOff  = new List <List <PositionCommand> >();

                if (item.type == 2)
                {
                    var tuple = GetPositionPlayOffBLL.Execute(item.id_turnament, false);
                    turnamentPlayOff = tuple.Item1;
                    positionPlayOff  = tuple.Item2;
                }

                var commands             = DbHelper.GetCommandForTurnament(item.id_turnament, true);
                var commandsForTurnament = new List <CommandForTurnament>();

                foreach (var command in commands)
                {
                    var commandForTurnament = new CommandForTurnament
                    {
                        Name   = command.Name,
                        Status = command.Status
                    };

                    commandsForTurnament.Add(commandForTurnament);
                }

                groupTourNumber.Sort((a, b) => a.NumberTour <= b.NumberTour ? -1 : 1);

                var turnament = new Turnament
                {
                    Id = item.id_turnament.ToString(),
                    ContributionGame       = item.сontribution_game,
                    ContributionTournament = item.сontribution_tournament,
                    DateEnd          = item.date_end == null ? null : item.date_end.Value.ToShortDateString(),
                    DateStart        = item.date_start == null ? null : item.date_start.Value.ToShortDateString(),
                    Description      = item.description,
                    Name             = item.name,
                    Commands         = commandsForTurnament,
                    Type             = item.type,
                    PositionCommand  = positionCommands,
                    GroupTourNumber  = groupTourNumber,
                    TurnamentGroups  = turnamentGroups,
                    TurnamentPlayOff = turnamentPlayOff,
                    PositionPlayOff  = positionPlayOff
                };

                response.Turnaments.Add(turnament);
            }
            ;

            return(response);
        }