Beispiel #1
0
        public static YakuValue 役牌自风(List <Meld> decompose, Tile winningTile, HandStatus handStatus,
                                     RoundStatus roundStatus, GameSetting settings)
        {
            var tile = roundStatus.SelfWind;

            foreach (var meld in decompose)
            {
                if (meld.IdenticalTo(MeldType.Triplet, tile))
                {
                    return new YakuValue {
                               Name = $"自风{tile}", Value = 1
                    }
                }
                ;
            }

            return(new YakuValue());
        }
Beispiel #2
0
        public static YakuValue 对对和(List <Meld> decompose, Tile winningTile, HandStatus handStatus,
                                    RoundStatus roundStatus, GameSetting settings)
        {
            int countPairs = decompose.Count(meld => meld.Type == MeldType.Pair);

            if (countPairs != 1)
            {
                return(new YakuValue());
            }
            if (decompose.All(meld => meld.Type == MeldType.Pair || meld.Type == MeldType.Triplet))
            {
                return new YakuValue {
                           Name = "对对和", Value = 2
                }
            }
            ;
            return(new YakuValue());
        }
Beispiel #3
0
        void Update()
        {
            HandStatus status = module.GetCurrentHandStatus();

            Color c = Color.white;

            switch (status)
            {
            case HandStatus.One:
                c = Color.red;
                break;

            case HandStatus.Two:
                c = Color.blue;
                break;

            case HandStatus.Three:
                c = Color.cyan;
                break;

            case HandStatus.Four:
                c = Color.green;
                break;

            case HandStatus.Open:
                c = Color.yellow;
                break;

            case HandStatus.Closed:
                c = Color.magenta;
                break;

            case HandStatus.Rockin:
                c = new Color(Random.value, Random.value, Random.value, 1.0f);
                break;

            default:
                c = Color.white;
                break;
            }

            renderer.material.color = c;
        }
Beispiel #4
0
 public static YakuValue 立直(List <Meld> decompose, Tile winningTile, HandStatus handStatus,
                            RoundStatus roundStatus, GameSetting settings)
 {
     if (handStatus.HasFlag(HandStatus.Menqing) && handStatus.HasFlag(HandStatus.Richi))
     {
         return new YakuValue {
                    Name = "立直", Value = 1
         }
     }
     ;
     if (handStatus.HasFlag(HandStatus.Menqing) && handStatus.HasFlag(HandStatus.WRichi))
     {
         return new YakuValue {
                    Name = "双立直", Value = 2
         }
     }
     ;
     return(new YakuValue());
 }
Beispiel #5
0
    public HandStatus getHandStatus()
    {
        HandStatus status       = HandStatus.NULL;
        float      thumb_angle  = getFingerAngle(thumb);
        float      index_angle  = getFingerAngle(index);
        float      middle_angle = getFingerAngle(middle);
        float      ring_angle   = getFingerAngle(ring);
        float      pinky_angle  = getFingerAngle(pinky);

        bool thumb_open  = (thumb_angle < OPEN_ANGLE / 3f);
        bool index_open  = (index_angle < OPEN_ANGLE);
        bool middle_open = (middle_angle < OPEN_ANGLE);
        bool ring_open   = (ring_angle < OPEN_ANGLE);
        bool pinky_open  = (pinky_angle < OPEN_ANGLE);

        //Debug.Log (string.Format("{0}, {1}, {2}, {3}", index_angle, middle_angle, ring_angle, pinky_angle));

        if (!thumb_open && index_open && !middle_open && !ring_open && !pinky_open)
        {
            status = HandStatus.ONE_FINGER;
        }
        if (!thumb_open && index_open && middle_open && !ring_open && !pinky_open)
        {
            status = HandStatus.TWO_FINGER;
        }
        if (!thumb_open && index_open && middle_open && ring_open && pinky_open)
        {
            status = HandStatus.FOUR_FINGER;
        }
        if (thumb_open && index_open && middle_open && ring_open && pinky_open)
        {
            status = HandStatus.OPEN;
        }
        if (!thumb_open && !index_open && !middle_open && !ring_open && !pinky_open)
        {
            status = HandStatus.CLOSED;
        }
        if (index_open && pinky_open && !middle_open && !ring_open && !thumb_open)
        {
            status = HandStatus.ROCKIN;
        }
        return(status);
    }
Beispiel #6
0
        public static YakuValue 断幺九(List <Meld> decompose, Tile winningTile, HandStatus handStatus,
                                    RoundStatus roundStatus, GameSetting settings)
        {
            if (!settings.OpenDuanYao && !handStatus.HasFlag(HandStatus.Menqing))
            {
                return(new YakuValue());
            }
            foreach (var meld in decompose)
            {
                if (meld.HasYaojiu)
                {
                    return(new YakuValue());
                }
            }

            return(new YakuValue {
                Name = "断幺九", Value = 1
            });
        }
Beispiel #7
0
        public static YakuValue 役牌北(List <Meld> decompose, Tile winningTile, HandStatus handStatus,
                                    RoundStatus roundStatus, GameSetting settings)
        {
            if (!settings.AllowBeiAsYaku)
            {
                return(new YakuValue());
            }
            var bei = new Tile(Suit.Z, 4);

            foreach (var meld in decompose)
            {
                if (meld.IdenticalTo(MeldType.Triplet, bei))
                {
                    return new YakuValue {
                               Name = "役牌北", Value = 1
                    }
                }
                ;
            }
            return(new YakuValue());
        }
Beispiel #8
0
        public static YakuValue 杠子系(List <Meld> decompose, Tile winningTile, HandStatus handStatus,
                                    RoundStatus roundStatus, GameSetting settings)
        {
            int count = decompose.Count(meld => meld.IsKong);

            if (count < 3)
            {
                return(new YakuValue());
            }
            if (count == 3)
            {
                return new YakuValue {
                           Name = "三杠子", Value = 2
                }
            }
            ;
            Assert.AreEqual(count, 4);
            return(new YakuValue {
                Name = "四杠子", Value = 1, Type = YakuType.Yakuman
            });
        }
Beispiel #9
0
    void setLineSetsColor(HandStatus status)
    {
        //Debug.Log (status);
        Color c = Color.white;

        switch (status)
        {
        case HandStatus.ONE_FINGER:
            c = Color.red;
            break;

        case HandStatus.TWO_FINGER:
            c = Color.blue;
            break;

        case HandStatus.FOUR_FINGER:
            c = Color.green;
            break;

        case HandStatus.OPEN:
            c = Color.yellow;
            break;

        case HandStatus.CLOSED:
            c = Color.magenta;
            break;

        case HandStatus.ROCKIN:
            c = new Color(Random.value, Random.value, Random.value, 1.0f);
            break;

        default:
            c = Color.white;
            break;
        }
        foreach (FingerRenderer line_set in line_sets)
        {
            line_set.setColor(c);
        }
    }
Beispiel #10
0
        protected void UpdateHandStatus()
        {
            this.previousHandStatus = this.currentHandStatus;
            this.currentHandStatus  = HandStatus.Null;

            bool openThumb  = IsFingerOpen(thumb, 3f);
            bool openIndex  = IsFingerOpen(index);
            bool openMiddle = IsFingerOpen(middle);
            bool openRing   = IsFingerOpen(ring);
            bool openPinky  = IsFingerOpen(pinky);

            if (openThumb && openIndex && openMiddle && openRing && openPinky)
            {
                this.currentHandStatus = HandStatus.Open;
            }
            else if (openIndex)
            {
                if (!openMiddle && !openRing && !openPinky)
                {
                    this.currentHandStatus = HandStatus.One;
                }
                if (openMiddle && !openRing && !openPinky)
                {
                    this.currentHandStatus = HandStatus.Two;
                }
                else if (openMiddle && ((openRing && !openPinky) || (!openRing && openPinky)))
                {
                    this.currentHandStatus = HandStatus.Three;
                }
                else if (openMiddle && openRing && openPinky)
                {
                    this.currentHandStatus = HandStatus.Four;
                }
                else if (!openMiddle && !openRing && openPinky)
                {
                    this.currentHandStatus = HandStatus.Rockin;
                }
            }
        }
Beispiel #11
0
        public static YakuValue 四喜系(List <Meld> decompose, Tile winningTile, HandStatus handStatus,
                                    RoundStatus roundStatus, GameSetting settings)
        {
            const int flag        = 15;
            int       tripletFlag = 0;
            int       pairFlag    = 0;

            foreach (var meld in decompose)
            {
                if (meld.Suit != Suit.Z || meld.First.Rank > 4)
                {
                    continue;
                }
                if (meld.Type == MeldType.Triplet)
                {
                    tripletFlag |= 1 << (meld.First.Rank - 1);
                }
                if (meld.Type == MeldType.Pair)
                {
                    pairFlag |= 1 << (meld.First.Rank - 1);
                }
            }

            if (tripletFlag == flag)
            {
                return new YakuValue {
                           Name = "大四喜", Value = 2, Type = YakuType.Yakuman
                }
            }
            ;
            if ((tripletFlag | pairFlag) == flag && pairFlag != flag)
            {
                return new YakuValue {
                           Name = "小四喜", Value = 1, Type = YakuType.Yakuman
                }
            }
            ;
            return(new YakuValue());
        }
Beispiel #12
0
        protected void ExecutePose(HandStatus status)
        {
            if (statusPairings[status] == null)
            {
                return;
            }

            switch (status)
            {
            case HandStatus.One:
                ExecuteEvents.Execute <IHandOneHandler>(eventData.one, eventData, (x, y) => x.OnHandOne(eventData));
                break;

            case HandStatus.Two:
                ExecuteEvents.Execute <IHandTwoHandler>(eventData.two, eventData, (x, y) => x.OnHandTwo(eventData));
                break;

            case HandStatus.Three:
                ExecuteEvents.Execute <IHandThreeHandler>(eventData.three, eventData, (x, y) => x.OnHandThree(eventData));
                break;

            case HandStatus.Four:
                ExecuteEvents.Execute <IHandFourHandler>(eventData.four, eventData, (x, y) => x.OnHandFour(eventData));
                break;

            case HandStatus.Open:
                ExecuteEvents.Execute <IHandOpenHandler>(eventData.open, eventData, (x, y) => x.OnHandOpen(eventData));
                break;

            case HandStatus.Closed:
                ExecuteEvents.Execute <IHandClosedHandler>(eventData.closed, eventData, (x, y) => x.OnHandClosed(eventData));
                break;

            case HandStatus.Rockin:
                ExecuteEvents.Execute <IHandRockinHandler>(eventData.rockin, eventData, (x, y) => x.OnHandRockin(eventData));
                break;
            }
        }
Beispiel #13
0
        public static PointInfo GetPointInfo(Tile[] handTiles, Meld[] openMelds, Tile winningTile,
                                             HandStatus handStatus, RoundStatus roundStatus, GameSetting settings, bool isQTJ,
                                             Tile[] doraTiles = null, Tile[] uraDoraTiles = null, int beiDora = 0)
        {
            var decomposes = Decompose(handTiles, openMelds, winningTile);

            if (decomposes.Count == 0)
            {
                return(new PointInfo());
            }
            // count dora
            int dora    = CountDora(handTiles, openMelds, winningTile, doraTiles);
            int uraDora = 0;

            if (handStatus.HasFlag(HandStatus.Richi) || handStatus.HasFlag(HandStatus.WRichi))
            {
                uraDora = CountDora(handTiles, openMelds, winningTile, uraDoraTiles);
            }

            int redDora = CountRed(handTiles, openMelds, winningTile);

            return(GetPointInfo(decomposes, winningTile, handStatus, roundStatus, settings, isQTJ, dora, uraDora, redDora, beiDora));
        }
Beispiel #14
0
    /*
     *
     */
    private void OnUpdatedHandsStatusReceived(object sender, HandStatus newHandStatus)
    {
#if DEBUG_MEMORY
        Debug.Log("OnUpdatedHandsStatusReceive_Start");
#endif
        globalDef.GetComponent <globalDefinitions>().currentHandStatus = newHandStatus;
        oldStatus = newStatus;
        newStatus = newHandStatus;
        getRightRotationType();
        getLeftRotationType();
        //Debug.Log(handTypePosition[0].ToString() + ":" + handTypePosition[1].ToString());
        detectMove();

        Material newHandMaterial = getHandMaterial();
        if (newHandMaterial != handMaterials)
        {
            Hands[(int)Hand.Right].GetComponent <HandManager>().changeMaterial(newHandMaterial);
            Hands[(int)Hand.Left].GetComponent <HandManager>().changeMaterial(newHandMaterial);
        }
#if DEBUG_MEMORY
        Debug.Log("OnUpdatedHandsStatusReceive_End");
#endif
    }
Beispiel #15
0
    public void SetStatus(HandStatus status)
    {
        m_PlayerStatus.gameObject.SetActive(true);
        Color statusColor = Color.black;

        switch (status)
        {
        case HandStatus.WIN:
            statusColor = Color.green;
            break;

        case HandStatus.BJ:
            statusColor = Color.yellow;
            break;

        case HandStatus.LOSE:
        case HandStatus.BUST:
            statusColor = Color.red;
            break;
        }
        m_PlayerStatus.color = statusColor;
        m_PlayerStatus.text  = status.ToString();
    }
Beispiel #16
0
        public static YakuValue 一色系(List <Meld> decompose, Tile winningTile, HandStatus handStatus,
                                    RoundStatus roundStatus, GameSetting settings)
        {
            // 字一色 has already been handled in 全带系
            var allM   = decompose.All(meld => meld.Suit == Suit.M || meld.Suit == Suit.Z);
            var allS   = decompose.All(meld => meld.Suit == Suit.S || meld.Suit == Suit.Z);
            var allP   = decompose.All(meld => meld.Suit == Suit.P || meld.Suit == Suit.Z);
            var single = allM || allS || allP;

            if (!single)
            {
                return(new YakuValue());
            }
            var anyZ = decompose.Any(meld => meld.Suit == Suit.Z);

            return(anyZ
                                ? new YakuValue {
                Name = "混一色", Value = handStatus.HasFlag(HandStatus.Menqing) ? 3 : 2
            }
                                : new YakuValue {
                Name = "清一色", Value = handStatus.HasFlag(HandStatus.Menqing) ? 6 : 5
            });
        }
Beispiel #17
0
        public static YakuValue 七对子(List <Meld> decompose, Tile winningTile, HandStatus handStatus,
                                    RoundStatus roundStatus, GameSetting settings)
        {
            if (!handStatus.HasFlag(HandStatus.Menqing))
            {
                return(new YakuValue());
            }
            if (decompose.Count != 7)
            {
                return(new YakuValue());
            }
            foreach (var meld in decompose)
            {
                if (meld.Type != MeldType.Pair)
                {
                    return(new YakuValue());
                }
            }

            return(new YakuValue {
                Name = "七对子", Value = 2
            });
        }
        //private static int alo = -1;
        public BodyData[] GetBodyFrame()
        {
            if (!BodyFrameAuthority)
            {
                throw new AuthorityException(AuthorityException.AuthorityTypes.Body, this);
            }
            if (!bodyFrameReady)
            {
                return(null);
            }

            byte[] buffer = null;
            if (bodyChannel.Read(out buffer) == false) // 쉐어드메모리 읽기 실패
            {
                return(lastBodyFrame);
            }

            MemoryStream stream      = new MemoryStream(buffer);
            BinaryReader reader      = new BinaryReader(stream);
            int          bodiesCount = reader.ReadInt32();

            /*
             *  if (alo != bodiesCount)
             *  {
             *      alo = bodiesCount;
             *      Console.WriteLine("YAY : " + alo.ToString());
             *  }
             */

            BodyData[] result = new BodyData[bodiesCount];
            for (int i = 0; i < bodiesCount; i++)
            {
                Dictionary <JointType, NuiJoint>            joints       = new Dictionary <JointType, NuiJoint>();
                Dictionary <JointType, NuiJointOrientation> orientations = new Dictionary <JointType, NuiJointOrientation>();

                int  bodyId     = reader.ReadInt32();
                bool valid      = reader.ReadBoolean();
                int  jointCount = reader.ReadInt32();
                for (int j = 0; j < jointCount; j++)
                {
                    JointType     type  = (JointType)reader.ReadInt32();
                    TrackingState state = (TrackingState)reader.ReadInt32();
                    double        x     = reader.ReadDouble();
                    double        y     = reader.ReadDouble();
                    double        z     = reader.ReadDouble();

                    float ox = reader.ReadSingle();
                    float oy = reader.ReadSingle();
                    float oz = reader.ReadSingle();
                    float ow = reader.ReadSingle();

                    NuiJoint            joint       = new NuiJoint(x, y, z, type, state);
                    NuiJointOrientation orientation = new NuiJointOrientation(type, ox, oy, oz, ow);
                    if (!joints.ContainsKey(type))
                    {
                        joints.Add(type, joint);
                    }
                    if (!orientations.ContainsKey(type))
                    {
                        orientations.Add(type, orientation);
                    }
                }
                HandStatus leftHand  = (HandStatus)reader.ReadInt16();
                HandStatus rightHand = (HandStatus)reader.ReadInt16();
                result[i] = new BodyData(joints, orientations, valid, bodyId, this, leftHand, rightHand);
                Console.WriteLine(sizeof(int) + i * 2048);

                stream.Seek(sizeof(int) + (i + 1) * 2048, SeekOrigin.Begin);
            }
            reader.Close();
            stream.Close();

            lastBodyFrame = result;

            return(result);
        }
Beispiel #19
0
        void OnAlert(PXCMHandData.AlertData alertData)
        {
            // NB: ignoring the low confidence state as I'm not sure what to do with
            // it because there is no 'high' confidence state.
            // Also, assumed that if I get an out of bottom/left/right/top then I
            // will also get an OUT_OF_BORDERS so I'm ignoring the 4 explicit states.
            // Also assuming that a HAND_TOO_CLOSE/FAR is followed by an INSIDE_BORDERS
            // as that seems to happen.
            HandStatus handStatus     = HandStatus.Ok;
            bool       alertTypeToAdd = false;

            if (this.statusValues.ContainsKey(alertData.handId))
            {
                handStatus = this.statusValues[alertData.handId];
            }

            switch (alertData.label)
            {
            case PXCMHandData.AlertType.ALERT_HAND_CALIBRATED:
            case PXCMHandData.AlertType.ALERT_HAND_DETECTED:
            case PXCMHandData.AlertType.ALERT_HAND_INSIDE_BORDERS:
            case PXCMHandData.AlertType.ALERT_HAND_TRACKED:
                handStatus    |= (HandStatus)alertData.label;
                alertTypeToAdd = true;
                break;

            case PXCMHandData.AlertType.ALERT_HAND_NOT_CALIBRATED:
                handStatus &= (HandStatus) ~PXCMHandData.AlertType.ALERT_HAND_CALIBRATED;
                break;

            case PXCMHandData.AlertType.ALERT_HAND_NOT_DETECTED:
                handStatus &= (HandStatus) ~PXCMHandData.AlertType.ALERT_HAND_DETECTED;
                break;

            case PXCMHandData.AlertType.ALERT_HAND_NOT_TRACKED:
                handStatus &= (HandStatus) ~PXCMHandData.AlertType.ALERT_HAND_TRACKED;
                break;

            case PXCMHandData.AlertType.ALERT_HAND_OUT_OF_BORDERS:
            case PXCMHandData.AlertType.ALERT_HAND_TOO_CLOSE:
            case PXCMHandData.AlertType.ALERT_HAND_TOO_FAR:
            case PXCMHandData.AlertType.ALERT_HAND_OUT_OF_BOTTOM_BORDER:
            case PXCMHandData.AlertType.ALERT_HAND_OUT_OF_LEFT_BORDER:
            case PXCMHandData.AlertType.ALERT_HAND_OUT_OF_RIGHT_BORDER:
            case PXCMHandData.AlertType.ALERT_HAND_OUT_OF_TOP_BORDER:
                handStatus &= (HandStatus) ~PXCMHandData.AlertType.ALERT_HAND_INSIDE_BORDERS;
                break;

            default:
                break;
            }
            if ((handStatus & (HandStatus)PXCMHandData.AlertType.ALERT_HAND_DETECTED) == 0)
            {
                // remove a value if we've been told that it's no longer detected.
                this.statusValues.Remove(alertData.handId);
            }
            else if (this.statusValues.ContainsKey(alertData.handId) || alertTypeToAdd)
            {
                // store any value into an existing slot but don't add a new slot
                // unless there's a good reason (i.e. not if we are receiving an
                // update to a hand that's been removed already).
                this.statusValues[alertData.handId] = handStatus;
            }
        }
Beispiel #20
0
        protected void ExecuteGlobalPoseUp(HandStatus status)
        {
            switch (status)
            {
            case HandStatus.One:
                foreach (HandGlobalReceiver r in receivers)
                {
                    if (!r.module || r.module.Equals(this))
                    {
                        ExecuteEvents.Execute <IGlobalHandOneUpHandler>(r.gameObject, eventData,
                                                                        (x, y) => x.OnGlobalHandOneUp(eventData));
                    }
                }
                break;

            case HandStatus.Two:
                foreach (HandGlobalReceiver r in receivers)
                {
                    if (!r.module || r.module.Equals(this))
                    {
                        ExecuteEvents.Execute <IGlobalHandTwoUpHandler>(r.gameObject, eventData,
                                                                        (x, y) => x.OnGlobalHandTwoUp(eventData));
                    }
                }
                break;

            case HandStatus.Three:
                foreach (HandGlobalReceiver r in receivers)
                {
                    if (!r.module || r.module.Equals(this))
                    {
                        ExecuteEvents.Execute <IGlobalHandThreeUpHandler>(r.gameObject, eventData,
                                                                          (x, y) => x.OnGlobalHandThreeUp(eventData));
                    }
                }
                break;

            case HandStatus.Four:
                foreach (HandGlobalReceiver r in receivers)
                {
                    if (!r.module || r.module.Equals(this))
                    {
                        ExecuteEvents.Execute <IGlobalHandFourUpHandler>(r.gameObject, eventData,
                                                                         (x, y) => x.OnGlobalHandFourUp(eventData));
                    }
                }
                break;

            case HandStatus.Open:
                foreach (HandGlobalReceiver r in receivers)
                {
                    if (!r.module || r.module.Equals(this))
                    {
                        ExecuteEvents.Execute <IGlobalHandOpenUpHandler>(r.gameObject, eventData,
                                                                         (x, y) => x.OnGlobalHandOpenUp(eventData));
                    }
                }
                break;

            case HandStatus.Closed:
                foreach (HandGlobalReceiver r in receivers)
                {
                    if (!r.module || r.module.Equals(this))
                    {
                        ExecuteEvents.Execute <IGlobalHandClosedUpHandler>(r.gameObject, eventData,
                                                                           (x, y) => x.OnGlobalHandClosedUp(eventData));
                    }
                }
                break;

            case HandStatus.Rockin:
                foreach (HandGlobalReceiver r in receivers)
                {
                    if (!r.module || r.module.Equals(this))
                    {
                        ExecuteEvents.Execute <IGlobalHandRockinUpHandler>(r.gameObject, eventData,
                                                                           (x, y) => x.OnGlobalHandRockinUp(eventData));
                    }
                }
                break;
            }
        }
 public bool Equals(HandStatus other)
 {
     if (ReferenceEquals(null, other)) return false;
     if (ReferenceEquals(this, other)) return true;
     return other.id == id;
 }
Beispiel #22
0
        private static IList <YakuValue> CountYaku(List <Meld> decompose, Tile winningTile, HandStatus handStatus,
                                                   RoundStatus roundStatus, GameSetting yakuSettings, bool isQTJ)
        {
            var result = new List <YakuValue>();

            if (decompose == null || decompose.Count == 0)
            {
                return(result);
            }
            foreach (var yakuMethod in YakuMethods)
            {
                var value = (YakuValue)yakuMethod.Invoke(yakuSettings,
                                                         new object[] { decompose, winningTile, handStatus, roundStatus, yakuSettings });
                if (value.Value != 0)
                {
                    result.Add(value);
                }
            }

            if (isQTJ)
            {
                return(result);
            }
            var hasYakuman = result.Any(yakuValue => yakuValue.Type == YakuType.Yakuman);

            return(hasYakuman ? result.Where(yakuValue => yakuValue.Type == YakuType.Yakuman).ToList() : result);
        }
Beispiel #23
0
        private static PointInfo GetPointInfo(ISet <List <Meld> > decomposes, Tile winningTile, HandStatus handStatus,
                                              RoundStatus roundStatus, GameSetting settings, bool isQTJ, int dora, int uraDora, int redDora, int beiDora)
        {
            Debug.Log($"GetPointInfo method, parameters: \ndecomposes: {DecompositionToString(decomposes)}, "
                      + $"winningTile: {winningTile}, handStatus: {handStatus}, roundStatus: {roundStatus}, "
                      + $"dora: {dora}, uraDora: {uraDora}, redDora: {redDora}, beiDora: {beiDora}");
            var infos = new List <PointInfo>();

            foreach (var decompose in decomposes)
            {
                var yakus = CountYaku(decompose, winningTile, handStatus, roundStatus, settings, isQTJ);
                var fu    = CountFu(decompose, winningTile, handStatus, roundStatus, yakus, settings);
                if (yakus.Count == 0)
                {
                    continue;
                }
                var info = new PointInfo(fu, yakus, isQTJ, dora, uraDora, redDora, beiDora);
                infos.Add(info);
                Debug.Log($"Decompose: {string.Join(", ", decompose)}, PointInfo: {info}");
            }

            if (infos.Count == 0)
            {
                return(new PointInfo());
            }
            infos.Sort();
            Debug.Log($"CountPoint: {string.Join(", ", infos.Select(info => info.ToString()))}");
            return(infos[infos.Count - 1]);
        }
 internal BodyData(Dictionary <JointType, Joint> joints, Dictionary <JointType, JointOrientation> orientations, bool valid, int id, NuiSensor sensor, HandStatus leftHand, HandStatus rightHand)
 {
     this.Joints       = joints;
     this.Orientations = orientations;
     this.Id           = id;
     this.Valid        = valid;
     this.Sensor       = sensor;
     this.LeftHand     = leftHand;
     this.RightHand    = rightHand;
 }
Beispiel #25
0
        public static int CountFu(List <Meld> decompose, Tile winningTile, HandStatus handStatus,
                                  RoundStatus roundStatus, IList <YakuValue> yakus, GameSetting settings)
        {
            if (decompose.Count == 7)
            {
                return(25);                      // 7 pairs
            }
            if (decompose.Count == 13)
            {
                return(30); // 13 orphans
            }
            int fu = 20;    // base fu

            // Menqing and not tsumo
            if (handStatus.HasFlag(HandStatus.Menqing) && !handStatus.HasFlag(HandStatus.Tsumo))
            {
                fu += 10;
            }
            // Tsumo
            if (handStatus.HasFlag(HandStatus.Tsumo) && !yakus.Any(yaku => yaku.Name == "平和" || yaku.Name == "岭上开花"))
            {
                fu += 2;
            }
            // pair
            var pair = decompose.First(meld => meld.Type == MeldType.Pair);

            if (pair.Suit == Suit.Z)
            {
                if (pair.First.Rank >= 5 && pair.First.Rank <= 7)
                {
                    fu += 2;                                               // dragons
                }
                var selfWind       = roundStatus.SelfWind;
                var prevailingWind = roundStatus.PrevailingWind;
                if (pair.First.EqualsIgnoreColor(selfWind))
                {
                    fu += 2;
                }

                if (pair.First.EqualsIgnoreColor(prevailingWind))
                {
                    if (!prevailingWind.EqualsIgnoreColor(selfWind) ||
                        settings.连风对子额外加符)
                    {
                        fu += 2;
                    }
                }
            }

            // sequences
            int flag = 0;

            foreach (var meld in decompose)
            {
                if (!meld.Tiles.Contains(winningTile))
                {
                    continue;
                }
                if (meld.Type == MeldType.Pair)
                {
                    flag++;
                }
                if (meld.Type == MeldType.Sequence && !meld.Revealed && meld.IsTwoSideIgnoreColor(winningTile))
                {
                    flag++;
                }
            }

            if (flag != 0)
            {
                fu += 2;
            }
            // triplets
            var winningTileInOther = decompose.Any(meld => !meld.Revealed &&
                                                   (meld.Type == MeldType.Pair ||
                                                    meld.Type == MeldType.Sequence) &&
                                                   meld.ContainsIgnoreColor(winningTile));

            foreach (var meld in decompose)
            {
                if (meld.Type != MeldType.Triplet)
                {
                    continue;
                }
                if (meld.Revealed)
                {
                    fu += GetTripletFu(meld, true);
                }
                else if (handStatus.HasFlag(HandStatus.Tsumo))
                {
                    fu += GetTripletFu(meld, false);
                }
                else if (winningTileInOther)
                {
                    fu += GetTripletFu(meld, false);
                }
                else if (meld.ContainsIgnoreColor(winningTile))
                {
                    fu += GetTripletFu(meld, true);
                }
                else
                {
                    fu += GetTripletFu(meld, false);
                }
            }

            return(ToNextUnit(fu, 10));
        }
        public BodyData[] GetBodyFrame()
        {
            if (!_bodyOpend) // 열기 시도도 안함
            {
                throw new Exception("GetBodyFrame호출 전에 GetBodyFrame를 호출해주세요.");
            }

            if (_bodyOpend && _bodyChannel == null) // 열기 시도했으나 열리지 않았음.
            {
                return(null);
            }

            if (State == SensorState.UNKNOWN)
            {
                throw new Exception("센서가 닫혀있습니다.");
            }

            byte[] data = null;

            if (_bodyChannel.Read(out data) == false) // 쉐어드메모리 읽기 실패
            {
                return(_lastSkeletonFrame);
            }

            MemoryStream stream      = new MemoryStream(data);
            BinaryReader reader      = new BinaryReader(stream);
            int          bodiesCount = reader.ReadInt32();

            BodyData[] result = new BodyData[bodiesCount];
            for (int i = 0; i < bodiesCount; i++)
            {
                Dictionary <JointType, Joint>            joints       = new Dictionary <JointType, Joint>();
                Dictionary <JointType, JointOrientation> orientations = new Dictionary <JointType, JointOrientation>();

                int  bodyId     = reader.ReadInt32();
                bool valid      = reader.ReadBoolean();
                int  jointCount = reader.ReadInt32();
                for (int j = 0; j < jointCount; j++)
                {
                    JointType     type  = (JointType)reader.ReadInt32();
                    TrackingState state = (TrackingState)reader.ReadInt32();
                    double        x     = reader.ReadDouble();
                    double        y     = reader.ReadDouble();
                    double        z     = reader.ReadDouble();

                    float ox = reader.ReadSingle();
                    float oy = reader.ReadSingle();
                    float oz = reader.ReadSingle();
                    float ow = reader.ReadSingle();

                    Joint            joint       = new Joint(x, y, z, type, state);
                    JointOrientation orientation = new JointOrientation(type, ox, oy, oz, ow);

                    if (!joints.ContainsKey(type))
                    {
                        joints.Add(type, joint);
                    }

                    if (!orientations.ContainsKey(type))
                    {
                        orientations.Add(type, orientation);
                    }
                }
                HandStatus leftHand  = (HandStatus)reader.ReadInt16();
                HandStatus rightHand = (HandStatus)reader.ReadInt16();
                result[i] = new BodyData(joints, orientations, valid, bodyId, this, leftHand, rightHand);
            }
            reader.Close();
            stream.Close();

            _lastSkeletonFrame = result;

            return(result);
        }
 // 手の位置の更新
 void hands_HandUpdate(object sender, HandUpdateEventArgs e)
 {
     handStates = HandStatus.Update;
       handPoints.Enqueue(e.Position);
 }
        // 手の検出終了
        void hands_HandDestroy(object sender, HandDestroyEventArgs e)
        {
            // 1.1.0.41 ではHandGenerator.StopTrackingでHandDestroyイベントが
              // 呼び出されるようで再帰になってしまう。
              // そのためトラッキング停止状態でない場合のみ、トラッキング停止をする
              if (handStates != HandStatus.NoTracking) {
            handStates = HandStatus.NoTracking;
            handPoints.Clear();

            // トラッキングの停止
            hands.StopTracking(e.UserID);
              }
        }
Beispiel #29
0
 // 手の位置の更新
 void hands_HandUpdate(object sender, HandUpdateEventArgs e)
 {
     handStates = HandStatus.Update;
     handPoints.Enqueue(e.Position);
 }
Beispiel #30
0
 public ListParticipant()
 {
     HandStatus = new HandStatus();
 }
Beispiel #31
0
 public bool has_status_of(HandStatus status)
 {
     return(this.status.Equals(status));
 }
Beispiel #32
0
 public void change_state_to(HandStatus hand_status)
 {
     status = hand_status;
 }
 // 手の検出開始
 void hands_HandCreate(object sender, HandCreateEventArgs e)
 {
     handStates = HandStatus.Create;
 }
Beispiel #34
0
 // 手の検出開始
 void hands_HandCreate(object sender, HandCreateEventArgs e)
 {
     handStates = HandStatus.Create;
 }