示例#1
0
        private void HideEntity(LogLine line)
        {
            Match match = PowerTaskList.HideEntityRegex.Match(line.Log);

            if (LogRegex.EntityRegex.IsMatch(match.Groups["entity"].Value))
            {
                Match  matchEntity = LogRegex.EntityRegex.Match(match.Groups["entity"].Value);
                HSCard card        = Game.GetCard(int.Parse(matchEntity.Groups["player"].Value), int.Parse(matchEntity.Groups["id"].Value));
                Match  matchPeek   = PowerTaskList.TagChangeRegex.Match(PeekLine(PowerReader).Log);
                if (HsConstants.StringToTag(match.Groups["tag"].Value).Equals(GameTag.ZONE))
                {
                    Zone oldzone = card.Zone;
                    card.AddTag(match.Groups["tag"].Value, match.Groups["value"].Value);
                    MoveCard(card, oldzone);
                }
                else
                {
                    throw new IndexOutOfRangeException();
                }
            }
            else
            {
                throw new IndexOutOfRangeException();
            }
        }
示例#2
0
        private void TagChange(LogLine line)
        {
            Match match = PowerTaskList.TagChangeRegex.Match(line.Log);

            if (match.Groups["entity"].Value.Equals("GameEntity"))
            {
                Game.AddTag(match.Groups["tag"].Value, match.Groups["value"].Value);
                if (HsConstants.StringToTag(match.Groups["tag"].Value).Equals(GameTag.STATE) && match.Groups["value"].Value.Equals("COMPLETE"))
                {
                    THS.Windows.THS.GameCore.EndGame();
                }
            }
            else if (match.Groups["entity"].Value.Equals(Game.User.PlayerName))
            {
                Game.User.AddTag(match.Groups["tag"].Value, match.Groups["value"].Value);
            }
            else if (match.Groups["entity"].Value.Equals(Game.Opponent.PlayerName))
            {
                Game.Opponent.AddTag(match.Groups["tag"].Value, match.Groups["value"].Value);
            }
            else if (LogRegex.EntityRegex.IsMatch(match.Groups["entity"].Value))
            {
                Match  matchEntity = LogRegex.EntityRegex.Match(match.Groups["entity"].Value);
                HSCard card        = Game.GetCard(int.Parse(matchEntity.Groups["player"].Value), int.Parse(matchEntity.Groups["id"].Value));
                if (HsConstants.StringToTag(match.Groups["tag"].Value).Equals(GameTag.ZONE))
                {
                    //Cambiar la zona de la carta en las variables
                    Zone oldzone = card.Zone;
                    card.AddTag(match.Groups["tag"].Value, match.Groups["value"].Value);
                    MoveCard(card, oldzone);
                }
                else
                {
                    card.AddTag(match.Groups["tag"].Value, match.Groups["value"].Value);
                }
            }
            else
            {
                throw new IndexOutOfRangeException();
            }
        }
示例#3
0
        private void UpdatingEntity(LogLine line)
        {
            Match match       = PowerTaskList.UpdatingEntityRegex.Match(line.Log);
            Match matchEntity = LogRegex.EntityRegex.Match(match.Groups["entity"].Value);

            if (!Game.PlayersOrdered)
            {
                if (matchEntity.Groups["player"].Value.Equals("2"))
                {
                    HSPlayer tmp = Game.User;
                    Game.User           = Game.Opponent;
                    Game.Opponent       = tmp;
                    Game.User.Enemy     = false;
                    Game.Opponent.Enemy = true;
                }
                Game.PlayersOrdered = true;
            }
            HSCard card = Game.GetCard(int.Parse(matchEntity.Groups["player"].Value), int.Parse(matchEntity.Groups["id"].Value));

            if (card.CardDB == null)
            {
                card.CardDB = Cards.All[match.Groups["cardId"].Value];
            }
            while (PowerTaskList.TagRegex.IsMatch(PeekLine(PowerReader).Log))
            {
                var a = GetLine(PowerReader).Log;
                match = PowerTaskList.TagRegex.Match(a);
                if (HsConstants.StringToTag(match.Groups["tag"].Value).Equals(GameTag.ZONE))
                {
                    Zone oldzone = card.Zone;
                    card.AddTag(match.Groups["tag"].Value, match.Groups["value"].Value);
                    MoveCard(card, oldzone);
                }
                else
                {
                    card.AddTag(match.Groups["tag"].Value, match.Groups["value"].Value);
                }
            }
            IO.LogDebug("Updated card " + card, IO.DebugFile.Hs, false);
        }
示例#4
0
        private void FullEntityUpdating(LogLine line)
        {
            Match  match = PowerTaskList.FullEntityUpdatingRegex.Match(line.Log);
            HSCard card  = Game.GetCard(int.Parse(match.Groups["player"].Value), int.Parse(match.Groups["id"].Value));

            if (card == null)
            {
                card = CreateCard(int.Parse(match.Groups["id"].Value), match.Groups["cardId"].Value);
            }
            else
            {
                if (card.CardDB == null)
                {
                    card.CardDB = Cards.All[match.Groups["cardId"].Value];
                }
                while (PowerTaskList.TagRegex.IsMatch(PeekLine(PowerReader).Log))
                {
                    var a = GetLine(PowerReader).Log;
                    match = PowerTaskList.TagRegex.Match(a);
                    card.AddTag(match.Groups["tag"].Value, match.Groups["value"].Value);
                }
            }
            IO.LogDebug("Updated card " + card, IO.DebugFile.Hs, false);
        }
示例#5
0
        private HSCard CreateCard(int id, string cardId)
        {
            HSCard card = new HSCard(id);
            Match  match;

            while (PowerTaskList.TagRegex.IsMatch(PeekLine(PowerReader).Log))
            {
                var a = GetLine(PowerReader).Log;
                match = PowerTaskList.TagRegex.Match(a);
                card.AddTag(match.Groups["tag"].Value, match.Groups["value"].Value);
            }
            if (cardId != "")
            {
                card.CardDB = Cards.All[cardId];
            }
            else
            {
                card.CardDB = null;
            }
            if (card.Controller == Game.User.PlayerId)
            {
                if (card.CardDB != null && card.CardType == CardType.HERO)
                {
                    Game.User.Hero = card;
                    return(card);
                }
                else if (card.CardDB != null && card.CardType == CardType.HERO_POWER)
                {
                    Game.User.HeroPower = card;
                    return(card);
                }
                switch (card.Zone)
                {
                case Zone.INVALID:
                    break;

                case Zone.PLAY:
                    Game.User.Play.Add(card);
                    break;

                case Zone.DECK:
                    Game.User.Deck.Add(card);
                    break;

                case Zone.HAND:
                    Game.User.Hand.Add(card);
                    break;

                case Zone.GRAVEYARD:
                    Game.User.Graveyard.Add(card);
                    break;

                case Zone.REMOVEDFROMGAME:
                    break;

                case Zone.SETASIDE:
                    Game.User.Setaside.Add(card);
                    break;

                case Zone.SECRET:
                    Game.User.Secret.Add(card);
                    break;

                default:
                    throw new OverflowException();
                }
            }
            else if (card.Controller == Game.Opponent.PlayerId)
            {
                if (card.CardDB != null && card.CardType == CardType.HERO)
                {
                    Game.Opponent.Hero = card;
                    return(card);
                }
                else if (card.CardDB != null && card.CardType == CardType.HERO_POWER)
                {
                    Game.Opponent.HeroPower = card;
                    return(card);
                }
                switch (card.Zone)
                {
                case Zone.INVALID:
                    break;

                case Zone.PLAY:
                    Game.Opponent.Play.Add(card);
                    break;

                case Zone.DECK:
                    Game.Opponent.Deck.Add(card);
                    break;

                case Zone.HAND:
                    Game.Opponent.Hand.Add(card);
                    break;

                case Zone.GRAVEYARD:
                    Game.Opponent.Graveyard.Add(card);
                    break;

                case Zone.REMOVEDFROMGAME:
                    break;

                case Zone.SETASIDE:
                    Game.Opponent.Setaside.Add(card);
                    break;

                case Zone.SECRET:
                    Game.Opponent.Secret.Add(card);
                    break;

                default:
                    throw new OverflowException();
                }
            }
            IO.LogDebug("Created card " + card.Id + " " + card.CardDB?.Name + " Zone: " + card.Zone + " Controller: " + card.Controller + " " + card.CardDB?.Type, IO.DebugFile.Hs, false);
            return(card);
        }