Silverfish重构【1】-发现卡牌的函数

前言

假期估计时间会比较多,能重构多少是多少,主要还是锻炼一下自己的思维和编程能力。由于能力和精力有限,可能会有错误,希望大家能够指出。

今天新开始从playfield中抽牌的函数动手吧,很多小白不理解参数的意思,索性全部写死。废话不多说,直接上代码。

由于我是云玩家,很多卡牌触发与否和触发顺序不太清楚,希望大家指出错误。

        /// <summary>
        /// 发现卡牌等(凡是不从牌库抽的都调用这个方法)
        /// </summary>
        /// <param name="ss">发现的牌的名字</param>
        /// <param name="own">是否是自己发现</param>
        public void DiscoverACard(CardDB.cardName ss, bool own)
        {
            CardDB.cardName s = ss;

            // cant hold more than 10 cards
            if (own)
            {

                if (s == CardDB.cardName.unknown)
                {
                    if (this.owncards.Count >= 10)
                    {
                        this.evaluatePenality += 15;
                        return;
                    }
                    this.owncarddraw++;
                }
                else
                {
                    if (this.owncards.Count >= 10)
                    {
                        this.evaluatePenality += 5;
                        return;
                    }
                    this.owncarddraw++;
                }
            }
            else
            {
                if (s == CardDB.cardName.unknown)
                {
                        if (this.enemyAnzCards >= 10)
                        {
                            this.evaluatePenality -= (this.turnCounter > 2) ? 20 : 50;
                            return;
                        }
                        this.enemycarddraw++;
                        this.enemyAnzCards++;
                }
                else
                {
                    if (this.enemyAnzCards >= 10)
                    {
                        this.evaluatePenality -= (this.turnCounter > 2) ? 20 : 50;
                        return;
                    }
                    this.enemycarddraw++;
                    this.enemyAnzCards++;
                }
                this.triggerCardsChanged(false);

                //据说克洛玛古斯不触发
                //if (anzEnemyChromaggus > 0 && s == CardDB.cardName.unknown)
                //{
                //    for (int i = 1; i <= anzEnemyChromaggus; i++)
                //    {
                //        if (this.enemyAnzCards >= 10)
                //        {
                //            this.evaluatePenality -= (this.turnCounter > 2) ? 20 : 50;
                //            return;
                //        }
                //        this.enemycarddraw++;
                //        this.enemyAnzCards++;
                //        this.triggerCardsChanged(false);

                //    }
                //}
                return;
            }

            if (s == CardDB.cardName.unknown)
            {
                CardDB.Card c = CardDB.Instance.getCardData(s);
                Handmanager.Handcard hc = new Handmanager.Handcard { card = c, position = this.owncards.Count + 1, manacost = 1000, entity = this.getNextEntity() };
                this.owncards.Add(hc);
                this.triggerCardsChanged(true);
            }
            else
            {
                CardDB.Card c = CardDB.Instance.getCardData(s);
                Handmanager.Handcard hc = new Handmanager.Handcard { card = c, position = this.owncards.Count + 1, manacost = c.calculateManaCost(this), entity = this.getNextEntity() };
                this.owncards.Add(hc);
                this.triggerCardsChanged(true);
            }

            //据说克洛玛古斯不触发
            //if (anzOwnChromaggus > 0 && s == CardDB.cardName.unknown)
            //{
            //    CardDB.Card c = CardDB.Instance.getCardData(s);
            //    for (int i = 1; i <= anzOwnChromaggus; i++)
            //    {
            //        if (this.owncards.Count >= 10)
            //        {
            //            this.evaluatePenality += 15;
            //            return;
            //        }
            //        this.owncarddraw++;

            //        Handmanager.Handcard hc = new Handmanager.Handcard { card = c, position = this.owncards.Count + 1, manacost = 1000, entity = this.getNextEntity() };
            //        this.owncards.Add(hc);
            //        this.triggerCardsChanged(true);
            //    }
            //}
        }

 

        /// <summary>
        /// 发现卡牌等(凡是不从牌库抽的都调用这个方法)
        /// </summary>
        /// <param name="ss">发现的牌的ID</param>
        /// <param name="own">是否是自己发现</param>
        public void DiscoverACard(CardDB.cardIDEnum ss, bool own)
        {
            CardDB.cardIDEnum s = ss;

            // cant hold more than 10 cards

            if (own)
            {
                if (s == CardDB.cardIDEnum.None)
                {
                    if (this.owncards.Count >= 10)
                    {
                        this.evaluatePenality += 15;
                        return;
                    }
                    this.owncarddraw++;
                }
                else
                {
                    if (this.owncards.Count >= 10)
                    {
                        this.evaluatePenality += 5;
                        return;
                    }
                    this.owncarddraw++;
                }
            }
            else
            {
                if (s == CardDB.cardIDEnum.None)
                {
                    if (this.enemyAnzCards >= 10)
                    {
                        this.evaluatePenality -= (this.turnCounter > 2) ? 20 : 50;
                        return;
                    }
                    this.enemycarddraw++;
                    this.enemyAnzCards++;
                }
                else
                {
                    if (this.enemyAnzCards >= 10)
                    {
                        this.evaluatePenality -= (this.turnCounter > 2) ? 20 : 50;
                        return;
                    }
                    this.enemycarddraw++;
                    this.enemyAnzCards++;

                }
                this.triggerCardsChanged(false);

                //if (anzEnemyChromaggus > 0 && s == CardDB.cardIDEnum.None)
                //{
                //    for (int i = 1; i <= anzEnemyChromaggus; i++)
                //    {
                //        if (this.enemyAnzCards >= 10)
                //        {
                //            this.evaluatePenality -= (this.turnCounter > 2) ? 20 : 50;
                //            return;
                //        }
                //        this.enemycarddraw++;
                //        this.enemyAnzCards++;
                //        this.triggerCardsChanged(false);
                //    }
                //}
                return;
            }

            if (s == CardDB.cardIDEnum.None)
            {
                CardDB.Card c = CardDB.Instance.getCardDataFromID(s);
                Handmanager.Handcard hc = new Handmanager.Handcard { card = c, position = this.owncards.Count + 1, manacost = 1000, entity = this.getNextEntity() };
                this.owncards.Add(hc);
                this.triggerCardsChanged(true);
            }
            else
            {
                CardDB.Card c = CardDB.Instance.getCardDataFromID(s);
                Handmanager.Handcard hc = new Handmanager.Handcard { card = c, position = this.owncards.Count + 1, manacost = c.calculateManaCost(this), entity = this.getNextEntity() };
                this.owncards.Add(hc);
                this.triggerCardsChanged(true);
            }

            //if (anzOwnChromaggus > 0 && s == CardDB.cardIDEnum.None && !nopen)
            //{
            //    CardDB.Card c = CardDB.Instance.getCardDataFromID(s);
            //    for (int i = 1; i <= anzOwnChromaggus; i++)
            //    {
            //        if (this.owncards.Count >= 10)
            //        {
            //            this.evaluatePenality += 15;
            //            return;
            //        }
            //        this.owncarddraw++;

            //        Handmanager.Handcard hc = new Handmanager.Handcard { card = c, position = this.owncards.Count + 1, manacost = 1000, entity = this.getNextEntity() };
            //        this.owncards.Add(hc);
            //        this.triggerCardsChanged(true);
            //    }
            //}

        }

 

posted @ 2021-01-09 16:09  魔王的骑士  阅读(557)  评论(0编辑  收藏  举报