Ejemplo n.º 1
0
        public void OnMoveMade(Player sender, List <Movement> moves)
        {
            // Q_ASSERT(m_gameInProgress);
            // Q_ASSERT(m_board->isLegalMove(move));
            if (sender != PlayerToMove)
            {
                //qDebug("%s tried to make a move on the opponent's turn", qPrintable(sender->name()));
                return;
            }

            Moves.AddRange(moves);
            addPGNMove(moves, evalString(sender.Evaluation));

            // Get the result before sending the move to the opponent
            foreach (Movement move in moves)
            {
                Game.MakeMove(move, true);
            }
            if (Result.IsNone)
            {
                Adjudicator.AddEval(Game, sender.Evaluation);
                if (Adjudicator.Result != null)
                {
                    Result = Adjudicator.Result;
                }
            }
            else
            {
                int q = 0;
            }
            for (int x = 0; x < moves.Count; x++)
            {
                Game.UndoMove();
            }

            Player player = PlayerToWait;

            player.MakeMove(moves);
            foreach (Movement move in moves)
            {
                Game.MakeMove(move, true);
            }

            if (Result.IsNone)
            {
                startTurn();
            }
            else
            {
                Stop();
            }

            emitLastMove();
        }
Ejemplo n.º 2
0
 //Loads the cache into the current data, without deleting the cache
 public void RestoreCache()
 {
     Name = CachedName;
     Moves.Clear();
     Moves.AddRange(CachedMoves);
     Passive      = CachedPassive;
     Picture      = CachedPicture;
     Dead         = CachedDead;
     TotalHP      = CachedTotalHP;
     CurrentHP    = CachedCurrentHP;
     TotalActions = CachedTotalActions;
     Actions      = CachedActions;
     IsPuppet     = CachedIsPuppet;
     CanPassTurn  = CachedCanPassTurn;
     DeathMessage = CachedDeathMessage;
     Effects.Clear();
     Effects.AddRange(Effects);
     Markers.Clear();
     Markers.AddRange(CachedMarkers);
 }
Ejemplo n.º 3
0
        public void GenerateOpening()
        {
            if (m_book[0] == null || m_book[1] == null)
            {
                return;
            }
            resetBoard();

            // First play moves that are already in the opening
            foreach (Movement move in Moves)
            {
                //Q_ASSERT(m_board->isLegalMove(move));

                Game.MakeMove(move, true);
                if (!Game.Result.IsNone)
                {
                    return;
                }
            }

            // Then play the opening book moves
            while (true)
            {
                List <Movement> moves = bookMove(Game.CurrentSide);
                if (moves == null)
                {
                    break;
                }

                foreach (Movement move in moves)
                {
                    Game.MakeMove(move, true);
                }
                if (!Game.Result.IsNone)
                {
                    break;
                }

                Moves.AddRange(moves);
            }
        }
Ejemplo n.º 4
0
 //Copies all essential elements from one card to this one
 public void CopyCard(BasicCard card)
 {
     Name = card.Name;
     Moves.Clear();
     Moves.AddRange(card.Moves);
     Passive      = card.Passive;
     Picture      = card.Picture;
     HasUltimate  = card.HasUltimate;
     HasPassive   = card.HasPassive;
     Dead         = card.Dead;
     TotalHP      = card.TotalHP;
     CurrentHP    = card.CurrentHP;
     TotalActions = card.TotalActions;
     Actions      = card.Actions;
     IsPuppet     = card.IsPuppet;
     CanPassTurn  = card.CanPassTurn;
     DeathMessage = card.DeathMessage;
     Effects.Clear();
     Effects.AddRange(card.Effects);
     Markers.Clear();
     Markers.AddRange(card.Markers);
 }
Ejemplo n.º 5
0
        //Swaps current data with the cache
        public void SwapCache()
        {
            var tempName = Name;

            Name       = CachedName;
            CachedName = tempName;

            List <BasicMove> tempMoves = new List <BasicMove>();

            tempMoves.AddRange(Moves);
            Moves.Clear();
            Moves.AddRange(CachedMoves);
            CachedMoves.Clear();
            CachedMoves.AddRange(tempMoves);

            var tempPassive = Passive;

            Passive       = CachedPassive;
            CachedPassive = tempPassive;

            var tempPicture = Picture;

            Picture       = CachedPicture;
            CachedPicture = tempPicture;

            var tempDead = Dead;

            Dead       = CachedDead;
            CachedDead = tempDead;

            var tempTotalHP = TotalHP;

            TotalHP       = CachedTotalHP;
            CachedTotalHP = tempTotalHP;


            var tempCurrentHP = CurrentHP;

            CurrentHP       = CachedCurrentHP;
            CachedCurrentHP = tempCurrentHP;

            var tempTotalActions = TotalActions;

            TotalActions       = CachedTotalActions;
            CachedTotalActions = tempTotalActions;

            var tempActions = Actions;

            Actions       = CachedActions;
            CachedActions = tempActions;

            var tempIsPuppet = IsPuppet;

            IsPuppet       = CachedIsPuppet;
            CachedIsPuppet = tempIsPuppet;

            var tempCanPassTurn = CanPassTurn;

            CanPassTurn       = CachedCanPassTurn;
            CachedCanPassTurn = tempCanPassTurn;

            var tempDeathMessage = DeathMessage;

            DeathMessage       = CachedDeathMessage;
            CachedDeathMessage = tempDeathMessage;

            List <BuffDebuff> tempEffects = new List <BuffDebuff>();

            tempEffects.AddRange(Effects);
            Effects.Clear();
            Effects.AddRange(CachedEffects);
            CachedEffects.Clear();
            CachedEffects.AddRange(tempEffects);

            List <Marker> tempMarkers = new List <Marker>();

            tempMarkers.AddRange(Markers);
            Markers.Clear();
            Markers.AddRange(CachedMarkers);
            CachedMarkers.Clear();
            CachedMarkers.AddRange(tempMarkers);
        }