Răsfoiți Sursa

Merge branch 'link-effect' into BT21

mbunch_kascope 1 an în urmă
părinte
comite
a224af85bd

+ 304 - 17
Assets/Prefab/FieldPermanentCard.prefab

@@ -31,7 +31,7 @@ Transform:
   - {fileID: 9035984395792137301}
   - {fileID: 8421186410680037055}
   m_Father: {fileID: 1328592280217377389}
-  m_RootOrder: 10
+  m_RootOrder: 11
   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
 --- !u!1 &294951820492146254
 GameObject:
@@ -64,7 +64,7 @@ Transform:
   - {fileID: 6029157311506101984}
   - {fileID: 8001544085524755595}
   m_Father: {fileID: 1328592280217377389}
-  m_RootOrder: 3
+  m_RootOrder: 4
   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
 --- !u!1 &318510059220149854
 GameObject:
@@ -304,7 +304,7 @@ Transform:
   - {fileID: 525311292421081592}
   - {fileID: 525311292421048760}
   m_Father: {fileID: 1328592280217377389}
-  m_RootOrder: 7
+  m_RootOrder: 8
   m_LocalEulerAnglesHint: {x: 80, y: 0, z: 0}
 --- !u!198 &525311292406949872
 ParticleSystem:
@@ -10074,7 +10074,7 @@ Transform:
   - {fileID: 2104079957368907959}
   - {fileID: 8380388874825695540}
   m_Father: {fileID: 1328592280217377389}
-  m_RootOrder: 12
+  m_RootOrder: 13
   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
 --- !u!1 &649682817835020130
 GameObject:
@@ -12091,7 +12091,7 @@ Transform:
   - {fileID: 5845795113992664770}
   - {fileID: 436240767566597934}
   m_Father: {fileID: 1328592280217377389}
-  m_RootOrder: 11
+  m_RootOrder: 12
   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
 --- !u!1 &2723462147788418096
 GameObject:
@@ -12575,6 +12575,162 @@ MonoBehaviour:
   m_hasFontAssetChanged: 0
   m_baseMaterial: {fileID: 0}
   m_maskOffset: {x: 0, y: 0, z: 0, w: 0}
+--- !u!1 &3231727069676248330
+GameObject:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  serializedVersion: 6
+  m_Component:
+  - component: {fileID: 8166325864803032717}
+  - component: {fileID: 333530339830813888}
+  - component: {fileID: 7358777270401090952}
+  m_Layer: 7
+  m_Name: Background (2)
+  m_TagString: Untagged
+  m_Icon: {fileID: 0}
+  m_NavMeshLayer: 0
+  m_StaticEditorFlags: 0
+  m_IsActive: 1
+--- !u!224 &8166325864803032717
+RectTransform:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 3231727069676248330}
+  m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
+  m_LocalPosition: {x: 0, y: 0, z: 0}
+  m_LocalScale: {x: 1, y: 1, z: 0}
+  m_ConstrainProportionsScale: 0
+  m_Children: []
+  m_Father: {fileID: 2868062790699068669}
+  m_RootOrder: 0
+  m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
+  m_AnchorMin: {x: 0.5, y: 0.5}
+  m_AnchorMax: {x: 0.5, y: 0.5}
+  m_AnchoredPosition: {x: 5.3999643, y: 0}
+  m_SizeDelta: {x: 115, y: 70}
+  m_Pivot: {x: 0.5, y: 0.5}
+--- !u!222 &333530339830813888
+CanvasRenderer:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 3231727069676248330}
+  m_CullTransparentMesh: 1
+--- !u!114 &7358777270401090952
+MonoBehaviour:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 3231727069676248330}
+  m_Enabled: 1
+  m_EditorHideFlags: 0
+  m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
+  m_Name: 
+  m_EditorClassIdentifier: 
+  m_Material: {fileID: 0}
+  m_Color: {r: 1, g: 1, b: 1, a: 1}
+  m_RaycastTarget: 0
+  m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
+  m_Maskable: 1
+  m_OnCullStateChanged:
+    m_PersistentCalls:
+      m_Calls: []
+  m_Sprite: {fileID: 21300000, guid: 1fe2ecbfa2b40d247adc420a46b6db20, type: 3}
+  m_Type: 1
+  m_PreserveAspect: 0
+  m_FillCenter: 1
+  m_FillMethod: 4
+  m_FillAmount: 1
+  m_FillClockwise: 1
+  m_FillOrigin: 0
+  m_UseSpriteMesh: 0
+  m_PixelsPerUnitMultiplier: 1
+--- !u!1 &3236524786908065594
+GameObject:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  serializedVersion: 6
+  m_Component:
+  - component: {fileID: 1856671696117204050}
+  - component: {fileID: 8111727156833061576}
+  - component: {fileID: 3015209766018844723}
+  m_Layer: 7
+  m_Name: LinkedDPText
+  m_TagString: Untagged
+  m_Icon: {fileID: 0}
+  m_NavMeshLayer: 0
+  m_StaticEditorFlags: 0
+  m_IsActive: 1
+--- !u!224 &1856671696117204050
+RectTransform:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 3236524786908065594}
+  m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
+  m_LocalPosition: {x: 0, y: 0, z: 0}
+  m_LocalScale: {x: 0.15, y: 0.15, z: 0}
+  m_ConstrainProportionsScale: 1
+  m_Children: []
+  m_Father: {fileID: 7887069501642103711}
+  m_RootOrder: 1
+  m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
+  m_AnchorMin: {x: 0, y: 0.5}
+  m_AnchorMax: {x: 0, y: 0.5}
+  m_AnchoredPosition: {x: 25.34, y: 0}
+  m_SizeDelta: {x: 160, y: 30}
+  m_Pivot: {x: 0.5, y: 0.5}
+--- !u!222 &8111727156833061576
+CanvasRenderer:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 3236524786908065594}
+  m_CullTransparentMesh: 1
+--- !u!114 &3015209766018844723
+MonoBehaviour:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 3236524786908065594}
+  m_Enabled: 1
+  m_EditorHideFlags: 0
+  m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3}
+  m_Name: 
+  m_EditorClassIdentifier: 
+  m_Material: {fileID: 0}
+  m_Color: {r: 1, g: 1, b: 1, a: 1}
+  m_RaycastTarget: 0
+  m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
+  m_Maskable: 1
+  m_OnCullStateChanged:
+    m_PersistentCalls:
+      m_Calls: []
+  m_FontData:
+    m_Font: {fileID: 12800000, guid: 385dce3fc9f7d434cb640e4d4d497263, type: 3}
+    m_FontSize: 150
+    m_FontStyle: 0
+    m_BestFit: 0
+    m_MinSize: 1
+    m_MaxSize: 300
+    m_Alignment: 3
+    m_AlignByGeometry: 0
+    m_RichText: 1
+    m_HorizontalOverflow: 1
+    m_VerticalOverflow: 1
+    m_LineSpacing: 1
+  m_Text: +2000
 --- !u!1 &3332119274403731063
 GameObject:
   m_ObjectHideFlags: 0
@@ -12759,6 +12915,97 @@ MonoBehaviour:
   m_EffectColor: {r: 0, g: 0, b: 0, a: 1}
   m_EffectDistance: {x: 2, y: 2}
   m_UseGraphicAlpha: 1
+--- !u!1 &3397349939581615624
+GameObject:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  serializedVersion: 6
+  m_Component:
+  - component: {fileID: 2868062790699068669}
+  - component: {fileID: 1379283346185656141}
+  - component: {fileID: 7248865144782854746}
+  - component: {fileID: 7979608387060210459}
+  m_Layer: 7
+  m_Name: Mask
+  m_TagString: Untagged
+  m_Icon: {fileID: 0}
+  m_NavMeshLayer: 0
+  m_StaticEditorFlags: 0
+  m_IsActive: 1
+--- !u!224 &2868062790699068669
+RectTransform:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 3397349939581615624}
+  m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
+  m_LocalPosition: {x: 0, y: 0, z: 0}
+  m_LocalScale: {x: 1, y: 1, z: 1}
+  m_ConstrainProportionsScale: 0
+  m_Children:
+  - {fileID: 8166325864803032717}
+  m_Father: {fileID: 7887069501642103711}
+  m_RootOrder: 0
+  m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
+  m_AnchorMin: {x: 0.5, y: 0.5}
+  m_AnchorMax: {x: 0.5, y: 0.5}
+  m_AnchoredPosition: {x: -5.4, y: 0}
+  m_SizeDelta: {x: 70, y: 70}
+  m_Pivot: {x: 0.5, y: 0.5}
+--- !u!114 &1379283346185656141
+MonoBehaviour:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 3397349939581615624}
+  m_Enabled: 1
+  m_EditorHideFlags: 0
+  m_Script: {fileID: 11500000, guid: 31a19414c41e5ae4aae2af33fee712f6, type: 3}
+  m_Name: 
+  m_EditorClassIdentifier: 
+  m_ShowMaskGraphic: 0
+--- !u!222 &7248865144782854746
+CanvasRenderer:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 3397349939581615624}
+  m_CullTransparentMesh: 1
+--- !u!114 &7979608387060210459
+MonoBehaviour:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 3397349939581615624}
+  m_Enabled: 1
+  m_EditorHideFlags: 0
+  m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
+  m_Name: 
+  m_EditorClassIdentifier: 
+  m_Material: {fileID: 0}
+  m_Color: {r: 1, g: 1, b: 1, a: 1}
+  m_RaycastTarget: 0
+  m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
+  m_Maskable: 1
+  m_OnCullStateChanged:
+    m_PersistentCalls:
+      m_Calls: []
+  m_Sprite: {fileID: 21300000, guid: 7946dbf02469e4c4bbb5b5e81ed5f2cd, type: 3}
+  m_Type: 0
+  m_PreserveAspect: 0
+  m_FillCenter: 1
+  m_FillMethod: 4
+  m_FillAmount: 1
+  m_FillClockwise: 1
+  m_FillOrigin: 0
+  m_UseSpriteMesh: 0
+  m_PixelsPerUnitMultiplier: 1
 --- !u!1 &3447094193646696824
 GameObject:
   m_ObjectHideFlags: 0
@@ -12947,7 +13194,7 @@ RectTransform:
   m_Children:
   - {fileID: 4217996184327941701}
   m_Father: {fileID: 1328592280217377389}
-  m_RootOrder: 9
+  m_RootOrder: 10
   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
   m_AnchorMin: {x: 0.5, y: 0.5}
   m_AnchorMax: {x: 0.5, y: 0.5}
@@ -13024,7 +13271,7 @@ RectTransform:
   m_ConstrainProportionsScale: 0
   m_Children: []
   m_Father: {fileID: 1328592280217377389}
-  m_RootOrder: 1
+  m_RootOrder: 2
   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
   m_AnchorMin: {x: 0.5, y: 0.5}
   m_AnchorMax: {x: 0.5, y: 0.5}
@@ -13267,7 +13514,7 @@ RectTransform:
   - {fileID: 8759670045046311849}
   - {fileID: 1174407048966754959}
   m_Father: {fileID: 1328592280217377389}
-  m_RootOrder: 5
+  m_RootOrder: 6
   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
   m_AnchorMin: {x: 0.5, y: 0.5}
   m_AnchorMax: {x: 0.5, y: 0.5}
@@ -14168,7 +14415,7 @@ RectTransform:
   - {fileID: 1335304837681312691}
   - {fileID: 2552041397315195806}
   m_Father: {fileID: 1328592280217377389}
-  m_RootOrder: 14
+  m_RootOrder: 15
   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
   m_AnchorMin: {x: 0.5, y: 0.5}
   m_AnchorMax: {x: 0.5, y: 0.5}
@@ -14235,7 +14482,7 @@ RectTransform:
   m_ConstrainProportionsScale: 0
   m_Children: []
   m_Father: {fileID: 1328592280217377389}
-  m_RootOrder: 2
+  m_RootOrder: 3
   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
   m_AnchorMin: {x: 0.5, y: 0.5}
   m_AnchorMax: {x: 0.5, y: 0.5}
@@ -15164,7 +15411,7 @@ RectTransform:
   m_Children:
   - {fileID: 7836597674142952899}
   m_Father: {fileID: 1328592280217377389}
-  m_RootOrder: 8
+  m_RootOrder: 9
   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
   m_AnchorMin: {x: 0.5, y: 0.5}
   m_AnchorMax: {x: 0.5, y: 0.5}
@@ -15261,6 +15508,7 @@ Transform:
   m_ConstrainProportionsScale: 0
   m_Children:
   - {fileID: 3830428523626426344}
+  - {fileID: 7887069501642103711}
   - {fileID: 2943868691849599935}
   - {fileID: 5372350319648457834}
   - {fileID: 393804494211063232}
@@ -15393,7 +15641,7 @@ RectTransform:
   - {fileID: 1859101999064975573}
   - {fileID: 2472837928933644935}
   m_Father: {fileID: 1328592280217377389}
-  m_RootOrder: 16
+  m_RootOrder: 17
   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
   m_AnchorMin: {x: 0.5, y: 0.5}
   m_AnchorMax: {x: 0.5, y: 0.5}
@@ -16083,7 +16331,7 @@ RectTransform:
   m_ConstrainProportionsScale: 0
   m_Children: []
   m_Father: {fileID: 1328592280217377389}
-  m_RootOrder: 15
+  m_RootOrder: 16
   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
   m_AnchorMin: {x: 0.5, y: 0.5}
   m_AnchorMax: {x: 0.5, y: 0.5}
@@ -16182,7 +16430,7 @@ RectTransform:
   - {fileID: 2655681794709095092}
   - {fileID: 164726633318854078}
   m_Father: {fileID: 1328592280217377389}
-  m_RootOrder: 6
+  m_RootOrder: 7
   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
   m_AnchorMin: {x: 0.5, y: 0.5}
   m_AnchorMax: {x: 0.5, y: 0.5}
@@ -16632,6 +16880,44 @@ MonoBehaviour:
   m_FillOrigin: 0
   m_UseSpriteMesh: 0
   m_PixelsPerUnitMultiplier: 1
+--- !u!1 &7307836182358109457
+GameObject:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  serializedVersion: 6
+  m_Component:
+  - component: {fileID: 7887069501642103711}
+  m_Layer: 7
+  m_Name: LinkedRoot
+  m_TagString: Untagged
+  m_Icon: {fileID: 0}
+  m_NavMeshLayer: 0
+  m_StaticEditorFlags: 0
+  m_IsActive: 1
+--- !u!224 &7887069501642103711
+RectTransform:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 7307836182358109457}
+  m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
+  m_LocalPosition: {x: 0, y: 0, z: 0}
+  m_LocalScale: {x: 0.7, y: 0.7, z: 0}
+  m_ConstrainProportionsScale: 0
+  m_Children:
+  - {fileID: 2868062790699068669}
+  - {fileID: 1856671696117204050}
+  m_Father: {fileID: 1328592280217377389}
+  m_RootOrder: 1
+  m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
+  m_AnchorMin: {x: 0.5, y: 0.5}
+  m_AnchorMax: {x: 0.5, y: 0.5}
+  m_AnchoredPosition: {x: 86.8, y: 56.8}
+  m_SizeDelta: {x: 100, y: 100}
+  m_Pivot: {x: 0.5, y: 0.5}
 --- !u!1 &7419170817971568005
 GameObject:
   m_ObjectHideFlags: 0
@@ -17490,7 +17776,7 @@ RectTransform:
   - {fileID: 8849154406048527291}
   - {fileID: 6423607905640078997}
   m_Father: {fileID: 1328592280217377389}
-  m_RootOrder: 4
+  m_RootOrder: 5
   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
   m_AnchorMin: {x: 0.5, y: 0.5}
   m_AnchorMax: {x: 0.5, y: 0.5}
@@ -17953,6 +18239,7 @@ MonoBehaviour:
   EvoRootCountText: {fileID: 4661699799995034945}
   EvoRootCountBackground: {fileID: 1712106131061476983}
   LevelText: {fileID: 5413509685045449317}
+  LinkedDPText: {fileID: 3015209766018844723}
   Parent: {fileID: 5460087358433802513}
   UsingSkillEffect: {fileID: 525311292421340442}
   addDigivolutionCardsEffect: {fileID: 875370635274675907}
@@ -18015,7 +18302,7 @@ RectTransform:
   - {fileID: 1749102974648084778}
   - {fileID: 5606136466184280358}
   m_Father: {fileID: 1328592280217377389}
-  m_RootOrder: 13
+  m_RootOrder: 14
   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
   m_AnchorMin: {x: 0.5, y: 0.5}
   m_AnchorMax: {x: 0.5, y: 0.5}
@@ -19143,7 +19430,7 @@ PrefabInstance:
       objectReference: {fileID: 0}
     - target: {fileID: 4872483841916080, guid: 189038a8fc10a2946b97658479b710ff, type: 3}
       propertyPath: m_RootOrder
-      value: 17
+      value: 18
       objectReference: {fileID: 0}
     - target: {fileID: 4872483841916080, guid: 189038a8fc10a2946b97658479b710ff, type: 3}
       propertyPath: m_LocalScale.x

+ 99 - 262
Assets/Scripts/CardController.cs

@@ -2524,268 +2524,6 @@ public class IPlacePermanentToDigivolutionCards
 }
 #endregion
 
-#region Link permanent to another permanent
-public class ILinkPermanentToPermanent
-{
-    public ILinkPermanentToPermanent(
-        List<Permanent[]> permanentArrays,
-        ICardEffect cardEffect)
-    {
-        permanentArrays.Clone().ForEach(permanentArray => _permanentArrays.Add(permanentArray.CloneArray()));
-        _cardEffect = cardEffect;
-    }
-
-    public void SetNotShowCards()
-    {
-        _notShowCards = true;
-    }
-
-    List<Permanent[]> _permanentArrays = new List<Permanent[]>();
-    ICardEffect _cardEffect = null;
-    bool _notShowCards = false;
-    public bool Linked { get; private set; } = false;
-    public IEnumerator LinkPermanent()
-    {
-        if (_permanentArrays.Count != 2)
-        {
-            yield break;
-        }
-
-        List<CardSource> addedLinkCards = new List<CardSource>();
-
-        List<Permanent> removeFieldPermanents = new List<Permanent>();
-
-        foreach (Permanent[] permanentArray in _permanentArrays)
-        {
-            Permanent LinkPermanent = permanentArray[0];
-            Permanent LinkedPermanent = permanentArray[1];
-
-            if (LinkPermanent != null && LinkedPermanent != null)
-            {
-                if (LinkPermanent.TopCard != null && LinkedPermanent.TopCard != null && !LinkedPermanent.IsToken)
-                {
-                    if (_cardEffect != null)
-                    {
-                        if (LinkPermanent.TopCard.CanNotBeAffected(_cardEffect) || LinkedPermanent.TopCard.CanNotBeAffected(_cardEffect))
-                        {
-                            continue;
-                        }
-                    }
-
-                    removeFieldPermanents.Add(LinkPermanent);
-                }
-            }
-        }
-
-        foreach (Permanent permanent in removeFieldPermanents)
-        {
-            permanent.willBeRemoveField = true;
-        }
-
-        if (removeFieldPermanents.Count == 0)
-        {
-            yield break;
-        }
-
-        #region When permanent would remove effect
-        List<SkillInfo> skillInfos = new List<SkillInfo>();
-
-        Hashtable hashtable1 =
-        CardEffectCommons.WhenPermanentWouldRemoveFieldCheckHashtable(
-                removeFieldPermanents,
-                _cardEffect,
-                null);
-
-        #region  "When permanents would remove field" effect
-
-        foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
-        {
-            #region permanents' effects
-            foreach (Permanent permanent1 in player.GetFieldPermanents())
-            {
-                foreach (ICardEffect cardEffect in permanent1.EffectList(EffectTiming.WhenRemoveField))
-                {
-                    if (cardEffect is ActivateICardEffect)
-                    {
-                        if (cardEffect.CanTrigger(hashtable1))
-                        {
-                            skillInfos.Add(new SkillInfo(cardEffect, hashtable1, EffectTiming.WhenRemoveField));
-                        }
-                    }
-                }
-            }
-            #endregion
-
-            #region players' effects
-            foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.WhenRemoveField))
-            {
-                if (cardEffect is ActivateICardEffect)
-                {
-                    if (cardEffect.CanTrigger(hashtable1))
-                    {
-                        skillInfos.Add(new SkillInfo(cardEffect, hashtable1, EffectTiming.WhenRemoveField));
-                    }
-                }
-            }
-            #endregion
-        }
-        #endregion
-
-        if (skillInfos.Count >= 1)
-        {
-            foreach (SkillInfo skillInfo in skillInfos)
-            {
-                GManager.instance.autoProcessing_CutIn.PutStackedSkill(skillInfo);
-            }
-
-            bool showEffect()
-            {
-                if (skillInfos.Count >= 2)
-                {
-                    return true;
-                }
-
-                else if (skillInfos.Count == 1)
-                {
-                    if (skillInfos[0].CardEffect.CanActivate(skillInfos[0].Hashtable))
-                    {
-                        return true;
-                    }
-                }
-
-                return false;
-            }
-
-            if (showEffect())
-            {
-                foreach (Permanent Permanent in removeFieldPermanents)
-                {
-                    if (Permanent != null)
-                    {
-                        if (Permanent.TopCard != null)
-                        {
-                            if (Permanent.willBeRemoveField)
-                            {
-                                if (Permanent.ShowingPermanentCard != null)
-                                {
-                                    if (Permanent.ShowingPermanentCard.WillRemoveFieldObject != null)
-                                    {
-                                        Permanent.ShowingPermanentCard.WillRemoveFieldObject.transform.parent.gameObject.SetActive(true);
-                                        Permanent.ShowingPermanentCard.WillRemoveFieldObject.SetActive(true);
-                                    }
-                                }
-                            }
-                        }
-                    }
-                }
-
-                #region shrink security Digimon display
-                if (GManager.instance.attackProcess.IsAttacking)
-                {
-                    if (GManager.instance.attackProcess.SecurityDigimon != null)
-                    {
-                        if (GManager.instance.GetComponent<Effects>().ShowUseHandCard.gameObject.activeSelf && GManager.instance.GetComponent<Effects>().ShowUseHandCard.cardSource == GManager.instance.attackProcess.SecurityDigimon)
-                        {
-                            yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().MoveToExecuteCardEffect(GManager.instance.attackProcess.SecurityDigimon));
-                            yield return ContinuousController.instance.StartCoroutine(GManager.instance.attackProcess.SecurityDigimon.Owner.brainStormObject.BrainStormCoroutine(GManager.instance.attackProcess.SecurityDigimon));
-                        }
-                    }
-                }
-                #endregion
-            }
-
-            // cut in effect process
-            yield return ContinuousController.instance.StartCoroutine(GManager.instance.autoProcessing_CutIn.TriggeredSkillProcess(false, null));
-
-            foreach (Permanent Permanent in removeFieldPermanents)
-            {
-                if (Permanent != null)
-                {
-                    if (Permanent.TopCard != null)
-                    {
-                        if (Permanent.ShowingPermanentCard != null)
-                        {
-                            if (Permanent.ShowingPermanentCard.WillRemoveFieldObject != null)
-                            {
-                                Permanent.ShowingPermanentCard.WillRemoveFieldObject.SetActive(false);
-                            }
-                        }
-                    }
-                }
-            }
-        }
-        #endregion
-
-        foreach (Permanent[] permanentArray in _permanentArrays)
-        {
-            Permanent LinkPermanent = permanentArray[0];
-            Permanent LinkedPermanent = permanentArray[1];
-
-            if (LinkPermanent != null && LinkedPermanent != null)
-            {
-                if (LinkPermanent.TopCard != null && LinkedPermanent.TopCard != null && !LinkedPermanent.IsToken && LinkPermanent.willBeRemoveField)
-                {
-                    yield return ContinuousController.instance.StartCoroutine(LinkPermanent.DiscardEvoRoots());
-
-                    CardSource cardSource = LinkPermanent.TopCard;
-
-                    #region record used effect
-                    if (_cardEffect != null)
-                    {
-                        if (LinkPermanent.TopCard != null)
-                        {
-                            LinkPermanent.PlaceOtherPermanentEffect = _cardEffect;
-                        }
-                    }
-                    #endregion
-
-                    yield return ContinuousController.instance.StartCoroutine(CardObjectController.RemoveField(
-                        LinkPermanent,
-                        ignoreOverflow: true));
-
-                    yield return ContinuousController.instance.StartCoroutine(LinkedPermanent.AddLinkedCard(cardSource, _cardEffect));
-
-                    cardSource.cEntity_EffectController.InitUseCountThisTurn();
-
-                    addedLinkCards.Add(cardSource);
-
-                    Linked = true;
-                }
-            }
-        }
-
-        #region add log
-        if (addedLinkCards.Count >= 1)
-        {
-            string log = "";
-
-            log += $"Link:";
-
-            foreach (CardSource cardSource in addedLinkCards)
-            {
-                log += $"\n{cardSource.BaseENGCardNameFromEntity}({cardSource.CardID})";
-            }
-
-            log += "\n";
-
-            PlayLog.OnAddLog?.Invoke(log);
-        }
-        #endregion
-
-        #region hide icon
-        if (addedLinkCards.Count >= 1)
-        {
-            if (!_notShowCards)
-            {
-                yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().ShowCardEffect(addedLinkCards, "Link Cards", true, true));
-            }
-        }
-
-        #endregion
-    }
-}
-#endregion
-
 #region Place permanents to security
 
 public class IPutSecurityPermanent
@@ -4172,6 +3910,105 @@ public class ITrashDigivolutionCards
 }
 #endregion
 
+#region Trash link cards
+public class ITrashLinkCards
+{
+    public ITrashLinkCards(Permanent permanent, List<CardSource> trashTargetCards, ICardEffect cardEffect)
+    {
+        _permanent = permanent;
+
+        _trashTargetCards = trashTargetCards.Clone();
+
+        _cardEffect = cardEffect;
+    }
+
+    Permanent _permanent = null;
+    List<CardSource> _trashTargetCards = new List<CardSource>();
+    ICardEffect _cardEffect = null;
+
+    public IEnumerator TrashLinkCards()
+    {
+        if (_trashTargetCards == null) yield break;
+        if (_cardEffect == null) yield break;
+        if (_permanent == null) yield break;
+        if (_permanent.TopCard == null) yield break;
+        if (_permanent.TopCard.CanNotBeAffected(_cardEffect)) yield break;
+        if (_permanent.HasNoDigivolutionCards) yield break;
+
+        _trashTargetCards = _trashTargetCards.Filter((cardSource) =>
+            _permanent.DigivolutionCards.Contains(cardSource) &&
+            !cardSource.CanNotTrashFromDigivolutionCards(_cardEffect));
+
+        if (_trashTargetCards.Count == 0) yield break;
+
+        _trashTargetCards.ForEach(source => source.willBeRemoveSources = true);
+
+        string message = "Discarded card" + Utils.PluralFormSuffix(_trashTargetCards.Count);
+        yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().ShowCardEffect(_trashTargetCards, message, true, true));
+
+        yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().CreateDebuffEffect(_permanent));
+
+        #region cut in effect - Would discard
+
+        // "When link cards would be trashed" effect
+        //TODO: Create CardEffectCommons.WhenLinkCardWouldDiscard function
+        /*yield return ContinuousController.instance.StartCoroutine(GManager.instance.autoProcessing_CutIn.StackSkillInfos(
+            CardEffectCommons.WhenDigivolutionCardWouldDiscardedCheckHashtable(
+                _permanent,
+                _trashTargetCards,
+                _cardEffect
+            ),
+            EffectTiming.WhenWouldDigivolutionCardDiscarded));*/
+
+        if (GManager.instance.autoProcessing_CutIn.HasAwaitingActivateEffects())
+        {
+            // effect
+            yield return ContinuousController.instance.StartCoroutine(GManager.instance.autoProcessing_CutIn.ShrinkSecurityDigimonDisplay());
+
+            // cut in effect process
+            yield return ContinuousController.instance.StartCoroutine(GManager.instance.autoProcessing_CutIn.TriggeredSkillProcess(false, AutoProcessing.HasExecutedSameEffect));
+        }
+        #endregion
+
+        //fix trash target permanent
+        Permanent permanentTarget_Fixed = _permanent;
+
+        // fix trash sources sources
+        List<CardSource> trashLinkCards_Fixed = _trashTargetCards.Filter(cardsource =>
+            cardsource != null
+            && cardsource.willBeRemoveSources);
+
+        #region "When link cards are trashed" effect
+
+        #region Hashtable Setting
+        Hashtable hashtable = new Hashtable()
+            {
+                {"CardEffect", _cardEffect},
+                {"Permanent", permanentTarget_Fixed},
+                {"DiscardedCards", trashLinkCards_Fixed},
+            };
+        #endregion
+        //TODO: Create OnLinkCardDiscarded timing
+        //yield return ContinuousController.instance.StartCoroutine(GManager.instance.autoProcessing.StackSkillInfos(hashtable, EffectTiming.OnDigivolutionCardDiscarded));
+        #endregion
+
+        yield return ContinuousController.instance.StartCoroutine(new AceOverflowClass(_trashTargetCards).Overflow());
+
+        foreach (CardSource cardSource in trashLinkCards_Fixed)
+        {
+            yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().RemoveDigivolveRootEffect(cardSource, permanentTarget_Fixed));
+
+            if (!cardSource.IsToken)
+            {
+                yield return ContinuousController.instance.StartCoroutine(permanentTarget_Fixed.RemoveLinkedCard(cardSource));
+            }
+
+            cardSource.willBeRemoveSources = false;
+        }
+    }
+}
+#endregion
+
 #region Return digivolution cards to deck bottom
 public class ReturnToLibraryBottomDigivolutionCardsClass
 {

+ 80 - 0
Assets/Scripts/CardEffectCommons/CanUseEffects/WhenLinked.cs

@@ -0,0 +1,80 @@
+using System.Collections;
+using System.Collections.Generic;
+using System;
+using System.Linq;
+using UnityEngine;
+
+public partial class CardEffectCommons
+{
+    #region Can trigger "When card is linked" effect
+    public static bool CanTriggerWhenLinking(Hashtable hashtable, Func<Permanent, bool> permanentCondition, CardSource card)
+    {
+        if (hashtable != null)
+        {
+            Permanent Permanent = GetPermanentFromHashtable(hashtable);
+
+            if (Permanent != null)
+            {
+                if (Permanent.TopCard != null)
+                {
+                    if (permanentCondition == null || permanentCondition(Permanent))
+                    {
+                        ICardEffect CardEffect = GetCardEffectFromHashtable(hashtable);
+
+                        if (CardEffect != null)
+                        {
+                            CardSource cardSource = GetCardFromHashtable(hashtable);
+
+                            if (cardSource != null)
+                            {
+                                if (cardSource == card)
+                                {
+                                    return true;
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+        }
+
+        return false;
+    }
+    #endregion
+
+    #region Can trigger "When a card gets linked" effect
+    public static bool CanTriggerWhenLinked(Hashtable hashtable, Func<Permanent, bool> permanentCondition, Func<CardSource, bool> sourcecCondition)
+    {
+        if (hashtable != null)
+        {
+            Permanent Permanent = GetPermanentFromHashtable(hashtable);
+
+            if (Permanent != null)
+            {
+                if (Permanent.TopCard != null)
+                {
+                    if (permanentCondition == null || permanentCondition(Permanent))
+                    {
+                        ICardEffect CardEffect = GetCardEffectFromHashtable(hashtable);
+
+                        if (CardEffect != null)
+                        {
+                            CardSource cardSource = GetCardFromHashtable(hashtable);
+
+                            if (cardSource != null)
+                            {
+                                if (sourcecCondition == null || sourcecCondition(cardSource))
+                                {
+                                    return true;
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+        }
+
+        return false;
+    }
+    #endregion
+}

+ 11 - 0
Assets/Scripts/CardEffectCommons/CanUseEffects/WhenLinked.cs.meta

@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: d0b9f21dcd5c5254c8d3fadfc6627f65
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 10 - 0
Assets/Scripts/CardEffectCommons/GameContextDeterminarion.cs

@@ -96,6 +96,16 @@ public partial class CardEffectCommons
     }
     #endregion
 
+    #region Whether the card is Linked
+    public static bool IsExistLinked(CardSource card)
+    {
+        if (IsExistOnField(card))
+            return card.PermanentOfThisCard().LinkedCards.Any(source => source.Source == card);
+
+        return false;
+    }
+    #endregion
+
     #region Whether the card is in trash
     public static bool IsExistOnTrash(CardSource card)
     {

+ 121 - 0
Assets/Scripts/CardEffectCommons/GiveEffect/GiveEffectToPermanent/ChangeLinkMax.cs

@@ -0,0 +1,121 @@
+using System.Collections;
+using System.Collections.Generic;
+using System;
+using System.Linq;
+using UnityEngine;
+
+public partial class CardEffectCommons
+{
+    #region Change target 1 Digimon's Link Max
+    public static IEnumerator ChangeDigimonLinkMax(Permanent targetPermanent, int changeValue, EffectDuration effectDuration, ICardEffect activateClass)
+    {
+        if (targetPermanent == null) yield break;
+        if (!IsPermanentExistsOnBattleArea(targetPermanent)) yield break;
+        if (changeValue == 0) yield break;
+        if (activateClass == null) yield break;
+        if (activateClass.EffectSourceCard == null) yield break;
+
+        CardSource card = activateClass.EffectSourceCard;
+        bool isUpValue = changeValue > 0;
+
+        bool CanUseCondition()
+        {
+            if (IsPermanentExistsOnBattleArea(targetPermanent))
+            {
+                if (!targetPermanent.TopCard.CanNotBeAffected(activateClass))
+                {
+                    return true;
+                }
+            }
+
+            return false;
+        }
+
+        ChangeLinkMaxClass changeLinkMaxClass = CardEffectFactory.ChangeTargetLinkMaxStaticEffect(
+                    targetPermanent: targetPermanent,
+                    changeValue: changeValue,
+                    isInheritedEffect: false,
+                    card: card,
+                    condition: CanUseCondition);
+
+        AddEffectToPermanent(
+            targetPermanent: targetPermanent,
+            effectDuration: effectDuration,
+            card: card,
+            cardEffect: changeLinkMaxClass,
+            timing: EffectTiming.None);
+
+        if (!targetPermanent.TopCard.CanNotBeAffected(activateClass))
+        {
+            if (isUpValue)
+            {
+                yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().CreateBuffEffect(targetPermanent));
+            }
+
+            else
+            {
+                yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().CreateDebuffEffect(targetPermanent));
+            }
+        }
+    }
+
+    public static IEnumerator ChangeDigimonLinkMax(Permanent targetPermanent, int changeValue, EffectDuration effectDuration, ICardEffect activateClass, bool activateAnimation, string hashstring = null)
+    {
+        if (targetPermanent == null) yield break;
+        if (!IsPermanentExistsOnBattleArea(targetPermanent)) yield break;
+        if (changeValue == 0) yield break;
+        if (activateClass == null) yield break;
+        if (activateClass.EffectSourceCard == null) yield break;
+
+        CardSource card = activateClass.EffectSourceCard;
+        bool isUpValue = changeValue > 0;
+
+        bool CanUseCondition()
+        {
+            if (IsPermanentExistsOnBattleArea(targetPermanent))
+            {
+                if (!targetPermanent.TopCard.CanNotBeAffected(activateClass))
+                {
+                    return true;
+                }
+            }
+
+            return false;
+        }
+
+        ChangeLinkMaxClass changeLinkMaxClass = CardEffectFactory.ChangeTargetLinkMaxStaticEffect(
+                    targetPermanent: targetPermanent,
+                    changeValue: changeValue,
+                    isInheritedEffect: false,
+                    card: card,
+                    condition: CanUseCondition,
+                    hashstring: hashstring);
+
+        AddEffectToPermanent(
+            targetPermanent: targetPermanent,
+            effectDuration: effectDuration,
+            card: card,
+            cardEffect: changeLinkMaxClass,
+            timing: EffectTiming.None);
+
+        if (!targetPermanent.TopCard.CanNotBeAffected(activateClass))
+        {
+            if (isUpValue)
+            {
+                if (activateAnimation)
+                {
+                    yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().CreateBuffEffect(targetPermanent));
+                }
+            }
+
+            else
+            {
+                if (activateAnimation)
+                {
+                    yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().CreateDebuffEffect(targetPermanent));
+                }
+            }
+        }
+    }
+    #endregion
+}

+ 11 - 0
Assets/Scripts/CardEffectCommons/GiveEffect/GiveEffectToPermanent/ChangeLinkMax.cs.meta

@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: f76ee890acdfe124db988841089049b6
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 183 - 0
Assets/Scripts/CardEffectCommons/TrashLinkedCards.cs

@@ -0,0 +1,183 @@
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+using System.Linq;
+using Photon;
+using System;
+using Photon.Pun;
+
+public partial class CardEffectCommons
+{
+    public static IEnumerator SelectTrashLinkedCards(Func<Permanent, bool> permanentCondition, Func<CardSource, bool> cardCondition, int maxCount, bool canNoTrash, bool isFromOnly1Permanent, ICardEffect activateClass, string selectString = "Digimon", Func<Permanent, List<CardSource>, IEnumerator> afterSelectionCoroutine = null)
+    {
+        if (maxCount <= 0) yield break;
+        if (activateClass == null) yield break;
+        CardSource card = activateClass.EffectSourceCard;
+        if (card == null) yield break;
+
+        bool CanSelectPermanentCondition(Permanent permanent)
+        {
+            if (IsPermanentExistsOnBattleArea(permanent))
+            {
+                if (permanentCondition == null || permanentCondition(permanent))
+                {
+                    if (!permanent.TopCard.CanNotBeAffected(activateClass))
+                    {
+                        return true;
+                    }
+                }
+            }
+
+            return false;
+        }
+
+        bool CanSelectCardCondition(CardSource cardSource)
+        {
+            if (cardCondition == null || cardCondition(cardSource))
+            {
+                return true;
+            }
+
+            return false;
+        }
+
+        int permanentSum =
+            GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer
+                .Map(player => player.GetBattleAreaPermanents().Filter(CanSelectPermanentCondition))
+                .Flat().Count();
+
+        int linkedCardsSum =
+                GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer
+                .Map(player => player.GetBattleAreaPermanents().Filter(CanSelectPermanentCondition))
+                .Flat()
+                .Map(permanent => permanent.LinkedCards.Map(link => link.Source).Count(CanSelectCardCondition))
+                .Sum();
+
+        int maxLinkDiscardCount = Math.Min(linkedCardsSum, maxCount);
+        int linkDiscardedCount = 0;
+
+        void EndSelection() => linkDiscardedCount = linkedCardsSum;
+        bool NotSelectYet() => linkDiscardedCount == 0;
+
+        int permanentSelectedCount = 0;
+
+        while (true)
+        {
+            if (isFromOnly1Permanent)
+            {
+                if (permanentSelectedCount >= 1)
+                {
+                    break;
+                }
+            }
+
+            if (linkDiscardedCount >= maxLinkDiscardCount)
+            {
+                break;
+            }
+
+            if (permanentSum < 1)
+            {
+                break;
+            }
+            else
+            {
+                permanentSelectedCount++;
+                maxCount = Math.Min(1, permanentSum);
+
+                SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
+
+                selectPermanentEffect.SetUp(
+                    selectPlayer: card.Owner,
+                    canTargetCondition: CanSelectPermanentCondition,
+                    canTargetCondition_ByPreSelecetedList: null,
+                    canEndSelectCondition: null,
+                    maxCount: maxCount,
+                    canNoSelect: canNoTrash && NotSelectYet(),
+                    canEndNotMax: false,
+                    selectPermanentCoroutine: SelectPermanentCoroutine,
+                    afterSelectPermanentCoroutine: AfterSelectPermanentCoroutine,
+                    mode: SelectPermanentEffect.Mode.Custom,
+                    cardEffect: activateClass);
+
+                selectPermanentEffect.SetUpCustomMessage($"Select 1 {selectString} that will trash digivolution cards.", $"The opponent is selecting 1 {selectString} that will trash digivolution cards.");
+
+                yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
+
+                IEnumerator SelectPermanentCoroutine(Permanent permanent)
+                {
+                    Permanent selectedPermanent = permanent;
+
+                    if (selectedPermanent.DigivolutionCards.Count(CanSelectCardCondition) >= 1)
+                    {
+                        int trashMaxCountOfTargetPermanent = Math.Min(
+                            maxLinkDiscardCount - linkDiscardedCount,
+                            selectedPermanent.DigivolutionCards.Count(CanSelectCardCondition));
+
+                        List<CardSource> selectedCards = new List<CardSource>();
+
+                        SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
+
+                        selectCardEffect.SetUp(
+                                    canTargetCondition: CanSelectCardCondition,
+                                    canTargetCondition_ByPreSelecetedList: null,
+                                    canEndSelectCondition: null,
+                                    canNoSelect: () => canNoTrash && NotSelectYet(),
+                                    selectCardCoroutine: SelectCardCoroutine,
+                                    afterSelectCardCoroutine: null,
+                                    message: "Select linked cards to trash.",
+                                    maxCount: trashMaxCountOfTargetPermanent,
+                                    canEndNotMax: trashMaxCountOfTargetPermanent >= 2 && !isFromOnly1Permanent,
+                                    isShowOpponent: true,
+                                    mode: SelectCardEffect.Mode.Custom,
+                                    root: SelectCardEffect.Root.Custom,
+                                    customRootCardList: selectedPermanent.LinkedCards.Map(linked => linked.Source),
+                                    canLookReverseCard: true,
+                                    selectPlayer: card.Owner,
+                                    cardEffect: activateClass);
+
+                        selectCardEffect.SetUpCustomMessage("Select linked cards to trash.", "The opponent is selecting linked cards to trash.");
+
+                        yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
+
+                        IEnumerator SelectCardCoroutine(CardSource cardSource)
+                        {
+                            selectedCards.Add(cardSource);
+
+                            yield return null;
+                        }
+
+                        yield return ContinuousController.instance.StartCoroutine(new ITrashDigivolutionCards(
+                                selectedPermanent,
+                                selectedCards,
+                                activateClass).TrashDigivolutionCards());
+
+                       linkDiscardedCount += selectedCards.Count;
+
+                        if (canNoTrash && NotSelectYet())
+                        {
+                            EndSelection();
+                        }
+
+                        if (afterSelectionCoroutine != null)
+                            yield return ContinuousController.instance.StartCoroutine(afterSelectionCoroutine(selectedPermanent, selectedCards));
+                    }
+                }
+
+                IEnumerator AfterSelectPermanentCoroutine(List<Permanent> permanents)
+                {
+                    if (permanents.Count == 0)
+                    {
+                        if (canNoTrash && NotSelectYet())
+                        {
+                            EndSelection();
+                        }
+                    }
+
+                    yield return null;
+                }
+            }
+        }
+    }
+
+}

+ 11 - 0
Assets/Scripts/CardEffectCommons/TrashLinkedCards.cs.meta

@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: e8c382c5aa5579d48be86c4bbc84081e
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 143 - 0
Assets/Scripts/CardEffectFactory/ChangeLinkMax.cs

@@ -0,0 +1,143 @@
+using System.Collections;
+using System.Collections.Generic;
+using System;
+using System.Linq;
+using UnityEngine;
+
+public partial class CardEffectFactory
+{
+    #region Static effect that changes one's own Link Max
+    public static ChangeLinkMaxClass ChangeSelfLinkMaxStaticEffect<T>(
+        T changeValue,
+        bool isInheritedEffect,
+        CardSource card,
+        Func<bool> condition)
+    {
+        bool CanUseCondition()
+        {
+            if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
+            {
+                if (condition == null || condition())
+                {
+                    return true;
+                }
+            }
+
+            return false;
+        }
+
+        return ChangeTargetLinkMaxStaticEffect(
+            targetPermanent: card.PermanentOfThisCard(),
+            changeValue: changeValue,
+            isInheritedEffect: isInheritedEffect,
+            card: card,
+            condition: CanUseCondition);
+    }
+    #endregion
+
+    #region Static effect that changes LinkMax
+    public static ChangeLinkMaxClass ChangeTargetLinkMaxStaticEffect<T>(
+        Permanent targetPermanent,
+        T changeValue,
+        bool isInheritedEffect,
+        CardSource card,
+        Func<bool> condition,
+        string hashstring = null)
+    {
+        bool PermanentCondition(Permanent permanent)
+        {
+            return permanent == targetPermanent;
+        }
+
+        return ChangeLinkMaxStaticEffect(
+            permanentCondition: PermanentCondition,
+            changeValue: changeValue,
+            isInheritedEffect: isInheritedEffect,
+            card: card,
+            condition: condition,
+            hashstring: hashstring
+        );
+    }
+
+    public static ChangeLinkMaxClass ChangeLinkMaxStaticEffect<T>(
+        Func<Permanent, bool> permanentCondition,
+        T changeValue,
+        bool isInheritedEffect,
+        CardSource card,
+        Func<bool> condition,
+        string hashstring = null)
+    {
+        bool isInt = typeof(T) == typeof(int);
+        bool isIntFunc = typeof(T) == typeof(Func<int>);
+
+        if (!isInt && !isIntFunc) return null;
+
+        if (isInt && (int)(object)changeValue == 0) return null;
+        if (isIntFunc && changeValue as Func<int> == null) return null;
+
+        int _changeValue() => isInt ? (int)(object)changeValue : (changeValue as Func<int>)();
+        bool isUpValue() => _changeValue() > 0;
+        string effectName() => isUpValue() ? $"Link Max +{_changeValue()}" : $"Link Max {_changeValue()}";
+
+        ChangeLinkMaxClass changeLinkMaxClass = new ChangeLinkMaxClass();
+        changeLinkMaxClass.SetUpICardEffect("", CanUseCondition, card);
+        changeLinkMaxClass.SetUpChangeLinkMaxClass(changeLinkMaxFunc: ChangeLinkMax, permanentCondition: PermanentCondition, isUpDown: _isUpDown);
+
+        if (hashstring != null)
+        {
+            changeLinkMaxClass.SetHashString(hashstring);
+        }
+
+        if (isInheritedEffect)
+        {
+            changeLinkMaxClass.SetIsInheritedEffect(true);
+        }
+
+        bool CanUseCondition(Hashtable hashtable)
+        {
+            if (condition == null || condition())
+            {
+                changeLinkMaxClass.SetEffectName(effectName());
+
+                return true;
+            }
+
+            return false;
+        }
+
+        int ChangeLinkMax(Permanent permanent, int linkMax)
+        {
+            if (PermanentCondition(permanent))
+            {
+                linkMax += _changeValue();
+            }
+
+            return linkMax;
+        }
+
+        bool PermanentCondition(Permanent permanent)
+        {
+            if (CardEffectCommons.IsPermanentExistsOnBattleArea(permanent))
+            {
+                if (!permanent.TopCard.CanNotBeAffected(changeLinkMaxClass))
+                {
+                    if (permanentCondition == null || permanentCondition(permanent))
+                    {
+                        return true;
+                    }
+                }
+            }
+
+            return false;
+        }
+
+        CalculateOrder _isUpDown()
+        {
+            return CalculateOrder.UpDownValue;
+        }
+
+        return changeLinkMaxClass;
+    }
+    #endregion
+
+}

+ 11 - 0
Assets/Scripts/CardEffectFactory/ChangeLinkMax.cs.meta

@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 041317187b942004c9a16222dc1cc74e
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 21 - 9
Assets/Scripts/CardEffectFactory/KeyWordEffects/Link.cs

@@ -7,11 +7,21 @@ using UnityEngine;
 public partial class CardEffectFactory
 {
     #region Trigger effect of Link
-    public static ActivateClass LinkEffect(CardSource card, Func<bool> condition, Func<Permanent, bool> digimonCondition)
+    /// <summary>
+    /// Linking 1 digimon in hand/field to another digimon
+    /// </summary>
+    /// <param name="CardSource">card being linked</param>
+    /// <param name="int">cost for link</param>
+    /// <param name="int">DP buff</param>
+    /// <param name="Func(bool)">condition for you to be able to link</param>
+    /// <param name="Func(Permanent,bool)">Any permaent condtion for you to link to</param>
+    /// <author>Mike Bunch</author>
+    public static ActivateClass LinkEffect(CardSource card, int cost, int dp, Func<bool> condition = null, Func<Permanent, bool> digimonCondition = null)
     {
         if (card == null) return null;
-        if (!CardEffectCommons.IsExistOnHand(card) || !CardEffectCommons.IsExistOnBattleAreaDigimon(card)) return null;
-        if (CardEffectCommons.HasMatchConditionPermanent(digimonCondition)) return null;
+        if (!CardEffectCommons.IsOwnerTurn(card)) return null;
+        if (!CardEffectCommons.IsExistOnHand(card) && !CardEffectCommons.IsExistOnBattleAreaDigimon(card)) return null;
+        if (!CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition)) return null;
 
         ActivateClass activateClass = new ActivateClass();
         activateClass.SetUpICardEffect("Link", CanUseCondition, card);
@@ -21,10 +31,12 @@ public partial class CardEffectFactory
         {
             if (CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card))
             {
-                if (card.CanPlayCardTargetFrame(permanent.PermanentFrame, false, activateClass))
+                if(permanent != card.PermanentOfThisCard())
                 {
-                    if(!permanent.TopCard.CanNotBeAffected(activateClass))
+                    if (digimonCondition == null || digimonCondition(permanent))
+                    {
                         return true;
+                    }
                 }
             }
 
@@ -49,6 +61,9 @@ public partial class CardEffectFactory
 
         IEnumerator ActivateCoroutine(Hashtable _hashtable)
         {
+
+            yield return ContinuousController.instance.StartCoroutine(card.Owner.AddMemory(-cost, activateClass));
+
             Permanent selectedPermanent = null;
 
             int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
@@ -81,10 +96,7 @@ public partial class CardEffectFactory
 
             if (selectedPermanent != null)
             {
-                if (CardEffectCommons.IsExistOnHand(card))
-                    yield return ContinuousController.instance.StartCoroutine(selectedPermanent.AddLinkedCard(card, activateClass));
-                else
-                    yield return ContinuousController.instance.StartCoroutine(new ILinkPermanentToPermanent(new List<Permanent[]>() { new Permanent[] { card.PermanentOfThisCard(), selectedPermanent } }, activateClass).LinkPermanent());
+                yield return ContinuousController.instance.StartCoroutine(selectedPermanent.AddLinkCard(card, dp, activateClass));
             }
         }
 

+ 9 - 0
Assets/Scripts/CardEffectInterfaces.cs

@@ -116,6 +116,15 @@ public interface IChangeSAttackEffect
 }
 #endregion
 
+#region "Change target permanent's Link Max" effect
+public interface IChangeLinkMaxEffect
+{
+    int GetLinkMax(int linkMax, Permanent permanent, int invertValue);
+    CalculateOrder isUpDown();
+    bool PermanentCondition(Permanent permanent);
+}
+#endregion
+
 #region "Invert target permanent's Security Attack" effect
 public interface IInvertSAttackEffect
 {

+ 72 - 0
Assets/Scripts/CardEffects/ChangeLinkMaxClass.cs

@@ -0,0 +1,72 @@
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+using System;
+using Unity.Mathematics;
+
+public class ChangeLinkMaxClass : ICardEffect, IChangeLinkMaxEffect
+{
+    public void SetUpChangeLinkMaxClass(Func<Permanent, int, int> changeLinkMaxFunc, Func<Permanent, bool> permanentCondition, Func<CalculateOrder> isUpDown)
+    {
+        _changeLinkMaxFunc = changeLinkMaxFunc;
+        _permanentCondition = permanentCondition;
+        _isUpDown = isUpDown;
+    }
+
+    Func<Permanent, int, int> _changeLinkMaxFunc = null;
+    Func<Permanent, bool> _permanentCondition = null;
+    Func<CalculateOrder> _isUpDown = null;
+
+    public int GetLinkMax(int LinkMax, Permanent permanent, int invertValue)
+    {
+        int changedLinkMax = LinkMax;
+
+        if (PermanentCondition(permanent))
+        {
+            changedLinkMax = _changeLinkMaxFunc(permanent, LinkMax);
+
+            switch (invertValue)
+            {
+                case -1:
+                    if(changedLinkMax < LinkMax)
+                        changedLinkMax = LinkMax + Mathf.Abs(changedLinkMax - LinkMax);
+                    break;
+                case 1:
+                    if (changedLinkMax > LinkMax)
+                        changedLinkMax = LinkMax - (changedLinkMax - LinkMax);
+                    break;
+            }
+        }
+
+        return changedLinkMax;
+    }
+
+    public CalculateOrder isUpDown()
+    {
+        if (_isUpDown != null)
+        {
+            return _isUpDown();
+        }
+
+        return CalculateOrder.UpToConstant;
+    }
+
+    public bool PermanentCondition(Permanent permanent)
+    {
+        if (permanent != null)
+        {
+            if (permanent.TopCard != null)
+            {
+                if (_permanentCondition != null)
+                {
+                    if (_permanentCondition(permanent))
+                    {
+                        return true;
+                    }
+                }
+            }
+        }
+
+        return false;
+    }
+}

+ 11 - 0
Assets/Scripts/CardEffects/ChangeLinkMaxClass.cs.meta

@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 02388e42090c57f42bdb475918454d2e
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 2 - 1
Assets/Scripts/CardSource.cs

@@ -253,7 +253,8 @@ public class CardSource : MonoBehaviour
     #region Permanent in the field containing this card
     public Permanent PermanentOfThisCard()
     {
-        return Owner.GetFieldPermanents().Find(permanent => permanent.cardSources.Contains(this) && !IsFlipped);
+        return Owner.GetFieldPermanents().Find(permanent => 
+            (permanent.cardSources.Contains(this) || permanent.LinkedCards.Any(linked => linked.Source == this)) && !IsFlipped);
     }
     #endregion
 

+ 8 - 0
Assets/Scripts/Effect Examples.meta

@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: 3ca64c3d0906a504797e7e90bfa8a077
+folderAsset: yes
+DefaultImporter:
+  externalObjects: {}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 185 - 0
Assets/Scripts/Effect Examples/Link_Examples.cs

@@ -0,0 +1,185 @@
+using System.Collections;
+using System.Collections.Generic;
+using System.Linq;
+
+namespace DCGO.CardEffects.Examples
+{
+    public class Link_Examples : CEntity_Effect
+    {
+        public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
+        {
+            List<ICardEffect> cardEffects = new List<ICardEffect>();
+
+            #region Basic link effect keyword
+            if (timing == EffectTiming.OnDeclaration)
+            {
+                cardEffects.Add(CardEffectFactory.LinkEffect(card, 1, 2000));
+            }
+            #endregion
+
+            #region When Linked Example, Specifically When THIS card is added as a linked card
+            if (timing == EffectTiming.WhenLinked)
+            {
+                ActivateClass activateClass = new ActivateClass();
+                activateClass.SetUpICardEffect("Testing When Linking", CanUseCondition, card);
+                activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
+                activateClass.SetIsLinkedEffect(true);
+                cardEffects.Add(activateClass);
+
+                string EffectDiscription()
+                {
+                    return "[When linked] Testing When linking";
+                }
+
+                bool CanUseCondition(Hashtable hashtable)
+                {
+                    return CardEffectCommons.CanTriggerWhenLinking(hashtable, null, card);
+                }
+
+                bool CanActivateCondition(Hashtable hashtable)
+                {
+                    return isExistOnField(card);
+                }
+
+                IEnumerator ActivateCoroutine(Hashtable _hashtable)
+                {
+                    UnityEngine.Debug.Log("CARD SUCCESSFULLY LINKED");
+                    yield return null;
+                }
+            }
+            #endregion
+
+            #region When Linked Example, When A card is linked at all
+            if (timing == EffectTiming.WhenLinked)
+            {
+                ActivateClass activateClass = new ActivateClass();
+                activateClass.SetUpICardEffect("Testing When Linked", CanUseCondition, card);
+                activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
+                cardEffects.Add(activateClass);
+
+                string EffectDiscription()
+                {
+                    return "[Your Turn] When this Digimon gets linked";
+                }
+
+                bool PermanentCondition(Permanent permanent)
+                {
+                    return permanent == card.PermanentOfThisCard();
+                }
+
+                bool CardCondition(CardSource source)
+                {
+                    return true;
+                }
+
+                bool CanUseCondition(Hashtable hashtable)
+                {
+                    return CardEffectCommons.CanTriggerWhenLinked(hashtable, PermanentCondition, CardCondition);
+                }
+
+                bool CanActivateCondition(Hashtable hashtable)
+                {
+                    return isExistOnField(card);
+                }
+
+                IEnumerator ActivateCoroutine(Hashtable _hashtable)
+                {
+                    UnityEngine.Debug.Log("CARD LINKED");
+                    yield return null;
+                }
+            }
+            #endregion
+
+            #region Trash 1 Link card
+            if (timing == EffectTiming.OnStartMainPhase)
+            {
+                ActivateClass activateClass = new ActivateClass();
+                activateClass.SetUpICardEffect("", CanUseCondition, card);
+                activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
+                cardEffects.Add(activateClass);
+
+                string EffectDiscription()
+                {
+                    return "";
+                }
+
+                bool CanSelectPermanentCondition(Permanent permanent)
+                {
+                    if (CardEffectCommons.IsPermanentExistsOnBattleAreaDigimon(permanent))
+                    {
+                        if (permanent.LinkedCards.Map(link => link.Source).Count(CanSelectCardCondition) >= 1)
+                        {
+                            return true;
+                        }
+                    }
+
+                    return false;
+                }
+
+                bool CanSelectCardCondition(CardSource cardSource)
+                {
+                    return true;
+                }
+
+                bool CanUseCondition(Hashtable hashtable)
+                {
+                    if (CardEffectCommons.IsExistOnBattleArea(card))
+                    {
+                        if (CardEffectCommons.IsOwnerTurn(card))
+                        {
+                            return true;
+                        }
+                    }
+
+                    return false;
+                }
+
+                bool CanActivateCondition(Hashtable hashtable)
+                {
+                    if (CardEffectCommons.IsExistOnBattleArea(card))
+                    {
+                        return true;
+                    }
+
+                    return false;
+                }
+
+                IEnumerator ActivateCoroutine(Hashtable _hashtable)
+                {
+                    yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.SelectTrashLinkedCards(
+                            permanentCondition: CanSelectPermanentCondition,
+                            cardCondition: CanSelectCardCondition,
+                            maxCount: 1,
+                            canNoTrash: false,
+                            isFromOnly1Permanent: true,
+                            activateClass: activateClass
+                        ));
+                }
+            }
+            #endregion
+
+            #region Change Link Max Count
+            if (timing == EffectTiming.None)
+            {
+                bool Condition()
+                {
+                    if (CardEffectCommons.IsExistOnBattleArea(card))
+                    {
+                        return true;
+                    }
+
+                    return false;
+                }
+
+                cardEffects.Add(CardEffectFactory.ChangeSelfLinkMaxStaticEffect(
+                    changeValue: 1,
+                    isInheritedEffect: true,
+                    card: card,
+                    condition: Condition));
+            }
+
+            return cardEffects;
+        }
+        #endregion
+    }
+}

+ 11 - 0
Assets/Scripts/Effect Examples/Link_Examples.cs.meta

@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 6bdd75f5dee4b6844ba9c5246554204e
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 24 - 0
Assets/Scripts/FieldPermanentCard.cs

@@ -50,6 +50,9 @@ public class FieldPermanentCard : MonoBehaviour
     [Header("レベルテキスト")]
     public TextMeshProUGUI LevelText;
 
+    [Header("Linked Text")]
+    public Text LinkedDPText;
+
     [Header("表示親")]
     public GameObject Parent;
 
@@ -119,6 +122,11 @@ public class FieldPermanentCard : MonoBehaviour
             EvoRootCountText.transform.parent.gameObject.SetActive(false);
         }
 
+        if (LinkedDPText != null)
+        {
+            LinkedDPText.transform.parent.gameObject.SetActive(false);
+        }
+
         if (DirectStrikeText != null)
         {
             DirectStrikeText.transform.parent.parent.gameObject.SetActive(true);
@@ -513,6 +521,22 @@ public class FieldPermanentCard : MonoBehaviour
                 }
             }
 
+            if (LinkedDPText != null)
+            {
+                if (ThisPermanent.LinkedCards.Count > 0)
+                {
+                    LinkedDPText.transform.parent.gameObject.SetActive(true);
+
+                    if (LinkedDPText.text != $"+{ThisPermanent.LinkedDP}")
+                        LinkedDPText.text = $"+{ThisPermanent.LinkedDP}";
+                }
+
+                else
+                {
+                    LinkedDPText.transform.parent.gameObject.SetActive(false);
+                }
+            }
+
             if (SummonSicknessObject != null)
             {
                 bool isActive = false;

+ 19 - 4
Assets/Scripts/ICardEffect.cs

@@ -27,6 +27,7 @@ public abstract class ICardEffect
         SetUseOptional(false);
         SetIsDeclarative(false);
         SetIsInheritedEffect(false);
+        SetIsLinkedEffect(false);
         SetIsSecurityEffect(false);
         SetIsCounterEffect(false);
         SetIsDigimonEffect(false);
@@ -273,15 +274,15 @@ public abstract class ICardEffect
             return false;
         }
         #endregion
-
-        #region Determination of availability for Inheritated Effect
+       
+        #region Determination of availability for Inheritated/Linked Effect
         if (this is ActivateICardEffect)
         {
             if (EffectSourceCard != null)
             {
                 if (EffectSourceCard.PermanentOfThisCard() != null)
                 {
-                    if (IsInheritedEffect)
+                    if (IsInheritedEffect || IsLinkedEffect)
                     {
                         if (EffectSourceCard == EffectSourceCard.PermanentOfThisCard().TopCard)
                         {
@@ -313,7 +314,7 @@ public abstract class ICardEffect
         #endregion
 
         #region Determination whether the permanent is same as when triggered
-        if (IsInheritedEffect)
+        if (IsInheritedEffect || IsLinkedEffect)
         {
             if (this is ActivateICardEffect)
             {
@@ -410,6 +411,19 @@ public abstract class ICardEffect
     }
     #endregion
 
+    #region Whether this effect is an Linked Effect
+    bool _isLinkededEffect = false;
+    public bool IsLinkedEffect
+    {
+        get { return _isLinkededEffect; }
+        private set { _isLinkededEffect = value; }
+    }
+    public void SetIsLinkedEffect(bool isLinkededEffect)
+    {
+        IsLinkedEffect = isLinkededEffect;
+    }
+    #endregion
+
     #region Whether this effect is an Security Effect
     bool _isSecurityEffect = false;
     public bool IsSecurityEffect
@@ -783,6 +797,7 @@ public enum EffectTiming
     OnReturnCardsToHandFromTrash,
     AfterEffectsActivate,
     WhenWouldDigivolutionCardDiscarded,
+    WhenLinked
 }
 #endregion
 

+ 2 - 2
Assets/Scripts/MultipleSkills.cs

@@ -129,7 +129,7 @@ public class MultipleSkills : MonoBehaviourPunCallbacks
                     }
                 }
 
-                if(skillInfo.CardEffect.ChainActivations > 0)
+                if (skillInfo.CardEffect.ChainActivations > 0)
                 {
                     if (GManager.instance.autoProcessing.IsCutInEffectUsedMaxCount(skillInfo.CardEffect))
                     {
@@ -157,7 +157,7 @@ public class MultipleSkills : MonoBehaviourPunCallbacks
 
             skillInfos_active = skillInfos_active.Filter(skillInfo => skillInfo != null && skillInfo.CardEffect != null
                 && skillInfo.CardEffect.CanActivate(skillInfo.Hashtable) && skillInfo.CardEffect.EffectSourceCard != null);
-
+            
             if (skillInfos_active.Count > 0)
             {
                 bool oldIsSecurityGlassBlue = player.securityObject.securityBreakGlass.IsBlueGlass && IsOnlyHandEffectStacked && IsOnlyOptionalEffectStacked && IsEachStackedEffectHasDistinctSourceCard;

+ 218 - 15
Assets/Scripts/Permanent.cs

@@ -317,7 +317,7 @@ public class Permanent
             {
                 DP = BaseDP;
 
-                #region DPを変更する効果
+                #region DP By Effect
 
                 List<ICardEffect> cardEffects_ChangeDP = new List<ICardEffect>();
 
@@ -459,6 +459,8 @@ public class Permanent
                 }
                 #endregion
 
+                DP += LinkedDP;
+
                 if (DP < 0)
                 {
                     DP = 0;
@@ -468,6 +470,10 @@ public class Permanent
             return DP;
         }
     }
+
+    public int LinkedDP { get; set; }
+
+    public int DPBoost { get; set; }
     #endregion
 
     #region Will it not receive negative DP effect?
@@ -625,11 +631,142 @@ public class Permanent
     #endregion
 
     #region Digivolution Cards
-    public List<CardSource> DigivolutionCards => cardSources.Filter(cardSource => cardSource != TopCard);
+    public List<CardSource> DigivolutionCards => cardSources.Filter(cardSource => cardSource != TopCard || LinkedCards.Any(linked => linked.Source == cardSource));
     #endregion
 
-    #region Linked Card
-    public CardSource LinkedCard = null;
+    #region Linked Cards
+    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)
+        {
+            DP = dp;
+            Source = source;
+        }
+
+        public int DP { get; }
+        public CardSource Source { get; }
+    }
+
+    public List<LinkCard> LinkedCards = new List<LinkCard>();
     #endregion
 
     #region Add Card Source
@@ -801,15 +938,65 @@ public class Permanent
     }
     #endregion
 
-    #region Add Card Source
-    public IEnumerator AddLinkedCard(CardSource cardSource, 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 (LinkedCard != null)
-            RemoveLinkedCard(null);
+        bool isFromDigimon = false;
 
-        LinkedCard = cardSource;
+        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(RemoveLinkedCard(LinkedCards[0].Source));
+
+        yield return ContinuousController.instance.StartCoroutine(CardObjectController.RemoveFromAllArea(addedLinkCard));
+
+        if (!this.IsToken && !addedLinkCard.IsToken)
+        {
+            LinkedCards.Insert(0, new LinkCard(0, addedLinkCard));
+            LinkedDP += DP;
+
+            this.cardSources.Insert(1, addedLinkCard);
+            addedLinkCard.SetFace();
+            addedCard = true;
+        }
+
+        if (addedCard)
+        {
+            if (ShowingPermanentCard != null)
+            {
+                yield return ContinuousController.instance.StartCoroutine(ShowingPermanentCard.ShowAddDigivolutionCardEffect());
+            }
+
+            #region Add Linked Card
+
+            #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
 
@@ -823,12 +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();
 
-        LinkedCard = null;
+        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}");
+            
+        }
+
+        //TODO: Add event call if something was removed
     }
     #endregion
 
@@ -982,6 +1180,7 @@ public class Permanent
         {
             foreach (CardSource cardSource in cardSources)
             {
+                
                 if (cardSource != null)
                 {
                     if (!cardSource.IsFlipped)
@@ -1000,7 +1199,7 @@ public class Permanent
                         {
                             if (cardEffect != null)
                             {
-                                if (isTopCard == cardEffect.IsInheritedEffect)
+                                if (isTopCard == cardEffect.IsInheritedEffect && isTopCard == cardEffect.IsLinkedEffect)
                                 {
                                     continue;
                                 }
@@ -3176,6 +3375,10 @@ public class Permanent
     public bool HasNoDigivolutionCards => DigivolutionCards.Count == 0;
     #endregion
 
+    #region Has No Link Cards
+    public bool HasNoLinkCards => LinkedCards.Count == 0;
+    #endregion
+
     #region Digivolution cards' colors
     public List<CardColor> DigivolutionCardsColors
     {