예제 #1
0
        public void run()
        {
            Console.WriteLine("starting Game. id = " + (short)id);
            GameCommand cmd = new GameCommand();
            InitMsg     msg = new InitMsg();
            int         i;

            Console.WriteLine("player 1: " + players[0].name);
            Console.WriteLine("player 2: " + players[1].name);
            Console.WriteLine("player 3: " + players[2].name);
            Console.WriteLine("player 4: " + players[3].name);
            msg.threadId = id;
            msg.players  = new string[4];
            for (i = 0; i < 4; ++i)
            {
                msg.players[i] =
                    players[i].name;
            }

            for (i = 0; i < 4; ++i)
            {
                msg.cards = Cards.getHand(i);
                players[i].con.SendObject <InitMsg>("InitMsg", msg);
            }

            Thread.Sleep(100);
            cmd.meta = (char)0;
            cmd.data = trump;
            players[0].con.SendObject <GameCommand>("GameCommand", cmd);
            // !! Add a while that check if a client can answer in less than 15 s. If it can't, leave the game
        }
예제 #2
0
 public void InitData(InitMsg msg)
 {
     gStart   = true;
     nCards   = 8;
     cards    = msg.cards;
     players  = msg.players;
     threadId = msg.threadId;
     displayPlayers();
     displayCards();
 }
예제 #3
0
 private void processInitMsg(PacketHeader packetHeader, Connection connection, InitMsg msg)
 {
     Console.WriteLine("Got init message");
     game.InitData(msg);
 }