private void SetWhichDieFacesSucceeded(DiceRollResult diceRollResult) { if (rollType == RollType.Attack) { foreach (KeyValuePair <int, DieFace> dieNumberDieFace in diceRollResult.dieFaces) { switch (dieNumberDieFace.Value) { case DieFace.Blank: diceRollResult.dieFaceResults[dieNumberDieFace.Key] = DieResult.Failure; break; case DieFace.Focus: if (isFocused == true) { diceRollResult.dieFaceResults[dieNumberDieFace.Key] = DieResult.Success; } else { diceRollResult.dieFaceResults[dieNumberDieFace.Key] = DieResult.Failure; } break; case DieFace.Hit: diceRollResult.dieFaceResults[dieNumberDieFace.Key] = DieResult.Success; break; case DieFace.Crit: diceRollResult.dieFaceResults[dieNumberDieFace.Key] = DieResult.Success; break; } } } }
public void AddDiceRollResult(DiceRollResult newDiceRollResult) { bool resultAlreadyExists = false; foreach (DiceRollResult diceRollResult in diceRollResults) { if (diceRollResult.uniqueId == newDiceRollResult.uniqueId) { resultAlreadyExists = true; diceRollResult.numberOfResults += newDiceRollResult.numberOfResults; break; } } if (resultAlreadyExists == false) { diceRollResults.Add(newDiceRollResult); } }
private AllDiceRollResults GetAllDiePossibilities(AllDiceRollResults allDiceRollResults, int currentDie, int numberOfDice, Dictionary <int, DieFace> currentRoll) { foreach (DieFace dieFace in dieFaces) { currentRoll[currentDie] = dieFace; if (currentDie < numberOfDice) { GetAllDiePossibilities(allDiceRollResults, currentDie + 1, numberOfDice, currentRoll); } // Only register the result when all die have a value else { DiceRollResult diceRollResult = new DiceRollResult(); diceRollResult.numberOfResults = 1; foreach (KeyValuePair <int, DieFace> dieNumberDieFace in currentRoll) { diceRollResult.dieFaces[dieNumberDieFace.Key] = dieNumberDieFace.Value; } SetWhichDieFacesSucceeded(diceRollResult); allDiceRollResults.AddDiceRollResult(diceRollResult); } } return(allDiceRollResults); }