コード例 #1
0
        internal override HearthInternalState NewLogLine(string line, ref HearthGame game)
        {
            if(line?.EndsWith("CREATE_GAME") ?? false) {
                return new HearthInternalStartingNewGame(eventObserver);
            }

            return this;
        }
コード例 #2
0
        internal override HearthInternalState NewLogLine(string line, ref HearthGame game)
        {
            if (line?.EndsWith("CREATE_GAME") ?? false)
            {
                return(new HearthInternalStartingNewGame(eventObserver));
            }

            return(this);
        }
コード例 #3
0
 private void HearthEvent(HearthstoneEvent hearthEvent)
 {
     if (hearthEvent is NewGame)
     {
         var newGameEvent = hearthEvent as NewGame;
         hearthstoneGame = newGameEvent.game;
         SetState(null, typeof(HSStateAcceptingBets));
     }
     else if (hearthEvent is EndOfGame)
     {
         var endGameEvent = hearthEvent as EndOfGame;
         lastGameEnding = endGameEvent;
         SetState(null, typeof(HSStateEndOfGame));
     }
     else if (hearthEvent is DrawCard)
     {
         var drawEvent = hearthEvent as DrawCard;
         if (currentState is HSStatePlaying)
         {
             var playingState = currentState as HSStatePlaying;
             playingState.NextTurn(drawEvent);
         }
     }
 }
コード例 #4
0
 internal abstract HearthInternalState NewLogLine(string line, ref HearthGame game);
コード例 #5
0
 public HearthstoneEvent(HearthGame game)
 {
     this.game = game;
 }
コード例 #6
0
ファイル: NewGame.cs プロジェクト: hardlydifficult/HardlyBot
 public NewGame(HearthGame game)
     : base(game)
 {
 }
コード例 #7
0
ファイル: DrawCard.cs プロジェクト: hardlydifficult/HardlyBot
 public DrawCard(HearthGame game, bool myTurn, HearthstoneCard card)
     : base(game)
 {
     this.myTurn = myTurn;
     this.card = card;
 }
コード例 #8
0
        internal override HearthInternalState NewLogLine(string line, ref HearthGame game)
        {
            // TAG_CHANGE Entity=HardlySober tag=PLAYSTATE value=WON
            if (line.Contains("TAG_CHANGE Entity=" + game.myPlayerName + " tag=PLAYSTATE value="))
            {
                if (line.EndsWith("WON"))
                {
                    return(new HearthInternalStateOff(eventObserver, true));
                }
                else if (line.EndsWith("LOST"))
                {
                    return(new HearthInternalStateOff(eventObserver, false));
                }
                else if (line.EndsWith("TIED"))
                {
                    return(new HearthInternalStateOff(eventObserver, null));
                }
            }

            // Learning cards
            // 14:43:05.8675879 GameState.DebugPrintOptions() -   option 3 type=POWER mainEntity=[name=Fiery War Axe id=8 zone=HAND zonePos=4 cardId=CS2_106 player=1]
            if (line.Contains("type=POWER mainEntity=[name="))
            {
                string cardId   = line.GetBetween(" cardId=", " ");
                string cardName = line.GetBetween("mainEntity=[name=", " id=");
                if (cardId != null && cardName != null)
                {
                    HearthstoneCard card = factory.CreateCard(cardId, cardName);
                    card.Save(); // TODO switch to lazy save
                }
            }

            // Drawing cards
            // D 14:42:40.6163131 GameState.DebugPrintPower() - ACTION_START Entity=HardlySober BlockType=TRIGGER Index=-1 Target=0
            // D 14:42:40.6163131 GameState.DebugPrintPower() -     SHOW_ENTITY - Updating Entity=[id=8 cardId= type=INVALID zone=DECK zonePos=0 player=1] CardID=CS2_106

            string otherPlayerName = game.myPlayerName.Equals(currentEntity) ? game.opponentPlayerName : game.myPlayerName;

            if (line.Contains("TAG_CHANGE Entity=" + otherPlayerName + " tag=CURRENT_PLAYER value=1"))
            {
                var entity = line.GetBetween("TAG_CHANGE Entity=", " tag=CURRENT_PLAYER");
                if (entity != null && !entity.Equals("GameEntity"))
                {
                    if (entity != currentEntity)
                    {
                        currentEntity   = entity;
                        firstCardOfTurn = true;
                    }
                }
            }

            if (firstCardOfTurn && currentEntity != null && line.Contains("SHOW_ENTITY - Updating Entity="))
            {
                string cardId = line.GetAfter("CardID=");
                if (cardId != null)
                {
                    bool?myTurn = null;
                    if (currentEntity.Equals(game.myPlayerName))
                    {
                        myTurn = true;
                    }
                    else if (currentEntity.Equals(game.opponentPlayerName))
                    {
                        myTurn = false;
                    }

                    if (myTurn != null)
                    {
                        HearthstoneCard card = factory.CreateCard(cardId);
                        eventObserver.Observe(new DrawCard(eventObserver.currentGame, myTurn.Value, card));
                        firstCardOfTurn = false;
                    }
                }
            }

            ///// TAG_CHANGE Entity=HardlySober tag=CURRENT_PLAYER value=1
            //if(currentEntity == null || line.Contains("TAG_CHANGE Entity=" + currentEntity + " tag=CURRENT_PLAYER value=0")) {
            //    if(almostReadyForNext) {
            //        lookForNewPlayer = true;
            //        almostReadyForNext = false;
            //    } else {
            //        almostReadyForNext = true;
            //    }
            //}

            return(this);
        }
コード例 #9
0
 public EndOfGame(HearthGame game, bool?iWon) : base(game)
 {
     this.iWon = iWon;
 }
コード例 #10
0
 public HearthstoneEvent(HearthGame game)
 {
     this.game = game;
 }
コード例 #11
0
 internal abstract HearthInternalState NewLogLine(string line, ref HearthGame game);
コード例 #12
0
        internal override HearthInternalState NewLogLine(string line, ref HearthGame game)
        {
            // TAG_CHANGE Entity=HardlySober tag=PLAYSTATE value=WON
            if(line.Contains("TAG_CHANGE Entity=" + game.myPlayerName + " tag=PLAYSTATE value=")) {
                if(line.EndsWith("WON")) {
                    return new HearthInternalStateOff(eventObserver, true);
                } else if(line.EndsWith("LOST")) {
                    return new HearthInternalStateOff(eventObserver, false);
                } else if(line.EndsWith("TIED")) {
                    return new HearthInternalStateOff(eventObserver, null);
                }
            }

            // Learning cards
            // 14:43:05.8675879 GameState.DebugPrintOptions() -   option 3 type=POWER mainEntity=[name=Fiery War Axe id=8 zone=HAND zonePos=4 cardId=CS2_106 player=1]
            if(line.Contains("type=POWER mainEntity=[name=")) {
                string cardId = line.GetBetween(" cardId=", " ");
                string cardName = line.GetBetween("mainEntity=[name=", " id=");
                if(cardId != null && cardName != null) {
                    HearthstoneCard card = factory.CreateCard(cardId, cardName);
                    card.Save(); // TODO switch to lazy save
                }
            }

            // Drawing cards
            // D 14:42:40.6163131 GameState.DebugPrintPower() - ACTION_START Entity=HardlySober BlockType=TRIGGER Index=-1 Target=0
            // D 14:42:40.6163131 GameState.DebugPrintPower() -     SHOW_ENTITY - Updating Entity=[id=8 cardId= type=INVALID zone=DECK zonePos=0 player=1] CardID=CS2_106

            string otherPlayerName = game.myPlayerName.Equals(currentEntity) ? game.opponentPlayerName : game.myPlayerName;
            if(line.Contains("TAG_CHANGE Entity=" + otherPlayerName + " tag=CURRENT_PLAYER value=1")) {
                var entity = line.GetBetween("TAG_CHANGE Entity=", " tag=CURRENT_PLAYER");
                if(entity != null && !entity.Equals("GameEntity")) {
                    if(entity != currentEntity) {
                        currentEntity = entity;
                        firstCardOfTurn = true;
                    }
                }
            }

            if(firstCardOfTurn && currentEntity != null && line.Contains("SHOW_ENTITY - Updating Entity=")) {
                string cardId = line.GetAfter("CardID=");
                if(cardId != null) {
                    bool? myTurn = null;
                    if(currentEntity.Equals(game.myPlayerName)) {
                        myTurn = true;
                    } else if(currentEntity.Equals(game.opponentPlayerName)) {
                        myTurn = false;
                    }

                    if(myTurn != null) {
                        HearthstoneCard card = factory.CreateCard(cardId);
                        eventObserver.Observe(new DrawCard(eventObserver.currentGame, myTurn.Value, card));
                        firstCardOfTurn = false;
                    }
                }
            }

            ///// TAG_CHANGE Entity=HardlySober tag=CURRENT_PLAYER value=1
            //if(currentEntity == null || line.Contains("TAG_CHANGE Entity=" + currentEntity + " tag=CURRENT_PLAYER value=0")) {
            //    if(almostReadyForNext) {
            //        lookForNewPlayer = true;
            //        almostReadyForNext = false;
            //    } else {
            //        almostReadyForNext = true;
            //    }
            //}

            return this;
        }
コード例 #13
0
 public EndOfGame(HearthGame game, bool? iWon)
     : base(game)
 {
     this.iWon = iWon;
 }
コード例 #14
0
 public DrawCard(HearthGame game, bool myTurn, HearthstoneCard card) : base(game)
 {
     this.myTurn = myTurn;
     this.card   = card;
 }
コード例 #15
0
ファイル: NewGame.cs プロジェクト: shashankmishra55/HardlyBot
 public NewGame(HearthGame game) : base(game)
 {
 }