(Page created) |
m |
||
Line 1: | Line 1: | ||
− | Here's an explanation of the Shadow Era card code for | + | Here's an explanation of the Shadow Era card code for [[Kraken Attack]]:<br> |
+ | [https://www.shadowera.com/wiki/index.php?title=Talk:Kraken_Attack&action=edit#Detailed_explanation Detailed explanation is below the code].<br> | ||
<center><img src="https://www.shadowera.com/landing/img/blog-separator-2.png" ></center><br /> | <center><img src="https://www.shadowera.com/landing/img/blog-separator-2.png" ></center><br /> | ||
{| class="wikitable" code-table" | {| class="wikitable" code-table" | ||
Line 7: | Line 8: | ||
| style="vertical-align: top;" | | | style="vertical-align: top;" | | ||
* <span style="color: violet;">rr155.cs</span>: Includes the logic for handling specific cards and abilities, such as `OnCast()`, `CanCast()`, `StartTargeting()`, `GetTargets()`, `IsValidTarget()`, and `NumberOfTargets()`. | * <span style="color: violet;">rr155.cs</span>: Includes the logic for handling specific cards and abilities, such as `OnCast()`, `CanCast()`, `StartTargeting()`, `GetTargets()`, `IsValidTarget()`, and `NumberOfTargets()`. | ||
+ | |- | ||
+ | ! <center>DETAILED CODE</center> | ||
|- | |- | ||
| style="vertical-align: top;" | | | style="vertical-align: top;" | | ||
Line 129: | Line 132: | ||
|} | |} | ||
<center><img src="https://www.shadowera.com/landing/img/blog-separator-2.png" ></center><br /> | <center><img src="https://www.shadowera.com/landing/img/blog-separator-2.png" ></center><br /> | ||
+ | ===Detailed explanation=== | ||
<br> | <br> | ||
Init Method:<br> | Init Method:<br> |
Here's an explanation of the Shadow Era card code for Kraken Attack:
Detailed explanation is below the code.
|
---|
|
|
using System.Collections.Generic; public class rr155 : SpecificCard { public override void Init() { parent.cardName = "Kraken Attack"; parent.rarity = RarityEnum.Common; parent.usableBy = UsableBy.Neutral; parent.cardType = CardTypeEnum.Ability; parent.castCost = 2; } public override int NumberOfTargets() { return 1; } private bool IsValidTarget(ShadowEraCard check) { if (!check.CanBeTargetedBy(parent) || check.cardType != CardTypeEnum.Item) { return false; } if (check.cardSubType == CardSubTypeEnum.Ship) { return true; } if (check.cardSubType == CardSubTypeEnum.Trap) { return false; } return check.castCost <= 2; } public override List<ShadowEraCard> GetTargets() { List<ShadowEraCard> list = new List<ShadowEraCard>(); for (int i = 0; i < GameModel.ItemsCount(); i++) { ShadowEraCard item = GameModel.GetItem(i); if (IsValidTarget(item)) { list.Add(item); } } for (int j = 0; j < GameModel.EnemyItemsCount(); j++) { ShadowEraCard enemyItem = GameModel.GetEnemyItem(j); if (IsValidTarget(enemyItem)) { list.Add(enemyItem); } } return list; } public override bool CanCast() { return GetTargets().Count > 0; } public override void OnCast() { if (targets.Count > 0) { ShadowEraCard shadowEraCard = targets[0]; if (GameModel.CheckCanItemBeDestroyed(shadowEraCard)) { if (shadowEraCard.cardSubType == CardSubTypeEnum.Ship) { int num = 999; ShadowEraCard shadowEraCard2 = null; for (int i = 0; i < shadowEraCard.attachedCards.Count; i++) { ShadowEraCard shadowEraCard3 = shadowEraCard.attachedCards[i]; if (shadowEraCard3.originalCardType == CardTypeEnum.Ally && shadowEraCard3.castCost < num) { shadowEraCard2 = shadowEraCard3; num = shadowEraCard3.castCost; } } if (shadowEraCard2 != null) { GameModel.Exile(shadowEraCard2); } int num2 = -1; ShadowEraCard shadowEraCard4 = null; for (int j = 0; j < shadowEraCard.attachedCards.Count; j++) { ShadowEraCard shadowEraCard5 = shadowEraCard.attachedCards[j]; if (shadowEraCard5.originalCardType == CardTypeEnum.Ally && shadowEraCard5.castCost > num2) { shadowEraCard4 = shadowEraCard5; num2 = shadowEraCard5.castCost; } } if (shadowEraCard4 != null) { GameModel.Exile(shadowEraCard4); } } shadowEraCard.DestroyCard(); } } targets.Clear(); MoveCastCardToGraveyard(); } public override void StartTargeting() { targets.Clear(); MoveToCastPosition(); MoveCameraToEnemy(); } } |
Init Method:
NumberOfTargets Method:
IsValidTarget Method:
GetTargets Method:
CanCast Method:
OnCast Method:
StartTargeting Method:
The key functions used are: