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); }
public CaseManager GetCase(IndexDataSource index) { CaseManager result = null; if (index != null && boardManager != null) { result = boardManager.FindCaseManager(index); } return(result); }
public CaseManager FindCaseManager(IndexDataSource index) { CaseManager result = null; if (index != null && _boardItems != null && _boardItems.ContainsKey(index)) { result = _boardItems[index].caseManager; } return(result); }
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); }
public bool IsBestColumnTurn(IndexDataSource indexDataSource) { var turn = boardManager.GetNextTurn(indexDataSource); return(indexDataSource.column == turn.bestColumn); }
public PlayerContext FindPlayer(IndexDataSource index) { return(ContextEngine.Instance.gameContext.players.FirstOrDefault(p => this.GetCurrentIndex(p).Equals(index))); }