protected override void UpdateVisualTargets()
    {
        int num = this.NumberOfCardsInOpponentsHand();

        base.m_TargetInfo.m_RandomTargetCountMin = num;
        base.m_TargetInfo.m_RandomTargetCountMax = num;
        ZonePlay zonePlay = SpellUtils.FindOpponentPlayZone(this);

        base.GenerateRandomPlayZoneVisualTargets(zonePlay);
        for (int i = 0; i < base.m_targets.Count; i++)
        {
            if (i < base.m_visualTargets.Count)
            {
                base.m_visualTargets[i] = base.m_targets[i];
            }
            else
            {
                this.AddVisualTarget(base.m_targets[i]);
            }
        }
    }
Ejemplo n.º 2
0
    protected override void OnAction(SpellStateType prevStateType)
    {
        this.m_originCards.Clear();
        Player   controller      = base.GetSourceCard().GetEntity().GetController();
        ZonePlay battlefieldZone = controller.GetBattlefieldZone();

        if (controller.IsRevealed())
        {
            for (int i = 0; i < base.m_targets.Count; i++)
            {
                string cardIdForTarget = this.GetCardIdForTarget(i);
                for (int j = 0; j < battlefieldZone.GetCardCount(); j++)
                {
                    Card cardAtIndex = battlefieldZone.GetCardAtIndex(j);
                    if (cardAtIndex.GetPredictedZonePosition() == 0)
                    {
                        string cardId = cardAtIndex.GetEntity().GetCardId();
                        if ((cardIdForTarget == cardId) && !this.m_originCards.ContainsValue(cardAtIndex))
                        {
                            this.m_originCards.Add(i, cardAtIndex);
                            break;
                        }
                    }
                }
            }
        }
        else
        {
            int index = 0;
            for (int k = 0; k < base.m_targets.Count; k++)
            {
                Card card3 = battlefieldZone.GetCardAtIndex(index);
                this.m_originCards.Add(k, card3);
                index++;
            }
        }
        base.OnAction(prevStateType);
    }
Ejemplo n.º 3
0
    public bool ShowFriendlySidePlayerTurnReminder()
    {
        GameState state = GameState.Get();

        if (state.IsMulliganManagerActive())
        {
            return(false);
        }
        Player friendlySidePlayer = state.GetFriendlySidePlayer();

        if (friendlySidePlayer == null)
        {
            return(false);
        }
        if (!friendlySidePlayer.IsCurrentPlayer())
        {
            return(false);
        }
        ZoneMgr mgr = ZoneMgr.Get();

        if (mgr == null)
        {
            return(false);
        }
        ZonePlay play = mgr.FindZoneOfType <ZonePlay>(Player.Side.FRIENDLY);

        if (play == null)
        {
            return(false);
        }
        List <Card> cards = this.GenerateCardsToRemindList(state, play.GetCards());

        if (cards.Count != 0)
        {
            this.PlayReminders(cards);
        }
        return(true);
    }
Ejemplo n.º 4
0
    public PlayErrors.SourceEntityInfo ConvertToSourceInfo(PlayErrors.PlayRequirementInfo playRequirementInfo, Entity parent)
    {
        List <string> entourageCardIDs = this.GetEntityDef().GetEntourageCardIDs();
        List <string> list2            = new List <string>();
        int           num = 0;
        ZoneMgr       mgr = ZoneMgr.Get();

        if (mgr != null)
        {
            ZonePlay play = mgr.FindZoneOfType <ZonePlay>(Player.Side.FRIENDLY);
            if (play != null)
            {
                foreach (Card card in play.GetCards())
                {
                    Entity entity = card.GetEntity();
                    if (entity != null)
                    {
                        list2.Add(entity.GetCardId());
                    }
                }
            }
            ZonePlay play2 = mgr.FindZoneOfType <ZonePlay>(Player.Side.OPPOSING);
            if (play2 != null)
            {
                foreach (Card card2 in play2.GetCards())
                {
                    Entity entity2 = card2.GetEntity();
                    if ((entity2 != null) && entity2.IsMinion())
                    {
                        num++;
                    }
                }
            }
        }
        PlayErrors.SourceEntityInfo info = new PlayErrors.SourceEntityInfo {
            requirementsMap = playRequirementInfo.requirementsMap,
            id     = base.GetEntityId(),
            cost   = base.GetCost(),
            attack = base.GetATK(),
            minAttackRequirement                = playRequirementInfo.paramMinAtk,
            maxAttackRequirement                = playRequirementInfo.paramMaxAtk,
            raceRequirement                     = playRequirementInfo.paramRace,
            numMinionSlotsRequirement           = playRequirementInfo.paramNumMinionSlots,
            numMinionSlotsWithTargetRequirement = playRequirementInfo.paramNumMinionSlotsWithTarget,
            minTotalMinionsRequirement          = playRequirementInfo.paramMinNumTotalMinions,
            minFriendlyMinionsRequirement       = playRequirementInfo.paramMinNumFriendlyMinions,
            minEnemyMinionsRequirement          = playRequirementInfo.paramMinNumEnemyMinions,
            numTurnsInPlay     = base.GetNumTurnsInPlay(),
            numAttacksThisTurn = base.GetNumAttacksThisTurn(),
            numWindfury        = base.GetWindfury(),
            cardType           = base.GetCardType(),
            zone              = base.GetZone(),
            isSecret          = base.IsSecret(),
            isDuplicateSecret = false
        };
        if (info.isSecret)
        {
            Player player = GameState.Get().GetPlayer(base.GetControllerId());
            if (player != null)
            {
                foreach (string str in player.GetSecretDefinitions())
                {
                    if (this.GetCardId().Equals(str, StringComparison.OrdinalIgnoreCase))
                    {
                        info.isDuplicateSecret = true;
                        break;
                    }
                }
            }
        }
        info.isExhausted           = base.IsExhausted();
        info.isMasterPower         = (base.GetZone() == TAG_ZONE.HAND) || base.IsHeroPower();
        info.isActionPower         = TAG_ZONE.HAND == base.GetZone();
        info.isActivatePower       = (base.GetZone() == TAG_ZONE.PLAY) || base.IsHeroPower();
        info.isAttackPower         = base.IsHero() || (!base.IsHeroPower() && (TAG_ZONE.PLAY == base.GetZone()));
        info.isFrozen              = base.IsFrozen();
        info.hasBattlecry          = base.HasBattlecry();
        info.canAttack             = base.CanAttack();
        info.entireEntourageInPlay = false;
        if (entourageCardIDs.Count > 0)
        {
            info.entireEntourageInPlay = list2.Count > 0;
    public static GameObject GetLocationObject(Spell spell)
    {
        SpellLocation location = spell.GetLocation();

        if (location == SpellLocation.NONE)
        {
            return(null);
        }
        GameObject parentObject = null;

        switch (location)
        {
        case SpellLocation.SOURCE:
            parentObject = spell.GetSource();
            break;

        case SpellLocation.SOURCE_AUTO:
            parentObject = FindAutoObjectForSpell(spell.GetSource());
            break;

        case SpellLocation.SOURCE_HERO:
        {
            Card card2 = FindHeroCard(spell.GetSourceCard());
            if (card2 == null)
            {
                return(null);
            }
            parentObject = card2.gameObject;
            break;
        }

        case SpellLocation.SOURCE_HERO_POWER:
        {
            Card card4 = FindHeroPowerCard(spell.GetSourceCard());
            if (card4 == null)
            {
                return(null);
            }
            parentObject = card4.gameObject;
            break;
        }

        case SpellLocation.SOURCE_PLAY_ZONE:
        {
            Card sourceCard = spell.GetSourceCard();
            if (sourceCard == null)
            {
                return(null);
            }
            Player   controller = sourceCard.GetEntity().GetController();
            ZonePlay play       = ZoneMgr.Get().FindZoneOfType <ZonePlay>(controller.GetSide());
            if (play == null)
            {
                return(null);
            }
            parentObject = play.gameObject;
            break;
        }

        case SpellLocation.TARGET:
            parentObject = spell.GetVisualTarget();
            break;

        case SpellLocation.TARGET_AUTO:
            parentObject = FindAutoObjectForSpell(spell.GetVisualTarget());
            break;

        case SpellLocation.TARGET_HERO:
        {
            Card card7 = FindHeroCard(spell.GetVisualTargetCard());
            if (card7 == null)
            {
                return(null);
            }
            parentObject = card7.gameObject;
            break;
        }

        case SpellLocation.TARGET_HERO_POWER:
        {
            Card card9 = FindHeroPowerCard(spell.GetVisualTargetCard());
            if (card9 == null)
            {
                return(null);
            }
            parentObject = card9.gameObject;
            break;
        }

        case SpellLocation.TARGET_PLAY_ZONE:
        {
            Card visualTargetCard = spell.GetVisualTargetCard();
            if (visualTargetCard == null)
            {
                return(null);
            }
            Player   player2 = visualTargetCard.GetEntity().GetController();
            ZonePlay play2   = ZoneMgr.Get().FindZoneOfType <ZonePlay>(player2.GetSide());
            if (play2 == null)
            {
                return(null);
            }
            parentObject = play2.gameObject;
            break;
        }

        case SpellLocation.BOARD:
            if (Board.Get() == null)
            {
                return(null);
            }
            parentObject = Board.Get().gameObject;
            break;

        case SpellLocation.FRIENDLY_HERO:
        {
            Player player3 = FindFriendlyPlayer(spell);
            if (player3 == null)
            {
                return(null);
            }
            Card heroCard = player3.GetHeroCard();
            if (heroCard == null)
            {
                return(null);
            }
            parentObject = heroCard.gameObject;
            break;
        }

        case SpellLocation.FRIENDLY_HERO_POWER:
        {
            Player player4 = FindFriendlyPlayer(spell);
            if (player4 == null)
            {
                return(null);
            }
            Card heroPowerCard = player4.GetHeroPowerCard();
            if (heroPowerCard == null)
            {
                return(null);
            }
            parentObject = heroPowerCard.gameObject;
            break;
        }

        case SpellLocation.FRIENDLY_PLAY_ZONE:
        {
            ZonePlay play3 = FindFriendlyPlayZone(spell);
            if (play3 == null)
            {
                return(null);
            }
            parentObject = play3.gameObject;
            break;
        }

        case SpellLocation.OPPONENT_HERO:
        {
            Player player5 = FindOpponentPlayer(spell);
            if (player5 == null)
            {
                return(null);
            }
            Card card13 = player5.GetHeroCard();
            if (card13 == null)
            {
                return(null);
            }
            parentObject = card13.gameObject;
            break;
        }

        case SpellLocation.OPPONENT_HERO_POWER:
        {
            Player player6 = FindOpponentPlayer(spell);
            if (player6 == null)
            {
                return(null);
            }
            Card card14 = player6.GetHeroPowerCard();
            if (card14 == null)
            {
                return(null);
            }
            parentObject = card14.gameObject;
            break;
        }

        case SpellLocation.OPPONENT_PLAY_ZONE:
        {
            ZonePlay play4 = FindOpponentPlayZone(spell);
            if (play4 == null)
            {
                return(null);
            }
            parentObject = play4.gameObject;
            break;
        }

        case SpellLocation.CHOSEN_TARGET:
        {
            Card powerTargetCard = spell.GetPowerTargetCard();
            if (powerTargetCard == null)
            {
                return(null);
            }
            parentObject = powerTargetCard.gameObject;
            break;
        }
        }
        if (parentObject == null)
        {
            return(null);
        }
        string locationTransformName = spell.GetLocationTransformName();

        if (!string.IsNullOrEmpty(locationTransformName))
        {
            GameObject obj3 = SceneUtils.FindChildBySubstring(parentObject, locationTransformName);
            if (obj3 != null)
            {
                return(obj3);
            }
        }
        return(parentObject);
    }
Ejemplo n.º 6
0
        public bool drop_held_card_worker(int requested_zone_position)
        {
            PegCursor.Get().SetMode(PegCursor.Mode.STOPDRAG);

            InputManager input_man = InputManager.Get();

            if (input_man.heldObject == null)
            {
                Log.log("Nothing held, when trying to drop");
                return(false);
            }
            Card component = input_man.heldObject.GetComponent <Card>();

            ZonePlay m_myPlayZone = PrivateHacker.get_m_myPlayZone();
            ZoneHand m_myHandZone = PrivateHacker.get_m_myHandZone();

            component.SetDoNotSort(false);
            iTween.Stop(input_man.heldObject);
            Entity entity = component.GetEntity();

            component.NotifyLeftPlayfield();
            GameState.Get().GetGameEntity().NotifyOfCardDropped(entity);
            m_myPlayZone.UnHighlightBattlefield();
            DragCardSoundEffects component2 = component.GetComponent <DragCardSoundEffects>();

            if (component2)
            {
                component2.Disable();
            }
            UnityEngine.Object.Destroy(input_man.heldObject.GetComponent <DragRotator>());
            input_man.heldObject = null;
            ProjectedShadow componentInChildren = component.GetActor().GetComponentInChildren <ProjectedShadow>();

            if (componentInChildren != null)
            {
                componentInChildren.DisableShadow();
            }

            // Check that the card is on the hand
            Zone card_zone = component.GetZone();

            if ((card_zone == null) || card_zone.m_ServerTag != TAG_ZONE.HAND)
            {
                return(false);
            }

            bool does_target = false;

            bool is_minion = entity.IsMinion();
            bool is_weapon = entity.IsWeapon();

            if (is_minion || is_weapon)
            {
                Zone zone = (!is_weapon) ? (Zone)m_myPlayZone : (Zone)PrivateHacker.get_m_myWeaponZone();
                if (zone)
                {
                    GameState gameState     = GameState.Get();
                    int       card_position = Network.NoPosition;
                    if (is_minion)
                    {
                        card_position = ZoneMgr.Get().PredictZonePosition(zone, requested_zone_position);
                        gameState.SetSelectedOptionPosition(card_position);
                    }
                    if (input_man.DoNetworkResponse(entity))
                    {
                        if (is_weapon)
                        {
                            PrivateHacker.set_m_lastZoneChangeList(ZoneMgr.Get().AddLocalZoneChange(component, zone, zone.GetLastPos()));
                        }
                        else
                        {
                            PrivateHacker.set_m_lastZoneChangeList(ZoneMgr.Get().AddPredictedLocalZoneChange(component, zone, requested_zone_position, card_position));
                        }
                        PrivateHacker.ForceManaUpdate(entity);
                        if (is_minion && gameState.EntityHasTargets(entity))
                        {
                            does_target = true;
                            if (TargetReticleManager.Get())
                            {
                                bool showArrow = true;
                                TargetReticleManager.Get().CreateFriendlyTargetArrow(entity, entity, true, showArrow, null);
                            }
                            PrivateHacker.set_m_battlecrySourceCard(component);
                        }
                    }
                    else
                    {
                        gameState.SetSelectedOptionPosition(Network.NoPosition);
                    }
                }
            }
            // Spell support
            else
            {
                if (entity.IsSpell())
                {
                    if (GameState.Get().EntityHasTargets(entity))
                    {
                        input_man.heldObject = null;
                        EnemyActionHandler.Get().NotifyOpponentOfCardDropped();
                        m_myHandZone.UpdateLayout(-1, true);
                        m_myPlayZone.SortWithSpotForHeldCard(-1);

                        return(true);
                    }
                    if (!GameState.Get().HasResponse(entity))
                    {
                        PlayErrors.DisplayPlayError(PlayErrors.GetPlayEntityError(entity), entity);
                    }
                    else
                    {
                        input_man.DoNetworkResponse(entity);
                        if (entity.IsSecret())
                        {
                            ZoneSecret m_mySecretZone = PrivateHacker.get_m_mySecretZone();
                            PrivateHacker.set_m_lastZoneChangeList(ZoneMgr.Get().AddLocalZoneChange(component, m_mySecretZone, m_mySecretZone.GetLastPos()));
                        }
                        else
                        {
                            PrivateHacker.set_m_lastZoneChangeList(ZoneMgr.Get().AddLocalZoneChange(component, TAG_ZONE.PLAY));
                        }
                        PrivateHacker.ForceManaUpdate(entity);
                        PrivateHacker.PlayPowerUpSpell(component);
                        PrivateHacker.PlayPlaySpell(component);
                    }
                }
            }
            m_myHandZone.UpdateLayout(-1, true);
            m_myPlayZone.SortWithSpotForHeldCard(-1);
            if (does_target)
            {
                if (EnemyActionHandler.Get())
                {
                    EnemyActionHandler.Get().NotifyOpponentOfTargetModeBegin(component);
                }
            }
            else
            {
                if (GameState.Get().GetResponseMode() != GameState.ResponseMode.SUB_OPTION)
                {
                    EnemyActionHandler.Get().NotifyOpponentOfCardDropped();
                }
            }
            return(true);
        }