Beispiel #1
1
    /// <summary>
    /// 创建卡牌效果
    /// </summary>
    /// <param name="effectType"></param>
    /// <returns></returns>
    public CardEffect CreateEffect(int effectType)
    {
        CardEffect cardEffect = new CardEffect
        {
            duelcard   = thiscard,
            effect     = thiscard.cardeffect.Count + 1,
            effectType = effectType,
            limit      = new List <EffectLimit>(),
        };

        cardEffect.speed = duel.GetCardSpeed(cardEffect);
        thiscard.cardeffect.Add(cardEffect);
        return(cardEffect);
    }
        /// <summary>
        /// First Effect: Draw 2 cards
        /// Second Effect: Restore 5 Health
        /// </summary>
        /// <param name="cardEffect">The card effect to use</param>
        /// <param name="target">The target of the heal</param>
        public void UseCardEffect(CardEffect cardEffect, IDamageableEntity target = null)
        {
            if (cardEffect == CardEffect.FIRST)
            {
                // Draw cards
                this.Owner.DrawCards(DRAW_COUNT);
            }
            else if (cardEffect == CardEffect.SECOND)
            {
                // Heal
                if (target == null)
                {
                    throw new InvalidOperationException("Needs to have a target!");
                }

                bool shouldAbort;
                GameEventManager.Healing(this.Owner, target, HEAL_AMOUNT, out shouldAbort);

                if (!shouldAbort)
                {
                    target.TakeHealing(HEAL_AMOUNT);
                }
            }
            else
            {
                throw new InvalidOperationException("You must choose a card effect to play it!");
            }
        }
Beispiel #3
0
 public override void Activate(IDamageableEntity target = null, CardEffect cardEffect = CardEffect.NONE)
 {
     int totalSpellDamage = MAX_SPELL_POWER + this.BonusSpellPower;
     GameEngine.GameState.CurrentPlayer.TakeDamage(totalSpellDamage);
     GameEngine.GameState.WaitingPlayer.TakeDamage(totalSpellDamage);
     GameEngine.GameState.CurrentPlayerPlayZone.Where(card => card != null).ToList().ForEach(card => ((IDamageableEntity)card).TakeDamage(totalSpellDamage));
     GameEngine.GameState.WaitingPlayerPlayZone.Where(card => card != null).ToList().ForEach(card => ((IDamageableEntity)card).TakeDamage(totalSpellDamage));
 }
Beispiel #4
0
        public override void Activate(IDamageableEntity target = null, CardEffect cardEffect = CardEffect.NONE)
        {
            if (target == null)
            {
                throw new ArgumentNullException("Fireball must be cast with target in mind");
            }

            // Deal damage to the target
            var damageToDeal = MAX_SPELL_POWER + this.BonusSpellPower;
            target.TakeDamage(damageToDeal);
        }
Beispiel #5
0
        private static void AddEffect(StringBuilder html, Card card, string text, bool isParagraph)
        {
            if (isParagraph)
            {
                html.Append("<p>");
            }

            var effect = CardEffect.Parse(statService, card, text);

            foreach (var token in effect.Tokens)
            {
                if (token.IsTrigger || token.IsStrong)
                {
                    html.Append("<b>");
                }

                if (token.IsEmphasized)
                {
                    html.Append("<i>");
                }

                if (token.IsIcon)
                {
                    html.Append("{" + token.Text + "}");
                }
                else if (token.IsTitleReference)
                {
                    html.Append("{title:" + token.Text + "}");
                }
                else
                {
                    html.Append(token.Text);
                }

                if (token.IsEmphasized)
                {
                    html.Append("</i>");
                }

                if (token.IsTrigger || token.IsStrong)
                {
                    html.Append("</b>");
                }
            }

            if (isParagraph)
            {
                html.Append("</p>");
            }
        }
Beispiel #6
0
 static int SetPosition(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 1);
         CardEffect obj = (CardEffect)ToLua.CheckObject <CardEffect>(L, 1);
         obj.SetPosition();
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Beispiel #7
0
    public void SetCard(string suit, string value, Transform parentTransform)
    {
        _suit  = suit;
        _value = value;
        MajorArcanaCard m = GameObject.Find("PlayerMajorArcana").GetComponent <PlayerMajorArcana>().GetSelectedArcana;

        //need to set the effect of the card for each of the divine

        this.transform.Find("CardTitle").gameObject.GetComponent <Text>().text = _value + " " + _suit;
        //get the current
        _currentEffect = _cardFactory.NewCardEffect(m, this);
        _updateEffect();

        this.transform.SetParent(parentTransform, false);
    }
Beispiel #8
0
    public void CloneValueFrom(CardObject cloneFrom)
    {
        cardName    = cloneFrom.cardName;
        image       = cloneFrom.image;
        description = cloneFrom.description;
        charges     = cloneFrom.charges;
        effect      = cloneFrom.effect;

        UsableIn    = cloneFrom.UsableIn;
        UsableRange = cloneFrom.UsableRange;
        type        = cloneFrom.type;

        Equipped = cloneFrom.Equipped;
        Slot     = cloneFrom.Slot;
    }
Beispiel #9
0
    Color getEffectColor(CardEffect ce)
    {
        switch (ce.effect)
        {
        case CardEffect.Effect.DICE:
            return(new Color(0, 0.08f, 0.89f, 0.5f));

        case CardEffect.Effect.HEALTH:
            return(new Color(0.85f, 0, 0.08f, 0.5f));

        case CardEffect.Effect.DICE_MOD:
            return(new Color(0.08f, 0.9f, 0.05f, 0.5f));
        }
        return(Color.white);
    }
Beispiel #10
0
 public void OnUse()
 {
     if (effect != null)
     {
         if (effectInstance == null)
         {
             effectInstance = Instantiate(effect);
         }
         if (effectInstance.cardObject == null)
         {
             effectInstance.Init(this);
         }
         effectInstance.Use();
     }
 }
Beispiel #11
0
    private void Watch(PhotonPlayer owner, CardEffect effect, List <PlayerVisual> stayedPlayers)
    {
        CardEffect.CardsAimType aim = effect.cardsAimType;
        int count = effect.NumberOfCards;

        List <Card> cards = new List <Card> ();

        switch (aim)
        {
        case CardEffect.CardsAimType.Drop:
            cards = NetworkCardGameManager.sInstance.GetPlayerDrop(owner);
            break;

        case CardEffect.CardsAimType.Hand:
            cards = NetworkCardGameManager.sInstance.GetPlayerHand(owner);
            break;

        case CardEffect.CardsAimType.Pile:
            cards = NetworkCardGameManager.sInstance.GetPlayerPile(owner);
            break;

        case CardEffect.CardsAimType.All:
            cards = NetworkCardGameManager.sInstance.GetPlayerCards(owner);
            break;
        }

        cards = cards.OrderBy(x => Guid.NewGuid()).ToList();


        cards = cards.Take(Mathf.Min(cards.Count, count)).ToList();


        Debug.Log(cards.Count);

        CardsManager.Instance.ChooseManager.FillChooseCardField(cards, 0, (List <CardVisual> chodenCards) => {
            if (stayedPlayers.Count > 0)
            {
                PhotonPlayer aimPlayer = (stayedPlayers[0] as PlayerVisual).Player;
                stayedPlayers.RemoveAt(0);
                Watch(aimPlayer, effect, stayedPlayers);
            }

            if (effect == effects[effects.Count - 1] && stayedPlayers.Count == 0)
            {
                callback.Invoke();
            }
        });
    }
        public async Task <VoidAppResult> ExecuteEffect(DtoEffectTargets effect, CardEffect cardEffect, Game game, User currentTurnPlayer,
                                                        CancellationToken cancellationToken = default(CancellationToken))
        {
            var parameters = JsonConvert.DeserializeObject <ChangeStatsEffectParameters>(cardEffect.EffectParameters);

            AppResult <List <GameCard> > targetsResult;

            switch (parameters.TargetingType)
            {
            case TargetingType.Title:
                targetsResult = await base.GetTargetsByTitle(effect, parameters, game);

                break;

            case TargetingType.CharacterName:
                targetsResult = await base.GetTargetsByCharacterName(effect, parameters, game);

                break;

            default:     // TargetingType.NumberOfTargets
                targetsResult = await base.GetTargetsByIds(effect, parameters, game);

                break;
            }
            if (targetsResult.IsErrorResult)
            {
                return(targetsResult.GetVoidAppResult());
            }
            var targets = targetsResult.SuccessReturnValue;

            if (targets.Any(_ => _.CardLocation != CardLocation.Board))
            {
                return(VoidAppResult.Error(ErrorPreset.InvalidTargets));
            }

            foreach (var target in targets)
            {
                target.Health             += parameters.EffectStrength;
                target.StatModifiersCount += parameters.EffectStrength;

                if (target.Health <= 0)
                {
                    target.CardLocation = CardLocation.OutOfPlay;
                }
            }

            return(VoidAppResult.Success());
        }
Beispiel #13
0
 static int SetConTime(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 3);
         CardEffect obj  = (CardEffect)ToLua.CheckObject <CardEffect>(L, 1);
         int        arg0 = (int)LuaDLL.luaL_checknumber(L, 2);
         int        arg1 = (int)LuaDLL.luaL_checknumber(L, 3);
         obj.SetConTime(arg0, arg1);
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Beispiel #14
0
 public void UseCardEffect(CardEffect cardEffect, IDamageableEntity target = null)
 {
     if (cardEffect == CardEffect.FIRST)
     {
         this.TakeBuff(ATTACK_BUFF, 0);
     }
     else if (cardEffect == CardEffect.SECOND)
     {
         this.TakeBuff(0, HEALTH_BUFF);
         this.ApplyStatusEffects(MinionStatusEffects.TAUNT);
     }
     else
     {
         throw new InvalidOperationException("You must choose a card effect to play!");
     }
 }
Beispiel #15
0
 static int CreateEffect(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         DuelEvent  obj  = (DuelEvent)ToLua.CheckObject <DuelEvent>(L, 1);
         int        arg0 = (int)LuaDLL.luaL_checknumber(L, 2);
         CardEffect o    = obj.CreateEffect(arg0);
         ToLua.PushObject(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Beispiel #16
0
 public void UseCardEffect(CardEffect cardEffect, IDamageableEntity target = null)
 {
     if (cardEffect == CardEffect.FIRST)
     {
         this.TakeBuff(ATTACK_BUFF, 0);
     }
     else if (cardEffect == CardEffect.SECOND)
     {
         this.TakeBuff(0, HEALTH_BUFF);
         this.ApplyStatusEffects(MinionStatusEffects.TAUNT);
     }
     else
     {
         throw new InvalidOperationException("You must choose a card effect to play!");
     }
 }
Beispiel #17
0
    private List <CardEffect> GetCardEffectsByText(string txt)
    {
        List <CardEffect> effects_list = new List <CardEffect>();

        string[] effects_array = txt.Split(';');
        foreach (var effect in effects_array)
        {
            CardEffect cardEffect = GetCardEffectByText(effect);
            if (cardEffect != null)
            {
                effects_list.Add(cardEffect);
            }
        }

        return(effects_list);
    }
Beispiel #18
0
    void OnMouseEnter()
    {
        List <RaycastResult> results     = new List <RaycastResult>();
        PointerEventData     pointerData = new PointerEventData(EventSystem.current);

        pointerData.position = Input.mousePosition;
        EventSystem.current.RaycastAll(pointerData, results);
        foreach (RaycastResult rr in results)
        {
            if (rr.gameObject.layer == 5)
            {
                return;
            }
        }

        if (CardsPlayer.Instance.DraggingCard)
        {
            return;
        }

        CameraController.Instance.AimedBlockChanged(this);

        if (CardsPlayer.Instance.ActiveCard)
        {
            CardEffect cardEffect = CardsPlayer.Instance.ActiveCard.CardAsset.CardEffects.FirstOrDefault(ce => ce.cardAim == CardEffect.CardAim.Player);
            if (cardEffect != null)
            {
                if (cardEffect.playerAimType == CardEffect.PlayerAimType.All || cardEffect.playerAimType == CardEffect.PlayerAimType.Enemies || cardEffect.playerAimType == CardEffect.PlayerAimType.You)
                {
                    return;
                }
            }


            cardEffect = CardsPlayer.Instance.ActiveCard.CardAsset.CardEffects.FirstOrDefault(ce => ce.cardAim == CardEffect.CardAim.Cell);
            if (cardEffect != null)
            {
                if (cardEffect.cellAimType == CardEffect.CellAimType.All || cardEffect.cellAimType == CardEffect.CellAimType.Random)
                {
                    return;
                }
            }
        }

        CardsPlayer.Instance.SelectAim(this);
        InformationPanel.Instance.ShowInfo(this);
    }
Beispiel #19
0
    static int get_thiseffect(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            DuelEvent  obj = (DuelEvent)o;
            CardEffect ret = obj.thiseffect;
            ToLua.PushObject(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index thiseffect on a nil value"));
        }
    }
        public async Task <AppResult <DtoEffect> > GetDtoEffect(CardEffect cardEffect)
        {
            var dtoEffect = new DtoEffect
            {
                Id         = cardEffect.Id,
                EffectType = cardEffect.EffectType
            };

            var configureResult = await this.effects[cardEffect.EffectType].ConfigureDtoEffect(cardEffect, dtoEffect);

            if (configureResult.IsErrorResult)
            {
                return(configureResult.GetErrorAppResult <DtoEffect>());
            }

            return(AppResult <DtoEffect> .Success(dtoEffect));
        }
Beispiel #21
0
    void Start()
    {
        distance_to_screen   = Camera.main.WorldToScreenPoint(gameObject.transform.position).z - 1;
        DescriptionText.text = description.ToString();

        if (GenerateRandomeData)
        {
            cardtype = (CardType)Random.Range(0, 2);


            mana = Random.Range(1, 10);

            //Generate Randome Name
            string[] characters = { "a", "b", "c", "d", "e", "f" };
            for (int i = 0; i < 5; i++)
            {
                _name += characters[Random.Range(0, characters.Length)];
            }
            if (cardtype == CardType.Magic)
            {
                health      = 0;
                _Attack     = 0;
                AddedAttack = Random.Range(1, 8);
                AddedHealth = Random.Range(1, 8);
                cardeffect  = (CardEffect)Random.Range(0, 3);
                if (cardeffect == CardEffect.ToSpecific)
                {
                    DescriptionText.text = "Add " + AddedAttack + "/" + AddedHealth + "\n" + "   To Any Selected Moster";
                }
                else if (cardeffect == CardEffect.ToAll)
                {
                    DescriptionText.text = "Add " + AddedAttack + "/" + AddedHealth + "\n" + "   To ALL";
                }
                else if (cardeffect == CardEffect.ToEnemies)
                {
                    DescriptionText.text = "Add " + AddedAttack + "/" + AddedHealth + "\n" + "   To ALL Enemies";
                }
            }
            else
            {
                //Generate Randome Data
                health  = Random.Range(1, 8);
                _Attack = Random.Range(1, 8);
            }
        }
    }
Beispiel #22
0
    static int set_thiseffect(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            DuelEvent  obj  = (DuelEvent)o;
            CardEffect arg0 = (CardEffect)ToLua.CheckObject <CardEffect>(L, 2);
            obj.thiseffect = arg0;
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index thiseffect on a nil value"));
        }
    }
Beispiel #23
0
    static int set_limit(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            CardEffect obj = (CardEffect)o;
            System.Collections.Generic.List <EffectLimit> arg0 = (System.Collections.Generic.List <EffectLimit>)ToLua.CheckObject(L, 2, typeof(System.Collections.Generic.List <EffectLimit>));
            obj.limit = arg0;
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index limit on a nil value"));
        }
    }
Beispiel #24
0
    static int set_contime(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            CardEffect obj  = (CardEffect)o;
            ConTime    arg0 = (ConTime)ToLua.CheckObject <ConTime>(L, 2);
            obj.contime = arg0;
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index contime on a nil value"));
        }
    }
Beispiel #25
0
    static int set_speed(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            CardEffect obj  = (CardEffect)o;
            int        arg0 = (int)LuaDLL.luaL_checknumber(L, 2);
            obj.speed = arg0;
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index speed on a nil value"));
        }
    }
Beispiel #26
0
    static int set_position(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            CardEffect obj  = (CardEffect)o;
            bool       arg0 = LuaDLL.luaL_checkboolean(L, 2);
            obj.position = arg0;
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index position on a nil value"));
        }
    }
Beispiel #27
0
    static int set_duelcard(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            CardEffect obj  = (CardEffect)o;
            DuelCard   arg0 = (DuelCard)ToLua.CheckObject <DuelCard>(L, 2);
            obj.duelcard = arg0;
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index duelcard on a nil value"));
        }
    }
Beispiel #28
0
    static int get_contime(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            CardEffect obj = (CardEffect)o;
            ConTime    ret = obj.contime;
            ToLua.PushObject(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index contime on a nil value"));
        }
    }
Beispiel #29
0
    static int get_limit(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            CardEffect obj = (CardEffect)o;
            System.Collections.Generic.List <EffectLimit> ret = obj.limit;
            ToLua.PushSealed(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index limit on a nil value"));
        }
    }
Beispiel #30
0
    static int get_duelcard(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            CardEffect obj = (CardEffect)o;
            DuelCard   ret = obj.duelcard;
            ToLua.PushObject(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index duelcard on a nil value"));
        }
    }
Beispiel #31
0
    static int get_speed(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            CardEffect obj = (CardEffect)o;
            int        ret = obj.speed;
            LuaDLL.lua_pushinteger(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index speed on a nil value"));
        }
    }
Beispiel #32
0
    static int get_position(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            CardEffect obj = (CardEffect)o;
            bool       ret = obj.position;
            LuaDLL.lua_pushboolean(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index position on a nil value"));
        }
    }
Beispiel #33
0
        private static void PutItIntoList(CardEffect effect, List <CardEffect> list)
        {
            list.Add(effect);

            if (effect.FunctionId == CardEffectType.ChooseOne)
            {
                var choose = effect as ChooseOneCardEffect;
                if (choose == null)
                {
                    return;
                }

                foreach (var e in choose.Candidate)
                {
                    PutItIntoList(e, list);
                }
            }
        }
Beispiel #34
0
 public static void addCardEffect(CardEffect newCardEffect)
 {
     if (newCardEffect.condition == CardEffect.Condition.FIRST || newCardEffect.condition == CardEffect.Condition.LAST)
     {
         foreach (CardEffect ce in cardEffects) // Search if there's any ce with same condition, and cond/eff numbers
         {
             if (ce.condition == newCardEffect.condition && ce.conditionNumber == newCardEffect.conditionNumber &&
                 ce.effect == newCardEffect.effect)
             {
                 ce.effectNumber += newCardEffect.effectNumber; // If there is, add new effect to the old one
                 return;
             }
         }
     }
     // If there isn't create a new one (to break the reference and avoid changes to the effect in deck's card)
     newCardEffect = new CardEffect(0, newCardEffect.condition, newCardEffect.conditionNumber, newCardEffect.effect, newCardEffect.effectNumber);
     cardEffects.Add(newCardEffect);
 }
 public override void Activate(IDamageableEntity target = null, CardEffect cardEffect = CardEffect.NONE)
 {
     throw new NotImplementedException();
 }
 public override void Activate(IDamageableEntity target = null, CardEffect cardEffect = CardEffect.NONE)
 {
     GameEngine.GameState.WaitingPlayerPlayZone.ForEach(minion => this.HealTarget((BaseMinion)minion, MAX_SPELL_POWER));
     GameEngine.GameState.CurrentPlayerPlayZone.ForEach(minion => this.HealTarget((BaseMinion)minion, MAX_SPELL_POWER));
 }
Beispiel #37
0
 /// <summary>
 /// Activates the spell card with an optional target
 /// </summary>
 /// <param name="target">The target for the spell card if applicable</param>
 /// <param name="cardEffect">The card effect to use</param>
 public abstract void Activate(IDamageableEntity target = null, CardEffect cardEffect = CardEffect.NONE);
Beispiel #38
0
 public override void Activate(IDamageableEntity target = null, CardEffect cardEffect = CardEffect.NONE)
 {
     this.Owner.Mana = Math.Min(this.Owner.Mana + 1, Constants.MAX_MANA_CAPACITY);
 }