Skip to content
This repository has been archived by the owner on Mar 3, 2022. It is now read-only.

JSON guide

Cyrielle edited this page Jan 18, 2020 · 14 revisions

The game uses the JSON format to store its data. Here is explained how it works for each object. The fields in italic are optional.

OpMon

The OpMons are stored in opmon.json. Here is an example of the format:

{
    "HP":65,
    "atk":60,
    "atkSpe":30,
    "def":58,
    "defSpe":52,
    "spe":33,
    "evolution":{
      "level":28,
      "species":7,
      "type":"level"
    },
    "evs":[
      6
    ],
    "opDex":4,
    "types":[
      6,
      -1
    ],
    "captureRate":45,
    "curve":1000000,
    "expGiven":93,
    "height":0.5,
    "weight":20.0
}

Warning : the JSON file has been generated automatically the first time, to spare some time. The fields are not in this order, but JSON works anyway, no matter the order. This example has been sorted to make it more understandable.

Field list

  • HP : The HP base stat (Integer)
  • atk : The attack base stat (Integer)
  • atkSpe : The special attack base stat (Integer)
  • def : The defense base stat (Integer)
  • defSpe : The special defense base stat (Integer)
  • spe : The Speed base stat (Integer)
  • evolution : Evolution data (Evolution)
  • evs : The given EVs when the OpMon is defeated (Array of stats)
  • opDex : The OpDex number of the OpMon. It determines the OpMon's name too, searches in the key opmon.name.X where X is the opDex value. If you want to add an OpMon, don't forget to add its name in the keys files. (Integer)
  • types : The two types of the OpMon (Two types in an array)
  • captureRate : The OpMon's capture rate. If it's low, the OpMon will be hard to capture, and vice versa (Integer)
  • curve : The EXP the OpMon will have at level 100 (Standard max EXP)
  • expGiven : The base EXP the OpMon will give when defeated (Integer)
  • height : The OpMon's height (Floating)
  • weight : The OpMon's weight (Floating)

Attacks

Warning: Attacks is a translation of "Attaques" in french, which is the official translation for the Pokémon "moves". The term "Attack" will soon be changed for "Move".

The moves are stored in attacks.json. Here is an example of the format:

 {
     "id" : "Tackle",
     "power" : 50,
     "type" : 9,
     "accuracy" : 100,
     "special" : false,
     "status" : false,
     "criticalRate" : 16,
     "neverFails" : false,
     "ppMax" : 35,
     "priority" : 0,
     "effects" : [
         {
             "null" : true
         },
         {
             "null" : true
         },
         {
             "null" : true
         }
     ],
     "animationOrder" : [18],
     "opMovementsAtk" : [
         {
             "translation" : {
                 "mode" : [ 1, 1 ],
                 "formulas" : [ [ 3, -6, 1, -5, 0, 30 ], [ 3, 6, 1, -5, 0, -30 ] ]
             },
             "time" : 10
         }
     ],
     "opMovementsDef" : [
         {
             "translation" : {
                 "mode" : [ 1, 1 ],
                 "formulas" : [ [ 3, 6, 1, -5, 0, -30 ], [ 3, -6, 1, -5, 0, 30 ] ]
             },
             "time" : 10
         }

     ],
     "animations" : ["default"]
 },

Field list

  • id : The identifier of the move. It is used to identify it in the code, but also to get its name in the different languages. (String)
  • power : The power of the move (Integer)
  • type : The type of the attack (Type)
  • accuracy : The accuracy of the move (Integer)
  • special : true if it's a special move, false otherwise (Boolean)
  • status : true if it's a status move (If it doesn't directly damages the opponent), false otherwise (Boolean)
  • criticalRate : The odds of getting a critical hit (1 out of the input) (Integer)
  • neverFails : true if the move never fails (Boolean)
  • ppMax : The maximum PP of the move (Integer)
  • priority : The level of priority of the move (Integer)
  • effects : An array of 3 effects. Respectively the effect before the damages, the effect after the damages, and the effect if the move fails. (Effect)
  • animationOrder : The order in which the animations will occur (TurnActionType)
  • opMovementsAtk : An array of sprite animations for the player's OpMon using the move. (Array of Sprite animations)
  • opMovementsDef : An array of sprite animations for the opponent's OpMon using the move. (Array of Sprite animations)
  • animations : An array of strings identifying the different screen animations present in the code (Screen animation)

Special

Evolution

There is several types of evolutions. Every Evolution has the "type" field, which can be filled with the type name.

Type : "no"

"evolution":{
      "level":-1,
      "species":-1,
      "type":"no"
}

The type "no" means no evolution. "level" and "species" must stay to -1.

Type : "level"

"evolution":{
      "level":28,
      "species":7,
      "type":"level"
}
  • level : The level at which the OpMon evolves (Number)
  • species : The opDex number of the species in which the OpMon evolves (Number)

Stats

Each stat is associated to a number, according to the enumeration in src/opmon/model/objects/Enums.hpp :

enum class Stats : int {
            ATK = 6,
            DEF = 1,
            ATKSPE = 2,
            DEFSPE = 3,
            SPE = 4,
            HP = 5,
            ACC = 7,
            EVA = 8,
            NOTHING = 0
};

There isn't EVs for accuracy, evasion and nothing, so putting these values will result in an undefined behavior.

Types

Each type is associated to a number, according to the enumeration in src/opmon/model/objects/Enums.hpp

enum class Type : int {
            LIQUID = 3,
            BURNING = 6,
            VEGETAL = 10,
            ELECTRON = 4,
            MENTAL = 12,
            BAD = 16,
            DRAGON = 2,
            FIGHT = 1,
            MINERAL = 13,
            GROUND = 14,
            NEUTRAL = 9,
            MAGIC = 5,
            GHOST = 15,
            TOXIC = 11,
            METAL = 0,
            BUG = 8,
            SKY = 17,
            COLD = 7,
            NOTHING = -1
};

Nothing isn't really a type, so putting this value will result in an undefined behavior.

Standard max EXP

There is different possible values for max EXP, each one corresponding to a different curve of EXP (Bulbapedia link).

  • 800,000 : Quick EXP curve
  • 1,000,000 : Normal EXP curve
  • 1,059,860 : Parabolic EXP curve
  • 1,250,000 : Slow EXP curve
  • 600,000 : Erratic EXP curve
  • 1,640,000 : Fluctuating EXP curve If some another value is entered, the default curve will be the normal one.

Effect

Exemple of effect

{
"null" : false,
"type" : "ChangeStatEffect",
"data" : {
    "target" : 1,
    "stat" : 6,
    "coef" : -1
}
}

Represents an effect present in the code. If "null" is true, the code ignores the object and assumes there is no effect. Else, there can be different types of effects that must be present into the code, identified by "type". Each effect takes different arguments in "data".

Current list of effects :

ChangeStatEffect

  • target : The target of the effect change. If 0, the target is OpMon using the move. If 1, it is the OpMon taking the move. (Integer)
  • stat : The stat modified by the effect (Stat)
  • coef : The coefficient of modification of the stat. It can be from -6 (The stat decreases 6 times) to 6 (The stat increases 6 times). (Integer between -6 and 6)

TurnActionType

The enumeration TurnActionType contains a lot of things in the code. Normally, for the animations, you'll only have to use two:

enum class TurnActionType : unsigned int {
[...]
ANIMATION = 17,
OPANIM = 18,
[...]
};

Note: If you want to break the game and use others, see Turn.hpp

  • ANIMATION: A screen animation will be played.
  • OPANIM: A sprite animation will be played. The animations are taken from first to last initialized in the JSON file. Exemple (The texts between parenthesis are comments, [...] replaces some code describing animations):
"opMovementAtk" : [
{[...]}, (OpAnim 1)
{[...]}, (OpAnim 2)
{[...]}, (OpAnim 3)
],
"opMovementDef" : [[...]], (The same number of animations here)
"animations" : ["sanim1","sanim2"]

In this exemple, if "animationOrder" : [18, 17, 18, 17, 18], the order of animations will be OpAnim 1 - sanim1 - OpAnim 2 - sanim2 - OpAnim 3. Warning: Putting more values in "animationOrder" than the number of animations will result in an undefined behavior.

Sprite Animation

Example of animation:

{
    "translation" : {
        "mode" : [0,1],
        "formulas" : [ [1,5,8,3], [ 3, -6, 1, -5, 0, 30 ] ]
    },
    "rotation" : {
        "mode" : 1,
        "formula" : [1, 2.0001, 1, 0, 0, -2.25],
        "origin" : [0,0]
    },
    "scaling" : {
        "mode" : [1,1],
        "formulas" : [ [2, -1, 3.14, -6.28], [4, 2, 8.15, 0.5, 4, 1, 0, 2] ],
        "origin" : [50,50]
    },
    "time" : 15
}
  • time : The duration of the animation, in frames (Integer)

There is three transformations which will compose the final animation. But they have all things in common :

Mode and formulas

The different transformations use formulas depending on time, in frames. The translation and the scaling use their first formula for the width, and the second for the height. The rotation use its only formula for the angle of rotation.

The system of formulas in OpMon is constructed with modes of interpretations of arrays. You can input any kind of floating number, positive or negative.

Mode 0 : Polynomial formulas

Every item of the array is the coefficient of a polynomial formula. Exemple: The array [2, 8, 2.6, 7.15] will be treated as 2 + 8t + 2.6t^2 + 7.15t^3

Mode 1 : Formulas with different base functions

This mode is a bit more complex. It works with the basic format [FUNCTION_ID, arg1, arg2, ..., FUNCTION_ID, arg1...] (You can put several function one after the other). Technically, you can input floating numbers or other numbers than those specified here for FUNCTION_ID, but if you do you'll surely break the program. This system will be improved in the future to allow more functions and formulas. Here is a list of the available functions :

0 : ·1 function
  • Use : [0, a]. The formula will interpret it as simply a.
  • Example : [0, 2]. The formula will be 2.
1 : Sine function
  • Use : [1, a, b, c]. The formula will interpret it as a·sin(b·t + c).
  • Example : [1, 3, -2.4, 0]. The formula will be 3sin(-2.4·t).
  • Warning : The sine function works with radians (2pi-periodic).
  • Note : If you leave "a" to 0, the function will be 0. If you leave "b" to 0, it will be the constant a·sin(c).
2 : Cosine function
  • Use : [2, a, b, c]. The formula will interpret it as a·cos(b·t + c).
  • Note : Basically works like the sine function.
3 : Absolute value function
  • Use : [3, a, b, c]. The formula will interpret it as a·|b·t + c|.
  • Note : Also works like the sinus function.
4 : Power function
  • Use : [4, ... another function ..., a].
  • Example : [4, 2, 1.2, 2, -4, 2] will be interpreted as (1.2·cos(2t - 4))^2
  • Warning : Unimplemented yet.

Origin

The origin is for the rotation and scaling, and it defines the origin of the transformation. You have to enter the coordinates of this origin in the [x,y] format.

Screen animation

These are animations played on the whole screen. It consists in images put one after the other. They must be registered in the code. Currently, none has been created.

Clone this wiki locally