diff --git a/Assets/Scripts/Alterations/DuplicateNextCard.cs b/Assets/Scripts/Alterations/DuplicateNextCard.cs index d80e471d8a02d2f85dc7162109a4f3725f81812e..ba7e9126f4c3b7d6b6f5571f7fa3b6b6c10e495c 100644 --- a/Assets/Scripts/Alterations/DuplicateNextCard.cs +++ b/Assets/Scripts/Alterations/DuplicateNextCard.cs @@ -11,19 +11,12 @@ public class DuplicateNextCard : Alteration public void OnCardPlayed(Card card) { - if (!card.wasDuplicated && card != null) - { - card.wasDuplicated = true; - for (int i = 0; i < mValue; i++) - { - card.ApplyDuplicated(); - } - } - - if (mValidity == Validity.ONE_USE) - { - CleanUp(); - } + card.ApplyDuplicated(mValue); + + if (mValidity == Validity.ONE_USE) + { + CleanUp(); + } } public override void CleanUp() diff --git a/Assets/Scripts/Cards/Card.cs b/Assets/Scripts/Cards/Card.cs index 61c2241ff482486b6689368987d90d2826f06d43..aad4eb26d1af830f36f0d4ad7a4739c8b9b3734b 100644 --- a/Assets/Scripts/Cards/Card.cs +++ b/Assets/Scripts/Cards/Card.cs @@ -1,137 +1,143 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine.EventSystems; -using UnityEngine; -using UnityEngine.Events; - -/* Class for a playable card*/ -public class Card : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler -{ - [SerializeField] - GameObject highlightBorder; - - protected List<Effect> mEffects; - - [SerializeField] - private int mCost; - - public int Cost => mCost; - - public bool Playable => Player.Instance.Energy >= mCost; - - public string Name = ""; - - private DraftChoice mChoice = null; //dirty hack for ui : if you click on the card in ui it will just add it to deck - - public bool wasDuplicated = false; // Further duplications should not be applied to a duplicated card - - private CardUi mCardUi; - - public List<Effect> GetEffects() - { - if (mEffects == null) - { - Start(); - } - return mEffects; - } - - public void Start() - { - if (mEffects == null) - { - mEffects = new List<Effect>(); - mEffects.AddRange(GetComponents<Effect>()); - } - if (mEffects == null || mEffects.Count < 0) - { - Debug.Log("this card has no effects!"); - } - this.transform.localScale = Vector3.one; - highlightBorder.SetActive(false); - } - - /* Run all effects */ - public void Apply() - { - - if (mChoice == null) - { - if (Player.Instance.Energy < mCost) - return; - CardEvent<Card>.Trigger(Event.CARD_PLAYED, this); - Effect endEffect = null; - foreach (Effect effect in mEffects) - { - if (effect is StopTurnEffect) - endEffect = effect; - else - effect.Apply(); - } - if (endEffect != null) - endEffect.Apply(); - gameObject.GetComponentInParent<Hand>().Discard(this); - Player.Instance.Energy -= mCost; - } - else - { - mChoice.Select(); - } - this.transform.localScale = Vector3.one; - highlightBorder.SetActive(false); - } - - /* Run all effects for a duplicated card*/ - public void ApplyDuplicated() - { - CardEvent<Card>.Trigger(Event.CARD_PLAYED, this); - foreach (Effect effect in mEffects) - { - effect.Apply(); - } - } - - public void OnCardPlayed(UnityAction onAnimationEnd) - { - mCardUi = GetComponent<CardUi>(); +using System.Collections; +using System.Collections.Generic; +using UnityEngine.EventSystems; +using UnityEngine; +using UnityEngine.Events; + +/* Class for a playable card*/ +public class Card : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler +{ + [SerializeField] + GameObject highlightBorder; + + protected List<Effect> mEffects; + + [SerializeField] + private int mCost; + + public int Cost => mCost; + + public bool Playable => Player.Instance.Energy >= mCost; + + public string Name = ""; + + private DraftChoice mChoice = null; //dirty hack for ui : if you click on the card in ui it will just add it to deck + + + private CardUi mCardUi; + + private int mEffectMultiplicator; + + public List<Effect> GetEffects() + { + if (mEffects == null) + { + Start(); + } + return mEffects; + } + + public void Start() + { + if (mEffects == null) + { + mEffects = new List<Effect>(); + mEffects.AddRange(GetComponents<Effect>()); + } + if (mEffects == null || mEffects.Count < 0) + { + Debug.Log("this card has no effects!"); + } + this.transform.localScale = Vector3.one; + highlightBorder.SetActive(false); + } + + /* Run all effects */ + public void Apply() + { + + if (mChoice == null) + { + mEffectMultiplicator = 1; + if (Player.Instance.Energy < mCost) + return; + CardEvent<Card>.Trigger(Event.CARD_PLAYED, this); + Effect endEffect = null; + for (int i = 0; i < mEffectMultiplicator; i++) + { + foreach (Effect effect in mEffects) + { + if (effect is StopTurnEffect) + endEffect = effect; + else + effect.Apply(); + } + if (endEffect != null) + { + endEffect.Apply(); + break; + } + } + gameObject.GetComponentInParent<Hand>().Discard(this); + Player.Instance.Energy -= mCost; + } + else + { + mChoice.Select(); + } + this.transform.localScale = Vector3.one; + highlightBorder.SetActive(false); + } + + + /* Run all effects for a duplicated card*/ + public void ApplyDuplicated(int amount) + { + if (amount > 0) + mEffectMultiplicator += amount; + } + + public void OnCardPlayed(UnityAction onAnimationEnd) + { + mCardUi = GetComponent<CardUi>(); if (mCardUi != null) { mCardUi.OnCardPlayed(onAnimationEnd); - } - } - - public void SetDraftChoice(DraftChoice choice) - { - mChoice = choice; - } - - - - public void OnPointerExit(PointerEventData eventData) - { - this.transform.localScale = Vector3.one; - highlightBorder.SetActive(false); - } - - public void OnPointerEnter(PointerEventData eventData) - { - this.transform.localScale = Vector3.one * 1.1f; - highlightBorder.SetActive(true); - } - - public void Show() - { - mCardUi = GetComponent<CardUi>(); - if(mCardUi == null) - return; - mCardUi.Show(); - } - - public void Hide() - { - mCardUi = GetComponent<CardUi>(); - if(mCardUi == null) - return; - mCardUi.Hide(); - } -} + } + } + + public void SetDraftChoice(DraftChoice choice) + { + mChoice = choice; + } + + + + public void OnPointerExit(PointerEventData eventData) + { + this.transform.localScale = Vector3.one; + highlightBorder.SetActive(false); + } + + public void OnPointerEnter(PointerEventData eventData) + { + this.transform.localScale = Vector3.one * 1.1f; + highlightBorder.SetActive(true); + } + + public void Show() + { + mCardUi = GetComponent<CardUi>(); + if(mCardUi == null) + return; + mCardUi.Show(); + } + + public void Hide() + { + mCardUi = GetComponent<CardUi>(); + if(mCardUi == null) + return; + mCardUi.Hide(); + } +} diff --git a/Assets/Scripts/Deck/Dump.cs b/Assets/Scripts/Deck/Dump.cs index 350d2492b1eeffb27a633ce35c01620ff7b4a3b8..028f065b4fbe7a549d75dc130e1cfc419de3ab86 100644 --- a/Assets/Scripts/Deck/Dump.cs +++ b/Assets/Scripts/Deck/Dump.cs @@ -36,7 +36,6 @@ public class Dump : MonoBehaviour public void DiscardNoAnim(Card card) { - card.wasDuplicated = false; CardEvent<Card>.Trigger(Event.CARD_DISCARD, card); card.transform.SetParent(transform); card.gameObject.SetActive(false); dumpStack.Push(card);