コード例 #1
0
ファイル: Pong.cs プロジェクト: lkw1830/mmomahjong
        public List<Mahjong.Plugin.IReferee.m_rulepossibility> Execute(List<PlayerData> players, PlayerData current)
        {
            List<Mahjong.Plugin.IReferee.m_rulepossibility> findrules = new List<IReferee.m_rulepossibility>();
            PlayerData tmp = GetRejectTilePlayer(players);
            if (tmp == null)
                return findrules;
            if (tmp == current)
                return findrules;
            Tile rejected = tmp.GetRejected();
            if (rejected == null)
                return findrules;
            Group gtmp = current.GetHand();

            Mahjong.Plugin.IReferee.m_rulepossibility rulepos = new IReferee.m_rulepossibility();
            rulepos.Rule = this;
            rulepos.Player = current;
            rulepos.Group = new Group();
            for (int i = 0; i < gtmp.Count; i++)
            {
                Tile ttmp = gtmp[i];
                if ((rejected.GetNumber() == ttmp.GetNumber()) && (rejected.GetFamily() == ttmp.GetFamily()))
                {
                    rulepos.Group.Add(ttmp);
                    if (rulepos.Group.Count == 2)
                        findrules.Add(rulepos);
                }
            }

            return findrules;
        }
コード例 #2
0
ファイル: Chow.cs プロジェクト: lkw1830/mmomahjong
        public List<Mahjong.Plugin.IReferee.m_rulepossibility> Execute(List<PlayerData> players, PlayerData current)
        {
            List<Mahjong.Plugin.IReferee.m_rulepossibility> findrules = new List<IReferee.m_rulepossibility>();
            PlayerData PrevPlayer = GetPreviousPlayer(players, current);
            Tile ttmp = PrevPlayer.GetRejected();

            if (ttmp == null)
                return findrules;
            if ((ttmp.GetFamily() == Tile.Family.Flower) || (ttmp.GetFamily() == Tile.Family.Season) || (ttmp.GetFamily() == Tile.Family.Wind) || (ttmp.GetFamily() == Tile.Family.Dragon))
                return findrules;

            if ((HaveTile(current, ttmp.GetFamily(), ttmp.GetNumber() - 2)) && (HaveTile(current, ttmp.GetFamily(), ttmp.GetNumber() - 1)))
            {
                Mahjong.Plugin.IReferee.m_rulepossibility rulepos = new IReferee.m_rulepossibility();
                rulepos.Rule = this;
                rulepos.Player = current;
                rulepos.Group = new Group();

                rulepos.Group.Add(GetTile(current, ttmp.GetFamily(), ttmp.GetNumber() - 2));
                rulepos.Group.Add(GetTile(current, ttmp.GetFamily(), ttmp.GetNumber() - 1));
                findrules.Add(rulepos);
            }

            if ((HaveTile(current, ttmp.GetFamily(), ttmp.GetNumber() - 1)) && (HaveTile(current, ttmp.GetFamily(), ttmp.GetNumber() + 1)))
            {
                Mahjong.Plugin.IReferee.m_rulepossibility rulepos = new IReferee.m_rulepossibility();
                rulepos.Rule = this;
                rulepos.Player = current;
                rulepos.Group = new Group();

                rulepos.Group.Add(GetTile(current, ttmp.GetFamily(), ttmp.GetNumber() - 1));
                rulepos.Group.Add(GetTile(current, ttmp.GetFamily(), ttmp.GetNumber() + 1));
                findrules.Add(rulepos);
            }

            if ((HaveTile(current, ttmp.GetFamily(), ttmp.GetNumber() + 1)) && (HaveTile(current, ttmp.GetFamily(), ttmp.GetNumber() + 2)))
            {
                Mahjong.Plugin.IReferee.m_rulepossibility rulepos = new IReferee.m_rulepossibility();
                rulepos.Rule = this;
                rulepos.Player = current;
                rulepos.Group = new Group();

                rulepos.Group.Add(GetTile(current, ttmp.GetFamily(), ttmp.GetNumber() + 1));
                rulepos.Group.Add(GetTile(current, ttmp.GetFamily(), ttmp.GetNumber() + 2));
                findrules.Add(rulepos);
            }
            return findrules;
        }
コード例 #3
0
ファイル: MMOServer.cs プロジェクト: lkw1830/mmomahjong
        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;
        }