m |
m |
||
(3 intermediate revisions by one user not shown) | |||
Line 1: | Line 1: | ||
Here's an explanation of the Shadow Era card code for [[Kraken Attack]]:<br> | Here's an explanation of the Shadow Era card code for [[Kraken Attack]]:<br> | ||
− | [https://www.shadowera.com/wiki/index.php | + | [https://www.shadowera.com/wiki/index.php/Talk:Kraken_Attack#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" | ||
|- | |- | ||
− | ! <center>FILE REFERENCE</center> | + | ! <center>FILE REFERENCE</center> || <center>KEY FUNCTIONS</center> |
|- | |- | ||
| style="vertical-align: top;" | | | style="vertical-align: top;" | | ||
− | + | <span style="color: violet;">rr155.cs</span>:<br> Includes the logic for handling specific cards and abilities, such as | |
+ | *`OnCast()`, | ||
+ | *`CanCast()`, | ||
+ | *`StartTargeting()`, | ||
+ | *`GetTargets()`, | ||
+ | *`IsValidTarget()`, and | ||
+ | *`NumberOfTargets()`. | ||
+ | || | ||
+ | *`Init`: Initializes card properties. | ||
+ | *`NumberOfTargets`: Returns the number of targets. | ||
+ | *`IsValidTarget`: Determines if a card is a valid target. | ||
+ | *`GetTargets`: Retrieves a list of valid targets. | ||
+ | *`CanCast`: Checks if the card can be cast. | ||
+ | *`OnCast`: Executes the card's effect. | ||
+ | *`StartTargeting`: Prepares for targeting. | ||
|- | |- | ||
− | ! <center>DETAILED CODE</center> | + | ! colspan="2"| <center>DETAILED CODE</center> |
|- | |- | ||
− | | | + | | colspan="2" | |
<small><syntaxhighlight lang="csharp"> | <small><syntaxhighlight lang="csharp"> | ||
using System.Collections.Generic; | using System.Collections.Generic; | ||
Line 187: | Line 201: | ||
*#Moves the camera to focus on the enemy (`MoveCameraToEnemy()`).<br> | *#Moves the camera to focus on the enemy (`MoveCameraToEnemy()`).<br> | ||
<br> | <br> | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− |
Here's an explanation of the Shadow Era card code for Kraken Attack:
Detailed explanation is below the code.
|
|
---|---|
rr155.cs:
|
|
| |
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: