Ejemplo n.º 1
0
        public void CheckIfCollision(Field currentField)
        {
            if (currentField != null)
            {
                if (currentField.MyPawn != null)
                {
                    Player currentPlayer = myBoard.CurrentTurn;
                    Pawn collisionPawn = currentField.MyPawn;
                    BaseField newField = null;

                    for (int i = 0; i < myBoard.AmountOfPlayers; i++)
                    {
                        if (currentField.MyPawn.MyColor == currentPlayer.MyColor)
                        {
                            newField = currentPlayer.GetBaseByNumber(currentField.MyPawn.MyNumber);
                            currentField.MyPawn.MyField = newField;
                            currentField.MyPawn = null;
                            currentField = newField;
                            currentField.MyPawn = collisionPawn;
                            collisionPawn.MyField = currentField;
                            break;
                        }
                        currentPlayer = currentPlayer.Next;
                    }
                    myBoard.MyView.UpdateView();
                }
            }
        }
Ejemplo n.º 2
0
        public Pawn(Player p, Field firstField)
        {
            _player = p;
            _currentField = firstField;
            _onSpawn = true;

            bool inPawnList = false;

            for (int i = 0; i < _player.pawns.Length; i++)
            {
                if (!inPawnList)
                {
                    if (_player.pawns[i] == null)
                    {
                        _player.pawns[i] = this;
                        inPawnList = true;
                    }
                }
            }
        }
Ejemplo n.º 3
0
 public void sendFieldCode(Field f)
 {
     Field temp = f;
     if (temp.pawn != null && temp.pawn.player.color == PlayerColor.GREEN)
     {
         main.fillField(temp.fieldCode, Colors.LawnGreen);
     }
     else if (temp.pawn != null && temp.pawn.player.color == PlayerColor.RED)
     {
         main.fillField(temp.fieldCode, Colors.Red);
     }
     else if (temp.pawn != null && temp.pawn.player.color == PlayerColor.BLUE)
     {
         main.fillField(temp.fieldCode, Colors.Blue);
     }
     else if (temp.pawn != null && temp.pawn.player.color == PlayerColor.YELLOW)
     {
         main.fillField(temp.fieldCode, Colors.Yellow);
     }
     else if ((temp.pawn == null && temp.fieldCode.Equals("field0")) || (temp.pawn == null && temp.fieldCode.StartsWith("goalgreen")) || (temp.pawn == null && temp.fieldCode.StartsWith("pgreen")))
     {
         main.fillField(temp.fieldCode, Colors.Green);
     }
     else if ((temp.pawn == null && temp.fieldCode.Equals("field10")) || (temp.pawn == null && temp.fieldCode.StartsWith("goalred")) || (temp.pawn == null && temp.fieldCode.StartsWith("pred")))
     {
         main.fillField(temp.fieldCode, Colors.DarkRed);
     }
     else if ((temp.pawn == null && temp.fieldCode.Equals("field20")) || (temp.pawn == null && temp.fieldCode.StartsWith("goalblue")) || (temp.pawn == null && temp.fieldCode.StartsWith("pblue")))
     {
         main.fillField(temp.fieldCode, Colors.DarkBlue);
     }
     else if ((temp.pawn == null && temp.fieldCode.Equals("field30")) || (temp.pawn == null && temp.fieldCode.StartsWith("goalyellow")) || (temp.pawn == null && temp.fieldCode.StartsWith("pyellow")))
     {
         main.fillField(temp.fieldCode, Colors.Goldenrod);
     }
     else
     {
         main.fillField(temp.fieldCode, Colors.White);
     }
 }
Ejemplo n.º 4
0
 public Pawn(Field myField, Color myColor, int myNumber)
 {
     this.MyField = myField;
     this.MyColor = myColor;
     this.MyNumber = myNumber;
 }
Ejemplo n.º 5
0
        public void move(int steps , Game g)
        {
            //The actual move
            bool direction = true;

            Field temp = currentField;
            //TESTCODE
            currentField.pawn = null;

            if (_onSpawn)
            {
                //_currentField = _currentField.nextF;
                _onSpawn = false;
            }
                for (int i = 1; i <= steps; i++)
                {

                    if (_currentField.nextF == null)
                    {
                        direction = false;
                    }

                    if (direction)
                    {
                        if (_currentField.switchF != null)
                        {
                            if (_currentField.switchF.player == this._player)
                            {
                                _currentField = _currentField.switchF;
                                _player.pawnsInGoal++;
                            }
                            else
                            {
                                //check if last move & is filled *not a switch*
                                if (i == steps)
                                {
                                    if (_currentField.nextF.pawn != null)
                                    {
                                        _currentField.nextF.pawn.player.pawnToSpawn(_currentField.nextF.pawn , g);
                                        _currentField = _currentField.nextF;
                                        _currentField.pawn = this;
                                    }
                                    else
                                    {
                                        _currentField = _currentField.nextF;
                                        _currentField.pawn = this;
                                    }
                                }
                                else
                                {
                                    //normal move
                                    _currentField = _currentField.nextF;
                                }
                            }
                        }
                        else
                        {
                            //check if last move & is filled *no switch*
                            if (i == steps)
                            {
                                if (_currentField.nextF.pawn != null)
                                {
                                    _currentField.nextF.pawn.player.pawnToSpawn(_currentField.nextF.pawn, g);
                                    _currentField = _currentField.nextF;
                                    _currentField.pawn = this;
                                }
                                else
                                {
                                    _currentField = _currentField.nextF;
                                    _currentField.pawn = this;
                                }
                            }
                            else
                            {
                                //normal move
                                _currentField = _currentField.nextF;
                            }
                        }

                    }
                    else
                    {
                        //check if last move & is filled *going backwards*
                        if (i == steps)
                        {
                            if (_currentField.previousF.pawn != null)
                            {
                                _currentField.previousF.pawn.player.pawnToSpawn(_currentField.previousF.pawn , g);
                                _currentField = _currentField.previousF;
                                _currentField.pawn = this;
                            }
                            else
                            {
                                _currentField = _currentField.previousF;
                                _currentField.pawn = this;
                            }
                        }
                        else
                        {
                            //normal move
                            _currentField = _currentField.previousF;
                        }

                            if (_currentField.switchF != null)
                            {
                                if (_currentField.switchF.player == _player)
                                {
                                    _player.pawnsInGoal--;
                                }
                            }
                      }   // end if else

                    //Drawing step by step
                    if (direction)
                    {
                        if (_currentField.pawn == null)
                        {
                            _currentField.pawn = this;

                        }

                        if (_currentField.previousF.pawn == this)
                        {
                            _currentField.previousF.pawn = null;

                            g.sendFieldCode(_currentField.previousF);
                        }
                    }
                    else
                    {
                        if (_currentField.pawn == null)
                        {
                            _currentField.pawn = this;

                        }

                        if (_currentField.nextF.pawn == this)
                        {
                            _currentField.nextF.pawn = null;

                            g.sendFieldCode(_currentField.nextF);
                        }

                        if (_currentField.switchF != null)
                        {
                            if (_currentField.switchF.pawn != null)
                            {
                                if (_currentField.switchF.pawn == this)
                                {
                                    _currentField.switchF.pawn = null;
                                    g.sendFieldCode(_currentField.switchF);
                                }
                            }
                        }

                    }

                        //no clue why, but wont work without V. maybe it delays something
                       g.colorSpawns();

                    //refresh
                    if (temp != currentField)
                    {
                        //Does not draw steps individually
                        g.sendFieldCode(currentField);
                    }

                }//endfor
                g.colorSpawns();
        }
Ejemplo n.º 6
0
        public void DrawHomeFields(Point startPoint, Field current)
        {
            Point endFieldPoint = new Point(startPoint.X, startPoint.Y);
            int index = 0;

            while (current != null)
            {
                Image img = new Image();
                switch (current.MyColor)
                {
                    case Color.Green:
                        switch(index)
                        {
                            case 0: startPoint.Y += 1; if (current.MyPawn != null) { img.Source = SetPawnImage(current.MyPawn); } else { img.Source = aGreen; } break;
                            case 1: startPoint.Y += 1; if (current.MyPawn != null) { img.Source = SetPawnImage(current.MyPawn); } else { img.Source = bGreen; } break;
                            case 2: startPoint.Y += 1; if (current.MyPawn != null) { img.Source = SetPawnImage(current.MyPawn); } else { img.Source = cGreen; } break;
                            case 3: startPoint.Y += 1; if (current.MyPawn != null) { img.Source = SetPawnImage(current.MyPawn); } else { img.Source = dGreen; } break;
                        }
                        img.SetValue(Grid.ColumnProperty, (int)startPoint.X);
                        img.SetValue(Grid.RowProperty, (int)startPoint.Y);
                        FieldsGrid.Children.Add(img);
                        break;
                    case Color.Red:
                        switch(index)
                        {
                            case 0: startPoint.X -= 1; if (current.MyPawn != null) { img.Source = SetPawnImage(current.MyPawn); } else { img.Source = aRed; } break;
                            case 1: startPoint.X -= 1; if (current.MyPawn != null) { img.Source = SetPawnImage(current.MyPawn); } else { img.Source = bRed; } break;
                            case 2: startPoint.X -= 1; if (current.MyPawn != null) { img.Source = SetPawnImage(current.MyPawn); } else { img.Source = cRed; } break;
                            case 3: startPoint.X -= 1; if (current.MyPawn != null) { img.Source = SetPawnImage(current.MyPawn); } else { img.Source = dRed; } break;
                        }
                        img.SetValue(Grid.ColumnProperty, (int)startPoint.X);
                        img.SetValue(Grid.RowProperty, (int)startPoint.Y);
                        FieldsGrid.Children.Add(img);
                        break;
                    case Color.Blue:
                        switch(index)
                        {
                            case 0: startPoint.Y -= 1; if (current.MyPawn != null) { img.Source = SetPawnImage(current.MyPawn); } else { img.Source = aBlue; } break;
                            case 1: startPoint.Y -= 1; if (current.MyPawn != null) { img.Source = SetPawnImage(current.MyPawn); } else { img.Source = bBlue; } break;
                            case 2: startPoint.Y -= 1; if (current.MyPawn != null) { img.Source = SetPawnImage(current.MyPawn); } else { img.Source = cBlue; } break;
                            case 3: startPoint.Y -= 1; if (current.MyPawn != null) { img.Source = SetPawnImage(current.MyPawn); } else { img.Source = dBlue; } break;
                        }
                        img.SetValue(Grid.ColumnProperty, (int)startPoint.X);
                        img.SetValue(Grid.RowProperty, (int)startPoint.Y);
                        FieldsGrid.Children.Add(img);
                        break;
                    case Color.Yellow:
                        switch(index)
                        {
                            case 0: startPoint.X += 1; if (current.MyPawn != null) { img.Source = SetPawnImage(current.MyPawn); } else { img.Source = aYellow; } break;
                            case 1: startPoint.X += 1; if (current.MyPawn != null) { img.Source = SetPawnImage(current.MyPawn); } else { img.Source = bYellow; } break;
                            case 2: startPoint.X += 1; if (current.MyPawn != null) { img.Source = SetPawnImage(current.MyPawn); } else { img.Source = cYellow; } break;
                            case 3: startPoint.X += 1; if (current.MyPawn != null) { img.Source = SetPawnImage(current.MyPawn); } else { img.Source = dYellow; } break;
                        }
                        img.SetValue(Grid.ColumnProperty, (int)startPoint.X);
                        img.SetValue(Grid.RowProperty, (int)startPoint.Y);
                        FieldsGrid.Children.Add(img);
                        break;
                }
                index++;
                current = current.NextHome;
            }

            startPoint = endFieldPoint;
        }
Ejemplo n.º 7
0
        public void BuildBoardFields(string[] lines)
        {
            Field currentField = null;
            Field previousField = null;
            Field continueOn = null;
            Player currentPlayer;
            for (int y = 1; y < lines.Length; y++)
            {
                for (int x = 0; x < lines[y].Length; x++)
                {
                    if (Origin != null)
                    {
                        previousField = currentField;
                    }
                    switch (y)
                    {
                        case 1: CurrentColor = Color.Yellow; break;
                        case 2: CurrentColor = Color.Green; break;
                        case 3: CurrentColor = Color.Red; break;
                        case 4: CurrentColor = Color.Blue; break;
                    }
                    if (x == 0)
                    {
                        currentField = new StartField(CurrentColor);
                        if (y == 1) { Origin = currentField; }
                        if (y > 1) { previousField = continueOn; previousField.Next = currentField; currentField.Previous = previousField; }
                        if (GetPlayerByColor(CurrentColor) != null)
                        {
                            currentPlayer = GetPlayerByColor(CurrentColor);
                            currentPlayer.MyStart = (StartField)currentField;
                        }

                    }
                    if (x > 0 && x < 9)
                    {
                        currentField = new Field();
                        currentField.Previous = previousField;
                        previousField.Next = currentField;
                    }
                    if (x == 9)
                    {
                        currentField = new EndField();
                        currentField.Previous = previousField;
                        previousField.Next = currentField;
                        continueOn = currentField;
                    }
                    if (x > 9)
                    {
                        Color previousColour = CurrentColor;
                        if (previousColour == Color.Yellow) CurrentColor = Color.Green;
                        if (previousColour == Color.Green) CurrentColor = Color.Red;
                        if (previousColour == Color.Red) CurrentColor = Color.Blue;
                        if (previousColour == Color.Blue) CurrentColor = Color.Yellow;
                        currentField = new HomeField(CurrentColor);
                        currentField.Previous = previousField;
                        previousField.NextHome = (HomeField)currentField;
                        if (GetPlayerByColor(CurrentColor) != null)
                        {
                            currentPlayer = GetPlayerByColor(CurrentColor);
                            currentPlayer.AddHome((HomeField)currentField);
                        }
                        CurrentColor = previousColour;
                    }
                    if (lines[y][x] != 'o')
                    {
                        BaseField current = OriginBaseField;
                        switch(lines[y][x])
                        {
                            case 'y': CurrentColor = Color.Yellow; break;
                            case 'g': CurrentColor = Color.Green; break;
                            case 'b': CurrentColor = Color.Blue; break;
                            case 'r': CurrentColor = Color.Red; break;
                            default: break;
                        }
                        int amount = 0;
                        int baseNr = 0;
                        while (current.MyColor == CurrentColor)
                        {
                            if (current.MyPawn != null)
                            {
                                amount++;
                            }
                            current = (BaseField)current.Next;
                        }
                        current = OriginBaseField;
                        while (current.Next != null)
                        {
                            if (current.MyColor == CurrentColor && current.MyPawn == null)
                            {
                                baseNr = current.MyNumber;
                                break;
                            }
                            current = (BaseField)current.Next;
                        }
                        if (GetPlayerByColor(CurrentColor) != null)
                        {
                            currentPlayer = GetPlayerByColor(CurrentColor);
                            currentField.MyPawn = new Pawn(current, CurrentColor, currentPlayer.GetNonUsedNumber());
                            currentField.MyPawn.MyField = currentField;
                            if(currentField.GetType() == typeof(HomeField))
                            {
                                currentField.IsLocked = true;
                                currentField.MyPawn.IsLocked = true;
                            }
                            currentPlayer.AddPawn(currentField.MyPawn);
                        }
                    }
                }
            }
            Origin.Previous = continueOn;
            continueOn.Next = Origin;
        }
Ejemplo n.º 8
0
 public void PlayTurn(int key)
 {
     if (amountOfTurns < myBoard.AmountOfPlayers + 1)
     {
         FirstTurns(key);
         if (amountOfTurns != 0 && amountOfTurns != myBoard.AmountOfPlayers + 1) { myBoard.CurrentTurn = myBoard.CurrentTurn.Next; currentTurnColor = myBoard.CurrentTurn.MyColor; myBoard.MyView.TurnLabel.Content = currentTurnColor; }
         if (amountOfTurns == myBoard.AmountOfPlayers + 1)
         {
             currentPawn = myBoard.CurrentTurn.GetPawnByNumber(1);
             if (currentPawn.MyField.GetType() == typeof(BaseField))
             {
                 currentField = currentPawn.MyField;
                 currentField.MyPawn = null;
                 currentField = myBoard.CurrentTurn.MyStart;
                 currentPawn.MyField = currentField;
                 currentField.MyPawn = currentPawn;
                 myBoard.CurrentTurn.MyStart.MyPawn = currentPawn;
                 myBoard.MyView.UpdateView();
             }
             SpaceToRethrow = true;
             WaitForSpaceInput = false;
             amountOfTurns += 2;
         }
     }
     else
     {
         if (SpaceToRethrow && !WaitForNumberInput && !WaitForSpaceInput)
         {
             SpaceToRethrow = false;
             ThrowDice();
             myBoard.MyView.UpdateDice();
             if (eyes == 6)
             {
                 WaitForNumberInput = true;
             }
             else
             {
                 if (myBoard.CurrentTurn.FullBase())
                 {
                     myBoard.CurrentTurn = myBoard.CurrentTurn.Next;
                     currentTurnColor = myBoard.CurrentTurn.MyColor;
                     myBoard.MyView.TurnLabel.Content = currentTurnColor;
                     WaitForSpaceInput = true;
                 }
                 else
                 {
                     WaitForNumberInput = true;
                 }
             }
         }
         else if (WaitForSpaceInput && !SpaceToRethrow && !WaitForNumberInput)
         {
             WaitForSpaceInput = false;
             ThrowDice();
             myBoard.MyView.UpdateDice();
             if (eyes == 6)
             {
                 WaitForNumberInput = true;
             }
             else
             {
                 if (myBoard.CurrentTurn.FullBase())
                 {
                     myBoard.CurrentTurn = myBoard.CurrentTurn.Next;
                     currentTurnColor = myBoard.CurrentTurn.MyColor;
                     myBoard.MyView.TurnLabel.Content = currentTurnColor;
                     WaitForSpaceInput = true;
                 }
                 else
                 {
                     WaitForNumberInput = true;
                 }
             }
         }
         else if (WaitForNumberInput && !WaitForSpaceInput && !SpaceToRethrow)
         {
             if (!myBoard.CurrentTurn.GetPawnByNumber(key).IsLocked)
             {
                 WaitForNumberInput = false;
                 if (myBoard.CurrentTurn.GetPawnByNumber(key).MyField.GetType() == typeof(BaseField))
                 {
                     if (eyes == 6)
                     {
                         currentPawn = myBoard.CurrentTurn.GetPawnByNumber(key);
                         currentField = currentPawn.MyField;
                         currentField.MyPawn = null;
                         currentField = myBoard.CurrentTurn.MyStart;
                         CheckIfCollision(currentField);
                         currentPawn.MyField = currentField;
                         currentField.MyPawn = currentPawn;
                         myBoard.CurrentTurn.MyStart.MyPawn = currentPawn;
                         myBoard.MyView.UpdateView();
                         SpaceToRethrow = true;
                     }
                     else
                     {
                         WaitForNumberInput = true;
                         //output
                     }
                 }
                 else
                 {
                     WaitForNumberInput = false;
                     currentPawn = myBoard.CurrentTurn.GetPawnByNumber(key);
                     currentField = currentPawn.MyField;
                     currentField.MyPawn = currentPawn;
                     Move(currentPawn, eyes, currentField);
                     if (eyes == 6)
                     {
                         SpaceToRethrow = true;
                     }
                     else
                     {
                         myBoard.CurrentTurn = myBoard.CurrentTurn.Next;
                         currentTurnColor = myBoard.CurrentTurn.MyColor;
                         myBoard.MyView.TurnLabel.Content = currentTurnColor;
                         WaitForSpaceInput = true;
                     }
                 }
             }
             else
             {
                 WaitForNumberInput = true;
             }
         }
     }
 }
Ejemplo n.º 9
0
 public void Move(Pawn currentPawn, int eyes, Field currentField)
 {
     if (currentField != null)
     {
         bool setToPrevious = false;
         currentField.MyPawn = null;
         for (int i = 0; i < eyes; i++)
         {
             if ((currentField.GetType() == typeof(EndField) && currentField.NextHome.MyColor == currentPawn.MyColor) || (currentField.GetType() == typeof(HomeField)))
             {
                 if (i == eyes - 1)
                 {
                     if (currentField.NextHome != null)
                     {
                         if (setToPrevious)
                         {
                             currentField = currentField.Previous;
                         }
                         else
                         {
                             currentField = currentField.NextHome;
                         }
                     }
                     else
                     {
                         setToPrevious = true;
                         currentField = currentField.Previous;
                     }
                     if (currentField.IsLocked)
                     {
                         while (currentField.IsLocked)
                         {
                             currentField = currentField.Previous;
                         }
                     }
                 }
                 else
                 {
                     if (setToPrevious)
                     {
                         currentField = currentField.Previous;
                     }
                     else
                     {
                         if (currentField.NextHome != null)
                         {
                             currentField = currentField.NextHome;
                         }
                         else
                         {
                             setToPrevious = true;
                             currentField = currentField.Previous;
                         }
                     }
                 }
             }
             else
             {
                 if (setToPrevious)
                 {
                     currentField = currentField.Previous;
                 }
                 else
                 {
                     currentField = currentField.Next;
                 }
             }
         }
         CheckIfCollision(currentField);
         currentPawn.MyField = currentField;
         currentField.MyPawn = currentPawn;
         if (currentField.GetType() == typeof(HomeField))
         {
             currentField.IsLocked = true;
             currentPawn.IsLocked = true;
             CheckIfWon(myBoard.CurrentTurn);
         }
         myBoard.MyView.UpdateView();
         setToPrevious = false;
     }
 }
Ejemplo n.º 10
0
        public void newCreateField(string[] field , Player[] players)
        {
            playerList = players;
            //Field creation prep
            char[] normalF = new char[field[3].Length];
            char[] greenG = new char[4];
            char[] redG = new char[4];
            char[] blueG = new char[4];
            char[] yellowG = new char[4];

            normalF = field[3].ToCharArray();
            greenG = field[4].ToCharArray();
            redG = field[5].ToCharArray();
            blueG = field[6].ToCharArray();
            yellowG = field[7].ToCharArray();

            int yellowPawns = 0, greenPawns = 0, bluePawns = 0, redPawns = 0;

            Field previous = null;
            Field current = null;
            first = null;
            Pawn tempPawn = null;

            //create spawns
            foreach (Player p in players)
            {
                if (p != null)
                {
                    for (int s = 0; s < p.spawns.Length; s++)
                    {
                        string spwnCode = "p" + p.color + "spawn" + s;
                        p.spawns[s] = new Spawn(spwnCode);
                    }
                }
            }

            //create field & goal
            for (int i = 0; i < normalF.Length; i++)
            {

                tempPawn = null;
                //the normal fieldcreation
                switch (normalF[i])
                {
                    // empty field
                    case 'O':
                        current = new Field();
                        current.fieldCode = "field" + i;
                        break;

                     // green on board
                    case 'G':
                        current = new Field();
                        current.fieldCode = "field" + i;
                        tempPawn = new Pawn(players[0], current);
                        current.pawn = tempPawn;
                        theGame.sendFieldCode(current);
                        //add pawn
                        if (players[0].pawns[greenPawns] == null)
                        {
                            tempPawn.onSpawn = false;
                            players[0].pawns[greenPawns] = tempPawn;
                            greenPawns++;
                        }
                        break;

                    //Red on board
                    case 'R':
                        current = new Field();
                        current.fieldCode = "field" + i;
                        tempPawn = new Pawn(players[1], current);
                        current.pawn = tempPawn;
                        theGame.sendFieldCode(current);

                        //add pawn
                        if (players[1].pawns[redPawns] == null)
                        {
                            tempPawn.onSpawn = false;
                            players[1].pawns[redPawns] = tempPawn;
                            redPawns++;
                        }
                        break;

                     // blue on board
                    case 'B':
                        current = new Field();
                        current.fieldCode = "field" + i;
                        tempPawn = new Pawn(players[2], current);
                        current.pawn = tempPawn;
                        theGame.sendFieldCode(current);

                        //add pawn
                        if (players[2].pawns[bluePawns] == null)
                        {
                            tempPawn.onSpawn = false;
                            players[2].pawns[bluePawns] = tempPawn;
                            bluePawns++;
                        }
                        break;

                    //yellow on board
                    case 'Y':
                        current = new Field();
                        current.fieldCode = "field" + i;
                        tempPawn = new Pawn(players[3], current);
                        current.pawn = tempPawn;
                        theGame.sendFieldCode(current);

                        //add pawn
                        if (players[3] != null)
                        {
                            if (players[3].pawns[yellowPawns] == null)
                            {
                                tempPawn.onSpawn = false;
                                players[3].pawns[yellowPawns] = tempPawn;
                                yellowPawns++;
                            }
                        }
                        break;

                }

                //special steps
                switch (i)
                {

                        //startingfields
                    case 0:
                        first = current;

                        players[0].startingField = current;
                        foreach (Spawn sp in players[0].spawns)
                        {
                            sp.nextF = current;
                        }
                        break;
                    case 10:
                        players[1].startingField = current;
                        foreach (Spawn sp in players[1].spawns)
                        {
                            sp.nextF = current;
                        }
                        break;
                    case 20:
                        if (players[2] != null)
                        {
                            players[2].startingField = current;
                            foreach (Spawn sp in players[2].spawns)
                            {
                                sp.nextF = current;
                            }
                        }
                        break;

                    case 30:

                        if (players[3] != null)
                        {
                            players[3].startingField = current;
                            foreach (Spawn sp in players[3].spawns)
                            {
                                sp.nextF = current;
                            }
                        }
                        break;

                        //switchpoints + goal creation
                    case 9:
                        Goal rTemp = null;
                        Goal rPrev = null;

                        for (int g = 0; g < redG.Length; g++)
                        {
                            string fc = "goal" + players[1].color + g;
                            if (redG[g].Equals('R'))
                            {
                                rTemp = new Goal(players[1], fc);
                                rTemp.pawn = new Pawn(players[1], rTemp);
                                players[1].pawnsInGoal += 1;
                                theGame.sendFieldCode(rTemp);
                                if (players[1].pawns[redPawns] == null)
                                {
                                    tempPawn.onSpawn = false;
                                    players[1].pawns[redPawns] = tempPawn;
                                    redPawns++;
                                }
                            }
                            else
                            {
                                rTemp = new Goal(players[1], fc);
                            }

                            if (g == 0)
                            {
                                current.switchF = rTemp;
                                rTemp.previousF = current;
                            }
                            else
                            {
                                rTemp.previousF = rPrev;
                                rPrev.nextF = rTemp;

                            }
                            rPrev = rTemp;
                        }
                        break;

                    case 19:
                        if (players[2] != null)
                        {

                            Goal bTemp = null;
                            Goal bPrev = null;

                            for (int g = 0; g < blueG.Length; g++)
                            {
                                string fc = "goal" + players[2].color + g;
                                if (blueG[g].Equals('B'))
                                {
                                    bTemp = new Goal(players[2], fc);
                                    bTemp.pawn = new Pawn(players[2], bTemp);
                                    players[2].pawnsInGoal += 1;
                                    theGame.sendFieldCode(bTemp);
                                    if (players[2].pawns[bluePawns] == null)
                                    {
                                        tempPawn.onSpawn = false;
                                        players[2].pawns[bluePawns] = tempPawn;
                                        bluePawns++;
                                    }
                                }
                                else
                                {
                                    bTemp = new Goal(players[2], fc);
                                }

                                if (g == 0)
                                {
                                    current.switchF = bTemp;
                                    bTemp.previousF = current;
                                }
                                else
                                {
                                    bTemp.previousF = bPrev;
                                    bPrev.nextF = bTemp;

                                }
                                bPrev = bTemp;
                            }
                        }
                        break;

                    case 29:
                        Goal yTemp = null;
                        Goal yPrev = null;

                        if (players[3] != null)
                        {

                            for (int g = 0; g < yellowG.Length; g++)
                            {
                                string fc = "goal" + players[3].color + g;
                                if (yellowG[g].Equals('Y'))
                                {
                                    yTemp = new Goal(players[3], fc);
                                    yTemp.pawn = new Pawn(players[3], yTemp);
                                    players[3].pawnsInGoal += 1;
                                    theGame.sendFieldCode(yTemp);
                                    if (players[3].pawns[yellowPawns] == null)
                                    {
                                        tempPawn.onSpawn = false;
                                        players[3].pawns[yellowPawns] = tempPawn;
                                        yellowPawns++;
                                    }
                                }
                                else
                                {
                                    yTemp = new Goal(players[3], fc);
                                }

                                if (g == 0)
                                {
                                    current.switchF = yTemp;
                                    yTemp.previousF = current;
                                }
                                else
                                {
                                    yTemp.previousF = yPrev;
                                    yPrev.nextF = yTemp;

                                }
                                yPrev = yTemp;
                            }

                        }
                    break;
                    case 39:

                        if (players[0] != null)
                        {
                            Goal gTemp = null;
                            Goal gPrev = null;

                            for (int g = 0; g < greenG.Length; g++)
                            {
                                string fc = "goal" + players[0].color + g;
                                if (greenG[g].Equals('G'))
                                {
                                    gTemp = new Goal(players[0], fc);
                                    gTemp.pawn = new Pawn(players[0], gTemp);
                                    players[0].pawnsInGoal += 1;
                                    theGame.sendFieldCode(gTemp);
                                    if (players[0].pawns[greenPawns] == null)
                                    {
                                        tempPawn.onSpawn = false;
                                        players[0].pawns[greenPawns] = tempPawn;
                                        greenPawns++;
                                    }
                                }
                                else
                                {
                                    gTemp = new Goal(players[0], fc);
                                }

                                if (g == 0)
                                {
                                    current.switchF = gTemp;
                                    gTemp.previousF = current;
                                }
                                else
                                {
                                    gTemp.previousF = gPrev;
                                    gPrev.nextF = gTemp;

                                }
                                gPrev = gTemp;
                            }
                            //link ends

                            previous.nextF = current;
                            current.previousF = previous;

                            current.nextF = first;
                            first.previousF = current;
                        }
                        break;

                }

                //link the list
                if (i != 0 && i != 39)
                {
                    previous.nextF = current;
                    current.previousF = previous;
                }

                previous = current;

            } // end for

            //create pawns if not created yet:
            foreach (Player p in players)
            {
                if (p != null)
                {
                    for (int counter1 = 0; counter1 < 4; counter1++)
                    {
                        if (p.pawns[counter1] == null)
                        {
                            bool placed = false;
                            while (!placed)
                            {
                                for (int counter2 = 0; counter2 < p.spawns.Length; counter2++)
                                {

                                    if (p.pawns[counter2] == null)
                                    {
                                        p.pawns[counter1] = new Pawn(p, p.spawns[counter2]);
                                        p.spawns[counter2].pawn = p.pawns[counter1];
                                        placed = true;
                                    }
                                } // last for
                            }
                        }
                    } // first for
                }
            }
        }