Skip to content

Instantly share code, notes, and snippets.

@PauloDuarte43
Forked from ReyesK/pogo_moves.rb
Created May 14, 2019 18:21
Show Gist options
  • Save PauloDuarte43/536f53c0bb449adddf77d1a9503741bb to your computer and use it in GitHub Desktop.
Save PauloDuarte43/536f53c0bb449adddf77d1a9503741bb to your computer and use it in GitHub Desktop.
Script to export all moves from POGO GAME_MASTER
# Script to export all moves from POGO GAME_MASTER
# Shout out to pekingduck on github https://github.com/pekingduck - This script will run off the file provided by pekingduck found here: https://github.com/pekingduck/pogo-game-master/blob/master/current.json
# Written with ruby 2.3.3p222 (2016-11-21 revision 56859) [x86_64-darwin16]
# ran on MacOS 10.12.5
#
# run script from directory using `ruby pogo_moves.rb`
require "open-uri"
require "json"
require "csv"
# read current GAME_MASTER
url = "https://raw.githubusercontent.com/pekingduck/pogo-game-master/master/current.json"
gm = JSON.parse(open(url).read) # GAME_MASTER as json data
headers = ["Name", "Pokemon Type", "Move Type", "Power"]
moves = []
gm["item_templates"].each do |template|
move_settings = template["move_settings"]
if move_settings
move_name = template["template_id"].split("_MOVE_")[1] # whatever is after VXXXX_MOVE_ should be the move name
name = move_name.gsub("_FAST", "")
pokemon_type = move_settings["pokemon_type"].split("POKEMON_TYPE_")[1] # get value without POKEMON_TYPE_ prefix
move_type = move_name.include?("_FAST") ? "FAST" : "CHARGE" # fast moves include _FAST while charge moves have no suffix
moves << [name, pokemon_type, move_type, move_settings["power"]]
end
end
moves.sort_by!{ |move| move[0]}
CSV.open("pogo_moves.csv", "wb", {write_headers: true, headers: headers}) do |csv|
moves.each do |move|
csv << move
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment