RunicBoard.ChangeRunePosition C# (CSharp) Méthode

ChangeRunePosition() public méthode

Change a rune's position if it doesn't break the chain to the center.
public ChangeRunePosition ( int actualPosition, int newPosition ) : bool
actualPosition int The actual position if the rune to move
newPosition int Where to place the rune
Résultat bool
    public bool ChangeRunePosition(int actualPosition, int newPosition)
    {
        Rune runeToMove;
        if (_runesOnBoard.TryGetValue(actualPosition, out runeToMove) && ClientManager.GetInstance()._client.IsMyTurn)
        {
            if (!_runesOnBoard.ContainsKey(newPosition))
            {
                // Copy of the runes on board without the rune we want to move
                Dictionary<int, Rune> tempRunesOnBoard = new Dictionary<int, Rune>(_runesOnBoard);
                tempRunesOnBoard.Remove(actualPosition);
                tempRunesOnBoard.Add(newPosition, runeToMove);
                //List<int> explored = new List<int>();

                if (EverythingIsConnectedToCenter(ref tempRunesOnBoard))
                {
                    _runesOnBoard.Add(newPosition, runeToMove);
                    _runesOnBoard.Remove(actualPosition);
                    runeToMove.PositionOnBoard = newPosition;
                    Logger.Debug("Rune moved from " + actualPosition + " to " + newPosition);
                    if (RunesOnBoard.Count == 2)
                        SecondPlaced = newPosition;
                    return true;
                }
                else
                {
                    Logger.Debug("Could not move rune from " + actualPosition + " to " + newPosition);
                }
            }
            else
            {
                Logger.Debug("A rune is already on " + newPosition);
            }
        }
        else
        {
            Logger.Error("ChangeRunePosition : no rune detected at " + actualPosition);
            return false;
        }

        return false;
    }