Beispiel #1
0
    // If this is called a card surely exists in the development card deck.
    public void ConfirmPress()
    {
        if (action == ActionCode.BUY_DEVELOPMENT_CARD)
        {
            // Close panel. Get a development card from the deck.
            statusPanel.SetActive(false);

            // Pay the card cost.
            inventory.TakeFromPlayer(Inventory.UnitCode.GRAIN, 1);
            inventory.TakeFromPlayer(Inventory.UnitCode.ORE, 1);
            inventory.TakeFromPlayer(Inventory.UnitCode.WOOL, 1);

            // Receive card.

            Inventory.UnitCode receivedCard = deck.TakeCard();

            inventory.ReceiveDevelopmentCard(receivedCard);

            // Event text.
            GameObject.Find("EventTextController").GetComponent <EventTextController>().SendEvent(EventTextController.EventCode.DEVELOPMENT_CARD_PURCHASED, PhotonNetwork.LocalPlayer);
        }
        else if (action == ActionCode.PLAY_DEVELOPMENT_CARD)
        {
            statusPanel.SetActive(false);

            // Play the card.
            inventory.PlayDevelopmentCard(cardToPlay);
        }
    }
    public void SetVictoryPoint(Inventory.UnitCode source, int amount)
    {
        switch (source)
        {
        case Inventory.UnitCode.SETTLEMENT:
            scoreText[0].text = "Settlements: +" + amount;
            break;

        case Inventory.UnitCode.CITY:
            scoreText[1].text = "Cities: +" + amount;
            break;

        case Inventory.UnitCode.LARGEST_ARMY:
            scoreText[2].text = "Largest Army: +" + amount;
            break;

        case Inventory.UnitCode.LONGEST_ROAD:
            scoreText[3].text = "Longest Road: +" + amount;
            break;

        case Inventory.UnitCode.VICTORY_CARD:
            scoreText[4].text = "Victory Cards: +" + amount;
            break;
        }
    }
    public void RetractResourceOffer(Inventory.UnitCode unitCode, int amount)
    {
        // Remove this resource from the local offers slot. Send a message to the other player to update their remote card slot.
        int oldAmount = localCards[(int)unitCode].getAmount();

        localCards[(int)unitCode].UpdateCard(oldAmount - amount);

        if (!supplyTrading)
        {
            int[] retractResourceOfferMessage = new int[4];

            retractResourceOfferMessage[0] = (int)GamePlayer.MessageCode.RESOURCE_RETRACTED; // Message code.
            retractResourceOfferMessage[1] = (amRecepient) ? senderId : recepientId;         // Who should read the message?
            retractResourceOfferMessage[2] = (int)unitCode;                                  // What resource am I retracting?
            retractResourceOfferMessage[3] = amount;                                         // How much of it am I retracting?

            GameObject.Find("TurnManager").GetComponent <TurnManager>().SendMove(retractResourceOfferMessage, false);

            // If the player confirmed locally and then attempts to make a change, unconfirm.
            if (confirmed)
            {
                UnlockLocalPanel();
            }
            if (otherConfirmed)
            {
                UnlockRemotePanel();
            }
        }
        else
        {
            SupplyOnOfferChanged();
        }
    }
Beispiel #4
0
    public static string GetResourceText(Inventory.UnitCode resourceCode)
    {
        if (resourceCode > Inventory.UnitCode.WOOL)
        {
            // Only happens if this function gets called for a non-resource parameter.
            return("<invalid_resource_code>");
        }

        return("<color=" + resourceColours[(int)resourceCode] + ">" + resourceNames[(int)resourceCode] + "</color>");
    }
Beispiel #5
0
    // This method is called only if the deck has cards.
    public Inventory.UnitCode TakeCard()
    {
        // Take a card from the top of the deck.
        Inventory.UnitCode card = deck.Peek();

        // Notify every client to discard the top card.
        photonView.RPC("RPCTakeCard", RpcTarget.All);

        return(card);
    }
    public void YearOfPlentyCardChosen(Inventory.UnitCode unitCode, int amount)
    {
        // Always adds to the selected cards. Use the Clear button in the top right hand corner to clear the remote cards.

        if (AvailableCards > 0)
        {
            int oldAmount = remoteCards[(int)unitCode].getAmount();
            remoteCards[(int)unitCode].UpdateCard(oldAmount + amount);

            AvailableCards -= amount;
        }
    }
Beispiel #7
0
    // Only called by the master client when the board is generated.
    private void ShuffleDeck()
    {
        // Create an unsorted deck.
        deck = new Queue <Inventory.UnitCode>();
        int[] cardStockCopy = new int[cardInitialStock.Length];
        cardInitialStock.CopyTo(cardStockCopy, 0);
        Inventory.UnitCode[] unsortedDeck = new Inventory.UnitCode[DEVELOPMENT_CARD_COUNT];

        for (int i = 0, j = 0; i < cardInitialStock.Length;)
        {
            if (cardStockCopy[i] != 0)
            {
                unsortedDeck[j++] = developmentCards[i];
                cardStockCopy[i]--;
            }
            else
            {
                i++;
            }
        }

        // Shuffle for 5 iterations.
        for (int i = 0; i < ITERATION_NUMBER; i++)
        {
            RecursiveShuffle(deck, unsortedDeck, 0, DEVELOPMENT_CARD_COUNT - 1, i);

            if (i != ITERATION_NUMBER - 1)
            {
                // Flush deck queue into unsortedDeck.
                int j = 0;
                while (deck.Count > 0)
                {
                    unsortedDeck[j++] = deck.Dequeue();
                }
            }
        }

        int[] sortedDeck = new int[DEVELOPMENT_CARD_COUNT];
        int   r          = 0;

        foreach (Inventory.UnitCode card in deck)
        {
            sortedDeck[r++] = (int)card;
        }

        GameObject.Find("ShopController").GetComponent <ShopController>().SetDeck(this);

        // Set this deck room-wide.
        photonView.RPC("RPCSetDeck", RpcTarget.OthersBuffered, sortedDeck);
    }
Beispiel #8
0
    // A monopoly card was selected. Steal this resource from all the other players.
    public void MonopolyCardClicked(Inventory.UnitCode unitCode)
    {
        monopolyPanel.SetActive(false);

        this.monopolyResource = unitCode;
        this.monopolyReplies  = 0;

        // Send a monopoly card message to all other players.
        int[] monopolyPlayedMessage = new int[3];
        monopolyPlayedMessage[0] = (int)GamePlayer.MessageCode.MONOPOLY_PLAYED; // Message code.
        monopolyPlayedMessage[1] = PhotonNetwork.LocalPlayer.ActorNumber;       // Who is sending the message.
        monopolyPlayedMessage[2] = (int)unitCode;                               // What resource should the others give to this player.

        GameObject.Find("TurnManager").GetComponent <TurnManager>().SendMove(monopolyPlayedMessage, false);
    }
Beispiel #9
0
    public void RetractResourceDiscard(Inventory.UnitCode unitCode, int amount)
    {
        // Remove a unit from the card panel.
        int oldAmount = discardCards[(int)unitCode].getAmount();

        discardCards[(int)unitCode].UpdateCard(oldAmount - amount);

        if (Remaining == 0)
        {
            // Disable the button again.
            discardButton.interactable = false;
        }

        Remaining++;
    }
    public void ResourceOfferRetracted(Inventory.UnitCode unitCode, int amount)
    {
        // Update remote card slot.

        int oldAmount = remoteCards[(int)unitCode].getAmount();

        remoteCards[(int)unitCode].UpdateCard(oldAmount - amount);

        // If the remote player had confirmed the trade beforehand, unlock both mine and his.
        if (confirmed)
        {
            UnlockLocalPanel();
        }
        if (otherConfirmed)
        {
            UnlockRemotePanel();
        }
    }
Beispiel #11
0
    public void DiscardResource(Inventory.UnitCode unitCode, int amount)
    {
        if (Remaining != 0)
        {
            int oldAmount = discardCards[(int)unitCode].getAmount();
            discardCards[(int)unitCode].UpdateCard(oldAmount + amount);

            Remaining--;

            if (Remaining == 0)
            {
                discardButton.interactable = true;
            }
        }
        else
        {
            inventory.GiveToPlayer(unitCode, amount);
        }
    }
Beispiel #12
0
    public void PlayDevelopmentCard(Inventory.UnitCode unitCode)
    {
        if (statusPanel.activeSelf == true)
        {
            // A card is opened already.
            return;
        }

        cardToPlay = unitCode;
        action     = ActionCode.PLAY_DEVELOPMENT_CARD;

        TextMeshProUGUI popupText = statusPanel.transform.GetChild(0).gameObject.transform.GetChild(0).GetComponent <TextMeshProUGUI>();

        if (inventory.CanPlayDevelopmentCard(unitCode))
        {
            // If the player has already played a development card this turn, prevent him from playing another.
            if (inventory.HasPlayedDevelopmentCardThisTurn())
            {
                popupText.text             = "<color=red>You may only play one Development card per turn.</color>";
                confirmButton.interactable = false;
            }
            else
            {
                popupText.text             = "<color=green>Are you sure you want to play this Development card?</color>";
                confirmButton.interactable = true;
            }
        }
        else
        {
            popupText.text             = "<color=red>Development cards can first be played a turn after their purchase.</color>";
            confirmButton.interactable = false;
        }

        // Open panel.
        statusPanel.SetActive(true);
    }
Beispiel #13
0
    private string GetMessage(EventCode code, int actorNumber, params object[] additionalParams)
    {
        switch (code)
        {
        case EventCode.FIRST_TURN_PHASE_ONE:

            return(ColourUtility.GetPlayerDisplayNameFromId(actorNumber) + " is placing their first settlement.");

        case EventCode.FIRST_TURN_PHASE_TWO:
            return(ColourUtility.GetPlayerDisplayNameFromId(actorNumber) + " is placing their first road.");

        case EventCode.SECOND_TURN_PHASE_ONE:

            return(ColourUtility.GetPlayerDisplayNameFromId(actorNumber) + " is placing their second settlement.");

        case EventCode.SECOND_TURN_PHASE_TWO:
            return(ColourUtility.GetPlayerDisplayNameFromId(actorNumber) + " is placing their second road.");

        case EventCode.ROAD_CONSTRUCTED:
            return(ColourUtility.GetPlayerDisplayNameFromId(actorNumber) + " has constructed a road.");

        case EventCode.SETTLEMENT_CONSTRUCTED:
            return(ColourUtility.GetPlayerDisplayNameFromId(actorNumber) + " has constructed a settlement.");

        case EventCode.CITY_CONSTRUCTED:
            return(ColourUtility.GetPlayerDisplayNameFromId(actorNumber) + " has upgraded a settlement into a city.");

        case EventCode.PRE_DICE_ROLL:

            return(ColourUtility.GetPlayerDisplayNameFromId(actorNumber) + " is rolling the dice.");

        case EventCode.DICE_ROLLED:
            int    diceValue       = (int)additionalParams[0];
            string diceValueString = "";
            if (diceValue == 7)
            {
                diceValueString = "<color=black>";
            }
            else if (diceValue == 6 || diceValue == 8)
            {
                diceValueString = "<color=red>";
            }

            diceValueString += diceValue;
            if (diceValue >= 6 && diceValue <= 8)
            {
                diceValueString += "</color>";
            }
            return(ColourUtility.GetPlayerDisplayNameFromId(actorNumber) + " has rolled a " + diceValueString + ".");

        case EventCode.PLAYER_IDLE:

            return("Waiting for an action from " + ColourUtility.GetPlayerDisplayNameFromId(actorNumber) + ".");

        case EventCode.RESOURCE_EARNED:

            int resourceType = (int)additionalParams[0];
            int amount       = (int)additionalParams[1];

            Debug.Log("resourceType = " + resourceType + ", amount = " + amount);

            return(ColourUtility.GetPlayerDisplayNameFromId(actorNumber) + " has earned " + amount + "x" + ColourUtility.GetResourceText((Inventory.UnitCode)resourceType) + ".");

        case EventCode.NO_RESOURCE_EARNED:

            return("No player has earned any resources from this roll.");

        case EventCode.TRADE_SUPPLY_INITIATED:

            return(ColourUtility.GetPlayerDisplayNameFromId(actorNumber) + " is trading with the supply.");

        case EventCode.TRADE_PLAYERS_INITIATED:
            int secondPlayerId = (int)additionalParams[0];
            return(ColourUtility.GetPlayerDisplayNameFromId(actorNumber) + " is trading with " + ColourUtility.GetPlayerDisplayNameFromId(secondPlayerId) + ".");

        case EventCode.TRADE_CANCELLED:

            return(ColourUtility.GetPlayerDisplayNameFromId(actorNumber) + " has cancelled the trade.");

        case EventCode.TRADE_SUPPLY_COMPLETED:

            return(ColourUtility.GetPlayerDisplayNameFromId(actorNumber) + " has finished trading with the supply.");

        case EventCode.TRADE_PLAYERS_COMPLETED:
            secondPlayerId = (int)additionalParams[0];
            return(ColourUtility.GetPlayerDisplayNameFromId(actorNumber) + " has finished trading with " + ColourUtility.GetPlayerDisplayNameFromId(secondPlayerId) + ".");

        case EventCode.SHOULD_DISCARD:

            string resultText = "Waiting for ";

            if (actorNumber == -1)
            {
                // Initial set.
                discardList = ((int[])additionalParams[0]).OfType <int>().ToList();

                bool first = true;
                for (int i = 0; i < discardList.Count; i++)
                {
                    if (first)
                    {
                        first = false;
                    }
                    else
                    {
                        resultText += ", ";
                    }
                    //discardlist[i] is null for some reason
                    resultText += ColourUtility.GetPlayerDisplayNameFromId(discardList[i]);
                }
                resultText += " to discard half of their resource cards.";
            }
            else
            {
                // Update. Remove the player from the discard list and then repeat.
                if (discardList.IndexOf(actorNumber) != -1)
                {
                    discardList.Remove(actorNumber);
                }

                bool first = true;
                for (int i = 0; i < discardList.Count; i++)
                {
                    if (first)
                    {
                        first = false;
                    }
                    else
                    {
                        resultText += ", ";
                    }
                    resultText += ColourUtility.GetPlayerDisplayNameFromId(discardList[i]);
                }
                resultText += " to discard half of their resource cards.";
            }

            Debug.Log(resultText);
            return(resultText);

        case EventCode.BANDIT_MOVE:
            return("Waiting for " + ColourUtility.GetPlayerDisplayNameFromId(actorNumber) + " to move the bandit to another hex.");

        case EventCode.SELECTING_STEAL_VICTIM:
            return("Waiting for " + ColourUtility.GetPlayerDisplayNameFromId(actorNumber) + " to select a player to steal from.");

        case EventCode.STEAL_NO_ADJACENT_PLAYER:
            return(ColourUtility.GetPlayerDisplayNameFromId(actorNumber) + " had nobody to steal from.");

        case EventCode.NO_RESOURCE_STOLEN:
            Player stealPlayer = PhotonNetwork.CurrentRoom.GetPlayer((int)additionalParams[0]);
            return(ColourUtility.GetPlayerDisplayNameFromId(actorNumber) + " had no cards to steal from " + ColourUtility.GetPlayerDisplayName(stealPlayer) + ".");

        case EventCode.RESOURCE_STOLEN:
            stealPlayer = PhotonNetwork.CurrentRoom.GetPlayer((int)additionalParams[0]);
            string resourceText = (string)additionalParams[1];
            return(ColourUtility.GetPlayerDisplayNameFromId(actorNumber) + " has stolen 1x" + resourceText + " from " + ColourUtility.GetPlayerDisplayName(stealPlayer) + ".");

        case EventCode.DEVELOPMENT_CARD_PURCHASED:
            return(ColourUtility.GetPlayerDisplayNameFromId(actorNumber) + " has purchased a development card from the supply.");

        case EventCode.DEVELOPMENT_CARD_PLAYED:
            Inventory.UnitCode cardCode = (Inventory.UnitCode)additionalParams[0];
            return(ColourUtility.GetPlayerDisplayNameFromId(actorNumber) + " has played a " + ColourUtility.GetDevelopmentText(cardCode) + " card!");

        case EventCode.YEAR_OF_PLENTY_INITIATED:
            return("Waiting for " + ColourUtility.GetPlayerDisplayNameFromId(actorNumber) + " to take 2 free Resource cards.");

        case EventCode.YEAR_OF_PLENTY_COMPLETED:
            return(ColourUtility.GetPlayerDisplayNameFromId(actorNumber) + " has taken two resource cards.");

        case EventCode.MONOPOLY_COMPLETE:
            resourceText = (string)additionalParams[0];
            return(ColourUtility.GetPlayerDisplayNameFromId(actorNumber) + " has stolen all " + resourceText + " cards from the other players!");

        case EventCode.LARGEST_ARMY_TAKE_FIRST_TIME:
            return(ColourUtility.GetPlayerDisplayNameFromId(actorNumber) + " has received the <color=black>Largest Army</color> card!");

        case EventCode.LARGEST_ARMY_STEAL:
            stealPlayer = PhotonNetwork.CurrentRoom.GetPlayer((int)additionalParams[0]);
            return(ColourUtility.GetPlayerDisplayNameFromId(actorNumber) + " has stolen the <color=black>Largest Army</color> card from " + ColourUtility.GetPlayerDisplayName(stealPlayer) + "!");

        case EventCode.LONGEST_ROAD_TAKE_FIRST_TIME:
            return(ColourUtility.GetPlayerDisplayNameFromId(actorNumber) + " has received the <color=black>Longest Road</color> card!");

        case EventCode.LONGEST_ROAD_STEAL:
            stealPlayer = PhotonNetwork.CurrentRoom.GetPlayer((int)additionalParams[0]);
            return(ColourUtility.GetPlayerDisplayNameFromId(actorNumber) + " has stolen the <color=black>Longest Road</color> card from " + ColourUtility.GetPlayerDisplayName(stealPlayer) + "!");

        case EventCode.LONGEST_ROAD_RETURNED:
            return("The <color=black>Longest Road</color> card no longer belongs to any player!");

        case EventCode.GAME_OVER:
            return(ColourUtility.GetPlayerDisplayNameFromId(actorNumber) + " has won the game! Press ESC to return to the main menu.");

        case EventCode.END_TURN:
            return(ColourUtility.GetPlayerDisplayNameFromId(actorNumber) + " has ended their turn.");
        }


        return("<invalid_text_code>");
    }
Beispiel #14
0
 public static string GetDevelopmentText(Inventory.UnitCode cardCode)
 {
     return("<color=" + "black" + ">" + developmentCardNames[(int)cardCode - 5] + "</color>");
 }
Beispiel #15
0
    // Gets called when another player makes a move.
    public void OnPlayerMove(Player sender, int turn, object move)
    {
        int[] moveMessage = (int[])move;

        MessageCode moveCode = (MessageCode)moveMessage[0];

        switch (moveCode)
        {
        case MessageCode.RESOURCE_INCOME:
            // If I am the player who should receive the resources, update my inventory. In this case, turn and sender don't matter.
            int playerId = moveMessage[1];
            Inventory.UnitCode resourceType = (Inventory.UnitCode)moveMessage[2];
            int amount = moveMessage[3];

            if (playerId == PhotonNetwork.LocalPlayer.ActorNumber)
            {
                inventory.GiveToPlayer(resourceType, amount);
            }
            break;

        case MessageCode.TRADE_REQUEST:
            // Check if I am the recepient of the trade request.
            int recepientId = moveMessage[1];

            if (recepientId == PhotonNetwork.LocalPlayer.ActorNumber)
            {
                // Display Accept/Decline message locally.
                tradeController.ReceiveTradeRequest(sender.ActorNumber, recepientId);
            }
            break;

        case MessageCode.TRADE_ACCEPTED:

            int senderId = moveMessage[1];

            // If I am the initial sender of the trade request, accept this message.
            if (senderId == PhotonNetwork.LocalPlayer.ActorNumber)
            {
                tradeController.RemoteTradeAccepted();
            }
            break;

        case MessageCode.TRADE_DECLINED:

            senderId = moveMessage[1];

            // If I am the initial sender of the trade request, accept this message.
            if (senderId == PhotonNetwork.LocalPlayer.ActorNumber)
            {
                tradeController.RemoteTradeDeclined();
            }
            break;

        case MessageCode.TRADE_CANCELLED:

            int receiverId = moveMessage[1];
            // Check if I am the recepient of this message.
            if (receiverId == PhotonNetwork.LocalPlayer.ActorNumber)
            {
                tradeController.RemoteTradeCancelled();
            }
            break;

        case MessageCode.TRADE_LOCK:

            receiverId = moveMessage[1];

            if (receiverId == PhotonNetwork.LocalPlayer.ActorNumber)
            {
                tradeController.RemoteTradeLocked();
            }
            break;

        case MessageCode.TRADE_UNLOCK:

            receiverId = moveMessage[1];

            if (receiverId == PhotonNetwork.LocalPlayer.ActorNumber)
            {
                tradeController.RemoteTradeUnlocked();
            }
            break;

        case MessageCode.TRADE_EXECUTE:

            receiverId = moveMessage[1];

            if (receiverId == PhotonNetwork.LocalPlayer.ActorNumber)
            {
                tradeController.RemoteTradeExecuted();
            }
            break;

        case MessageCode.RESOURCE_OFFERED:

            receiverId = moveMessage[1];

            if (receiverId == PhotonNetwork.LocalPlayer.ActorNumber)
            {
                tradeController.ResourceOffered((Inventory.UnitCode)moveMessage[2], moveMessage[3]);
            }
            break;

        case MessageCode.RESOURCE_RETRACTED:
            // Check if I am the recepient of this message.
            receiverId = moveMessage[1];

            if (receiverId == PhotonNetwork.LocalPlayer.ActorNumber)
            {
                tradeController.ResourceOfferRetracted((Inventory.UnitCode)moveMessage[2], moveMessage[3]);
            }
            break;

        case MessageCode.SEVEN_ROLLED_ANNOUNCEMENT:

            // Every player does this.
            senderId = moveMessage[1];

            int[] sevenRolledAcknowledgementMessage = new int[4];

            sevenRolledAcknowledgementMessage[0] = (int)MessageCode.SEVEN_ROLLED_ACKNOWLEDGEMENT;
            sevenRolledAcknowledgementMessage[1] = senderId;
            sevenRolledAcknowledgementMessage[2] = PhotonNetwork.LocalPlayer.ActorNumber;
            if (ShouldDiscard())
            {
                sevenRolledAcknowledgementMessage[3] = 1;
                turnManager.SendMove(sevenRolledAcknowledgementMessage, false);

                GameObject.Find("DiscardController").GetComponent <DiscardController>().DiscardHalf(senderId);
            }
            else
            {
                sevenRolledAcknowledgementMessage[3] = 0;
                turnManager.SendMove(sevenRolledAcknowledgementMessage, false);
            }

            break;

        case MessageCode.SEVEN_ROLLED_ACKNOWLEDGEMENT:

            recepientId = moveMessage[1];

            // Only the player who rolled the 7 does this.
            if (recepientId == PhotonNetwork.LocalPlayer.ActorNumber)
            {
                haveToDiscard[FindPosition(moveMessage[2])] = moveMessage[3] == 1 ? true : false;
                acknowledged++;
                if (acknowledged == PhotonNetwork.CurrentRoom.PlayerCount)
                {
                    waitingForDiscardCount = 0;
                    List <int> playerList = new List <int>();
                    for (int i = 0; i < 4; i++)
                    {
                        if (haveToDiscard[i])
                        {
                            playerList.Add(PhotonNetwork.PlayerList[i].ActorNumber);
                            waitingForDiscardCount++;
                        }
                    }
                    if (waitingForDiscardCount != 0)
                    {
                        eventTextController.SendEvent(EventTextController.EventCode.SHOULD_DISCARD, null, playerList.ToArray());
                    }
                    else
                    {
                        // No one is discarding. Move bandit.
                        MoveBandit();
                    }
                }
            }
            break;

        case MessageCode.SEVEN_ROLLED_DISCARD_COMPLETE:

            recepientId = moveMessage[1];

            if (recepientId == PhotonNetwork.LocalPlayer.ActorNumber)
            {
                // Find out who sent the message.
                senderId = moveMessage[2];


                // Check if it was the last person who was being waited on to send the discard complete message.
                waitingForDiscardCount--;

                if (waitingForDiscardCount == 0)
                {
                    // Last person to discard. Continue on to the moving the bandit phase.
                    MoveBandit();
                }
                else
                {
                    // Notify event text to update.
                    eventTextController.SendEvent(EventTextController.EventCode.SHOULD_DISCARD, PhotonNetwork.CurrentRoom.GetPlayer(senderId));
                }
            }
            break;

        case MessageCode.STEAL_RESOURCE_REQUEST:

            recepientId = moveMessage[1];

            if (recepientId == PhotonNetwork.LocalPlayer.ActorNumber)
            {
                // I am the person who should give my opponent a random resource card.
                inventory.GiveRandomResourceCard(moveMessage[2]);
            }

            break;

        case MessageCode.STEAL_RESOURCE_REPLY:

            recepientId = moveMessage[1];
            if (recepientId == PhotonNetwork.LocalPlayer.ActorNumber)
            {
                // Check which resource the player sent you.

                inventory.ReceiveStolenCard(sender.ActorNumber, moveMessage[2]);
                DisableRollDiceButton();
                EnableEndingTurn();

                eventTextController.SendEvent(EventTextController.EventCode.PLAYER_IDLE, PhotonNetwork.LocalPlayer);
                currentPhase = Phase.TRADE_BUILD_IDLE;
            }
            break;

        case MessageCode.MONOPOLY_PLAYED:

            senderId = moveMessage[1];

            if (PhotonNetwork.LocalPlayer.ActorNumber != senderId)
            {
                // Give ALL of my resources to the sender.
                inventory.GiveAllOfResourceToPlayer((Inventory.UnitCode)moveMessage[2], senderId);
            }
            break;

        case MessageCode.MONOPOLY_REPLY:

            recepientId = moveMessage[1];

            if (recepientId == PhotonNetwork.LocalPlayer.ActorNumber)
            {
                // A player has given me all their resource of the adequate type.
                GameObject.Find("DiscardController").GetComponent <DiscardController>().MonopolyReplyReceived(moveMessage[2]);
            }
            break;

        case MessageCode.LARGEST_ARMY_OVERTAKE:

            senderId = moveMessage[1];
            if (PhotonNetwork.LocalPlayer.ActorNumber != senderId)
            {
                inventory.SetLargestArmyOwner(senderId, moveMessage[2]);
            }

            break;

        case MessageCode.LONGEST_ROAD_OVERTAKE:

            senderId = moveMessage[1];
            if (PhotonNetwork.LocalPlayer.ActorNumber != senderId)
            {
                inventory.SetLongestRoadOwner(senderId, moveMessage[2]);
            }
            else
            {
                if (moveMessage[3] == 0)
                {
                    // Calling from the settlement overtake.
                    inventory.GiveToPlayer(Inventory.UnitCode.LONGEST_ROAD, 1);
                    inventory.AddVictoryPoint(Inventory.UnitCode.LONGEST_ROAD);
                }
            }

            break;

        case MessageCode.LONGEST_ROAD_RETURNED:
            inventory.SetLongestRoadOwner(-1, -1);

            break;

        case MessageCode.GAME_OVER:

            // A player has signalled that the game is over. Allow the local player to go back to the main menu by pressing ESC.
            this.gameOver = true;

            break;
        }
    }