I am creating a game that must calculate differences in player stats (Blood Bowl for those curious) and have written a routine to do such. However I am worried that changing variables may change the objects, which I do not want.
MyPanel AttackerCell = Frm_Menu.GameBoard.SelectedCell;
MyPanel DefenderCell = this;
int AttackerStrength = AttackerCell.PlayerOnCell.ST;
int DefenderStrength = PlayerOnCell.ST;
if (DefenderStrength > AttackerStrength && AttackerCell.PlayerOnCell.Skills.Contains("Dauntless"))
{
Random Dice = new Random();
int DiceResult = Dice.Next(1, 7);
if (DiceResult + AttackerStrength < DefenderStrength)
{
AttackerStrength = DefenderStrength;
}
}
PlayerOnCell is of custom type player - and has an integer property called ST (Strength)
ignoring the if statements, they are to do with the game rules, the line AttackerStrength = DefenderStength; possess my issue.
Will the new assignment of AttackerStrength propagate back and effect AttackerCell.PlayerOnCell.ST? If so, how do I stop this?