Ejemplo n.º 1
0
        public ActionResult Index(FormCollection collection)
        {
            TournoiWS ts  = null;
            string    nom = collection.Get(1);

            using (ServiceReference.ServiceClient service = new ServiceReference.ServiceClient())
            {
                TournoiWS tn = service.getTournois().Where(x => x.Nom == nom).First();
                ts = service.playTournoi(tn);
            }
            TournoiViewModel mod = new TournoiViewModel(ts);

            using (ServiceReference.ServiceClient service = new ServiceReference.ServiceClient())
            {
                int butin = service.getPoints(User.Identity.GetUserName());
                mod.Mise = Int32.Parse(collection.Get("Mise"));
                mod.Mise = (mod.Mise <0 ? 0 : mod.Mise> butin ? butin : mod.Mise);
                mod.Jedi = collection.Get("Jedi");
                bool gagne = mod.Jedi == mod.Matches.list.Where(x => x.Phase == EPhaseTournoiWS.Finale).First().JediVainqueur.Nom;
                mod.Gain = (gagne ? mod.Mise * 2 + 1 : 0);
                var userId = User.Identity.GetUserId();

                mod.Total  = service.getPoints(User.Identity.GetUserName());
                mod.Total += (gagne ? mod.Gain : -mod.Mise);
                mod.Total  = mod.Total < 0 ? 0 : mod.Total;
                service.setPoints(User.Identity.GetUserName(), mod.Total);
            }

            return(View("Details", mod));
        }
Ejemplo n.º 2
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            Tvm = new TournoiViewModel(tournoi);
            TournoiController.DataContext = Tvm;

            MatchPLayerGlobal mpg = new MatchPLayerGlobal(this);
            Dispatcher.BeginInvoke(new Action(mpg.play), DispatcherPriority.ContextIdle);
        }
Ejemplo n.º 3
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            Tvm = new TournoiViewModel(tournoi);
            TournoiController.DataContext = Tvm;

            MatchPLayerGlobal mpg = new MatchPLayerGlobal(this);

            Dispatcher.BeginInvoke(new Action(mpg.play), DispatcherPriority.ContextIdle);
        }
        // GET : Tournoi/Arborescence/5
        public ActionResult Arborescence(int id)
        {
            TournoiViewModel tournoiVM = new TournoiViewModel(_context.Tournois.Include(p => p.Participants).Include(p => p.Parties).FirstOrDefault(t => t.ID == id));

            return(View(tournoiVM));
        }
        public ActionResult Delete(int id)
        {
            TournoiViewModel tournoiVM = new TournoiViewModel(_context.Tournois.FirstOrDefault(f => f.ID == id));

            return(View(tournoiVM));
        }
Ejemplo n.º 6
0
 public ActionResult Details(TournoiViewModel tws)
 {
     return(View(tws));
 }
Ejemplo n.º 7
0
        public void playBis()
        {
            TournoiViewModel tvm = Tv.Tvm;
            BackgroundWorker bw  = new BackgroundWorker();

            // this allows our worker to report progress during work
            bw.WorkerReportsProgress = true;

            // what to do in the background thread
            bw.DoWork += new DoWorkEventHandler(
                delegate(object o, DoWorkEventArgs args)
            {
                BackgroundWorker b = o as BackgroundWorker;

                // do some simple processing for 10 seconds
                Thread.Sleep(2000);
            });

            // what to do when progress changed (update the progress bar for example)
            bw.ProgressChanged += new ProgressChangedEventHandler(
                delegate(object o, ProgressChangedEventArgs args)
            {
            });

            // what to do when worker completes its task (notify the user)
            bw.RunWorkerCompleted += new RunWorkerCompletedEventHandler(
                delegate(object o, RunWorkerCompletedEventArgs args)
            {
                if (i == 0)
                {
                    int st = rnd.Next(0, stades.Count);
                    Match match;
                    if (j != 2)
                    {
                        match = new Match(jtm.useAvailableIDMatch(), null, null, EPhaseTournoi.DemiFinale, tvm.Matchs.ElementAt(st).Stade);
                    }
                    else
                    {
                        match = new Match(jtm.useAvailableIDMatch(), null, null, EPhaseTournoi.Finale, tvm.Matchs.ElementAt(st).Stade);
                    }

                    tvm.Matchs.Add(match);
                    tvm.Matchs.ElementAt(current).Jedi1 = mp.Vainqueur;
                }
                else
                {
                    tvm.Matchs.ElementAt(current).Jedi2 = mp.Vainqueur;
                }

                i++;

                if (i == 2)
                {
                    i = 0;
                    j++;
                    current++;
                }

                Tv.TournoiController.DataContext = null;
                Tv.TournoiController.DataContext = tvm;


                if (current <= 6)
                {
                    play();
                }
                else
                {
                    mp = new MatchPlayer(tvm.Matchs[6], Tv.Auto, Tv.IdJ1, Tv.IdJ2, this);
                }
            });

            bw.RunWorkerAsync();
        }
Ejemplo n.º 8
0
        public void play()
        {
            TournoiViewModel tvm = Tv.Tvm;

            mp = new MatchPlayer(tvm.Matchs[IdMatchs[current].ElementAt(i)], Tv.Auto, Tv.IdJ1, Tv.IdJ2, this);
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Constructeur.
        /// </summary>
        public TournoisViewModel()
        {
            JediTournamentManager manager = new JediTournamentManager();

            _tournois = new ObservableCollection<TournoiViewModel>();
            List<Tournoi> tournoisModel = manager.getAllTournois();
            _availableMatchs = new ObservableCollection<Match>(manager.getAllQuartFinaleMatch());
            _affectedMatchs = new ObservableCollection<Match>();

            // Liste des tournois + forme la liste des matchs disponibles
            foreach (Tournoi t in tournoisModel)
            {
                _tournois.Add(new TournoiViewModel(t));

                if (t.Matchs != null)
                {
                    // Supprime les matchs qui ne sont plus disponibles
                    foreach (Match m in t.Matchs)
                    {
                        _availableMatchs.Remove(m);
                    }
                }
            }

            // Auto sélection du premier tournoi
            if (_tournois.Count > 0)
            {
                _selectedTournoi = _tournois[0];
                _affectedMatchs = new ObservableCollection<Match>(_selectedTournoi.Matchs);
            }

            if (_availableMatchs.Count > 0)
            {
                _selectedAvailableMatch = _availableMatchs[0];
            }

            if (_affectedMatchs.Count > 0)
            {
                _selectedAffectedMatch = _affectedMatchs[0];
            }
        }