Je veux simplement être capable de marquer mes jets de dés suivant un ensemble de règles. Les règles varient d'un simple 1 roulé vaut 100 points et trois 1 vaut 400, flush droit vaut quelques points et 6x1 vaut 8000.Marquer mes jets de dés en utilisant C# et Unity
Voici le code.
Je ne sais pas comment faire le code de calcul des scores individuellement
int[] rollDice(int numDice)
{
int[] diceRolls = new int[6];
//int[] diceRolls = null;
for (int i = 0; i < NumDice; i++)
{
diceRolls[i] = rollSingleDie(6);
}
return diceRolls;
}
//Score the dice rolls in the array
int scoreDiceRolls(int[] rolls)
{
int score = 0;
//TODO: Complete the scoring logic
// for (int i = 0; i < NumDice; i++)
// {
// if (rolls[i] == 2 && 4)
// {
// score += 10;
// }
// }
// if (rolls[1] == 2)
// {
// score += 100;
// }
//SIX ONES RULE ////////////////////////////////////////////////////// NEED HELP HERE.
if (rolls[0] == 1)
{
if (rolls[1] == 1)
{
if (rolls[2] == 1)
{
if (rolls[3] == 1)
{
if (rolls[4] == 1)
{
if (rolls[5] == 1)
{
score += 8000;
}
}
}
}
}
}
// ROLL A ONE RULE = 100 points
for (int i = 0; i < NumSides; i++)
{
if (rolls[i] == 1)
{
score += 100;
}
}
// int intToCheck = 1;
//foreach (int one in rolls)
//{
// if (x.Equals(1))
// {
// score += 10;
//
// }
//}
// if (rolls[)
//for (int i = 0; i < 6; i++)
//{
// if (rolls[i] == 1)
// {
// score += 10;
// }
//}
return score;
}
'if (rolls.Any (y => y == 1))' – DLeh