Card Game Mechanics (Irina)

From Yanfly.moe Wiki
Jump to navigation Jump to search

Welcome to the wiki! This is where you can find resources from Yanfly.moe, Ækashics.moe,
VisuStella, Caz Wolf, Fallen Angel Olivia, Atelier Irina, and other affiliated content creators.



Download

System

This is a plugin created for RPG Maker MV.

For help on how to install plugins, click here.

For help on how to update plugins, click here.

Got errors with your RPG Maker MV plugin? Click here.


Masterarbeit Writer

Atelier Irina

IrinaAvatar.png

This is a plugin created by Atelier Irina.

You can also follow Atelier Irina on itch.io.

RPG Maker Version

This plugin is made for and tested on RPG Maker MV with version 1.6.2. I cannot guarantee if it works on lower versions. Some of the plugin parameters require the later updates of RPG Maker MV for you to be able to use their entries so please update RPG Maker MV to the latest version if you want the best experience in using this plugin.

Terms of Use

You are only allowed to use the plugins made by Atelier Irina if you agree to all of the following:

  1. These plugins may be used in free or commercial games.
  2. 'RPG Maker Irina' must be given credit in your games.
  3. You are allowed to edit the code.
  4. Do NOT change the filename, parameters, and information of the plugin.
  5. You are NOT allowed to redistribute these Plugins.
  6. You may NOT take code for your own released Plugins.

Required Plugins

The following plugins are required in order to use this plugin.

Place the following plugins above this plugin located in the Plugin Manager.

Extension Plugins

The following plugins are Extension Plugins that require this plugin as its Parent Plugin.

Place the following plugins below this plugin located in the Plugin Manager if you plan on using them.

Introduction

This file is the third of three files to be included in the collectible card game set of plugins and this one's primary focus is on providing many functions that help compose the mechanics of a playable card game. The plugin will not provide the battle structure. Instead, that is provided in the card game sample project, as it is custom evented. This plugin's purpose is to provide the functions and mechanics for the card game battle system itself.

Instructions

The plugin itself doesn't provide much to be accessible by itself as it is your job as the game dev to make the provided functions work. However, the sample project will provide the card game's custom evented battle system to show you how it's done (or if you just want to use it as is). Download it from the card game's project page:

itch.io Project Page

If you wish to import the card game's custom evented battle system into your game, then what you have to do is the following:

Step 1.

Open up the Card Game sample project's game folder.

Step 2.

Open up the Database and go to the Common Events tab.

Step 3.

Mass select the Common Events from #891 to #1000.

Step 4.

Copy them to clipboard.

Step 5.

Open up your own game project.

Step 6.

Open up the Database and go to the Common Events tab.

Step 7.

Increase the maximum number of Common Events to 1000.

Step 8.

Select Common Event slot #891.

Step 9.

Paste from clipboard.

Step 10.

Congratulations, you have now imported the whole custom battle system.

If for whatever reason you wish to start at a different number (ie. if you were already using those common events slots for something else), you can paste them else where. However, you will need to readjust the common events linked to them from within the pasted common events themselves or else the custom evented battle system will not work.

---

Variable 901 - Card Game Turn Count
Variable 902 - Card Game Phase
Variable 911 - Card Spell 1 Icon
Variable 912 - Card Spell 1 Name
Variable 913 - Card Spell 2 Icon
Variable 914 - Card Spell 2 Name
Variable 915 - Card Spell 3 Icon
Variable 916 - Card Spell 3 Name
Variable 917 - Card Spell 4 Icon
Variable 918 - Card Spell 4 Name

I also recommend raising your game project's variables to at least 920 and reserve the variable ID's listed above since they're used by the custom evented battle system.

---

Common Event #901: "Card Game Battle Flow <Merge>" has <Merge> in its name. Do not remove the <Merge> since it is a vital part in making the common event work (credits to Yanfly). What this does is make the common event and all other sub-level common events that are ran from inside it merge its contents into one continuous common event. Why is this done? It's so that other common events can use the Label events on the <Merge> level.

For that reason, be cautious of making common events loop into one another. This is will cause an infinite loop and the game will crash. I am not responsible if you do this and lock out your game.

---

Plugin Parameters

There are Plugin Parameters that you may configure for this plugin.

There are a lot of plugin parameters to set here although the majority of them could be left as is. The ones you should pay attention to are the ones at top:

---

Mechanics

Mechanics: Merge on Boot

This will cause the Common Event <Merge> to occur as the game boots up, requiring less processing time in-game. To understand what the <Merge> is, read the "Instructions" section above.

Mechanics: Variable: Turn Tracker

This is the variable used to track the current turn count in the card game custom evented battle system. Keep in mind that changing this variable here will not change the one inside the common events. This will only change the variable ID reference for the JavaScript code found in the rest of the plugin parameters.

Mechanics: Variable: Phase Tracker

This is the variable used to track the current phase in the card game custom evented battle system. Keep in mind that changing this variable here will not change the one inside the common events. This will only change the variable ID reference for the JavaScript code found in the rest of the plugin parameters.

---

Select Deck Window

Before starting a battle with another player, the player can pick what deck they wish to play against that player. These plugin parameters allow you to adjust how they look.

---

Card Game Board

These plugin parameters adjust the appearance of how the Card Game HUD looks, how some sprites act when changing, and the JavaScript used to set up the board to make it look the way you want.

Card Game Board: Sprite Fluctuation

When a player takes damage or has their shields reduced, the sprite will shake a bit. Change the values here to let you decide how much they will shake by.

---

Hand Window

The cards that a player holds in his or her hand is actually held together by a window object. You can change the width of the hand window to adjust how closely held together the cards.

Hand Window: Skip Turn Card

The Skip Turn Card will refer to a Database Item to represent the Skip Turn function. As provided in the sample project, it is a No-Element, 0 Level, 0 Power card, something that will be played if the player decides to skip that turn.

Hand Window: Always Show Skip Turn

You can decide to have the Skip Turn card always show or hide it until there are no more cards in the player's hand. The Skip Turn card will always appear if the player ran out of cards in their hand.

---

List Window

There are some card effects that let the player pick from a list of cards and then perform a follow up action with them. These settings let you determine how it appears.

---

Sprite Positioning

These are JavaScript code entries to let you determine how sprites will position themselves on the screen. For example, while in the deck, they will be tilted at a certain angle. While in the hand, they will appear up right. This can be left alone for the most part unless you wish to tweak your card game board heavily.

---

Custom Pile Positioning

Custom Piles aren't used in the sample project. However, for those who wish to customize the card game custom evented battle system further and make use of the custom piles, these plugin parameters will allow you to adjust the angle, scale, and other properties of them. For more information, look in the "Custom Piles" section of the help file.

Custom Evented Battle System Structure

The custom evented battle structure found in the sample project will work like this assuming that nothing has been changed about it. There's a couple of keywords I'll be using so to avoid confusing you, I'll explain them here:

---

  • Hand: This refers to the cards in the player's hand and where cards go into

when the player draws.

  • Library: This refers to the stack of cards that make up the player's deck

that the player will draw from.

  • Discard: This is where the used up cards go. The player does not draw from

this, but the Discard pile does get recycled.

  • Exhaust: This is where the other used up cards go. The player does not draw

from this. This pile does not get recycled.

  • A.I.: Artificial intelligence. It's what I call the computer opponent.

---

Here is how the battle structure works:

  1. The Card Game Starts.
    1. Create all the necessary assets for the card game battle. This includes pictures, the battle backgrounds, windows, etc.
    2. Start Game Effects: Any card effects that would occur from the Hand, Library, Discard Pile, or Exhaust Pile that are programmed to activate at this time would activate at this time.
    3. Both players then draw 5 cards.
    4. Determine if any victory conditions have been met. If they are, go to Finishing the Card Game Battle.
  2. Upkeep Phase
    1. This phase is to keep track of the turn count and other variables you decide to do.
    2. Upkeep Effects: Any card effects that would occur from the Hand, Library, Discard Pile, or Exhaust Pile that are programmed to activate at this time would activate at this time.
    3. Determine if any victory conditions have been met. If they are, go to Finishing the Card Game Battle.
  3. Draw Phase
    1. Both players draw 1 card.
    2. Draw Phase Effects: Any card effects that would occur from the Hand, Library, Discard Pile, or Exhaust Pile that are programmed to activate at this time would activate at this time.
    3. Determine if any victory conditions have been met. If they are, go to Finishing the Card Game Battle.
  4. Main Phase
    1. The players selects a card from their hand to play. Said card can be immediately used for battle or if they have effects, the effects would be used at this point.
    2. If the A.I. (computer opponent) has card effects to play, the A.I. will wait until the player has selected his/her battle card before playing them as to not interrupt the battle flow.
    3. The A.I. then selects the battle card to play against the player before entering the next phase.
    4. Determine if any victory conditions have been met. If they are, go to Finishing the Card Game Battle.
  5. Battle Phase
    1. Both player hands are visibly put away to not cause distractions.
    2. Both player's battle cards then move onto center stage where they're flipped over and revealed to each other.
      1. Pre-Battle Effects: If there are any pre-battle effects, such as boosting one's own stats or decreasing the other's, perform them here during this step.
      2. Battle Step: It's time to determine winner.

      3. Element Check: First, each card's element will be checked. If a card's element is superior to the other, that card instantly wins while the other loses, then go to the Post-Battle Effects step.
        1. Fire wins against Wind but loses against Water.
        2. Water wins against Fire but loses against Earth.
        3. Earth wins against Water but loses against Wind.
        4. Wind wins against Earth but loses against Fire.
        5. Light and Dark will both win and lose against each other resulting in a double K.O.
      4. Level Check: If neither card's element is superior to the other, then it's time to check each card's level. The card with the higher level will win while the other loses, then go to the Post-Battle Effects step.
      5. Power Check: If neither card's level is higher than the other, then it's time for the power check. The card with the higher power level will win while the other loses, then go to the Post-Battle Effects step.
      6. Health Check: This option has to be turned on from the plugin parameters. Otherwise, this part will be ignored. If neither card's power is higher than the other, then it's time for the health check. The card with a higher health value will win while the other loses, then go to the Post-Battle Effects step.
      7. Tie: If both players have not been able to determine a victor, then the results of that battle is a tie.
      8. Post-Battle Effects: This step would usually involve damaging the other player if the card won against them.
      9. Resolve Battle Effects: The battle cards then play resolve effects. By default, this will involve players discard their just battled cards regardless of them winning or losing. Some cards would be sent to the Exhaust Pile if their effects call for it. Also move the player's Hands back into the visible corner.
      10. Determine if any victory conditions have been met. If they are, go to Finishing the Card Game Battle.
  6. End Phase
    1. It's time to clean things up from the battle.
    2. End Phase Effects: Any card effects that would occur from the Hand, Library, Discard Pile, or Exhaust Pile that are programmed to activate at this time would activate at this time.
    3. Determine if any victory conditions have been met. If they are, go to Finishing the Card Game Battle.
    4. If there hasn't been a victor determined by this point, return back to the Upkeep Phase.
  7. Finishing the Card Game Battle
    1. Fade out all the assets.
    2. Determine if the player won, lost, or had a draw.
    3. Clear out the variables used in the battle.
    4. Resume the usual map activities.

All of that is evented so any bit of it can be cut out, changed, or expanded upon by you, the game dev. Keep in mind that I'm not responsible for any changes you have made to the custom evented battle system.

Custom Piles

A grouping of cards is called a 'pile'. There are multiple piles in a card game at times. Here are the ones that currently exist:

  • Hand: This refers to the cards in the player's hand and where cards go into

when the player draws.

  • Library: This refers to the stack of cards that make up the player's deck

that the player will draw from.

  • Discard: This is where the used up cards go. The player does not draw from

this, but the Discard pile does get recycled.

  • Exhaust: This is where the other used up cards go. The player does not draw

from this. This pile does not get recycled.

While this is plenty to get a basic card game out and going, it may not be enough for all the users out there. Therefore, custom piles are included so that game devs can add in their "Lands" pile, their "Spells/Traps" pile, their "Monster Zone" pile, and so on.

There are 26 custom piles that can be used, from Custom Pile A to Custom Pile Z. There is limited custom support for them since there's too many ways to go about custom piles, but of the support there is, you can find them in the plugin parameters under "Custom Pile Positioning" and the script calls.

Plugin Parameter: Custom Pile Positioning

Custom Piles aren't used in the sample project. However, for those who wish to customize the card game custom evented battle system further and make use of the custom piles, these plugin parameters will allow you to adjust the angle, scale, and other properties of them.

Script Calls

owner.removeCardFromCustomPile(card, letter)
- This will remove the specific card from a custom pile
- Replace 'owner' with $cardPlayer() or $cardOpponent()
- Replace 'card' with a card object to be removed
- Replace 'letter' with a string of the letter representing the pile
- Example: owner.removeCardFromCustomPile(card, 'A')
owner.addCardToPile(card, letter)
- This will add the specific card to a custom pile
- Replace 'owner' with $cardPlayer() or $cardOpponent()
- Replace 'card' with a card object to be added
- Replace 'letter' with a string of the letter representing the pile
- Example: owner.addCardToPile(card, 'A')
owner.setPileLocation(letter, x, y)
- Sets the location of a custom pile so that the sprites and such will be
aligned to it.
- Replace 'owner' with $cardPlayer() or $cardOpponent()
- Replace 'letter' with a letter from A to Z. This is a string and must be
surrounded by quotes.
- Replace 'x' with the X coordinates (center).
- Replace 'y' with the Y coordinates (center).
- Example: $cardPlayer().setPileLocation('A', 256, 360)
owner.pileLocationX(letter)
owner.pileLocationY(letter)
- Gets the stored X and Y locations of the custom piles.
- Replace 'owner' with $cardPlayer() or $cardOpponent()
- Replace 'letter' with a letter from A to Z. This is a string and must be
surrounded by quotes.
- Example: $cardPlayer().pileLocationX('A')
 $cardPlayer().pileLocationY('A')

Notetags

NotetagsMV.png

RPG Maker MV's editor is unable to allow for custom traits/properties that a game dev may wish to associate with a database object, event, map, etc. Notetags are used to work around such limitations by allowing the game dev to tag certain traits/properties using specific Notetags declared by the related plugin.

Here is a list of Notetag(s) that you may use.

---

You may have noticed that there are mentions of card effects that can occur at certain steps. While the majority of these notetags are custom made through events, this section will provide a list of them that are made available through the custom evented battle system:

Start Phase Notetags

<Card Hand Start JS>
code
code
</Card Hand Start JS>
- Runs the JavaScript 'code' inbetween the two notetags if the card is found
in your hand at the start of the game.
<Card Hand Start Common Event: x>
- Runs common event 'x' if the card is found in your hand at the start of
the game. The common event will run after the JavaScript runs.
<Card Discard Start JS>
code
code
</Card Discard Start JS>
- Runs the JavaScript 'code' inbetween the two notetags if the card is found
in discard hand at the start of the game.
<Card Discard Start Common Event: x>
- Runs common event 'x' if the card is found in your discard at the start of
the game. The common event will run after the JavaScript runs.
<Card Exhaust Start JS>
code
code
</Card Exhaust Start JS>
- Runs the JavaScript 'code' inbetween the two notetags if the card is found
in your exhaust at the start of the game.
<Card Hand Start Common Event: x>
- Runs common event 'x' if the card is found in your exhaust at the start of
the game. The common event will run after the JavaScript runs.
<Card Library Start JS>
code
code
</Card Library Start JS>
- Runs the JavaScript 'code' inbetween the two notetags if the card is found
in your library at the start of the game.
<Card Library Start Common Event: x>
- Runs common event 'x' if the card is found in your library at the start of
the game. The common event will run after the JavaScript runs.

Upkeep Phase Notetags

<Card Hand Upkeep JS>
code
code
</Card Hand Upkeep JS>
- Runs the JavaScript 'code' inbetween the two notetags if the card is found
in your hand during Upkeep Phase.
<Card Hand Upkeep Common Event: x>
- Runs common event 'x' if the card is found in your hand during Upkeep
Phase. The common event will run after the JavaScript runs.
<Card Discard Upkeep JS>
code
code
</Card Discard Upkeep JS>
- Runs the JavaScript 'code' inbetween the two notetags if the card is found
in discard hand during Upkeep Phase.
<Card Discard Upkeep Common Event: x>
- Runs common event 'x' if the card is found in your discard during Upkeep
Phase. The common event will run after the JavaScript runs.
<Card Exhaust Upkeep JS>
code
code
</Card Exhaust Upkeep JS>
- Runs the JavaScript 'code' inbetween the two notetags if the card is found
in your exhaust during Upkeep Phase.
<Card Hand Upkeep Common Event: x>
- Runs common event 'x' if the card is found in your exhaust during Upkeep
Phase. The common event will run after the JavaScript runs.
<Card Library Upkeep JS>
code
code
</Card Library Upkeep JS>
- Runs the JavaScript 'code' inbetween the two notetags if the card is found
in your library during Upkeep Phase.
<Card Library Upkeep Common Event: x>
- Runs common event 'x' if the card is found in your library during Upkeep
Phase. The common event will run after the JavaScript runs.

Draw Phase Notetags

<Card Hand Draw JS>
code
code
</Card Hand Draw JS>
- Runs the JavaScript 'code' inbetween the two notetags if the card is found
in your hand during Draw Phase.
<Card Hand Draw Common Event: x>
- Runs common event 'x' if the card is found in your hand during Draw
Phase. The common event will run after the JavaScript runs.
<Card Discard Draw JS>
code
code
</Card Discard Draw JS>
- Runs the JavaScript 'code' inbetween the two notetags if the card is found
in discard hand during Draw Phase.
<Card Discard Draw Common Event: x>
- Runs common event 'x' if the card is found in your discard during Draw
Phase. The common event will run after the JavaScript runs.
<Card Exhaust Draw JS>
code
code
</Card Exhaust Draw JS>
- Runs the JavaScript 'code' inbetween the two notetags if the card is found
in your exhaust during Draw Phase.
<Card Hand Draw Common Event: x>
- Runs common event 'x' if the card is found in your exhaust during Draw
Phase. The common event will run after the JavaScript runs.
<Card Library Draw JS>
code
code
</Card Library Draw JS>
- Runs the JavaScript 'code' inbetween the two notetags if the card is found
in your library during Draw Phase.
<Card Library Draw Common Event: x>
- Runs common event 'x' if the card is found in your library during Draw
Phase. The common event will run after the JavaScript runs.

Main Phase Notetags

<Card No Battle>
- This card is unable to battle.

- - -

<Card Spell 1 JS>
code
code
</Card Spell 1 JS>
- If this card's spell 1 is used, perform the JavaScript 'code' inbetween
the two notetags.
<Card Spell 1 Common Event: x>
- If this card's spell 1 is used, perform common event 'x'. The common event
will run after the JavaScript runs.
<Card Spell 1 Enable>
code
enable = code
</Card Spell 1 Enable>
- If this notetag is found, then the JavaScript 'code' will determine if the
'enable' variable is true/false, making the spell enabled or not.
<Card Spell 1 Icon: x>
- Uses icon 'x' for this card's spell 1.
<Card Spell 1 Name: x>
- Gives this card's spell 1 a name as 'x'.
<Card Spell 1 Animation: x>
- Plays animation 'x' when this card's spell 1 is used.
<Card Spell 1 Allow AI Use>
- Will allow the A.I. to use this card's spell 1.
<Card Spell 1 Check AI Use>
code
enable = code
</Card Spell 1 Check AI Use>
- If this notetag is found, then the JavaScript 'code' will determine if the
'enable' variable is true/false, making the spell allowed to be used by A.I.
or not. This can be used to prevent the A.I. from using healing at full HP.

- - -

<Card Spell 2 JS>
code
code
</Card Spell 2 JS>
- If this card's spell 2 is used, perform the JavaScript 'code' inbetween
the two notetags.
<Card Spell 2 Common Event: x>
- If this card's spell 2 is used, perform common event 'x'. The common event
will run after the JavaScript runs.
<Card Spell 2 Enable>
code
enable = code
</Card Spell 2 Enable>
- If this notetag is found, then the JavaScript 'code' will determine if the
'enable' variable is true/false, making the spell enabled or not.
<Card Spell 2 Icon: x>
- Uses icon 'x' for this card's spell 2.
<Card Spell 2 Name: x>
- Gives this card's spell 2 a name as 'x'.
<Card Spell 2 Animation: x>
- Plays animation 'x' when this card's spell 2 is used.
<Card Spell 2 Allow AI Use>
- Will allow the A.I. to use this card's spell 2.
<Card Spell 2 Check AI Use>
code
enable = code
</Card Spell 2 Check AI Use>
- If this notetag is found, then the JavaScript 'code' will determine if the
'enable' variable is true/false, making the spell allowed to be used by A.I.
or not. This can be used to prevent the A.I. from using healing at full HP.

- - -

<Card Spell 3 JS>
code
code
</Card Spell 3 JS>
- If this card's spell 3 is used, perform the JavaScript 'code' inbetween
the two notetags.
<Card Spell 3 Common Event: x>
- If this card's spell 3 is used, perform common event 'x'. The common event
will run after the JavaScript runs.
<Card Spell 3 Enable>
code
enable = code
</Card Spell 3 Enable>
- If this notetag is found, then the JavaScript 'code' will determine if the
'enable' variable is true/false, making the spell enabled or not.
<Card Spell 3 Icon: x>
- Uses icon 'x' for this card's spell 3.
<Card Spell 3 Name: x>
- Gives this card's spell 3 a name as 'x'.
<Card Spell 3 Animation: x>
- Plays animation 'x' when this card's spell 3 is used.
<Card Spell 3 Allow AI Use>
- Will allow the A.I. to use this card's spell 3.
<Card Spell 3 Check AI Use>
code
enable = code
</Card Spell 3 Check AI Use>
- If this notetag is found, then the JavaScript 'code' will determine if the
'enable' variable is true/false, making the spell allowed to be used by A.I.
or not. This can be used to prevent the A.I. from using healing at full HP.

- - -

<Card Spell 4 JS>
code
code
</Card Spell 4 JS>
- If this card's spell 4 is used, perform the JavaScript 'code' inbetween
the two notetags.
<Card Spell 4 Common Event: x>
- If this card's spell 4 is used, perform common event 'x'. The common event
will run after the JavaScript runs.
<Card Spell 4 Enable>
code
enable = code
</Card Spell 4 Enable>
- If this notetag is found, then the JavaScript 'code' will determine if the
'enable' variable is true/false, making the spell enabled or not.
<Card Spell 4 Icon: x>
- Uses icon 'x' for this card's spell 4.
<Card Spell 4 Name: x>
- Gives this card's spell 4 a name as 'x'.
<Card Spell 4 Animation: x>
- Plays animation 'x' when this card's spell 4 is used.
<Card Spell 4 Allow AI Use>
- Will allow the A.I. to use this card's spell 4.
<Card Spell 4 Check AI Use>
code
enable = code
</Card Spell 4 Check AI Use>
- If this notetag is found, then the JavaScript 'code' will determine if the
'enable' variable is true/false, making the spell allowed to be used by A.I.
or not. This can be used to prevent the A.I. from using healing at full HP.

- - -

There are four spells available per card. Nothing more provided by default.

Battle Phase Notetags

<Card AI Priority-behavior: x>
- This affects the A.I. only. It will make the A.I. pick specific cards over
others depending on the 'behavior' and the 'x' value.
- Replace 'behavior' with a string stating the behavior type to differentiate
different priority settings when a card has multiples of this notetag.
- Replace 'x' with a number depicting the priority value. Lower values mean
the card is less likely to be picked while higher priority means the card is
more likely to be picked.
- Example: <Card AI Priority-Strong: 50>
 <Card AI Priority-Strong: 25>
 <Card AI Priority-Weak: 60>
 <Card AI Priority-Weak: 30>
 <Card AI Priority-Tactical: 90>
 <Card AI Priority-Tactical: 45>

*NOTE* The A.I. will also pick from a pick list of cards using the 'Strong'
behavior. If a setting turns on the "$calc.pickWeakest" flag, then it will
use the 'Weak' behavior. Keep that in mind when making certain cards pickable
for discarding or adding to the hand.

- - -

<Card Pre-Battle JS>
code
code
</Card Pre-Battle JS>
- If this notetag is found, it will occur before damage calculations. It will
run the JavaScript 'code' found between the two notetags.
<Card Pre-Battle Common Event: x>
- If this notetag is found, it will occur before damage calculations. Perform
common event 'x'. The common event will run after the JavaScript runs.

- - -

<Card Tie Battle JS>
code
code
</Card Tie Battle JS>
- If this notetag is found, it will occur if the battle is tied. It will
run the JavaScript 'code' found between the two notetags.
<Card Tie Battle Common Event: x>
- If this notetag is found, it will occur if the battle is tied. Perform
common event 'x'. The common event will run after the JavaScript runs.

- - -

<Card Lose Battle JS>
code
code
</Card Lose Battle JS>
- If this notetag is found, it will occur if the card loses a battle. It will
run the JavaScript 'code' found between the two notetags.
<Card Lose Battle Common Event: x>
- If this notetag is found, it will occur if the card loses a battle. Perform
common event 'x'. The common event will run after the JavaScript runs.

- - -

<Card Win Battle JS>
code
code
</Card Win Battle JS>
- If this notetag is found, it will occur if the card wins a battle. It will
run the JavaScript 'code' found between the two notetags.
<Card Win Battle Common Event: x>
- If this notetag is found, it will occur if the card wins a battle. Perform
common event 'x'. The common event will run after the JavaScript runs.

*NOTE* If neither of the notetags are found in the card, then there will be
a default effect of dealing 5 damage to the opposing player's health. This
can be modified from within the ╘ Post-Damage Effects common event.

- - -

<Card Post-Battle JS>
code
code
</Card Post-Battle JS>
- If this notetag is found, it will occur after win/loss effects. It will
run the JavaScript 'code' found between the two notetags.

<pre>
<Card Post-Battle Common Event: x>
- If this notetag is found, it will occur after win/loss effects. Perform
common event 'x'. The common event will run after the JavaScript runs.

- - -

<Card Resolve Battle JS>
code
code
</Card Resolve Battle JS>
- If this notetag is found, it will occur after post-battle effects. It will
run the JavaScript 'code' found between the two notetags.
<Card Resolve Battle Common Event: x>
- If this notetag is found, it will occur after post-battle effects. Perform
common event 'x'. The common event will run after the JavaScript runs.

*NOTE* If neither of the notetags are found in the card, then there will be
a default effect of sending the card to the player's discard pile. This can
be modified from within the ╘ Post-Damage Effects common event.

End Phase Notetags

<Card Hand End JS>
code
code
</Card Hand End JS>
- Runs the JavaScript 'code' inbetween the two notetags if the card is found
in your hand during End Phase.
<Card Hand End Common Event: x>
- Runs common event 'x' if the card is found in your hand during End
Phase. The common event will run after the JavaScript runs.
<Card Discard End JS>
code
code
</Card Discard End JS>
- Runs the JavaScript 'code' inbetween the two notetags if the card is found
in discard hand during End Phase.
<Card Discard End Common Event: x>
- Runs common event 'x' if the card is found in your discard during End
Phase. The common event will run after the JavaScript runs.
<Card Exhaust End JS>
code
code
</Card Exhaust End JS>
- Runs the JavaScript 'code' inbetween the two notetags if the card is found
in your exhaust during End Phase.

<Card Hand End Common Event: x> - Runs common event 'x' if the card is found in your exhaust during End Phase. The common event will run after the JavaScript runs.

<Card Library End JS>
code
code
</Card Library End JS>
- Runs the JavaScript 'code' inbetween the two notetags if the card is found
in your library during End Phase.
<Card Library End Common Event: x>
- Runs common event 'x' if the card is found in your library during End
Phase. The common event will run after the JavaScript runs.

---

Script Calls

ScriptCallsMV.png

Script Calls are event commands that are used to run JavaScript code during an event to call upon unique functions, usually added by the related plugin.

Here is a list of Script Call(s) that you may use:

Use these script calls to help mold your custom evented battle system.

General Use Script Calls/JavaScript

$makeArrayOfCurrentDeck();
- Use this while you are in the Deck Builder scene.
- It will create an array of the currently selected deck, making it easier
for you to copy/paste array data when designing an opponent's deck.

-

$pickPlayerDeck(ruleset);
- Opens up a deck list for the player to pick from using a specific ruleset.
- Replace 'ruleset' with a ruleset from the Deck Builder plugin parameters.
- This must be a string so place quotes around it.
- Example: $pickPlayerDeck('Standard');

-

$wait(x)
- This will make the game wait 'x' frames. This can be used as a part of a
JavaScript code effect.
- The wait will not occur immediately in the code and make the rest of the
code wait until it is done. Sadly, that is not how code works. Instead, it
will run the entirity of the JavaScript code, then make the game wait 'x'
frames.
- If multiples of these are used, then the wait time will stack.

-

var deck = $newDeck(ruleset, name);
- This will create a new deck using the 'ruleset' and have a specific 'name'.
- This is primarily used for creating decks for your opponent.
- Example: $cardOpponent().deck = $newDeck('Standard', 'Burn Deck');

-

$calc = {};
- This turns the $calc variable into an open object, allowing it to take on
any data needed.

-

$selectedCard = null;
- This clears the $selectedCard variable.

-

$cardPlayer() and $cardOpponent Script Calls/JavaScript

$cardPlayer()
$cardOpponent()
- This will refer to the card player or opponent. Use it as a base class for
grabbing other necessary data.

-

owner.deck
- Returns the deck object used by the owner
- Replace 'owner' with $cardPlayer() or $cardOpponent()

-

owner.startHealth = x;
- Sets the starting health for that player to 'x'.
- Use this before the start of a card game battle.
- Replace 'owner' with $cardPlayer() or $cardOpponent()

-

owner.maxHealth
- Returns the owner's maximum health (determined by startHealth)
- Replace 'owner' with $cardPlayer() or $cardOpponent()

-

owner.currentHealth
- Returns the owner's current health (determined by startHealth initially)
- Replace 'owner' with $cardPlayer() or $cardOpponent()

-

owner.health
- Same as currentHealth
- Replace 'owner' with $cardPlayer() or $cardOpponent()

-

owner.shield
- Returns the owner's shield count
- Replace 'owner' with $cardPlayer() or $cardOpponent()

-

owner.shield = x
- Replace 'x' to change how many shields the owner would have
- Replace 'owner' with $cardPlayer() or $cardOpponent()

-

owner.actor
- Returns the actor used to represent the owner
- Replace 'owner' with $cardPlayer() or $cardOpponent()

-

owner.actor = x
- Sets the actor used to represent the owner as someone else.
- Replace 'x' with that actor's ID
- Replace 'owner' with $cardPlayer() or $cardOpponent()

-

owner.ai = 'behavior'
- Replace 'behavior' with an A.I. behavior pattern
- Example: $cardOpponent().ai = 'STRONG';
- Replace 'owner' with $cardPlayer() or $cardOpponent()

-

owner.allCards
- Returns an array of all the cards currently in the owner's possession
including the Library, Hand, Discard, Exhaust, and all the custom Piles
- Replace 'owner' with $cardPlayer() or $cardOpponent()

-

owner.library
- Returns an array of all the cards currently in the owner's Library
- Replace 'owner' with $cardPlayer() or $cardOpponent()

-

owner.discard
- Returns an array of all the cards currently in the owner's Discard Pile
- Replace 'owner' with $cardPlayer() or $cardOpponent()

-

owner.exhaust
- Returns an array of all the cards currently in the owner's Exhaust Pile
- Replace 'owner' with $cardPlayer() or $cardOpponent()

-

owner.hand
- Returns an array of all the cards currently in the owner's hand
- Replace 'owner' with $cardPlayer() or $cardOpponent()

-

owner.pileA
- Returns an array of all the cards currently in pileA for the owner.
- Replace 'owner' with $cardPlayer() or $cardOpponent()
- Piles can go from A to Z.

-

owner.battleCard
- Returns the card designated as the owner's battle card
- Replace 'owner' with $cardPlayer() or $cardOpponent()

-

owner.prepareForCardBattle();
- Initialize the deck owners, making them ready to battle in the upcoming
card game battle.
- Replace 'owner' with $cardPlayer() or $cardOpponent()

-

owner.setLibraryLocation(x, y)
owner.setDiscardLocation(x, y)
owner.setExhaustLocation(x, y)
- Sets the location of owner's specific pile so that all the sprites and such
will be aligned to it.
- Replace 'owner' with $cardPlayer() or $cardOpponent()
- Replace 'x' with the X coordinates (center).
- Replace 'y' with the Y coordinates (center).

-

owner.setPileLocation(letter, x, y)
- Sets the location of a custom pile so that the sprites and such will be
aligned to it.
- Replace 'owner' with $cardPlayer() or $cardOpponent()
- Replace 'letter' with a letter from A to Z. This is a string and must be
surrounded by quotes.
- Replace 'x' with the X coordinates (center).
- Replace 'y' with the Y coordinates (center).
- Example: $cardPlayer().setPileLocation('A', 256, 360)

-

owner.pileLocationX(letter)
owner.pileLocationY(letter)
- Gets the stored X and Y locations of the custom piles.
- Replace 'owner' with $cardPlayer() or $cardOpponent()
- Replace 'letter' with a letter from A to Z. This is a string and must be
surrounded by quotes.
- Example: $cardPlayer().pileLocationX('A')
 $cardPlayer().pileLocationY('A')

-

var shuffle = true;
var wait = false;
owner.readyCurrentDeck(shuffle, wait);
- Sets the deck location of an owner so that all the sprites and such will be
created there.
- Replace 'owner' with $cardPlayer() or $cardOpponent()
- Set 'shuffle' to true/false to shuffle the deck/not.
- Set 'wait' to true/false to apply wait frames.

-

owner.drawCard(cards, wait);
- Participant draws a card if they can.
- Replace 'owner' with $cardPlayer() or $cardOpponent()
- Replace 'cards' with number of cards drawn at once.
- Replace 'wait' with true or false
- If true, wait 10 frames between each draw.

-

owner.drawCardFromLibrary();
- Replace 'owner' with $cardPlayer() or $cardOpponent()
- Draws a card from the library.

-

owner.removeCardFromAllPiles(card);
- This will remove the specific card from all of the owner's piles
- Replace 'owner' with $cardPlayer() or $cardOpponent()
- Replace 'card' with a card object to be removed

-

owner.removeCardFromLibrary(card);
owner.removeCardFromDiscard(card);
owner.removeCardFromExhaust(card);
owner.removeCardFromHand(card);
- This will remove the specific card from the library, discard, exhaust, or
hand depending on which function is used.
- Replace 'owner' with $cardPlayer() or $cardOpponent()
- Replace 'card' with a card object to be removed

-

owner.removeCardFromCustomPile(card, letter)
- This will remove the specific card from a custom pile
- Replace 'owner' with $cardPlayer() or $cardOpponent()
- Replace 'card' with a card object to be removed
- Replace 'letter' with a string of the letter representing the pile
- Example: owner.removeCardFromCustomPile(card, 'A')

-

ower.addCardToLibrary(card, bottom)
- This will add a specific card to the library
- Replace 'owner' with $cardPlayer() or $cardOpponent()
- Replace 'card' with a card object to be added
- Replace 'bottom' with true or false to determine if it will go to the
bottom of the library or the top of the library.

-

owner.addCardToDiscard(card)
owner.addCardToExhaust(card)
owner.addCardToHand(card)
- This will add a specific card to one of the owner's piles depending on
which function is used.
- Replace 'owner' with $cardPlayer() or $cardOpponent()
- Replace 'card' with a card object to be added

-

owner.addCardToPile(card, letter)
- This will add the specific card to a custom pile
- Replace 'owner' with $cardPlayer() or $cardOpponent()
- Replace 'card' with a card object to be added
- Replace 'letter' with a string of the letter representing the pile
- Example: owner.addCardToPile(card, 'A')

-

owner.startAnimation(animationId, mirror, delay)
- This will play a battle animation on the owner
- Replace 'owner' with $cardPlayer() or $cardOpponent()
- Replace 'animationId' with the ID of the battle animation
- Replace 'mirror' with true or false depending if you want to mirror it/not
- Replace 'delay' with a number telling how many frames to delay it

-

owner.returnPileToLibrary(pile)
- This will return an entire pile to the owner's library
- Replace 'owner' with $cardPlayer() or $cardOpponent()
- Replace 'pile' with an array of cards like the following:
  - owner.discard
  - owner.exhaust
  - owner.hand
  - owner.pileA

-

owner.shuffleCards(pile)
- This will shuffle the selected pile
- Replace 'owner' with $cardPlayer() or $cardOpponent()
- Replace 'pile' with an array of cards like the following:
  - owner.library
  - owner.discard
  - owner.exhaust
  - owner.hand
  - owner.pileA

-

$scene() Script Calls/JavaScript

-

$scene().sortCardGameCardSprites();
- Sorts all the card sprites currently on the screen to make sure they are
positioned properly with their aligned piles/hands/libraries.

-

$scene().createCardGameHUDWindow();
- Creates a HUD for the Card Game.

-

$scene().fadeOutCardGameHUDWindow(duration)
- Fades out the HUD.
- Replace 'duration' with the number of frames to fade it out by.

-

$scene().refreshCardGameHUD();
- Refreshes the card game HUD window.

-

$scene().fadeOutPlayableCards(duration)
- Fades out all the playable cards on screen
- Replace 'duration' with the number of frames to fade them out by.

-

$scene().createCardGameHandWindow(owner, x, y, width, height, cardScale);
- Creates a window to hold the owner's cards in hand.
- Replace 'owner' with $cardPlayer() or $cardOpponent()
- Replace 'x' and 'y' with the x/y coordinates.
- Replace 'width' and 'height' for window width/height.
- Replace 'scale' with how small the cards are in hand.

-

$scene().activateCardGameHandWindow(owner);
- Activates the card window of a participant's hand.
- Replace 'owner' with $cardPlayer() or $cardOpponent()
- Picked card is then saved onto $selectedCard.

-

$scene().moveCardGameHandWindow(owner, x, y, duration);
- Moves the owner's hand window.
- Replace 'owner' with $cardPlayer() or $cardOpponent()
- Replace 'x' with the target X coordinate.
- Replace 'y' with the target Y coordinate.
- Replace 'duration' with the number of frames to move it by.

-

$scene().createCardGameBattleListWindow();
- Creates the card list window used when searching through card piles to pull
out a picked card.

-

$scene().setupCardGameBattleListWindow(array, text);
- Opens up the card list window with an array of cards and a text message.
- Replace 'array' with an array of cards to put into the window.
- Replace 'text' with the text to display.

-

$scene().removeCardGameBattleListWindow();
- This removes the card list window from the scene.
- Use this after the card game battle is over.

-

$scene().createCardGameBattleBrowseWindow();
- Creates the card browser window used when the player wants to look through
a Discard, Exhaust, etc. pile without interrupting gameplay.

-

$scene().registerCardGamePileLocation(pile, rect, text);
- Registers a pile into the card browser window.
- Replace 'pile' with the card pile that will be browsed into.
- Replcae 'rect' with a Rectangle object depicting the x, y, width, height
of the clickable space to trigger it with the mouse.
- Replace 'text' with the text message to be displayed if there is one.
- Example:

var pool = $cardPlayer().discard;
var rect = {
  x: $cardPlayer()._discardLocation.x - 50,
  y: $cardPlayer()._discardLocation.y - 50,
  width: 100,
  height: 100
}
var text = $cardPlayer().actor.name() + "'s Discarded Cards";
$scene().registerCardGamePileLocation(pool, rect, text);

-

$scene().removeCardGameBattleBrowserWindow();
- Removes the card browser window from the scene.
- Use this after the card game battle is over.

-

$scene().moveChoiceWindowToCard(card);
- Moves the choice window (event command) to where the target card object is
on the screen and shifted down a little bit.

- - -