about summary refs log tree commit diff stats
path: root/data/maps/the_impressive/rooms/Green Eye.txtpb
blob: d452e9e18992099fcf59322012e6efcc61cd1a65 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
name: "Green Eye"
display_name: "Impressive"
panels {
  name: "RETURN"
  path: "Panels/entry_5"
  clue: "return"
  answer: "turn"
  symbols: "sparkles"
}
panels {
  name: "TO"
  path: "Panels/entry_6"
  clue: "to"
  answer: "to"
}
panels {
  name: "LEFT"
  path: "Panels/entry_7"
  clue: "left"
  answer: "right"
  symbols: "sun"
}
ports {
  name: "PLAZA"
  path: "Components/Warps/worldport3"
  orientation: "east"
}
'>248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282
/*
 * Copyright (C) 2017 hatkirby
 *
 * This software may be modified and distributed under the terms
 * of the MIT license.  See the LICENSE file for details.
 */
#include "deserialize.h"
#include <stdio.h>
#include "encoding.h"

cJSON* pokemonToJson(const struct PokemonIntermediate* pki)
{
  char d_pokename[31];
  decodePokemonCharset(pki->nickname, 10, d_pokename, pki->language);

  char d_otName[22];
  decodePokemonCharset(pki->otName, 7, d_otName, pki->language);

  char d_key[57];
  sprintf(
    d_key,
    "%08lx%08lx%08lx%08lx%08lx%08lx%08lx",
    pki->key[0],
    pki->key[1],
    pki->key[2],
    pki->key[3],
    pki->key[4],
    pki->key[5],
    pki->key[6]);

  cJSON* jPoke = cJSON_CreateObject();

  cJSON_AddNumberToObject(
    jPoke,
    "species",
    __builtin_bswap16(pki->species));

  cJSON_AddItemToObject(
    jPoke,
    "nickname",
    cJSON_CreateString(d_pokename));

  cJSON_AddItemToObject(
    jPoke,
    "otName",
    cJSON_CreateString(d_otName));

  cJSON_AddNumberToObject(
    jPoke,
    "otId",
    __builtin_bswap16(pki->otId));

  cJSON_AddNumberToObject(
    jPoke,
    "level",
    pki->level);

  cJSON_AddNumberToObject(
    jPoke,
    "hp",
    __builtin_bswap32(pki->hp));

  cJSON_AddNumberToObject(
    jPoke,
    "attack",
    __builtin_bswap32(pki->attack));

  cJSON_AddNumberToObject(
    jPoke,
    "defense",
    __builtin_bswap32(pki->defense));

  cJSON_AddNumberToObject(
    jPoke,
    "speed",
    __builtin_bswap32(pki->speed));

  cJSON_AddNumberToObject(
    jPoke,
    "spAttack",
    __builtin_bswap32(pki->spAttack));

  cJSON_AddNumberToObject(
    jPoke,
    "spDefense",
    __builtin_bswap32(pki->spDefense));

  cJSON_AddNumberToObject(
    jPoke,
    "coolness",
    pki->cool);

  cJSON_AddNumberToObject(
    jPoke,
    "beauty",
    pki->beauty);

  cJSON_AddNumberToObject(
    jPoke,
    "cuteness",
    pki->cute);

  cJSON_AddNumberToObject(
    jPoke,
    "smartness",
    pki->smart);

  cJSON_AddNumberToObject(
    jPoke,
    "toughness",
    pki->tough);

  cJSON_AddNumberToObject(
    jPoke,
    "sheen",
    pki->sheen);

  cJSON_AddItemToObject(
    jPoke,
    "key",
    cJSON_CreateString(d_key));

  cJSON_AddNumberToObject(
    jPoke,
    "experience",
    __builtin_bswap32(pki->experience));

  cJSON_AddNumberToObject(
    jPoke,
    "heldItem",
    __builtin_bswap16(pki->heldItem));

  cJSON* jMoves = cJSON_CreateArray();

  for (int j=0; j<4; j++)
  {
    if (pki->moves[j] != 0)
    {
      cJSON* jMove = cJSON_CreateObject();

      cJSON_AddNumberToObject(
        jMove,
        "id",
        __builtin_bswap16(pki->moves[j]));

      cJSON_AddNumberToObject(
        jMove,
        "ppBonuses",
        (pki->ppBonuses >> (2*j)) & 3);

      cJSON_AddItemToArray(jMoves, jMove);
    } else {
      break;
    }
  }

  cJSON_AddItemToObject(
    jPoke,
    "moves",
    jMoves);

  if (pki->otGender)
  {
    cJSON_AddStringToObject(jPoke, "otGender", "female");
  } else {
    cJSON_AddStringToObject(jPoke, "otGender", "male");
  }

  cJSON_AddNumberToObject(
    jPoke,
    "metLevel",
    pki->metLevel);

  cJSON_AddNumberToObject(
    jPoke,
    "metLocation",
    pki->metLocation);

  cJSON_AddBoolToObject(
    jPoke,
    "shiny",
    pki->shiny);

  cJSON_AddNumberToObject(
    jPoke,
    "nature",
    pki->nature);

  if (pki->gender == 0)
  {
    cJSON_AddStringToObject(jPoke, "gender", "male");
  } else if (pki->gender == 1)
  {
    cJSON_AddStringToObject(jPoke, "gender", "female");
  } else if (pki->gender == 2)
  {
    cJSON_AddStringToObject(jPoke, "gender", "genderless");
  }

  cJSON_AddBoolToObject(
    jPoke,
    "secondAbility",
    pki->altAbility);

  // Handle Unown form.
  if (__builtin_bswap16(pki->species) == 201)
  {
    cJSON_AddNumberToObject(
      jPoke,
      "unownLetter",
      pki->unownLetter);
  }

  cJSON_AddNumberToObject(jPoke, "coolRibbons", pki->coolRibbons);
  cJSON_AddNumberToObject(jPoke, "beautyRibbons", pki->beautyRibbons);
  cJSON_AddNumberToObject(jPoke, "cuteRibbons", pki->cuteRibbons);
  cJSON_AddNumberToObject(jPoke, "smartRibbons", pki->smartRibbons);
  cJSON_AddNumberToObject(jPoke, "toughRibbons", pki->toughRibbons);

  u16 miscRibbons = __builtin_bswap16(pki->miscRibbons);
  if (miscRibbons & CHAMPION_RIBBON)
  {
    cJSON_AddBoolToObject(jPoke, "championRibbon", true);
  }

  if (miscRibbons & WINNING_RIBBON)
  {
    cJSON_AddBoolToObject(jPoke, "winningRibbon", true);
  }

  if (miscRibbons & VICTORY_RIBBON)
  {
    cJSON_AddBoolToObject(jPoke, "victoryRibbon", true);
  }

  if (miscRibbons & ARTIST_RIBBON)
  {
    cJSON_AddBoolToObject(jPoke, "artistRibbon", true);
  }

  if (miscRibbons & EFFORT_RIBBON)
  {
    cJSON_AddBoolToObject(jPoke, "effortRibbon", true);
  }

  if (miscRibbons & MARINE_RIBBON)
  {
    cJSON_AddBoolToObject(jPoke, "marineRibbon", true);
  }

  if (miscRibbons & LAND_RIBBON)
  {
    cJSON_AddBoolToObject(jPoke, "landRibbon", true);
  }

  if (miscRibbons & SKY_RIBBON)
  {
    cJSON_AddBoolToObject(jPoke, "skyRibbon", true);
  }

  if (miscRibbons & COUNTRY_RIBBON)
  {
    cJSON_AddBoolToObject(jPoke, "countryRibbon", true);
  }

  if (miscRibbons & NATIONAL_RIBBON)
  {
    cJSON_AddBoolToObject(jPoke, "nationalRibbon", true);
  }

  if (miscRibbons & EARTH_RIBBON)
  {
    cJSON_AddBoolToObject(jPoke, "earthRibbon", true);
  }

  if (miscRibbons & WORLD_RIBBON)
  {
    cJSON_AddBoolToObject(jPoke, "worldRibbon", true);
  }

  return jPoke;
}