Beispiel #1
0
        public DraftLotteryViewModel(GameCore core, League league) : base(core)
        {
            ViewHeading         = "Draft Lottery";
            this.league         = league;
            this.nextPickNumber = 1;

            Teams = new UpdatableObservableCollection <TeamViewModel>(league.Teams.Select(team => team.ToViewModel(core)));

            NextDraw = new RelayCommand(() =>
            {
                var team = Teams.Where(x => x.DraftOrder == 0).GetRandom();

                if (team != null)
                {
                    team.DraftOrder = nextPickNumber;
                    nextPickNumber++;
                    Teams.UpdateCollection();
                }

                if (Teams.All(x => x.DraftOrder > 0))
                {
                    UpdateLeague();
                }
            });
        }
        public DraftLotteryViewModel(GameCore core, League league) : base(core)
        {
            ViewHeading = "Draft Lottery";
            this.league = league;
            this.nextPickNumber = 1;

            Teams = new UpdatableObservableCollection<TeamViewModel>(league.Teams.Select(team => team.ToViewModel(core)));

            NextDraw = new RelayCommand(() =>
            {
                var team = Teams.Where(x => x.DraftOrder == 0).GetRandom();

                if (team != null)
                {
                    team.DraftOrder = nextPickNumber;
                    nextPickNumber++;
                    Teams.UpdateCollection();
                }

                if (Teams.All(x => x.DraftOrder > 0))
                {
                    UpdateLeague();
                }
            });
        }
        public PlayerDraftRoundViewModel(GameCore core, League league, int roundNumber) : base(core)
        {
            RoundNumber = roundNumber;

            DraftPicks = new UpdatableObservableCollection <DraftCardViewModel>();

            this.league = league;

            InitializeDraftPicks();
        }
        public PlayerDraftRoundViewModel(GameCore core, League league, int roundNumber)
            : base(core)
        {
            RoundNumber = roundNumber;

            DraftPicks = new UpdatableObservableCollection<DraftCardViewModel>();

            this.league = league;

            InitializeDraftPicks();
        }
        public PlayerDraftMasterViewModel(GameCore core, League league, Func<Player, bool> playerFilter = null)
            : base(core)
        {
            this.league = league;
            this.draftService = new NaiveDraftService();

            Teams = new ObservableCollection<TeamViewModel>();
            DraftRounds = new UpdatableObservableCollection<PlayerDraftRoundViewModel>(new List<PlayerDraftRoundViewModel>());

            IEnumerable<Player> availablePlayers = core.GameState.DraftPool.AvailablePlayers;

            if (playerFilter != null)
            {
                availablePlayers = availablePlayers.Where(playerFilter);
            }

            AvailablePlayers = new ObservableCollection<Player>(availablePlayers);
            ViewHeading = "Player Draft";

            NextPick = new RelayCommand(ProcessNextPick);
            DraftPlayer = new RelayCommand(ProcessDraftPick);
            AutomatePicks = new RelayCommand(() =>
            {
                while (CanDraftPlayer || CanGoToNextPick)
                {
                    if (CanDraftPlayer)
                    {
                        ProcessDraftPick();
                    }
                    if (CanGoToNextPick)
                    {
                        ProcessNextPick();
                    }
                }
            });

            Reload(core);

            ProcessNextPick();
            SelectHumanTeamIfSingle();
        }
        public PlayerDraftMasterViewModel(GameCore core, League league, Func <Player, bool> playerFilter = null) : base(core)
        {
            this.league       = league;
            this.draftService = new NaiveDraftService();

            Teams       = new ObservableCollection <TeamViewModel>();
            DraftRounds = new UpdatableObservableCollection <PlayerDraftRoundViewModel>(new List <PlayerDraftRoundViewModel>());

            IEnumerable <Player> availablePlayers = core.GameState.DraftPool.AvailablePlayers;

            if (playerFilter != null)
            {
                availablePlayers = availablePlayers.Where(playerFilter);
            }

            AvailablePlayers = new ObservableCollection <Player>(availablePlayers);
            ViewHeading      = "Player Draft";

            NextPick      = new RelayCommand(ProcessNextPick);
            DraftPlayer   = new RelayCommand(ProcessDraftPick);
            AutomatePicks = new RelayCommand(() =>
            {
                while (CanDraftPlayer || CanGoToNextPick)
                {
                    if (CanDraftPlayer)
                    {
                        ProcessDraftPick();
                    }
                    if (CanGoToNextPick)
                    {
                        ProcessNextPick();
                    }
                }
            });

            Reload(core);

            ProcessNextPick();
            SelectHumanTeamIfSingle();
        }