Ejemplo n.º 1
0
        public override void OnCheckCaptureNeis(TriadGameData gameData, int boardPos, int[] neiPos, List <int> captureList)
        {
            TriadCardInstance checkCard = gameData.board[boardPos];

            for (int sideIdx = 0; sideIdx < 4; sideIdx++)
            {
                int testNeiPos = neiPos[sideIdx];
                if (testNeiPos >= 0 && gameData.board[testNeiPos] != null)
                {
                    TriadCardInstance neiCard = gameData.board[testNeiPos];
                    if (checkCard.owner != neiCard.owner)
                    {
                        int  numPosPattern   = checkCard.GetNumber((ETriadGameSide)sideIdx);
                        int  numOtherPattern = neiCard.GetOppositeNumber((ETriadGameSide)sideIdx);
                        int  sumPattern      = numPosPattern + numOtherPattern;
                        bool bIsCaptured     = false;

                        for (int vsSideIdx = 0; vsSideIdx < 4; vsSideIdx++)
                        {
                            int vsNeiPos = neiPos[vsSideIdx];
                            if (vsNeiPos >= 0 && sideIdx != vsSideIdx && gameData.board[vsNeiPos] != null)
                            {
                                TriadCardInstance vsCard = gameData.board[vsNeiPos];

                                int numPosVs   = checkCard.GetNumber((ETriadGameSide)vsSideIdx);
                                int numOtherVs = vsCard.GetOppositeNumber((ETriadGameSide)vsSideIdx);
                                int sumVs      = numPosVs + numOtherVs;

                                if (sumPattern == sumVs)
                                {
                                    bIsCaptured = true;

                                    if (vsCard.owner != checkCard.owner)
                                    {
                                        vsCard.owner = checkCard.owner;
                                        captureList.Add(vsNeiPos);

                                        if (gameData.bDebugRules)
                                        {
                                            Logger.WriteLine(">> " + RuleName + "! [" + vsNeiPos + "] " + vsCard.card.Name + " => " + vsCard.owner);
                                        }
                                    }
                                }
                            }
                        }

                        if (bIsCaptured)
                        {
                            neiCard.owner = checkCard.owner;
                            captureList.Add(testNeiPos);

                            if (gameData.bDebugRules)
                            {
                                Logger.WriteLine(">> " + RuleName + "! [" + testNeiPos + "] " + neiCard.card.Name + " => " + neiCard.owner);
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public override void OnCheckCaptureNeis(TriadGameData gameData, int boardPos, int[] neiPos, List <int> captureList)
        {
            TriadCardInstance checkCard = gameData.board[boardPos];
            int numSame        = 0;
            int neiCaptureMask = 0;

            for (int sideIdx = 0; sideIdx < 4; sideIdx++)
            {
                int testNeiPos = neiPos[sideIdx];
                if (testNeiPos >= 0 && gameData.board[testNeiPos] != null)
                {
                    TriadCardInstance neiCard = gameData.board[testNeiPos];

                    int numPos   = checkCard.GetNumber((ETriadGameSide)sideIdx);
                    int numOther = neiCard.GetOppositeNumber((ETriadGameSide)sideIdx);
                    if (numPos == numOther)
                    {
                        numSame++;

                        if (neiCard.owner != checkCard.owner)
                        {
                            neiCaptureMask |= (1 << sideIdx);
                        }
                    }
                }
            }

            if (numSame >= 2)
            {
                for (int sideIdx = 0; sideIdx < 4; sideIdx++)
                {
                    int testNeiPos = neiPos[sideIdx];
                    if ((neiCaptureMask & (1 << sideIdx)) != 0)
                    {
                        TriadCardInstance neiCard = gameData.board[testNeiPos];
                        neiCard.owner = checkCard.owner;
                        captureList.Add(testNeiPos);

                        if (gameData.bDebugRules)
                        {
                            Logger.WriteLine(">> " + RuleName + "! [" + testNeiPos + "] " + neiCard.card.Name.GetCodeName() + " => " + neiCard.owner);
                        }
                    }
                }
            }
        }
Ejemplo n.º 3
0
        private void CheckCaptures(TriadGameData gameData, int boardPos, List <int> comboList, int comboCounter)
        {
            // combo:
            // - modifiers are active only in intial placement
            // - only card captured via modifiers can initiate combo (same, plus)
            // - type modifiers (ascention, descention) values are baked in card and influence combo
            // - can't proc another plus/same as a result of combo

            int[] neis      = cachedNeis[boardPos];
            bool  allowMods = comboCounter == 0;

            if (allowMods && (modFeatures & TriadGameModifier.EFeature.CaptureNei) != 0)
            {
                foreach (TriadGameModifier mod in modifiers)
                {
                    mod.OnCheckCaptureNeis(gameData, boardPos, neis, comboList);
                }
            }

            TriadCardInstance checkCard = gameData.board[boardPos];

            for (int sideIdx = 0; sideIdx < 4; sideIdx++)
            {
                int neiPos = neis[sideIdx];
                if (neiPos >= 0 && gameData.board[neiPos] != null)
                {
                    TriadCardInstance neiCard = gameData.board[neiPos];
                    if (checkCard.owner != neiCard.owner)
                    {
                        int numPos   = checkCard.GetNumber((ETriadGameSide)sideIdx);
                        int numOther = neiCard.GetOppositeNumber((ETriadGameSide)sideIdx);

                        if (allowMods && (modFeatures & TriadGameModifier.EFeature.CaptureWeights) != 0)
                        {
                            foreach (TriadGameModifier mod in modifiers)
                            {
                                mod.OnCheckCaptureCardWeights(gameData, boardPos, neiPos, ref numPos, ref numOther);
                            }
                        }

                        bool bIsCaptured = (numPos > numOther);
                        if (allowMods && (modFeatures & TriadGameModifier.EFeature.CaptureMath) != 0)
                        {
                            foreach (TriadGameModifier mod in modifiers)
                            {
                                mod.OnCheckCaptureCardMath(gameData, boardPos, neiPos, numPos, numOther, ref bIsCaptured);
                            }
                        }

                        if (bIsCaptured)
                        {
                            neiCard.owner = checkCard.owner;
                            if (comboCounter > 0)
                            {
                                comboList.Add(neiPos);
                            }

                            if (gameData.bDebugRules)
                            {
                                Logger.WriteLine(">> " + (comboCounter > 0 ? "combo!" : "") + " [" + neiPos + "] " + neiCard.card.Name.GetCodeName() + " => " + neiCard.owner);
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 4
0
        private void CheckCaptures(TriadGameData gameData, int boardPos, List <int> comboList, int comboCounter)
        {
            int[] neis = GetNeighbors(gameData, boardPos);
            bool  bAllowBasicCaptureCombo = (comboCounter > 0);

            if ((comboCounter == 0) && ((modFeatures & TriadGameModifier.EFeature.CaptureNei) != 0))
            {
                foreach (TriadGameModifier mod in modifiers)
                {
                    mod.OnCheckCaptureNeis(gameData, boardPos, neis, comboList);
                }

                bAllowBasicCaptureCombo = bAllowBasicCaptureCombo || (comboList.Count > 0);
            }

            TriadCardInstance checkCard = gameData.board[boardPos];

            for (int sideIdx = 0; sideIdx < 4; sideIdx++)
            {
                int neiPos = neis[sideIdx];
                if (neiPos >= 0 && gameData.board[neiPos] != null)
                {
                    TriadCardInstance neiCard = gameData.board[neiPos];
                    if (checkCard.owner != neiCard.owner)
                    {
                        int numPos   = checkCard.GetNumber((ETriadGameSide)sideIdx);
                        int numOther = neiCard.GetOppositeNumber((ETriadGameSide)sideIdx);
                        if ((modFeatures & TriadGameModifier.EFeature.CaptureWeights) != 0)
                        {
                            foreach (TriadGameModifier mod in modifiers)
                            {
                                mod.OnCheckCaptureCardWeights(gameData, boardPos, neiPos, ref numPos, ref numOther);
                            }
                        }

                        bool bIsCaptured = (numPos > numOther);
                        if ((modFeatures & TriadGameModifier.EFeature.CaptureMath) != 0)
                        {
                            foreach (TriadGameModifier mod in modifiers)
                            {
                                mod.OnCheckCaptureCardMath(gameData, boardPos, neiPos, numPos, numOther, ref bIsCaptured);
                            }
                        }

                        if (bIsCaptured)
                        {
                            neiCard.owner = checkCard.owner;
                            if (bAllowBasicCaptureCombo)
                            {
                                comboList.Add(neiPos);
                            }

                            if (gameData.bDebugRules)
                            {
                                Logger.WriteLine(">> " + (comboCounter > 0 ? "combo!" : "") + " [" + neiPos + "] " + neiCard.card.Name + " => " + neiCard.owner);
                            }
                        }
                    }
                }
            }
        }