// PRIVATE METHODS private PlayerStep checkIfSuitablePlayerStepSavedInList(PlayerStep i_PlayerStep) { int suitablePlayerStepIndex = 0; bool isPlayerStepFound = false; PlayerStep stepPlayerToReturn; for (int i = 0; i < this.r_ArtificialPlayerStepMemoryList.Count; i++) { if (!i_PlayerStep.Equals(this.r_ArtificialPlayerStepMemoryList[i])) { if (CheckCardMatch(i_PlayerStep, this.r_ArtificialPlayerStepMemoryList[i])) { suitablePlayerStepIndex = i; isPlayerStepFound = true; break; } } } if (isPlayerStepFound) { stepPlayerToReturn = this.r_ArtificialPlayerStepMemoryList[suitablePlayerStepIndex]; this.r_ArtificialPlayerStepMemoryList.RemoveAt(suitablePlayerStepIndex); } else { stepPlayerToReturn = GetRandomMachineStep(); } return(stepPlayerToReturn); }
public void SaveMachineStepInList(PlayerStep i_PlayerStep) { if (checkIfCurrentPlayerStepIsNotInList(i_PlayerStep)) { this.r_ArtificialPlayerStepMemoryList.Add(i_PlayerStep); } }
public bool CheckCardMatch(PlayerStep i_FirstStep, PlayerStep i_SecondStep) { char firstCardSymbol, secondCardSymbol; firstCardSymbol = GetSymbol(i_FirstStep.RowIndex, i_FirstStep.ColumnIndex); secondCardSymbol = GetSymbol(i_SecondStep.RowIndex, i_SecondStep.ColumnIndex); return(firstCardSymbol == secondCardSymbol); }
private bool checkIfCurrentPlayerStepIsNotInList(PlayerStep i_PlayerStepToCheck) { bool resultToReturn = true; for (int i = 0; i < this.r_ArtificialPlayerStepMemoryList.Count; i++) { if (i_PlayerStepToCheck.Equals(this.r_ArtificialPlayerStepMemoryList[i])) { resultToReturn = false; } } return(resultToReturn); }
private PlayerStep getValidStep(string i_PlayerName) { int rowIndex = 0, columnIndex = 0; string playerInput = string.Empty; bool isCurrentStepValidFlag = false; while (!isCurrentStepValidFlag) { Console.Write(string.Format("{0}'s step: ", i_PlayerName)); playerInput = Console.ReadLine(); isCurrentStepValidFlag = isCurrentStepValid(playerInput); } rowIndex = (int)char.GetNumericValue(playerInput[1]) - 1; columnIndex = playerInput[0] - 'A'; PlayerStep playerStep = new PlayerStep(rowIndex, columnIndex); return(playerStep); }
// PUBLIC METHODS public PlayerStep GetRandomMachineStep() { int rowIndex, columnIndex, randomNum; this.r_RandomPlacementList.Clear(); for (int i = 0; i < m_Height; i++) { for (int n = 0; n < m_Width; n++) { if (!this.m_MemoryBoard[i, n].IsShown) { this.r_RandomPlacementList.Add((i * this.m_Width) + n); } } } randomNum = this.m_randomNumGenerator.Next(0, this.r_RandomPlacementList.Count); convertRandomNumToMatrixIndexes(this.r_RandomPlacementList[randomNum], out rowIndex, out columnIndex); PlayerStep machinePlayerStep = new PlayerStep(rowIndex, columnIndex); return(machinePlayerStep); }
public PlayerStep GetMachineSecondStep(PlayerStep i_MachineFirstStep) { PlayerStep currentMachineStep = checkIfSuitablePlayerStepSavedInList(i_MachineFirstStep); return(currentMachineStep); }
public void SwitchCardStatus(PlayerStep i_PlayerStep) { bool currentCardStatus = this.m_MemoryBoard[i_PlayerStep.RowIndex, i_PlayerStep.ColumnIndex].IsShown; this.m_MemoryBoard[i_PlayerStep.RowIndex, i_PlayerStep.ColumnIndex].IsShown = !currentCardStatus; }