Skip to content

Multiplayer

Millie Macdonald edited this page Jan 18, 2017 · 1 revision

Major classes and packages

In Singularity we will have a number of Messages. These will be simple, immutable records that are easily serialisable.

At singularity.common.representations.pyramidscheme.multiplayer, there is an

abstract class Message {
}

with concrete classes

class QueueDetailsMessage extends Message {

    class QueueDetails implements Serializable {
        String username;
        String champion; 
        HashMap<String, Integer> deck;
    }
}

for each message specified in the protocol section.

Protocol

Joining the Queue

When a user wants to play multiplayer, they have to join a matchmaking queue. The player will need to have chosen a name, and a deck, before joining the queue.

To Singularity

class QueueDetails implements Serializable {
    String username; // Where username is the name the client has self assigned
    String champion; 
    HashMap<String, Integer> deck; // where String is the name of card, where Integer is the quantity
}

From Singularity

class QueueConfirm implements Serializable {
    int token; // Where token is a unique assigned identifier created by singularity
}

Note that token will be used in all future communications generated by each client. This permits two clients to have the same username.

Joining a game

When Singularity has successfully found a pairing between users, it attempts to start a game between them.

From Singularity

class GameDetails implements Serializable {
    long seed; // A RNG seed for the game
}

From Singularity

class OpponentDetails implements Serializable {
    String username; 
    String champion; 
}

OpponentDetails is just a forwarded copy of QueueDetails. Ideally, all this information is unpacked into Match (or some other class that can be accessed through a Singleton). BasicMatchController will need to unpack all this information from Match on initialization.

From Singularity

class OpponentDeck implements Serializable {

    class Card implements Serializable {
        String cardname;
        String UID;
    }

    ArrayList<Card> cards;
}

Singularity has tagged all cards of both decks, to assign them a unique identifier. This will be used to coordinate game actions.

Playing a game

To Singularity, and forwarded to opponent

class Shuffle imlements Serializable {
    int token; // The token of the client that's shuffling the deck
    String target; // Decks or pyramids can be shuffled
}

To Singularity, and forwarded to opponent

class ArrangePyramid implements Serializable {
    int token;
    String arrangementName; // e.g. "pyramid"
}

To Singularity, and forwarded to opponent

class PlayCard implements Serializable {
    int token;
    int cardUID;
    int x;
    int y;
}

To Singularity, and forwarded to opponent

class HoldCard implements Serializable  {
    int token;
    int cardUID;
    int x;
    int y;
}

To Singularity, and forwarded to opponent

class GrindCard implements Serializable {
    int token;
    int cardUID;
}

To Singularity, and forwarded to opponent

class PassTurn implements Serializable {
    int token;
}

To Singularity, and forwarded to opponent

class ChampionAbility implements Serializable {
    int token;
    String ability;
    int targetCardUID;
}

Note that the specified x and y coordinates are the senders screenspace coordinates. Reiterating, he player will transmit a message using their screenspace coordiantes. The other player will need to convert these coordinates (perhaps by mirroring the x coordinate) so the card is placed / moved to the correct location.

Home

Saving and Loading

Statistics tracking

Game Play

APIs


Game Guide

Other Guides

Design Guides

Overviews

Features

Animations

Splash Screen & Create Account Screen

Player Account Settings

AI

Duck Dust


Brainstorming


Future Development


http://cultofthepartyparrot.com/parrots/partyparrot.gifhttp://cultofthepartyparrot.com/parrots/partyparrot.gifhttp://cultofthepartyparrot.com/parrots/partyparrot.gifhttp://cultofthepartyparrot.com/parrots/partyparrot.gif

Clone this wiki locally