static DecodeNetworkObjects()
        {
            var messageDecoder = new NetworkMessageObject.MessageObjectReader();
            var boolDecoder = new NetworkBoolObject.BoolObjectReader();
            var newPlayerDecoder = new NetworkNewPlayerObject.NewPlayerObjectReader();
            var cardDecoder = new NetworkCardObject.CardObjectReader();
            var playerDecoder = new NetworkPlayerObject.PlayerObjectReader();
            var byteDecoder = new NetworkByteObject.ByteObjectDecoder();
            RegisterDecoder(Message, messageDecoder);
            RegisterDecoder(ReceiveMessage, messageDecoder);
            RegisterDecoder(PlayerConnected, newPlayerDecoder);
            RegisterDecoder(PlayerDisconnected, newPlayerDecoder);
            RegisterDecoder(AnnounceCard, cardDecoder);
            RegisterDecoder(SendGameState, new NetworkGameStateObject.GameStateObjectReader());
            RegisterDecoder(RevealRole, new NetworkRevealRoleObject.RevealRoleObjectReader());
            RegisterDecoder(Multiple, new NetworkMultipleObject.MultipleObjectReader());
            RegisterDecoder(AnnouncePresident, playerDecoder);
            RegisterDecoder(AnnounceChancellor, playerDecoder);
            RegisterDecoder(CastVote, boolDecoder);
            RegisterDecoder(PlayerVoted, playerDecoder);
            RegisterDecoder(AnnounceVotes, new NetworkVoteResultObject.VoteResultObjectDecoder());
            RegisterDecoder(PolicyCardsDrawn, byteDecoder);
            RegisterDecoder(PresidentPickPolicyCard, cardDecoder);
            RegisterDecoder(ChancellorPickPolicyCard, cardDecoder);
            RegisterDecoder(PresidentPolicyCardPicked, byteDecoder);
            RegisterDecoder(ChancellorPolicyCardPicked, byteDecoder);
            RegisterDecoder(CardPlayed, cardDecoder);
            RegisterDecoder(RevealMembership, newPlayerDecoder);
            RegisterDecoder(KillPlayer, playerDecoder);
            RegisterDecoder(NotHitler, playerDecoder);
            RegisterDecoder(PresidentRequestVetoAllowed, boolDecoder);
            RegisterDecoder(AnnounceVetoResult, boolDecoder);

            RegisterDecoder(PresidentAction, byteDecoder);
            RegisterDecoder(PresidentDoingAction, playerDecoder);

            RegisterDecoder(PresidentActionExamine, cardDecoder);
            //Other Actions are plain objects

            //Examine object is a plain object notifying the server the player is done
            RegisterDecoder(PresidentActionKillResponse, playerDecoder);
            RegisterDecoder(PresidentActionChoosePresidentResponse, playerDecoder);
            RegisterDecoder(PresidentActionInvestigatePresidentResponse, playerDecoder);
        }
예제 #2
0
 public void NetworkNewPlayerObject()
 {
     var obj = new NetworkNewPlayerObject(ServerCommands.PlayerConnected, Player.GetPlayer("Sander"), 1);
     var decoder = new NetworkNewPlayerObject.NewPlayerObjectReader();
     var bytes = decoder.GenerateByteStream(obj);
     var generatedObj = decoder.GenerateObject(bytes, false);
     Assert.IsInstanceOfType(generatedObj, typeof(NetworkNewPlayerObject));
     var newPlayerObj = generatedObj as NetworkNewPlayerObject;
     Assert.AreEqual(newPlayerObj.SeatPos, obj.SeatPos);
     Assert.AreEqual(newPlayerObj.Player, obj.Player);
     CompareDefaultObject(obj, newPlayerObj);
 }