예제 #1
0
        private bool GetMessageLOG(NetPlayer p, String[] tab, NetMessage msg, ref String DiconnectionReason)
        {
            p.Send("LOG:OK");
            p.SetName(tab[1]);
            for (int i = 0; i < m_rooms.Count; i++)
            {
                p.Send("ROM:LST:" + m_rooms[i].Name + ":" + m_rooms[i].GetPlayer() + ":" + m_rooms[i].GetMaxPlayer());
            }

            return(true);
        }
예제 #2
0
        private bool GetMessageCAL(NetPlayer p, String[] tab, NetMessage msg, ref String DiconnectionReason)
        {
            List <Mahjong.Plugin.IReferee.m_rulepossibility> lpos = p.CurrentRoom.GetReferee().GetRulesPossibilities(p);

            Mahjong.Plugin.IReferee.m_rulepossibility tmp = new IReferee.m_rulepossibility();

            tmp.Player = p;
            tmp.Rule   = p.CurrentRoom.GetReferee().GetRuleByName(tab[1]);
            tmp.Group  = new Group();

            for (int i = 2; i < tab.Length;)
            {
                Tile ins = p.CurrentRoom.GetReferee().GetTile(tab[i], Convert.ToInt32(tab[i + 1]));

                tmp.Group.Add(ins);
                i += 2;
            }

            //for (int i = 0; i < lpos.Count; i++)
            //{
            //    Mahjong.Plugin.IReferee.m_rulepossibility rptmp = lpos[i];
            //    if (rptmp.Equal(tmp) == true)
            //    {
            if (p.CurrentRoom.GetReferee().Call(tmp) == true)
            {
                //p.Send("CAL:OK");
                String netmsg = "CAL:" + p.GetName();
                for (int j = 0; j < tmp.Group.Count; j++)
                {
                    netmsg += ":" + tmp.Group[j].GetFamily() + ":" + tmp.Group[j].GetNumber().ToString();
                    p.Send("TIL:REMOVE:" + tmp.Group[j].GetFamily() + ":" + tmp.Group[j].GetNumber().ToString());
                }
                p.CurrentRoom.Send(netmsg, null);

                p.CurrentRoom.Send("TRN:" + p.CurrentRoom.GetReferee().CurrentPlayer().GetName(), null);
            }
            else
            {
                p.Send("CAL:KO");
            }
//                }

            //           }

            return(true);
        }
예제 #3
0
 private bool SendAll(String Msg)
 {
     for (int i = 0; i < m_players.Count; i++)
     {
         NetPlayer tmp = m_players[i];
         tmp.Send(Msg);
     }
     return(true);
 }
예제 #4
0
        private bool GetMessageTIL(NetPlayer p, String[] tab, NetMessage msg, ref String DiconnectionReason)
        {
            if (tab[1] == "TAKE")
            {
                if (p != p.CurrentRoom.GetReferee().CurrentPlayer())
                {
                    p.Send("TIL:TAKE:KO");
                    return(true);
                }

                Tile t = p.CurrentRoom.GetReferee().Take(p.CurrentRoom.GetReferee().CurrentPlayer());

                if (t == null)
                {
                    p.Send("TIL:TAKE:KO");
                }
                else
                {
                    p.Send("TIL:GET:" + t.GetFamily().ToString() + ":" + t.GetNumber().ToString());
                }
            }
            if (tab[1] == "REMOVE")
            {
                Tile t = p.CurrentRoom.GetReferee().GetTile(tab[2], Convert.ToInt32(tab[3]));
                if (p.CurrentRoom.GetReferee().Rejected(p.CurrentRoom.GetReferee().CurrentPlayer(), t) == false)
                {
                    p.Send("TIL:REMOVE:KO");
                }
                else
                {
                    p.Send("TIL:REMOVE:" + tab[2] + ":" + tab[3]);
                    p.CurrentRoom.Send("TIL:REMOVED:" + p.GetName() + ":" + tab[2] + ":" + tab[3], null);
                    // Check Rules possibilities
                    Room tmp = p.CurrentRoom;
                    for (int i = 0; i < tmp.GetPlayer(); i++)
                    {
                        SendPosibilities(tmp.GetPlayer(i));
                    }

                    SendTurn(p);
                }
            }
            return(true);
        }
예제 #5
0
        private bool SendHandTiles(NetPlayer p)
        {
            Group tmp = p.GetHand();

            for (int i = 0; i < tmp.Count; i++)
            {
                p.Send("TIL:GET:" + tmp[i].GetFamily().ToString() + ":" + tmp[i].GetNumber().ToString());
            }
            return(true);
        }
예제 #6
0
        private bool SendPosibilities(NetPlayer p)
        {
            List <Mahjong.Plugin.IReferee.m_rulepossibility> lpos = p.CurrentRoom.GetReferee().GetRulesPossibilities(p);

            for (int i = 0; i < lpos.Count; i++)
            {
                String netmsg;
                Mahjong.Plugin.IReferee.m_rulepossibility rp = lpos[i];
                netmsg = "RUL:" + rp.Rule.GetName();
                for (int j = 0; j < rp.Group.Count; j++)
                {
                    netmsg += ":" + rp.Group[j].GetFamily() + ":" + rp.Group[j].GetNumber().ToString();
                }
                p.Send(netmsg);
            }

            return(true);
        }
예제 #7
0
        private bool GetMessageROM(NetPlayer p, String[] tab, NetMessage msg, ref String DiconnectionReason)
        {
            if (tab[1] == "ADD")
            {
                //Room already exist ??
                Room ins = new Room(tab[2]);
                m_rooms.Add(ins);
                SendAll("ROM:LST:" + ins.Name + ":" + ins.GetPlayer() + ":" + ins.GetMaxPlayer());
                p.Send("ROM:ADD:OK");
            }

            if (tab[1] == "DEL")
            {
                //Room ins = new Room(tab[2]);
            }

            if (tab[1] == "JOIN")
            {
                //Room ins = new Room(tab[2]);
                Room tmp = GetRoomByName(tab[2]);
                if (tmp.GetPlayer() == tmp.GetMaxPlayer())
                {
                    p.Send("ROM:JOIN:KO");
                    return(true);
                }
                p.Send("ROM:JOIN:OK");
                tmp.AddPlayer(p);
                p.CurrentRoom = tmp;
                for (int i = 0; i < tmp.GetPlayer(); i++)
                {
                    NetPlayer tmpp = tmp.GetPlayer(i);
                    p.Send("ROM:PLAYER:ADD:" + tmpp.GetName());
                }
                p.CurrentRoom.Send("ROM:PLAYER:ADD:" + p.GetName(), p);
                List <IReferee> plugins = m_plugin.GetReferees();
                for (int i = 0; i < plugins.Count; i++)
                {
                    p.Send("ROM:REFEREE:ADD:" + plugins[i].GetName());
                }
                if (tmp.GetReferee() != null)
                {
                    p.Send("ROM:REFEREE:SELECTED:" + tmp.GetReferee().GetName());
                }
            }

            if (tab[1] == "LEAVE")
            {
                Room tmp = p.CurrentRoom;

                tmp.Send("ROM:PLAYER:LEAVE:" + p.GetName(), null);
                tmp.RemovePlayer(p);
            }

            if (tab[1] == "REFEREE")
            {
                Room            tmp     = p.CurrentRoom;
                List <IReferee> plugins = m_plugin.GetReferees();
                IReferee        iref    = null;
                for (int i = 0; i < plugins.Count; i++)
                {
                    if (plugins[i].GetName() == tab[2])
                    {
                        iref = plugins[i];
                    }
                }
                if (iref != null)
                {
                    tmp.AddReferee(iref);
                    p.CurrentRoom.Send("ROM:REFEREE:SELECTED:" + tmp.GetReferee().GetName(), null);
                }
                else
                {
                    p.Send("ROM:REFEREE:KO");
                }
            }

            if (tab[1] == "START")
            {
                // Make PlayerData List
                if (p.CurrentRoom.GetReferee() == null)
                {
                    p.Send("ROM:START:KO");
                    return(true);
                }
                Room tmp = p.CurrentRoom;
                List <PlayerData> ltmp = new List <PlayerData>();

                tmp.Send("STR:" + p.GetName(), null);
                for (int i = 0; i < tmp.GetPlayer(); i++)
                {
                    ltmp.Add(tmp.GetPlayer(i));
                }

                p.CurrentRoom.GetReferee().NewGame(ltmp);
                for (int i = 0; i < tmp.GetPlayer(); i++)
                {
                    SendHandTiles(tmp.GetPlayer(i));
                }
                SendTurn(p);
            }

            return(true);
        }
예제 #8
0
        private bool GetMessageCAL(NetPlayer p, String[] tab, NetMessage msg, ref String DiconnectionReason)
        {
            List<Mahjong.Plugin.IReferee.m_rulepossibility> lpos = p.CurrentRoom.GetReferee().GetRulesPossibilities(p);

            Mahjong.Plugin.IReferee.m_rulepossibility tmp = new IReferee.m_rulepossibility();

            tmp.Player = p;
            tmp.Rule = p.CurrentRoom.GetReferee().GetRuleByName(tab[1]);
            tmp.Group = new Group();

            for (int i = 2; i < tab.Length; )
            {
                Tile ins = p.CurrentRoom.GetReferee().GetTile(tab[i], Convert.ToInt32(tab[i + 1]));

                tmp.Group.Add(ins);
                i += 2;
            }

            //for (int i = 0; i < lpos.Count; i++)
            //{
            //    Mahjong.Plugin.IReferee.m_rulepossibility rptmp = lpos[i];
            //    if (rptmp.Equal(tmp) == true)
            //    {
            if (p.CurrentRoom.GetReferee().Call(tmp) == true)
            {
                //p.Send("CAL:OK");
                String netmsg = "CAL:" + p.GetName();
                for (int j = 0; j < tmp.Group.Count; j++)
                {
                    netmsg += ":" + tmp.Group[j].GetFamily() + ":" + tmp.Group[j].GetNumber().ToString();
                    p.Send("TIL:REMOVE:" + tmp.Group[j].GetFamily() + ":" + tmp.Group[j].GetNumber().ToString());

                }
                p.CurrentRoom.Send(netmsg, null);

                p.CurrentRoom.Send("TRN:" + p.CurrentRoom.GetReferee().CurrentPlayer().GetName(), null);

            }
            else
            {
                p.Send("CAL:KO");
            }
            //                }

             //           }

            return true;
        }
예제 #9
0
        private bool SendPosibilities(NetPlayer p)
        {
            List<Mahjong.Plugin.IReferee.m_rulepossibility> lpos = p.CurrentRoom.GetReferee().GetRulesPossibilities(p);
            for (int i = 0; i < lpos.Count; i++)
            {
                String netmsg;
                Mahjong.Plugin.IReferee.m_rulepossibility rp = lpos[i];
                netmsg = "RUL:" + rp.Rule.GetName();
                for (int j = 0; j < rp.Group.Count; j++)
                {
                    netmsg += ":" + rp.Group[j].GetFamily() + ":" + rp.Group[j].GetNumber().ToString();
                }
                p.Send(netmsg);
            }

            return true;
        }
예제 #10
0
 private bool SendHandTiles(NetPlayer p)
 {
     Group tmp = p.GetHand();
     for (int i = 0; i < tmp.Count; i++)
     {
         p.Send("TIL:GET:" + tmp[i].GetFamily().ToString() + ":" + tmp[i].GetNumber().ToString());
     }
     return true;
 }
예제 #11
0
        private bool GetMessageTIL(NetPlayer p, String[] tab, NetMessage msg, ref String DiconnectionReason)
        {
            if (tab[1] == "TAKE")
            {
                if (p != p.CurrentRoom.GetReferee().CurrentPlayer())
                {
                    p.Send("TIL:TAKE:KO");
                    return true;
                }

                Tile t = p.CurrentRoom.GetReferee().Take(p.CurrentRoom.GetReferee().CurrentPlayer());

                if (t == null)
                {
                    p.Send("TIL:TAKE:KO");
                }
                else
                {
                    p.Send("TIL:GET:" + t.GetFamily().ToString() + ":" + t.GetNumber().ToString());
                }
            }
            if (tab[1] == "REMOVE")
            {
                Tile t = p.CurrentRoom.GetReferee().GetTile(tab[2], Convert.ToInt32(tab[3]));
                if (p.CurrentRoom.GetReferee().Rejected(p.CurrentRoom.GetReferee().CurrentPlayer(), t) == false)
                    p.Send("TIL:REMOVE:KO");
                else
                {
                    p.Send("TIL:REMOVE:" + tab[2] + ":" + tab[3]);
                    p.CurrentRoom.Send("TIL:REMOVED:" + p.GetName() + ":" + tab[2] + ":" + tab[3], null);
                    // Check Rules possibilities
                    Room tmp = p.CurrentRoom;
                    for (int i = 0; i < tmp.GetPlayer(); i++)
                    {
                        SendPosibilities(tmp.GetPlayer(i));
                    }

                    SendTurn(p);
                }
            }
            return true;
        }
예제 #12
0
        private bool GetMessageROM(NetPlayer p, String[] tab, NetMessage msg, ref String DiconnectionReason)
        {
            if (tab[1] == "ADD")
            {
                //Room already exist ??
                Room ins = new Room(tab[2]);
                m_rooms.Add(ins);
                SendAll("ROM:LST:" + ins.Name + ":" + ins.GetPlayer() + ":" + ins.GetMaxPlayer());
                p.Send("ROM:ADD:OK");
            }

            if (tab[1] == "DEL")
            {
                //Room ins = new Room(tab[2]);
            }

            if (tab[1] == "JOIN")
            {
                //Room ins = new Room(tab[2]);
                Room tmp = GetRoomByName(tab[2]);
                if (tmp.GetPlayer() == tmp.GetMaxPlayer())
                {
                    p.Send("ROM:JOIN:KO");
                    return true;
                }
                p.Send("ROM:JOIN:OK");
                tmp.AddPlayer(p);
                p.CurrentRoom = tmp;
                for (int i = 0; i < tmp.GetPlayer(); i++)
                {
                    NetPlayer tmpp = tmp.GetPlayer(i);
                    p.Send("ROM:PLAYER:ADD:" + tmpp.GetName());

                }
                p.CurrentRoom.Send("ROM:PLAYER:ADD:" + p.GetName(), p);
                List<IReferee> plugins = m_plugin.GetReferees();
                for (int i = 0; i < plugins.Count; i++)
                {
                    p.Send("ROM:REFEREE:ADD:" + plugins[i].GetName());
                }
                if (tmp.GetReferee() != null)
                {
                    p.Send("ROM:REFEREE:SELECTED:" + tmp.GetReferee().GetName());
                }
            }

            if (tab[1] == "LEAVE")
            {
                Room tmp = p.CurrentRoom;

                tmp.Send("ROM:PLAYER:LEAVE:" + p.GetName(), null);
                tmp.RemovePlayer(p);
            }

            if (tab[1] == "REFEREE")
            {
                Room tmp = p.CurrentRoom;
                List<IReferee> plugins = m_plugin.GetReferees();
                IReferee iref = null;
                for (int i = 0; i < plugins.Count; i++)
                {
                    if (plugins[i].GetName() == tab[2])
                        iref = plugins[i];
                }
                if (iref != null)
                {
                    tmp.AddReferee(iref);
                    p.CurrentRoom.Send("ROM:REFEREE:SELECTED:" + tmp.GetReferee().GetName(), null);
                }
                else
                    p.Send("ROM:REFEREE:KO");
            }

            if (tab[1] == "START")
            {
                // Make PlayerData List
                if (p.CurrentRoom.GetReferee() == null)
                {
                    p.Send("ROM:START:KO");
                    return true;
                }
                Room tmp = p.CurrentRoom;
                List<PlayerData> ltmp = new List<PlayerData>();

                tmp.Send("STR:" + p.GetName(), null);
                for (int i = 0; i < tmp.GetPlayer(); i++)
                {
                    ltmp.Add(tmp.GetPlayer(i));
                }

                p.CurrentRoom.GetReferee().NewGame(ltmp);
                for (int i = 0; i < tmp.GetPlayer(); i++)
                    SendHandTiles(tmp.GetPlayer(i));
                SendTurn(p);
            }

            return true;
        }
예제 #13
0
        private bool GetMessageLOG(NetPlayer p, String[] tab, NetMessage msg, ref String DiconnectionReason)
        {
            p.Send("LOG:OK");
            p.SetName(tab[1]);
            for (int i = 0; i < m_rooms.Count; i++)
            {
                p.Send("ROM:LST:" + m_rooms[i].Name + ":" + m_rooms[i].GetPlayer() + ":" + m_rooms[i].GetMaxPlayer());
            }

            return true;
        }