AddJogressConditionClass.cs 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using System;
  5. public class AddJogressConditionClass : ICardEffect, IAddJogressConditionEffect
  6. {
  7. Func<CardSource, JogressCondition> _getJogressCondition { get; set; }
  8. public void SetUpAddJogressConditionClass(Func<CardSource, JogressCondition> getJogressCondition)
  9. {
  10. _getJogressCondition = getJogressCondition;
  11. }
  12. public JogressCondition GetJogressCondition(CardSource cardSource)
  13. {
  14. if (cardSource != null)
  15. {
  16. if (_getJogressCondition != null)
  17. {
  18. JogressCondition jogressCondition = _getJogressCondition(cardSource);
  19. if (jogressCondition != null)
  20. {
  21. if (jogressCondition.elements != null)
  22. {
  23. JogressConditionElement[] newElements = jogressCondition.elements.Map((element) =>
  24. {
  25. bool EvoRootCondition(Permanent permanent)
  26. {
  27. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, cardSource) && (element.EvoRootCondition == null || element.EvoRootCondition(permanent));
  28. }
  29. return new JogressConditionElement(evoRootCondition: EvoRootCondition, selectMessage: element.SelectMessage);
  30. });
  31. return new JogressCondition(newElements, jogressCondition.cost);
  32. }
  33. }
  34. }
  35. }
  36. return null;
  37. }
  38. }