void UndoPips(PharoahDie die) { die.UndoTempPips(); }
// delegate: when the player chooses a die, this will get called. // user clicked on a die. Which one is it? We have to keep track here for this ability. bool PickDie(PharoahDie die) { bool bLegalDie = false; bool bIsNewDie = false; if (!die.isDieType(onlyFor)) { myPlayer.AskToChooseDie(this.PickDie, this.GetType().ToString()); // ask the player to choose a die or dice GameState.Message("Cannot pick " + die.name + " because it's\nthe wrong type."); return(false); } if (isNewDie(die)) { bIsNewDie = true; } else { bLegalDie = true; // we picked a die that we already have picked } if (adjustedDice.Count < actualNumDice) // can still pick new dice { if (bIsNewDie) { die.ClearTempPips(); adjustedDice.Add(die); // add the new die to the list of dice we are modifying bLegalDie = true; } } // if we are a legal die, then we can add pips to it (or undo the addpips) if (bLegalDie) { if (die != curDie) { lastDie = curDie; } curDie = die; if (isExactlyNumPips) // we add exactly this number of pips. { if (die.getTempPips() == 0) // we haven't messed with this die yet { if (die.GetSide() + nPips > 6) // failure case. we can't add this many pips! { adjustedDice.Remove(die); myPlayer.AskToChooseDie(this.PickDie, this.GetType().ToString()); // ask the player to choose a die or dice GameState.Message("ERROR: Can't add exactly " + nPips.ToString() + " to " + die.name); return(false); } else { die.AddTempPips(nPips); } } else// we've messed with this die already { die.UndoTempPips(); } } else// we can add up to the number of pips specified in nPips to any die { if (die.getTempPips() + 1 > nPips) { die.UndoTempPips(); } else { if (!setToAnyFace && (die.GetSide() + 1 > 6)) // failure case. we can't add this many pips! { die.UndoTempPips(); } if (!isEntertainer) { if (!isSoothsayer) { // do the wrap around. if (die.GetSide() + 1 > 6) { // set the temppips such that it equals 1. die.SetTempPipsValue(1); } else { die.AddTempPips(1); } } else// Soothsayer nonsense here { int exactlyNumDice = 2; if (isAstrologer) { exactlyNumDice = 3; } if (adjustedDice.Count != exactlyNumDice) { GameState.Message("Select exactly " + exactlyNumDice.ToString() + " dice."); } else { PharoahDie otherDie = GetOtherDie(die); if (isAstrologer) { otherDie = lastDie; } if ((otherDie.GetSide() > 1) && (die.GetSide() < 6)) // we can still subtract value from otherDie { die.AddTempPips(1); otherDie.AddTempPips(-1); } else if ((die.GetSide() > 1) && (otherDie.GetSide() < 6))// if we have some value in this die, we can add to the other { die.AddTempPips(-1); otherDie.AddTempPips(1); } else// can't do either, both dice are 1. Make an error { GameState.Message("Cannot change values."); } } } } else// entertainer flipping nonsense { int setVal = 7 - die.GetSide(); if (die.getTempPips() == 0) { die.SetTempPipsValue(setVal); } else { die.UndoTempPips(); } } } } } else { GameState.Message("Can't choose " + die.name + " for " + this.name); } myPlayer.AskToChooseDie(this.PickDie, this.GetType().ToString()); // ask the player to choose a die or dice return(bLegalDie); }
// delegate: when the player chooses a die, this will get called. // user clicked on a die. Which one is it? We have to keep track here for this ability. bool PickDie(PharoahDie die) { bool bLegalDie = false; bool bIsNewDie = false; if (!die.isDieType(onlyFor)) { myPlayer.AskToChooseDie(this.PickDie, this.GetType().ToString()); // ask the player to choose a die or dice GameState.Message("Cannot pick " + die.name + " because it's\nthe wrong type."); return false; } if (isNewDie(die)) { bIsNewDie = true; } else { bLegalDie = true; // we picked a die that we already have picked } if (adjustedDice.Count < actualNumDice) // can still pick new dice { if (bIsNewDie) { die.ClearTempPips(); adjustedDice.Add(die); // add the new die to the list of dice we are modifying bLegalDie = true; } } // if we are a legal die, then we can add pips to it (or undo the addpips) if (bLegalDie) { if (die != curDie) lastDie = curDie; curDie = die; if (isExactlyNumPips) // we add exactly this number of pips. { if (die.getTempPips()==0) // we haven't messed with this die yet { if (die.GetSide() + nPips > 6) // failure case. we can't add this many pips! { adjustedDice.Remove(die); myPlayer.AskToChooseDie(this.PickDie, this.GetType().ToString()); // ask the player to choose a die or dice GameState.Message("ERROR: Can't add exactly " + nPips.ToString() + " to " + die.name); return false; } else { die.AddTempPips(nPips); } } else// we've messed with this die already { die.UndoTempPips(); } } else// we can add up to the number of pips specified in nPips to any die { if (die.getTempPips()+1 > nPips) { die.UndoTempPips(); } else { if (!setToAnyFace && (die.GetSide() + 1 > 6)) // failure case. we can't add this many pips! { die.UndoTempPips(); } if (!isEntertainer) { if (!isSoothsayer) { // do the wrap around. if (die.GetSide() + 1 > 6) { // set the temppips such that it equals 1. die.SetTempPipsValue(1); } else { die.AddTempPips(1); } } else// Soothsayer nonsense here { int exactlyNumDice = 2; if (isAstrologer) exactlyNumDice = 3; if (adjustedDice.Count!= exactlyNumDice) { GameState.Message("Select exactly " + exactlyNumDice.ToString() + " dice."); } else { PharoahDie otherDie = GetOtherDie(die); if (isAstrologer) otherDie = lastDie; if ((otherDie.GetSide() > 1) && (die.GetSide() < 6)) // we can still subtract value from otherDie { die.AddTempPips(1); otherDie.AddTempPips(-1); } else if ((die.GetSide() > 1) && (otherDie.GetSide() < 6))// if we have some value in this die, we can add to the other { die.AddTempPips(-1); otherDie.AddTempPips(1); } else// can't do either, both dice are 1. Make an error { GameState.Message("Cannot change values."); } } } } else// entertainer flipping nonsense { int setVal = 7-die.GetSide(); if (die.getTempPips() == 0) { die.SetTempPipsValue(setVal); } else { die.UndoTempPips(); } } } } } else { GameState.Message("Can't choose " + die.name + " for " + this.name); } myPlayer.AskToChooseDie(this.PickDie, this.GetType().ToString()); // ask the player to choose a die or dice return bLegalDie; }