|
|
@@ -635,7 +635,125 @@ public class Permanent
|
|
|
#endregion
|
|
|
|
|
|
#region Linked Cards
|
|
|
- public int LinkedMax { get; set; } = 1;
|
|
|
+ public int LinkedMax
|
|
|
+ {
|
|
|
+ get
|
|
|
+ {
|
|
|
+ int Max = 1;
|
|
|
+
|
|
|
+ #region Effect of changing the number of sheets to undergo security check
|
|
|
+
|
|
|
+ List<ICardEffect> cardEffects_ChangeLinkedMax = new List<ICardEffect>();
|
|
|
+
|
|
|
+ foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
|
|
|
+ {
|
|
|
+ foreach (Permanent permanent in player.GetFieldPermanents())
|
|
|
+ {
|
|
|
+ #region Effects of permanents in play
|
|
|
+ foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
|
|
|
+ {
|
|
|
+ if (cardEffect is IChangeLinkMaxEffect)
|
|
|
+ {
|
|
|
+ if (((IChangeLinkMaxEffect)cardEffect).PermanentCondition(this))
|
|
|
+ {
|
|
|
+ if (cardEffect.CanUse(null))
|
|
|
+ {
|
|
|
+ if (!TopCard.CanNotBeAffected(cardEffect))
|
|
|
+ {
|
|
|
+ cardEffects_ChangeLinkedMax.Add(cardEffect);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ #endregion
|
|
|
+ }
|
|
|
+
|
|
|
+ #region player effect
|
|
|
+ foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
|
|
|
+ {
|
|
|
+ if (cardEffect is IChangeLinkMaxEffect)
|
|
|
+ {
|
|
|
+ if (((IChangeLinkMaxEffect)cardEffect).PermanentCondition(this))
|
|
|
+ {
|
|
|
+ if (cardEffect.CanUse(null))
|
|
|
+ {
|
|
|
+ if (!TopCard.CanNotBeAffected(cardEffect))
|
|
|
+ {
|
|
|
+ cardEffects_ChangeLinkedMax.Add(cardEffect);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ #endregion
|
|
|
+ }
|
|
|
+
|
|
|
+ List<ICardEffect> cardEffects_ChangeLinkedMax_UpToConstant = new List<ICardEffect>();
|
|
|
+ List<ICardEffect> cardEffects_ChangeLinkedMax_UpDownValue = new List<ICardEffect>();
|
|
|
+ List<ICardEffect> cardEffects_ChangeLinkedMax_DownToConstant = new List<ICardEffect>();
|
|
|
+
|
|
|
+ foreach (ICardEffect cardEffect in cardEffects_ChangeLinkedMax)
|
|
|
+ {
|
|
|
+ if (cardEffect is IChangeLinkMaxEffect)
|
|
|
+ {
|
|
|
+ if (cardEffect.CanUse(null))
|
|
|
+ {
|
|
|
+ switch (((IChangeLinkMaxEffect)cardEffect).isUpDown())
|
|
|
+ {
|
|
|
+ case CalculateOrder.UpToConstant:
|
|
|
+ cardEffects_ChangeLinkedMax_UpToConstant.Add(cardEffect);
|
|
|
+ break;
|
|
|
+
|
|
|
+ case CalculateOrder.UpDownValue:
|
|
|
+ cardEffects_ChangeLinkedMax_UpDownValue.Add(cardEffect);
|
|
|
+ break;
|
|
|
+
|
|
|
+ case CalculateOrder.DownToConstant:
|
|
|
+ cardEffects_ChangeLinkedMax_DownToConstant.Add(cardEffect);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ foreach (ICardEffect cardEffect in cardEffects_ChangeLinkedMax_UpToConstant)
|
|
|
+ {
|
|
|
+ if (cardEffect is IChangeLinkMaxEffect)
|
|
|
+ {
|
|
|
+ if (cardEffect.CanUse(null))
|
|
|
+ {
|
|
|
+ Max = ((IChangeLinkMaxEffect)cardEffect).GetLinkMax(Max, this, InvertSecutiryValue);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ foreach (ICardEffect cardEffect in cardEffects_ChangeLinkedMax_UpDownValue)
|
|
|
+ {
|
|
|
+ if (cardEffect is IChangeLinkMaxEffect)
|
|
|
+ {
|
|
|
+ if (cardEffect.CanUse(null))
|
|
|
+ {
|
|
|
+ Max = ((IChangeLinkMaxEffect)cardEffect).GetLinkMax(Max, this, InvertSecutiryValue);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ foreach (ICardEffect cardEffect in cardEffects_ChangeLinkedMax_DownToConstant)
|
|
|
+ {
|
|
|
+ if (cardEffect is IChangeLinkMaxEffect)
|
|
|
+ {
|
|
|
+ if (cardEffect.CanUse(null))
|
|
|
+ {
|
|
|
+ Max = ((IChangeLinkMaxEffect)cardEffect).GetLinkMax(Max, this, InvertSecutiryValue);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ #endregion
|
|
|
+
|
|
|
+ return Max;
|
|
|
+ }
|
|
|
+ }
|
|
|
public struct LinkCard
|
|
|
{
|
|
|
public LinkCard(int dp, CardSource source)
|
|
|
@@ -820,26 +938,65 @@ public class Permanent
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
- #region Add Card Source
|
|
|
- public IEnumerator AddLinkedCard(CardSource cardSource, int DP, ICardEffect cardEffect)
|
|
|
+ #region Add Link cards
|
|
|
+ /// <summary>
|
|
|
+ /// IEnumerator to add a list of CardSource to a permanents top sources, CAN NOT be used to put a field permanent under must use IPlacePermanentToDigivolutionCards
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="addedLinkCards"></param>
|
|
|
+ /// <param name="cardEffect"></param>
|
|
|
+ /// <param name="skipEffectAndActivateSkill"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ public IEnumerator AddLinkCard(CardSource addedLinkCard, int DP, ICardEffect cardEffect)
|
|
|
{
|
|
|
- yield return null;
|
|
|
+ bool addedCard = false;
|
|
|
|
|
|
- if(LinkedCards.Count >= LinkedMax)
|
|
|
- RemoveLinkedCard(null);
|
|
|
+ bool isFromDigimon = false;
|
|
|
+
|
|
|
+ if (CardEffectCommons.IsExistOnBattleArea(addedLinkCard))
|
|
|
+ {
|
|
|
+ if (addedLinkCard.PermanentOfThisCard().DigivolutionCards.Count >= 1)
|
|
|
+ {
|
|
|
+ isFromDigimon = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Debug.Log($"LINK CARDS: {LinkedCards.Count} >= {LinkedMax}");
|
|
|
+ if (LinkedCards.Count >= LinkedMax)
|
|
|
+ yield return ContinuousController.instance.StartCoroutine(RemoveCardSource(LinkedCards[0].Source));
|
|
|
|
|
|
- yield return ContinuousController.instance.StartCoroutine(CardObjectController.RemoveFromAllArea(cardSource));
|
|
|
+ yield return ContinuousController.instance.StartCoroutine(CardObjectController.RemoveFromAllArea(addedLinkCard));
|
|
|
|
|
|
- if (ShowingPermanentCard != null)
|
|
|
+ if (!this.IsToken && !addedLinkCard.IsToken)
|
|
|
{
|
|
|
- yield return ContinuousController.instance.StartCoroutine(ShowingPermanentCard.ShowAddDigivolutionCardEffect());
|
|
|
+ LinkedCards.Insert(0, new LinkCard(0, addedLinkCard));
|
|
|
+ LinkedDP += DP;
|
|
|
+
|
|
|
+ this.cardSources.Insert(1, addedLinkCard);
|
|
|
+ addedLinkCard.SetFace();
|
|
|
+ addedCard = true;
|
|
|
}
|
|
|
|
|
|
- LinkedCards.Insert(0, new LinkCard(0,cardSource));
|
|
|
- LinkedDP += DP;
|
|
|
+ if (addedCard)
|
|
|
+ {
|
|
|
+ if (ShowingPermanentCard != null)
|
|
|
+ {
|
|
|
+ yield return ContinuousController.instance.StartCoroutine(ShowingPermanentCard.ShowAddDigivolutionCardEffect());
|
|
|
+ }
|
|
|
+
|
|
|
+ #region Add Linked Card
|
|
|
|
|
|
- cardSources.Insert(1, cardSource);
|
|
|
- cardSource.SetFace();
|
|
|
+ #region Hashtable Setting
|
|
|
+ Hashtable hashtable = new Hashtable()
|
|
|
+ {
|
|
|
+ {"Permanent", this},
|
|
|
+ {"CardEffect", cardEffect},
|
|
|
+ {"Card", addedLinkCard},
|
|
|
+ {"isFromDigimon", isFromDigimon},
|
|
|
+ };
|
|
|
+ #endregion
|
|
|
+
|
|
|
+ yield return ContinuousController.instance.StartCoroutine(GManager.instance.autoProcessing.StackSkillInfos(hashtable, EffectTiming.WhenLinked));
|
|
|
+ #endregion
|
|
|
+ }
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
@@ -853,14 +1010,23 @@ public class Permanent
|
|
|
#endregion
|
|
|
|
|
|
#region Remove Linked Card
|
|
|
- public IEnumerator RemoveLinkedCard(ICardEffect cardEffect)
|
|
|
+ public IEnumerator RemoveLinkedCard(CardSource cardSource)
|
|
|
{
|
|
|
- //TODO: Add event call if something was removed
|
|
|
- yield return null;
|
|
|
+ LinkCard linked = LinkedCards.Where(linked => linked.Source == cardSource).FirstOrDefault();
|
|
|
+
|
|
|
+ Debug.Log($"REMOVE LINK CARD: {LinkedCards.Count} >= {linked.Source}");
|
|
|
+ if (linked.Source != null)
|
|
|
+ {
|
|
|
+
|
|
|
+ LinkedDP -= linked.DP;
|
|
|
+ yield return ContinuousController.instance.StartCoroutine(RemoveCardSource(linked.Source));
|
|
|
+ yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddTrashCard(linked.Source));
|
|
|
+ LinkedCards.Remove(linked);
|
|
|
+ Debug.Log($"REMOVE LINK CARD: {linked.Source}");
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
- LinkedDP -= LinkedCards[0].DP;
|
|
|
- RemoveCardSource(LinkedCards[0].Source);
|
|
|
- LinkedCards.RemoveAt(0);
|
|
|
+ //TODO: Add event call if something was removed
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
@@ -1014,6 +1180,7 @@ public class Permanent
|
|
|
{
|
|
|
foreach (CardSource cardSource in cardSources)
|
|
|
{
|
|
|
+
|
|
|
if (cardSource != null)
|
|
|
{
|
|
|
if (!cardSource.IsFlipped)
|
|
|
@@ -1032,7 +1199,7 @@ public class Permanent
|
|
|
{
|
|
|
if (cardEffect != null)
|
|
|
{
|
|
|
- if (isTopCard == cardEffect.IsInheritedEffect)
|
|
|
+ if (isTopCard == cardEffect.IsInheritedEffect && isTopCard == cardEffect.IsLinkedEffect)
|
|
|
{
|
|
|
continue;
|
|
|
}
|