[JAVA] Introduction to Slay the Spire Mod Development (3) Original Card Definition

Introduction

In this chapter, we will explain the following methods by quoting the source code.

If you want to see the whole picture of each file, please refer to the following.

https://github.com/kojim/StSModStudy/tree/master/mod001

ModTheSpire.json

{
  "modid": "StsModStudy",
  "name": "StsModStudy",
  "author_list": ["ykojim"],
  "description": "",
  "version": "0.0.1",
  "sts_version": "01-11-2019",
  "mts_version": "3.7.0",
  "dependencies": ["basemod", "stslib"],
  "update_json": ""
}

It's almost as you saw it. The modid must be unique, so give it a name that doesn't overlap with others.

Entry point class

@SpireInitializer
public class Main implements
  EditCardsSubscriber,   //Implement when adding a card
  EditStringsSubscriber  //Implement when reading a language file
{

    public Main(){
        BaseMod.subscribe(this);
    }

    // @Classes qualified with SpireInitializer need to define this method
    public static void initialize() {
        Main main = new Main();
    }

    @Override
    public void receiveEditStrings() {
        //Add your own defined language file
        // Settings.JPN for Japanese,ENG is included in English
        BaseMod.loadCustomStringsFile(CardStrings.class, "assets/loc/cards-" + Settings.language + ".json");
    }

    @Override
    public void receiveEditCards() {
        //Add your own defined card
        BaseMod.addCard(new Flare());
    }
}

@spireinitializerThe class qualified with annotation is the entry point class. Here, we will activate each language file and card defined independently. Please note that the interface to implement will change depending on what you want to achieve. Also note that the initialize method is required.

Original card definition class

//Cards are defined by inheriting the CustomCard class
public class Flare extends CustomCard {
    public static final String ID = "stsmodstudy:Flare";
    //cards read in the Main class with getCardStrings-JPN.Get the string information in json
    private static CardStrings cardStrings = CardCrawlGame.languagePack.getCardStrings(ID);
    public static final String NAME = cardStrings.NAME;
    public static final String DESCRIPTION = cardStrings.DESCRIPTION;

You can define your own card by defining a class that inherits the CustomCard class.

Since the character string data that the user can see needs to be internationalized, it is defined in the language file, not in this class. Only the key `` `stsmodstudy: Flare``` to get the information from the language file is defined here.

It is a good practice to put the modid in front of and the card name after.




```java
    //Effect activated when using a card
    @Override
    public void use(AbstractPlayer p, AbstractMonster m) {
        //Cause damage
        AbstractDungeon.actionManager.addToBottom(
            new com.megacrit.cardcrawl.actions.common.DamageAction(
                m,
                new DamageInfo(p, this.damage, this.damageTypeForTurn),
                AbstractGameAction.AttackEffect.SLASH_DIAGONAL) //Screen effect
        );
        //Make a vulnerability
        AbstractDungeon.actionManager.addToBottom(
            new ApplyPowerAction(                                //Buff/All debuffs are treated as power internally
                m,
                p,
                new VulnerablePower(m, this.magicNumber, false), //Vulnerable(=enemy)To
                this.magicNumber,
                true,
                AbstractGameAction.AttackEffect.NONE)            //Screen effect
        );
    }

This method is the number one key on the card. As anyone who has played the game may have guessed, this game is based on a model in which the effects of using cards are piled up on the stack and processed in sequence.

AbstractDungeon.By calling each method of actionManager, processing is added to the stack.


 Here, we are giving damage and weakening.

# Language file

```json
{
  "stsmodstudy:Flare": {
    "NAME": "56 warriors",
    "DESCRIPTION": "!D!Cause damage"
  }
}

Defines the language information of the card. nameIs the card name,descriptionIs the explanation of the card effect. descriptionIn!d! !b! !m!Each has a special meaning. !d!Is a card classdamage basedamage upgradeddamagevariable, !b!Is a card classblock baseblock upgradedblockvariable, !m!Is a card classmagicnumber basemagicnumber upgradedmagicnumberIt is expanded into variables according to the situation.

Recommended Posts

Introduction to Slay the Spire Mod Development (3) Original Card Definition
Introduction to Slay the Spire Mod Development (1) Introduction
Introduction to Slay the Spire Mod Development (2) Development Environment Construction
Introduction to Keycloak development
Introduction to Android application development
Run the sample "Introduction to TensorFlow Development" on Jetson nano
minecraft1.14.4 MOD development memorandum 1 [Original recipe]
Output of the book "Introduction to Java"
Introduction to Docker / Kubernetes Practical Container Development
Learn while making a WEB server Introduction to WEB application development from the basics