Example #1
0
        public IndexDataSource GetCurrentIndex(PlayerContext player)
        {
            IndexDataSource result  = null;
            HistoryContext  history = null;

            if (player.currentTurn != null && player.currentTurn.paths.Any())
            {
                history = player.currentTurn;
            }
            else
            {
                if (ContextEngine.Instance.gameContext.state == GameStateType.Qualification)
                {
                    if (player.qualification != null)
                    {
                        history = player.qualification.turnHistories.Last();
                    }
                }
                else
                {
                    history = player.turnHistories.Last();
                }
            }

            if (history != null && history.paths.Any())
            {
                result = history.paths.Last().Last();
            }

            return(result);
        }
Example #2
0
        public CaseManager GetCase(IndexDataSource index)
        {
            CaseManager result = null;

            if (index != null && boardManager != null)
            {
                result = boardManager.FindCaseManager(index);
            }
            return(result);
        }
Example #3
0
        public CaseManager FindCaseManager(IndexDataSource index)
        {
            CaseManager result = null;

            if (index != null && _boardItems != null && _boardItems.ContainsKey(index))
            {
                result = _boardItems[index].caseManager;
            }
            return(result);
        }
Example #4
0
        public BendDataSource GetNextTurn(IndexDataSource indexDataSource)
        {
            BendDataSource result      = null;
            var            currentCase = this.FindCaseManager(indexDataSource);

            while (result == null)
            {
                if (currentCase.bendDataSource != null)
                {
                    result = currentCase.bendDataSource;
                }
                else
                {
                    var nextIndex = currentCase.itemDataSource.targets.FirstOrDefault(i => i.enable && i.column == indexDataSource.column);
                    if (nextIndex == null)
                    {
                        nextIndex = currentCase.itemDataSource.targets.FirstOrDefault();
                    }
                    currentCase = this.FindCaseManager(nextIndex);
                }
            }
            return(result);
        }
Example #5
0
        public bool IsBestColumnTurn(IndexDataSource indexDataSource)
        {
            var turn = boardManager.GetNextTurn(indexDataSource);

            return(indexDataSource.column == turn.bestColumn);
        }
Example #6
0
 public PlayerContext FindPlayer(IndexDataSource index)
 {
     return(ContextEngine.Instance.gameContext.players.FirstOrDefault(p => this.GetCurrentIndex(p).Equals(index)));
 }