I'm close to quitting Photon... Shuffling Cards

It's been 35h straight, i've been staying up all night and day non stop trying to figure this out, i read all the forums referring to the topic: Shuffling cards.
https://imgur.com/a/1U0lW1F
I'm working on Card Game that is more of a 2 card match card game style rather than your classic playing card game.
All cards are facing down and and each player flips up a card, so all cards need to be shuffled on Awake().

I know that the master client has to to be the only one to shuffle the cards otherwise each player would have different shuffled board cards. The problem is that i can't send the values of type 'Card' to the other clients:

I know that i must use the Photon Custom data types for that but the problem is that in my type class 'Card' i've got Sprites, strings, gameobjects(particle effects) , array of gameObjects. So you can see where my problem is...

The structure of my game and the core of my problem will make a bit more sense by looking at the screenshots:

- You will see the 'Card' class that i have stated above
- How the Card scriptableObject class is used as a List of 'Card' gameobjects( don't worry i will make it an array instead for Photon) and how each boardCards.card = to the List<Card> in Awake() (Ps: this is the solo mode i know that i would need to call RPC's)
- The editor to see how tbe script is used and attached to the boardCard Gameobject with a PhotonView.

i have tried in Awake(){
if(PhotonNetwork.IsMasterClient){
Shuffle()
for (int i = 0; i < cardAssets.Count; i++)
{

boardCards.GetComponent<CardAnimation>().card = cardAssets;
}
}
After that i learned that i must use Custom data types but i don't know how to do that, i've seen all the forums about it but don't know how to implement it with my 'Card' class.

Please help i'm so exhausted trying to figure out something as simple as this...

Answers

  • don't know how to upload images so i have uploaded the images on the link above
  • I know that the master client has to to be the only one to shuffle the cards otherwise each player would have different shuffled board cards. The problem is that i can't send the values of type 'Card' to the other clients:
    yes but also not necesarrily
    I know that i must use the Photon Custom data types for that but the problem is that in my type class 'Card' i've got Sprites, strings, gameobjects(particle effects) , array of gameObjects. So you can see where my problem is...
    don't quit photon yet! you have zero netcode!!! you haven't even started! all you need to do is figure out a way to send the cards state from whoever shuffled to everyone else! many ways to do this! using custom object oriented things in this case is not helping though. if possible, best to represent complex structures (like, say, a card) via a byte (or a short or an int if you really have to, but for cards, byte should work fine). then you can send a byte array over via an RPC and everybody on the same page fam! i gotchu
  • matthewjd24
    edited August 15
    @UniquelyTama9 I think how I've set mine up may help. In my multiplayer rooms, each player has a team color, 'faction' they're playing as, their username, and their rank. Whenever any of this changes, the request goes to the master client, and then he processes it, and then the master client sends out what is on his screen to everybody else. So I think I've how done that is similar to how you need to sync your cards across every player's screen.

    I put the players' data into an object[16]. Then I call an RPC, putting that object into the RPC, and send it to everyone else. Then they 'unpackage' that object and use it to update their screen. Here is what the master client sends:
    public void SendFullRoomStatus()
        {
            object[] playersdata = new object[16];
    
            int x = 0;
            foreach (var e in playersInRoom) {
                playersdata[x] = e.userID;
                x++;
                playersdata[x] = e.team;
                x++;
                playersdata[x] = e.government;
                x++;
                playersdata[x] = e.Rank;
                x++;
            }
    
            photonView.RPC("UpdateRoom", RpcTarget.All, playersdata);
        }
    

    And here is what the receivers do with it:
    [PunRPC]
        void UpdateRoom(object[] RoomStatus)
        {
            playersInRoom.Clear();
    
            for(int i = 0; i <= 12; i += 4) {
                if (RoomStatus[i] != null) {
                    PlayerInRoom newPlayer = new PlayerInRoom() {
                        userID = RoomStatus[i].ToString(),
                        team = (Team)RoomStatus[i + 1],
                        government = (Government)RoomStatus[i + 2],
                        Rank = (int)RoomStatus[i + 3]
                    };
                    playersInRoom.Add(newPlayer);
                }
            }
    
            UpdateUI();   
        }
    

    So if I'm reading your post right, you need to take all of the information about each card, put it into an object, and pass that object into the RPC. As you can see, my multiplayer rooms have 4 players, and 4 attributes for each player, which ends up being 16 pieces of data that need to be sent. Similarly, if you have 52 cards, and just one piece of information about each (the 'value'), you can make an object[52] and put in all of that information. The other players can unpackage that object and use it to make sure their cards are shuffled similarly as well.