Beispiel #1
0
        public void getMoveListForPlayfield(Playfield p, bool log, bool lethalCheck)
        {
            bool own = p.isOwnTurn;
            Player mPlayer;
            int playerNumber = 1;
            if (own)
            {
                mPlayer = p.playerFirst;
                playerNumber = 1;
            }
            else
            {
                mPlayer = p.playerSecond;
                playerNumber = 2;
            }

            Action playedAction;          

            if (p.moveList.Count == 0) //if starting, generate move
            {
                //GameManager.Instance.moveCount++;
                p.moveList = new List<Action>(getMoveList(p, lethalCheck, true, true));
                if (log)
                {
                    Helpfunctions.Instance.logg("######################start turn for player " + playerNumber);
                }
            }
            else //non starting, generate move from existing moves
            {
                playedAction = mPlayer.playactions[mPlayer.playactions.Count - 1];

                if (log)
                {
                    Helpfunctions.Instance.logg("Action:------------------------------------");
                    playedAction.print();
                    p.printMoveList();
                }

                if (p.moveTrigger.handcardAdded || p.moveTrigger.tauntChanged || p.moveTrigger.manaChanged ||
                    p.moveTrigger.ownNewTarget || p.moveTrigger.enemyNewTarget)
                {
                    p.moveList = getMoveList(p, lethalCheck, true, true);
                }
                else 
                {
                    if (p.moveTrigger.minionDied)
                    {
                        foreach (int entityID in p.moveTrigger.minionDiedList)
                        {
                            p.moveList.RemoveAll(x => ((x.target != null && x.target.entitiyID == entityID) || ((x.actionType == actionEnum.attackWithMinion) && x.own.entitiyID == entityID)));
                        }
                    }
                    //Helpfunctions.Instance.logg("movecount == " + GameManager.Instance.moveCount);
                    if (playedAction.actionType == actionEnum.playcard) //play a card
                    {
                        p.moveList.RemoveAll(x => (x.card != null && x.card.entity == playedAction.card.entity));
                    }
                    if (playedAction.actionType == actionEnum.attackWithMinion)//
                    {
                        if (playedAction.own.entitiyID == 1008 && playedAction.target.entitiyID == 1003)
                        {
                            int debug = 1;
                        }
                        if ((playedAction.own.windfury && playedAction.own.numAttacksThisTurn == 2) || !playedAction.own.windfury)
                        {
                            p.moveList.RemoveAll(x => (x.actionType == actionEnum.attackWithMinion && x.own.entitiyID == playedAction.own.entitiyID));
                        }
                    }
                    if (playedAction.actionType == actionEnum.useHeroPower)
                    {
                        p.moveList.RemoveAll(x => x.actionType == actionEnum.useHeroPower);
                    }

                    //mana
                    p.moveList.RemoveAll(x => x.manaCost > mPlayer.mana);
                }
            }

            foreach (int m in p.moveTrigger.minionDiedList)
            {
                if (m == 1008)
                {
                    int debug = 1;
                }
            }
            p.moveTrigger.Clear();

            if (log)
            {
                if (p.isOwnTurn)
                {
                    Helpfunctions.Instance.logg("player 1 Mana: " + p.playerFirst.mana + "/" + p.playerFirst.ownMaxMana);
                }
                else
                {
                    Helpfunctions.Instance.logg("player 2 Mana: " + p.playerSecond.mana + "/" + p.playerSecond.ownMaxMana);
                }
                p.printMoveList();
            }
        }