Merge master branch into branch 'black-and-white-2'

Conflicts:
	pokedex/data/csv/pokemon_forms.csv
	pokedex/data/csv/pokemon_species.csv
This commit is contained in:
Lynn "Zhorken" Vaughan 2012-06-21 14:21:11 -04:00
commit b8ece53720
31 changed files with 11820 additions and 1481 deletions

40
bin/reset-postgresql-sequences Executable file
View file

@ -0,0 +1,40 @@
#!/usr/bin/env python2
import sys
from sqlalchemy.sql import func
from sqlalchemy.types import Integer
from pokedex.db import connect
from pokedex.db.tables import mapped_classes
import optparse
parser = optparse.OptionParser()
parser.add_option('-v', '--verbose', action='store_true', default=False,
help="verbose output")
parser.add_option('-e', '--engine', dest='engine_uri', default=None,
help="database engine uri")
options, _ = parser.parse_args(sys.argv[1:])
session = connect(options.engine_uri)
assert session.connection().dialect.name == 'postgresql'
def sequence_columns(table):
for c in table.__table__.primary_key:
if c.autoincrement and not c.foreign_keys and \
isinstance(c.type, Integer):
yield c
for table in sorted(mapped_classes):
table_name = table.__tablename__
for c in sequence_columns(table):
max_value, = session.query(func.max(c)).one()
if options.verbose:
print "%s.%s <- %s" % (table_name, c.name, max_value)
session.execute(func.setval(
func.pg_get_serial_sequence(table_name, c.name),
max_value,
))

2
doc/.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
/_build/
/_gh-pages/

146
doc/Makefile Normal file
View file

@ -0,0 +1,146 @@
# Makefile for Sphinx documentation
#
# You can set these variables from the command line.
SPHINXOPTS =
SPHINXBUILD = sphinx-build
PAPER =
BUILDDIR = _build
# Internal variables.
PAPEROPT_a4 = -D latex_paper_size=a4
PAPEROPT_letter = -D latex_paper_size=letter
ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest
all: doctest
$(MAKE) html coverage
commit:
mkdir -p _gh-pages
(cd _gh-pages && git init || true)
rm -rf _build/html/.git
cp -r _gh-pages/.git _build/html
(cd _build/html && git add . && git commit -m "sphinx build $$(date --rfc-3339=seconds)" || true)
(cd _gh-pages && git pull ../_build/html)
help:
@echo "Please use \`make <target>' where <target> is one of"
@echo " html to make standalone HTML files"
@echo " dirhtml to make HTML files named index.html in directories"
@echo " singlehtml to make a single large HTML file"
@echo " pickle to make pickle files"
@echo " json to make JSON files"
@echo " htmlhelp to make HTML files and a HTML help project"
@echo " qthelp to make HTML files and a qthelp project"
@echo " devhelp to make HTML files and a Devhelp project"
@echo " epub to make an epub"
@echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
@echo " latexpdf to make LaTeX files and run them through pdflatex"
@echo " text to make text files"
@echo " man to make manual pages"
@echo " changes to make an overview of all changed/added/deprecated items"
@echo " linkcheck to check all external links for integrity"
@echo " doctest to run all doctests embedded in the documentation (if enabled)"
clean:
-rm -rf $(BUILDDIR)/*
html:
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
touch $(BUILDDIR)/html/.nojekyll
@echo
@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
dirhtml:
$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
@echo
@echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
singlehtml:
$(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
@echo
@echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."
pickle:
$(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
@echo
@echo "Build finished; now you can process the pickle files."
json:
$(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
@echo
@echo "Build finished; now you can process the JSON files."
htmlhelp:
$(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
@echo
@echo "Build finished; now you can run HTML Help Workshop with the" \
".hhp project file in $(BUILDDIR)/htmlhelp."
qthelp:
$(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
@echo
@echo "Build finished; now you can run "qcollectiongenerator" with the" \
".qhcp project file in $(BUILDDIR)/qthelp, like this:"
@echo "# qcollectiongenerator $(BUILDDIR)/qthelp/pokedex.qhcp"
@echo "To view the help file:"
@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/pokedex.qhc"
devhelp:
$(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
@echo
@echo "Build finished."
@echo "To view the help file:"
@echo "# mkdir -p $$HOME/.local/share/devhelp/pokedex"
@echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/pokedex"
@echo "# devhelp"
epub:
$(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub
@echo
@echo "Build finished. The epub file is in $(BUILDDIR)/epub."
latex:
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
@echo
@echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
@echo "Run \`make' in that directory to run these through (pdf)latex" \
"(use \`make latexpdf' here to do that automatically)."
latexpdf:
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
@echo "Running LaTeX files through pdflatex..."
make -C $(BUILDDIR)/latex all-pdf
@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
text:
$(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text
@echo
@echo "Build finished. The text files are in $(BUILDDIR)/text."
man:
$(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man
@echo
@echo "Build finished. The manual pages are in $(BUILDDIR)/man."
changes:
$(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
@echo
@echo "The overview file is in $(BUILDDIR)/changes."
linkcheck:
$(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
@echo
@echo "Link check complete; look for any errors in the above output " \
"or in $(BUILDDIR)/linkcheck/output.txt."
doctest:
$(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
@echo "Testing of doctests in the sources finished, look at the " \
"results in $(BUILDDIR)/doctest/output.txt."
coverage:
$(SPHINXBUILD) -b coverage $(ALLSPHINXOPTS) $(BUILDDIR)/coverage
cat $(BUILDDIR)/coverage/*.txt

230
doc/conf.py Normal file
View file

@ -0,0 +1,230 @@
# -*- coding: utf-8 -*-
#
# pokedex documentation build configuration file, created by
# sphinx-quickstart on Tue Apr 12 17:43:05 2011.
#
# This file is execfile()d with the current directory set to its containing dir.
#
# Note that not all possible configuration values are present in this
# autogenerated file.
#
# All configuration values have a default; values that are commented out
# serve to show the default.
import sys, os
reload(sys)
sys.setdefaultencoding("UTF-8")
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#sys.path.insert(0, os.path.abspath('.'))
# -- General configuration -----------------------------------------------------
# If your documentation needs a minimal Sphinx version, state it here.
#needs_sphinx = '1.0'
# Add any Sphinx extension module names here, as strings. They can be extensions
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.doctest',
'sphinx.ext.todo',
'sphinx.ext.pngmath',
'sphinx.ext.intersphinx',
#'sphinx.ext.viewcode',
'sphinx.ext.coverage',
'pokedex.doc.tabledoc',
]
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
# The suffix of source filenames.
source_suffix = '.rst'
# The encoding of source files.
source_encoding = 'utf-8'
# The master toctree document.
master_doc = 'index'
# General information about the project.
project = u'pokedex'
copyright = u'2011, Alex Munroe (Eevee)'
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = '0.1'
# The full version, including alpha/beta/rc tags.
release = '0.1'
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#language = None
# There are two options for replacing |today|: either, you set today to some
# non-false value, then it is used:
#today = ''
# Else, today_fmt is used as the format for a strftime call.
#today_fmt = '%B %d, %Y'
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
exclude_patterns = ['_build']
# The reST default role (used for this markup: `text`) to use for all documents.
#default_role = None
# If true, '()' will be appended to :func: etc. cross-reference text.
#add_function_parentheses = True
# If true, the current module name will be prepended to all description
# unit titles (such as .. function::).
add_module_names = True
# If true, sectionauthor and moduleauthor directives will be shown in the
# output. They are ignored by default.
#show_authors = False
# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'
# A list of ignored prefixes for module index sorting.
#modindex_common_prefix = []
intersphinx_mapping = {'sqlalchemy': ('http://www.sqlalchemy.org/docs', None)}
# -- Options for HTML output ---------------------------------------------------
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
html_theme = 'default'
# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
#html_theme_options = {}
# Add any paths that contain custom themes here, relative to this directory.
#html_theme_path = []
# The name for this set of Sphinx documents. If None, it defaults to
# "<project> v<release> documentation".
#html_title = None
# A shorter title for the navigation bar. Default is the same as html_title.
#html_short_title = None
# The name of an image file (relative to this directory) to place at the top
# of the sidebar.
#html_logo = None
# The name of an image file (within the static path) to use as favicon of the
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
# pixels large.
#html_favicon = None
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
# using the given strftime format.
#html_last_updated_fmt = '%b %d, %Y'
# If true, SmartyPants will be used to convert quotes and dashes to
# typographically correct entities.
#html_use_smartypants = True
# Custom sidebar templates, maps document names to template names.
#html_sidebars = {}
# Additional templates that should be rendered to pages, maps page names to
# template names.
#html_additional_pages = {}
# If false, no module index is generated.
#html_domain_indices = True
# If false, no index is generated.
#html_use_index = True
# If true, the index is split into individual pages for each letter.
#html_split_index = False
# If true, links to the reST sources are added to the pages.
#html_show_sourcelink = True
# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
#html_show_sphinx = True
# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
html_show_copyright = False
# If true, an OpenSearch description file will be output, and all pages will
# contain a <link> tag referring to it. The value of this option must be the
# base URL from which the finished HTML is served.
#html_use_opensearch = ''
# This is the file name suffix for HTML files (e.g. ".xhtml").
#html_file_suffix = None
# Output file base name for HTML help builder.
htmlhelp_basename = 'pokedexdoc'
# -- Options for LaTeX output --------------------------------------------------
# The paper size ('letter' or 'a4').
#latex_paper_size = 'letter'
# The font size ('10pt', '11pt' or '12pt').
#latex_font_size = '10pt'
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title, author, documentclass [howto/manual]).
latex_documents = [
('index', 'pokedex.tex', u'Pokedex Documentation',
u'veekun', 'manual'),
]
# The name of an image file (relative to this directory) to place at the top of
# the title page.
#latex_logo = None
# For "manual" documents, if this is true, then toplevel headings are parts,
# not chapters.
#latex_use_parts = False
# If true, show page references after internal links.
#latex_show_pagerefs = False
# If true, show URL addresses after external links.
#latex_show_urls = False
# Additional stuff for the LaTeX preamble.
#latex_preamble = ''
# Documents to append as an appendix to all manuals.
#latex_appendices = []
# If false, no module index is generated.
#latex_domain_indices = True
# -- Options for manual page output --------------------------------------------
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
('index', 'pokedex', u'Pokedex Documentation',
[u'veekun'], 1)
]

25
doc/index.rst Normal file
View file

@ -0,0 +1,25 @@
.. pokedex documentation master file, created by
sphinx-quickstart on Tue Apr 12 17:43:05 2011.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
The pokedex documentation
=========================
Jump right in!
Contents:
.. toctree::
:maxdepth: 2
installing
usage
schema
Indices and tables
==================
* :ref:`genindex`
* :ref:`search`

156
doc/installing.rst Normal file
View file

@ -0,0 +1,156 @@
Installing the pokedex library
==============================
Quick startup with Ubuntu/Debian-like systems
---------------------------------------------
Run the following from an empty directory::
$ sudo apt-get install git python python-pip python-sqlalchemy
$ git clone git://github.com/veekun/pokedex.git
$ pip install -E env -e pokedex
$ source env/bin/activate
(env)$ pokedex setup -v
(env)$ pokedex lookup eevee
If it all goes smoothly, you can now use ``env/bin/pokedex``, the command-line
tool, and ``env/bin/python``, a Python interpreter configured to use the
pokedex library.
That is all you need. Feel free to skip the rest of this chapter if you're not
interested in the details.
Prerequisites
-------------
Linux
^^^^^
Ubuntu/Debian users should run the following::
$ sudo apt-get install git python python-pip
With other Linuxes, install the packages for git, python (2.6 or 2.7,
*not* 3.x), and python-pip.
If you succeeded, skip the Detailed instructions.
Detailed instructions
^^^^^^^^^^^^^^^^^^^^^
You should know what a command line is and how to work with it.
The here we assume you're using Linux [#]_, if that's not the case, make
sure you have enough computer knowledge to translate the instructions to your
operating system.
Pokedex is distributed via Git_. So, get Git.
You will also need Python_ 2; the language pokedex is written in. Be sure to get
version **2.6** or **2.7**. Pokedex does not work with Python 3.x yet, and it
most likely won't work with 2.5 or earlier.
Next, get pip_, a tool to install Python packages. Experts can use another
tool, of course.
Make sure git and pip are on your path.
Optionally you can install SQLAlchemy_, `Python markdown`_, Whoosh_,
or construct_. If you don't, pip will atuomatically download and install a copy
for you, but some are pretty big so you might want to install it system-wide.
(Unfortunately, many distros have outdated versions of these libraries, so pip
will install pokedex's own copy anyway.)
Getting and installing pokedex
------------------------------
Run the following from an empty directory::
$ git clone git://git.veekun.com/pokedex.git
$ pip install -E env -e pokedex
This will give you two directories: pokedex (containing the source code and
data), and env (a virtualenv_).
In env/bin, there are three interesting files:
* pokedex: The pokedex program
* python: A copy of Python that knows about pokedex and its prerequisites.
* activate: Typing ``source env/bin/activate`` in a shell will put
pokedex and our bin/python on the $PATH, and generally set things up to work
with them. Your prompt will change to let you know of this. You can end such
a session by typing ``deactivate``.
This documentation will assume that you've activated the virtualenv, so
``pokedex`` means ``env/bin/pokedex``.
Advanced
^^^^^^^^
You can of course install into an existing virtualenv, by either using its pip
and leaving out the ``-E env``, or running the setup script directly::
(anotherenv)$ cd pokedex
(anotherenv)pokedex$ python setup.py develop
It is also possible to install pokedex system-wide. There are problems with
that. Don't do it. The only time you need ``sudo`` is for getting the
prerequisites.
Loading the database
--------------------
Before you can do anything useful with pokedex, you need to load the database::
$ pokedex setup -v
This will load the data into a default SQLite database and create a default
Whoosh index.
Advanced
^^^^^^^^
If you want to use another database, make sure you have the corresponding
`SQLAlchemy engine`_ for it and either use the ``-e`` switch, (e.g.
``-e postgresql://@/pokedex``), or set the ``POKEDEX_DB_ENGINE`` environment
variable.
To use another lookup index directory, specify it with ``-i`` or the
``POKEDEX_INDEX_DIR`` variable.
Make sure you always use the same options whenever you use pokedex.
If you're confused about what pokedex thinks its settings are, check
``pokedex status``.
See ``pokedex help`` for even more options.
All done
--------
To verify that all went smoothly, check that the pokedex tool finds your
favorite pokémon::
$ pokedex lookup eevee
Yes, that was a bit anti-climatic. The command-line tool doesn't do much,
currently.
.. _Git: http://git-scm.com/
.. _Python: http://www.python.org/
.. _pip: http://pypi.python.org/pypi/pip
.. _SQLAlchemy: www.sqlalchemy.org/
.. _`Python markdown`: http://www.freewisdom.org/projects/python-markdown/
.. _Whoosh: http://whoosh.ca/
.. _construct: pypi.python.org/pypi/construct
.. _virtualenv: http://www.virtualenv.org/en/latest/
.. _`SQLAlchemy engine`: http://www.sqlalchemy.org/docs/core/engines.html
.. rubric:: Footnotes
.. [#] If you write instructions for another OS, well be happy to include them
here. The reason your OS is not listed here is because the author doesn't
use it, so naturally he can't write instructions for it.

179
doc/main-tables.rst Normal file
View file

@ -0,0 +1,179 @@
The pokédex tables
==================
.. module:: pokedex.db.tables
The :mod:`pokedex.db.tables` module defines all of the tables in the Pokédex.
They are all defined with SQLAlchemy's
:mod:`~sqlalchemy.ext.declarative` extension.
To introspect the tables programmatically, you can use the following:
.. data:: mapped_classes
A list of all the classes you see below.
.. data:: metadata
The SQLAlchemy :class:`~sqlalchemy.schema.MetaData` containing all the
tables.
Each of the classes has a ``translation_classes`` attribute: a potentially
empty list of translation classes. See :mod:`pokedex.db.multilang` for how
these work.
Many tables have these columns:
- **id**: An integer primary key. Sometimes it's semantically meaningful, most
often it isn't.
- **identifier**: A string identifier of the class, and the preferred way to
access individual items.
- **name**: A name (uses the multilang functionality)
Pokémon
-------
.. dex-table:: PokemonSpecies
.. dex-table:: Pokemon
.. dex-table:: PokemonForm
.. dex-table:: EvolutionChain
.. dex-table:: PokemonEvolution
Moves
-----
.. dex-table:: Move
.. dex-table:: MoveEffect
.. dex-table:: MoveMeta
Items
-----
.. dex-table:: Item
.. dex-table:: Berry
Types
-----
.. dex-table:: Type
Abilities
---------
.. dex-table:: Ability
Language
--------
.. dex-table:: Language
Version stuff
-------------
.. dex-table:: Generation
.. dex-table:: VersionGroup
.. dex-table:: Version
.. dex-table:: Pokedex
.. dex-table:: Region
Encounters
----------
.. dex-table:: Location
.. dex-table:: LocationArea
.. dex-table:: LocationAreaEncounterRate
.. dex-table:: Encounter
.. dex-table:: EncounterCondition
.. dex-table:: EncounterConditionValue
.. dex-table:: EncounterMethod
.. dex-table:: EncounterSlot
Contests
--------
.. dex-table:: ContestCombo
.. dex-table:: ContestEffect
.. dex-table:: SuperContestCombo
.. dex-table:: SuperContestEffect
Enum tables
-----------
.. dex-table:: BerryFirmness
.. dex-table:: ContestType
.. dex-table:: EggGroup
.. dex-table:: EvolutionTrigger
.. dex-table:: GrowthRate
.. dex-table:: ItemCategory
.. dex-table:: ItemFlingEffect
.. dex-table:: ItemPocket
.. dex-table:: MoveBattleStyle
.. dex-table:: MoveDamageClass
.. dex-table:: MoveMetaAilment
.. dex-table:: MoveMetaCategory
.. dex-table:: MoveTarget
.. dex-table:: Nature
.. dex-table:: PalParkArea
.. dex-table:: PokemonColor
.. dex-table:: PokemonMoveMethod
.. dex-table:: PokemonShape
.. dex-table:: Stat
Changelogs
----------
.. dex-table:: AbilityChangelog
.. dex-table:: MoveEffectChangelog
.. dex-table:: MoveChangelog
Flavor text
-----------
.. dex-table:: ItemFlavorText
.. dex-table:: AbilityFlavorText
.. dex-table:: MoveFlavorText
.. dex-table:: PokemonSpeciesFlavorText
Association tables
------------------
.. dex-table:: BerryFlavor
.. dex-table:: EncounterConditionValueMap
.. dex-table:: ItemFlag
.. dex-table:: ItemFlagMap
.. dex-table:: Machine
.. dex-table:: MoveFlag
.. dex-table:: MoveFlagMap
.. dex-table:: MoveMetaStatChange
.. dex-table:: NatureBattleStylePreference
.. dex-table:: NaturePokeathlonStat
.. dex-table:: PokeathlonStat
.. dex-table:: PokemonAbility
.. dex-table:: PokemonEggGroup
.. dex-table:: PokemonFormPokeathlonStat
.. dex-table:: PokemonHabitat
.. dex-table:: PokemonMove
.. dex-table:: PokemonStat
.. dex-table:: PokemonItem
.. dex-table:: PokemonType
.. dex-table:: TypeEfficacy
.. dex-table:: VersionGroupPokemonMoveMethod
.. dex-table:: VersionGroupRegion
Index maps
----------
.. dex-table:: ItemGameIndex
.. dex-table:: LocationGameIndex
.. dex-table:: PokemonDexNumber
.. dex-table:: PokemonFormGeneration
.. dex-table:: PokemonGameIndex
Mics tables
-----------
.. dex-table:: Experience
.. dex-table:: PalPark
.. dex-table:: StatHint

6
doc/schema.rst Normal file
View file

@ -0,0 +1,6 @@
The database schema
===================
.. toctree::
main-tables

193
doc/usage.rst Normal file
View file

@ -0,0 +1,193 @@
Using pokedex
=============
The pokédex is, first and foremost, a Python library. To get the most of it,
you'll need to learn `Python`_ and `SQLAlchemy`_.
Here is a small example of using pokedex:
.. testcode::
from pokedex.db import connect, tables, util
session = connect()
pokemon = util.get(session, tables.PokemonSpecies, 'bulbasaur')
print u'{0.name}, the {0.genus} Pokemon'.format(pokemon)
Running this will give you some Bulbasaur info:
.. testoutput::
Bulbasaur, the Seed Pokemon
Connecting
----------
To get information out of the Pokédex, you will need to create a
:class:`Session <pokedex.db.multilang.MultilangSession>`. To do that, use
:func:`pokedex.db.connect`. For simple uses, you don't need to give it any
arguments: it the database that ``pokedex load`` fills up by default. If you
need to select another database, give its URI as the first argument.
The object :func:`~pokedex.db.connect` gives you is actually a
:class:`SQLAlchemy session <sqlalchemy.orm.session.Session>`, giving you the
full power of SQLAlchemy for working with the data. We'll cover some basics
here, but if you intend to do some serious work, do read SQLAlchemy's docs.
Pokédex tables
--------------
Data in the pokédex is organized in tables, defined in
:mod:`pokedex.db.tables`.
There is quite a few or them. To get you started, here are a few common ones:
* :class:`~pokedex.db.tables.PokemonSpecies`
* :class:`~pokedex.db.tables.Move`
* :class:`~pokedex.db.tables.Item`
* :class:`~pokedex.db.tables.Type`
Getting things
--------------
If you know what you want from the pokédex, you can use the
:func:`pokedex.db.util.get` function. It looks up a thing in a table, based on
its identifier, name, or ID, and returns it.
.. testcode::
def print_pokemon(pokemon):
print u'{0.name}, the {0.genus} Pokemon'.format(pokemon)
print_pokemon(util.get(session, tables.PokemonSpecies, identifier='eevee'))
print_pokemon(util.get(session, tables.PokemonSpecies, name=u'Ho-Oh'))
print_pokemon(util.get(session, tables.PokemonSpecies, id=50))
def print_item(item):
print u'{0.name}: ${0.cost}'.format(item)
print_item(util.get(session, tables.Item, identifier='great-ball'))
print_item(util.get(session, tables.Item, name='Potion'))
print_item(util.get(session, tables.Item, id=30))
.. testoutput::
Eevee, the Evolution Pokemon
Ho-Oh, the Rainbow Pokemon
Diglett, the Mole Pokemon
Great Ball: $600
Potion: $300
Fresh Water: $200
Querying
--------
So, how do you get data from the session? You use the session's
:meth:`~sqlalchemy.orm.session.Session.query` method, and give it a pokédex
Table as an argument. This will give you a :class:`SQLAlchemy query
<sqlalchemy.orm.query.Query>`.
Ordering
^^^^^^^^
As always with SQL, you should not rely on query results being in some
particular order unless you have ordered the query first. This means that
you'll want to sort just about every query you will make.
For example, you can get a list of all pokémon species, sorted by their
:attr:`~pokedex.db.tables.PokemonSpecies.id`, like so:
.. testcode::
for pokemon in session.query(tables.PokemonSpecies).order_by(tables.PokemonSpecies.id):
print pokemon.name
.. testoutput::
Bulbasaur
Ivysaur
Venusaur
Charmander
Charmeleon
...
Keldeo
Meloetta
Genesect
Or to order by :attr:`~pokedex.db.tables.PokemonSpecies.name`:
.. testcode::
for pokemon in session.query(tables.PokemonSpecies).order_by(tables.PokemonSpecies.name):
print pokemon.name
.. testoutput::
Abomasnow
...
Zweilous
Filtering
^^^^^^^^^
Another major operation on queries is filtering, using the query's
:meth:`~sqlalchemy.orm.query.Query.filter` or
:meth:`~sqlalchemy.orm.query.Query.filter_by` methods:
.. testcode::
for move in session.query(tables.Move).filter(tables.Move.power > 200):
print move.name
.. testoutput::
Explosion
Joining
^^^^^^^
The final operation we'll cover here is joining other tables to the query,
using the query's :meth:`~sqlalchemy.orm.query.Query.join`.
You will usually want to join on a relationship, such as in the following
example:
.. testcode::
query = session.query(tables.Move)
query = query.join(tables.Move.type)
query = query.filter(tables.Type.identifier == 'grass')
query = query.filter(tables.Move.power >= 100)
query = query.order_by(tables.Move.power)
query = query.order_by(tables.Move.name)
print 'The most powerful Grass-type moves:'
for move in query:
print u'{0.name} ({0.power})'.format(move)
.. testoutput::
The most powerful Grass-type moves:
Petal Dance (120)
Power Whip (120)
Seed Flare (120)
SolarBeam (120)
Wood Hammer (120)
Leaf Storm (140)
Frenzy Plant (150)
That concludes our brief tutorial.
If you need to do more, consult the `SQLAlchemy documentation`_.
API documentation
-----------------
.. autofunction:: pokedex.db.connect
See :class:`sqlalchemy.orm.session.Session` for more documentation on the
returned object.
.. autofunction:: pokedex.db.util.get
.. _Python: http://www.python.org
.. _SQLAlchemy: http://www.sqlalchemy.org
.. _`SQLAlchemy documentation`: http://www.sqlalchemy.org/docs/orm/tutorial.html

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -2,12 +2,12 @@ move_effect_id,local_language_id,short_effect,effect
1,9,Inflicts regular damage with no additional effect.,Inflicts [regular damage]{mechanic:regular-damage}.
2,9,Puts the target to sleep.,Puts the target to [sleep]{mechanic:sleep}.
3,9,Has a $effect_chance% chance to [poison]{mechanic:poison} the target.,Inflicts [regular damage]{mechanic:regular-damage}. Has a $effect_chance% chance to [poison]{mechanic:poison} the target.
4,9,Heals the user by half the damage inflicted.,Inflicts [regular damage]{mechanic:regular-damage}. Heals the user for half the damage inflicted.
4,9,Drains half the damage inflicted to heal the user.,Inflicts [regular damage]{mechanic:regular-damage}. [Drains]{mechanic:drain} half the damage inflicted to heal the user.
5,9,Has a $effect_chance% chance to [burn]{mechanic:burn} the target.,Inflicts [regular damage]{mechanic:regular-damage}. Has a $effect_chance% chance to [burn]{mechanic:burn} the target.
6,9,Has a $effect_chance% chance to [freeze]{mechanic:freeze} the target.,Inflicts [regular damage]{mechanic:regular-damage}. Has a $effect_chance% chance to [freeze]{mechanic:freeze} the target.
7,9,Has a $effect_chance% chance to [paralyze]{mechanic:paralysis} the target.,Inflicts [regular damage]{mechanic:regular-damage}. Has a $effect_chance% chance to [paralyze]{mechanic:paralyze} the target.
8,9,User faints.,"User [faint]{mechanic:faint}s, even if the attack [fail]{mechanic:fail}s or [miss]{mechanic:miss}es. Inflicts [regular damage]{mechanic:regular-damage}."
9,9,Only works on sleeping Pokémon. Heals the user by half the damage inflicted.,Only works on [sleep]{mechanic:sleep}ing Pokémon. Inflicts [regular damage]{mechanic:regular-damage}. Heals the user for half the damage inflicted.
9,9,Only works on sleeping Pokémon. Drains half the damage inflicted to heal the user.,[Fails]{mechanic:fail} if not used on a [sleep]{mechanic:sleep}ing Pokémon. Inflicts [regular damage]{mechanic:regular-damage}. [Drains]{mechanic:drain} half the damage inflicted to heal the user.
10,9,Uses the target's last used move.,"Uses the last move targeted at the user by a Pokémon still on the [field]{mechanic:field}. A move counts as targeting the user even if it hit multiple Pokémon, as long as the user was one of them; however, moves targeting the [field]{mechanic:field} itself do not count. If the user has not been targeted by an appropriate move since entering the [field]{mechanic:field}, or if no Pokémon that targeted the user remains on the [field]{mechanic:field}, this move will [fail]{mechanic:fail}.
Moves that [fail]{mechanic:fail}ed, [miss]{mechanic:miss}ed, had [no effect]{mechanic:no-effect}, or were [block]{mechanic:block}ed are still copied.
@ -40,7 +40,7 @@ Doesn't affect Pokémon with []{ability:suction-cups} or under the effect of []{
30,9,Hits 2-5 times in one turn.,"Inflicts [regular damage]{mechanic:regular-damage}. Hits 25 times in one turn.
Has a 3/8 chance each to hit 2 or 3 times, and a 1/8 chance each to hit 4 or 5 times. Averages to 3 hits per use."
31,9,User's type changes to the type of one of its moves at random.,"User's [type]{mechanic:type} changes to the [type]{mechanic:type} of one of its moves, selected at random. []{move:hidden-power} and []{move:weather-ball} are treated as []{type:normal}. Only moves with a different [type]{mechanic:type} are eligible, and []{move:curse} is never eligible. If the user has no suitable moves, this move will fail."
31,9,User's type changes to the type of one of its moves at random.,"User's [type]{mechanic:type} changes to the [type]{mechanic:type} of one of its moves, selected at random. []{move:hidden-power} and []{move:weather-ball} are treated as []{type:normal}. Only moves with a different [type]{mechanic:type} are eligible, and []{move:curse} is never eligible. If the user has no suitable moves, this move will [fail]{mechanic:fail}."
32,9,Has a $effect_chance% chance to make the target flinch.,Inflicts [regular damage]{mechanic:regular-damage}. Has a $effect_chance% chance to make the target []{mechanic:flinch}.
33,9,Heals the user by half its max HP.,Heals the user for half its max [HP]{mechanic:hp}.
34,9,"Badly poisons the target, inflicting more damage every turn.",[Badly poisons]{mechanic:badly-poisons} the target.
@ -53,7 +53,7 @@ If the user is holding []{item:light-clay}, the barrier lasts for eight turns.
37,9,"Has a $effect_chance% chance to [burn]{mechanic:burn}, [freeze]{mechanic:freeze}, or [paralyze]{mechanic:paralysis} the target.","Inflicts [regular damage]{mechanic:regular-damage}. Has a $effect_chance% chance to [burn]{mechanic:burn}, [freeze]{mechanic:freeze}, or [paralyze]{mechanic:paralyze} the target. One of these effects is selected at random; they do not each have independent chances to occur."
38,9,"User sleeps for two turns, completely healing itself.","User falls to [sleep]{mechanic:sleep} and immediately regains all its [HP]{mechanic:hp}. If the user has another [major status effect]{mechanic:major-status-effect}, [sleep]{mechanic:sleep} will replace it. The user will always wake up after two turns, or one turn with []{ability:early-bird}.
This move fails if the Pokémon cannot fall asleep due to []{move:uproar}, []{ability:insomnia}, or []{ability:vital-spirit}. It also fails if the Pokémon is at full health or is already asleep."
This move [fail]{mechanic:fail}s if the Pokémon cannot fall asleep due to []{move:uproar}, []{ability:insomnia}, or []{ability:vital-spirit}. It also fails if the Pokémon is at full health or is already asleep."
39,9,Causes a one-hit KO.,"Inflicts damage equal to the target's max [HP]{mechanic:hp}. Ignores [accuracy]{mechanic:accuracy} and [evasion]{mechanic:evasion} modifiers. This move's [accuracy]{mechanic:accuracy} is 30% plus 1% for each level the user is higher than the target. If the user is a lower level than the target, this move will [fail]{mechanic:fail}.
Because this move inflicts a specific and finite amount of damage, []{move:endure} still prevents the target from fainting.
@ -79,7 +79,7 @@ This move cannot be used while []{move:gravity} is in effect."
[]{move:guard-swap}, []{move:heart-swap}, and []{move:power-swap} may still be used.
[]{move:defog} used by an opponent will end this effect."
48,9,Increases the user's chance to score a critical hit.,"User's [critical hit]{mechanic:critical-hit} rate is two levels higher until it leaves the field. If the user has already used []{move:focus-energy} since entering the field, this move will fail.
48,9,Increases the user's chance to score a critical hit.,"User's [critical hit]{mechanic:critical-hit} rate is two levels higher until it leaves the field. If the user has already used []{move:focus-energy} since entering the field, this move will [fail]{mechanic:fail}.
This effect is passed on by []{move:baton-pass}."
49,9,User receives 1/4 the damage it inflicts in recoil.,Inflicts [regular damage]{mechanic:regular-damage}. User takes 1/4 the damage it inflicts in recoil.
@ -117,7 +117,7 @@ This move cannot be selected by []{move:sleep-talk}."
77,9,Has a $effect_chance% chance to confuse the target.,Inflicts [regular damage]{mechanic:regular-damage}. Has a $effect_chance% chance to [confuse]{mechanic:confuse} the target.
78,9,Hits twice in the same turn. Has a $effect_chance% chance to poison the target.,Inflicts [regular damage]{mechanic:regular-damage}. Hits twice in the same turn. Has a $effect_chance% chance to [poison]{mechanic:poison} the target.
79,9,Never misses.,Inflicts [regular damage]{mechanic:regular-damage}. Ignores [accuracy]{mechanic:accuracy} and [evasion]{mechanic:evasion} modifiers.
80,9,"Transfers 1/4 of the user's max HP into a doll, protecting the user from further damage or status changes until it breaks.","Transfers 1/4 the user's max [HP]{mechanic:hp} into a doll that absorbs damage and causes most negative move effects to fail. If the user leaves the [field]{mechanic:field}, the doll will vanish. If the user cannot pay the [HP]{mechanic:hp} cost, this move will fail.
80,9,"Transfers 1/4 of the user's max HP into a doll, protecting the user from further damage or status changes until it breaks.","Transfers 1/4 the user's max [HP]{mechanic:hp} into a doll that absorbs damage and causes most negative move effects to [fail]{mechanic:fail}. If the user leaves the [field]{mechanic:field}, the doll will vanish. If the user cannot pay the [HP]{mechanic:hp} cost, this move will fail.
The doll takes damage as normal, using the user's stats and types, and will break when its [HP]{mechanic:hp} reaches zero. Self-inflicted damage from [confusion]{mechanic:confusion} or recoil is not absorbed. Healing effects from opponents ignore the doll and heal the user as normal. Moves that work based on the user's [HP]{mechanic:hp} still do so; the doll's [HP]{mechanic:hp} does not influence any move.
@ -138,15 +138,15 @@ The doll is passed on by []{move:baton-pass}. It keeps its existing [HP]{mechan
All other effects work as normal."
81,9,User foregoes its next turn to recharge.,"Inflicts [regular damage]{mechanic:regular-damage}. User loses its next turn to ""recharge"", and cannot attack or [switch]{mechanic:switch} out during that turn."
82,9,"If the user is hit after using this move, its Attack rises by one stage.","Inflicts [regular damage]{mechanic:regular-damage}. Every time the user is hit after it uses this move but before its next action, its [Attack]{mechanic:attack} raises by one [stage]{mechanic:stage}."
83,9,Copies the target's last used move.,"This move is replaced by the target's last successfully used move, and its PP changes to 5. If the target hasn't used a move since entering the field, if it tried to use a move this turn and [failed]{mechanic:failed}, or if the user already knows the targeted move, this move will fail. This effect vanishes when the user leaves the field.
83,9,Copies the target's last used move.,"This move is replaced by the target's last successfully used move, and its PP changes to 5. If the target hasn't used a move since entering the field, if it tried to use a move this turn and [failed]{mechanic:fail}, or if the user already knows the targeted move, this move will fail. This effect vanishes when the user leaves the field.
If []{move:chatter}, []{move:metronome}, []{move:mimic}, []{move:sketch}, or []{move:struggle} is selected, this move will fail.
If []{move:chatter}, []{move:metronome}, []{move:mimic}, []{move:sketch}, or []{move:struggle} is selected, this move will [fail]{mechanic:fail}.
This move cannot be copied by []{move:mirror-move}, nor selected by []{move:assist} or []{move:metronome}, nor forced by []{move:encore}."
84,9,Randomly selects and uses any move in the game.,"Selects any move at random and uses it. Moves the user already knows are not eligible. Assist, meta, protection, and reflection moves are also not eligible; specifically, []{move:assist}, []{move:chatter}, []{move:copycat}, []{move:counter}, []{move:covet}, []{move:destiny-bond}, []{move:detect}, []{move:endure}, []{move:feint}, []{move:focus-punch}, []{move:follow-me}, []{move:helping-hand}, []{move:me-first}, []{move:metronome}, []{move:mimic}, []{move:mirror-coat}, []{move:mirror-move}, []{move:protect}, []{move:quick-guard}, []{move:sketch}, []{move:sleep-talk}, []{move:snatch}, []{move:struggle}, []{move:switcheroo}, []{move:thief}, []{move:trick}, and []{move:wide-guard} will not be selected by this move.
This move cannot be copied by []{move:mimic} or []{move:mirror-move}, nor selected by []{move:assist}, []{move:metronome}, or []{move:sleep-talk}."
85,9,"Seeds the target, stealing HP from it every turn.","Plants a seed on the target that steals 1/8 of its max [HP]{mechanic:hp} at the end of every turn and heals the user for the amount taken. Has no effect on []{type:grass} Pokémon. The seed remains until the target leaves the field.
85,9,"Seeds the target, stealing HP from it every turn.","Plants a seed on the target that [drains]{mechanic:drain} 1/8 of its max [HP]{mechanic:hp} at the end of every turn and heals the user for the amount taken. Has no effect on []{type:grass} Pokémon. The seed remains until the target leaves the field.
The user takes damage instead of being healed if the target has []{ability:liquid-ooze}.
@ -167,9 +167,9 @@ This move cannot be copied by []{move:mirror-move}, nor selected by []{move:assi
If the target hasn't used a move since entering the [field]{mechanic:field}, if it tried to use a move this turn and [failed]{mechanic:failed}, if it does not know the selected move, or if the selected move has 0 [PP]{mechanic:pp} remaining, this move will fail. If the target's last used move was []{move:encore}, []{move:mimic}, []{move:mirror-move}, []{move:sketch}, []{move:struggle}, or []{move:transform}, this move will fail."
92,9,Sets the user's and targets's HP to the average of their current HP.,"Changes the user's and target's remaining [HP]{mechanic:hp} to the average of their current remaining [HP]{mechanic:hp}. Ignores [accuracy]{mechanic:accuracy} and [evasion]{mechanic:evasion} modifiers. This effect does not count as inflicting damage for other moves and effects that respond to damage taken.
This effect fails against a []{move:substitute}."
This effect [fail]{mechanic:fail}s against a []{move:substitute}."
93,9,Has a $effect_chance% chance to make the target flinch. Only works if the user is sleeping.,Only usable if the user is [sleep]{mechanic:sleep}ing. Inflicts [regular damage]{mechanic:regular-damage}. Has a $effect_chance% chance to make the target []{mechanic:flinch}.
94,9,Changes the user's type to a random type either resistant or immune to the last move used against it.,"Changes the user's type to a type either resistant or immune to the last damaging move that hit it. The new type is selected at random and cannot be a type the user already is. If there is no eligible new type, this move will fail."
94,9,Changes the user's type to a random type either resistant or immune to the last move used against it.,"Changes the user's type to a type either resistant or immune to the last damaging move that hit it. The new type is selected at random and cannot be a type the user already is. If there is no eligible new type, this move will [fail]{mechanic:fail}."
95,9,Ensures that the user's next move will hit the target.,"If the user targets the same target again before the end of the next turn, the move it uses is guaranteed to hit. This move itself also ignores [accuracy]{mechanic:accuracy} and [evasion]{mechanic:evasion} modifiers.
One-hit KO moves are also guaranteed to hit, as long as the user is equal or higher level than the target. This effect also allows the user to hit Pokémon that are off the field due to moves such as []{move:dig} or []{move:fly}.
@ -177,7 +177,7 @@ One-hit KO moves are also guaranteed to hit, as long as the user is equal or hig
If the target uses []{move:detect} or []{move:protect} while under the effect of this move, the user is not guaranteed to hit, but has a (100 - accuracy)% chance to break through the protection.
This effect is passed on by []{move:baton-pass}."
96,9,Permanently becomes the target's last used move.,"Permanently replaces itself with the target's last used move. If that move is []{move:chatter} or []{move:struggle}, this move will fail.
96,9,Permanently becomes the target's last used move.,"Permanently replaces itself with the target's last used move. If that move is []{move:chatter} or []{move:struggle}, this move will [fail]{mechanic:fail}.
This move cannot be copied by []{move:mimic} or []{move:mirror-move}, nor selected by []{move:assist} or []{move:metronome}, nor forced by []{move:encore}."
98,9,Randomly uses one of the user's other three moves. Only works if the user is sleeping.,"Only usable if the user is [sleep]{mechanic:sleep}ing. Randomly selects and uses one of the user's other three moves. Use of the selected move requires and costs 0 [PP]{mechanic:pp}.
@ -230,9 +230,9 @@ Otherwise: Lowers the user's [Speed]{mechanic:speed} by one [stage]{mechanic:sta
The curse effect is passed on by []{move:baton-pass}.
This move cannot be copied by []{move:mirror-move}."
112,9,Prevents any moves from hitting the user this turn.,"No moves will hit the user for the remainder of this turn. If the user is last to act this turn, this move will fail.
112,9,Prevents any moves from hitting the user this turn.,"No moves will hit the user for the remainder of this turn. If the user is last to act this turn, this move will [fail]{mechanic:fail}.
If the user successfully used []{move:detect}, []{move:endure}, []{move:protect}, []{move:quick-guard}, or []{move:wide-guard} on the last turn, this move has a 50% chance to fail.
If the user successfully used []{move:detect}, []{move:endure}, []{move:protect}, []{move:quick-guard}, or []{move:wide-guard} on the last turn, this move has a 50% chance to [fail]{mechanic:fail}.
[]{move:lock-on}, []{move:mind-reader}, and []{ability:no-guard} provide a (100 accuracy)% chance for moves to break through this move. This does not apply to one-hit KO moves ([]{move:fissure}, []{move:guillotine}, []{move:horn-drill}, and []{move:sheer-cold}); those are always blocked by this move.
@ -268,7 +268,7 @@ This move cannot be copied by []{move:mirror-move}."
[]{move:moonlight}, []{move:morning-sun}, and []{move:synthesis} only heal 1/4 the user's max [HP]{mechanic:hp}."
117,9,Prevents the user's HP from lowering below 1 this turn.,"The user's [HP]{mechanic:hp} cannot be lowered below 1 by any means for the remainder of this turn.
If the user successfully used []{move:detect}, []{move:endure}, []{move:protect}, []{move:quick-guard}, or []{move:wide-guard} on the last turn, this move has a 50% chance to fail.
If the user successfully used []{move:detect}, []{move:endure}, []{move:protect}, []{move:quick-guard}, or []{move:wide-guard} on the last turn, this move has a 50% chance to [fail]{mechanic:fail}.
This move cannot be selected by []{move:assist} or []{move:metronome}."
118,9,"Power doubles every turn this move is used in succession after the first, resetting after five turns.","Inflicts [regular damage]{mechanic:regular-damage}. User is forced to use this move for five turns. Power doubles every time this move is used in succession to a maximum of 16x, and resets to normal after the lock-in ends. If this move misses or becomes unusable, the lock-in ends.
@ -276,7 +276,7 @@ This move cannot be selected by []{move:assist} or []{move:metronome}."
If the user has used []{move:defense-curl} since entering the field, this move has double power."
119,9,Raises the target's Attack by two stages and confuses the target.,"Raises the target's [Attack]{mechanic:attack} by two [stages]{mechanic:stage}, then [confuses]{mechanic:confuses} it. If the target's [Attack]{mechanic:attack} cannot be [raised]{mechanic:raised} by two [stages]{mechanic:stage}, the [confusion]{mechanic:confusion} is not applied."
120,9,"Power doubles every turn this move is used in succession after the first, maxing out after five turns.","Inflicts [regular damage]{mechanic:regular-damage}. Power doubles after every time this move is used, whether consecutively or not, maxing out at 16x. If this move misses or the user leaves the [field]{mechanic:field}, power resets."
121,9,"Target falls in love if it has the opposite gender, and has a 50% chance to refuse attacking the user.","Causes the target to fall in love with the user, giving it a 50% chance to do nothing each turn. If the user and target are the same gender, or either is genderless, this move will fail. If either Pokémon leaves the [field]{mechanic:field}, this effect ends."
121,9,"Target falls in love if it has the opposite gender, and has a 50% chance to refuse attacking the user.","Causes the target to fall in love with the user, giving it a 50% chance to do nothing each turn. If the user and target are the same gender, or either is genderless, this move will [fail]{mechanic:fail}. If either Pokémon leaves the [field]{mechanic:field}, this effect ends."
122,9,"Power increases with happiness, up to a maximum of 102.","Inflicts [regular damage]{mechanic:regular-damage}. Power increases with [happiness]{mechanic:happiness}, given by `happiness * 2 / 5`, to a maximum of 102. Power bottoms out at 1."
123,9,Randomly inflicts damage with power from 40 to 120 or heals the target for 1/4 its max HP.,"Randomly uses one of the following effects.
@ -291,7 +291,7 @@ On average, this move inflicts [regular damage]{mechanic:regular-damage} with 52
124,9,"Power increases as happiness decreases, up to a maximum of 102.","Inflicts [regular damage]{mechanic:regular-damage}. Power increases inversely with [happiness]{mechanic:happiness}, given by `(255 - happiness) * 2 / 5`, to a maximum of 102. Power bottoms out at 1."
125,9,Protects the user's field from major status ailments and confusion for five turns.,"Protects Pokémon on the user's side of the [field]{mechanic:field} from [major status]{mechanic:major-status} effects and [confusion]{mechanic:confusion} for five turns. Does not cancel existing ailments. This effect remains even if the user leaves the [field]{mechanic:field}.
If []{move:yawn} is used while this move is in effect, it will immediately fail.
If []{move:yawn} is used while this move is in effect, it will immediately [fail]{mechanic:fail}.
[]{move:defog} used by an opponent will end this effect.
@ -408,7 +408,7 @@ Pokémon with []{ability:solar-power} have their original [Special Attack]{mecha
139,9,Has a $effect_chance% chance to raise the user's Defense by one stage.,Inflicts [regular damage]{mechanic:regular-damage}. Has a $effect_chance% chance to raise the user's [Defense]{mechanic:defense} one [stage]{mechanic:stage}.
140,9,Has a $effect_chance% chance to raise the user's Attack by one stage.,Inflicts [regular damage]{mechanic:regular-damage}. Has a $effect_chance% chance to raise the user's [Attack]{mechanic:attack} one [stage]{mechanic:stage}.
141,9,Has a $effect_chance% chance to raise all of the user's stats by one stage.,Inflicts [regular damage]{mechanic:regular-damage}. Has a $effect_chance% chance to raise all of the user's stats one [stage]{mechanic:stage}.
143,9,User pays half its max HP to max out its Attack.,"User pays half its max [HP]{mechanic:hp} to raise its [Attack]{mechanic:attack} to +6 [stages]{mechanic:stage}. If the user cannot pay the [HP]{mechanic:hp} cost, this move will fail."
143,9,User pays half its max HP to max out its Attack.,"User pays half its max [HP]{mechanic:hp} to raise its [Attack]{mechanic:attack} to +6 [stages]{mechanic:stage}. If the user cannot pay the [HP]{mechanic:hp} cost, this move will [fail]{mechanic:fail}."
144,9,Discards the user's stat changes and copies the target's.,"Discards the user's [stat changes]{mechanic:stat-changes} and copies the target's.
This move cannot be copied by []{move:mirror-move}."
@ -428,7 +428,7 @@ If the target is in the first turn of []{move:dig}, this move will hit with doub
This effect breaks through []{ability:wonder-guard}.
If the target is protected by []{move:protect} or []{move:detect} on the turn this move is used, this move will fail. However, the damage on the third turn will break through protection.
If the target is protected by []{move:protect} or []{move:detect} on the turn this move is used, this move will [fail]{mechanic:fail}. However, the damage on the third turn will break through protection.
The damage is applied at the end of the turn, so it ignores []{move:endure} and []{item:focus-sash}.
@ -478,10 +478,10 @@ This move cannot be selected by []{move:sleep-talk}."
161,9,Stores energy up to three times for use with Spit Up and Swallow.,"Raises the user's [Defense]{mechanic:defense} and [Special Defense]{mechanic:special-defense} by one [stage]{mechanic:stage} each. Stores energy for use with []{move:spit-up} and []{move:swallow}. Up to three levels of energy can be stored, and all are lost if the user leaves the [field]{mechanic:field}. Energy is still stored even if the stat boosts cannot be applied.
If the user uses []{move:baton-pass}, the stat boosts are passed as normal, but the stored energy is not."
162,9,Power is 100 times the amount of energy Stockpiled.,"Inflicts [regular damage]{mechanic:regular-damage}. Power is equal to 100 times the amount of energy stored by []{move:stockpile}. Ignores the random factor in the damage formula. Stored energy is consumed, and the user's [Defense]{mechanic:defense} and [Special Defense]{mechanic:special-defense} are reset to what they would be if []{move:stockpile} had not been used. If the user has no energy stored, this move will fail.
162,9,Power is 100 times the amount of energy Stockpiled.,"Inflicts [regular damage]{mechanic:regular-damage}. Power is equal to 100 times the amount of energy stored by []{move:stockpile}. Ignores the random factor in the damage formula. Stored energy is consumed, and the user's [Defense]{mechanic:defense} and [Special Defense]{mechanic:special-defense} are reset to what they would be if []{move:stockpile} had not been used. If the user has no energy stored, this move will [fail]{mechanic:fail}.
This move cannot be copied by []{move:mirror-move}."
163,9,"Recovers 1/4 HP after one Stockpile, 1/2 HP after two Stockpiles, or full HP after three Stockpiles.","Heals the user depending on the amount of energy stored by []{move:stockpile}: 1/4 its max [HP]{mechanic:hp} after one use, 1/2 its max [HP]{mechanic:hp} after two uses, or fully after three uses. Stored energy is consumed, and the user's [Defense]{mechanic:defense} and [Special Defense]{mechanic:special-defense} are reset to what they would be if []{move:stockpile} had not been used. If the user has no energy stored, this move will fail."
163,9,"Recovers 1/4 HP after one Stockpile, 1/2 HP after two Stockpiles, or full HP after three Stockpiles.","Heals the user depending on the amount of energy stored by []{move:stockpile}: 1/4 its max [HP]{mechanic:hp} after one use, 1/2 its max [HP]{mechanic:hp} after two uses, or fully after three uses. Stored energy is consumed, and the user's [Defense]{mechanic:defense} and [Special Defense]{mechanic:special-defense} are reset to what they would be if []{move:stockpile} had not been used. If the user has no energy stored, this move will [fail]{mechanic:fail}."
165,9,Changes the weather to a hailstorm for five turns.,"Changes the weather to hail for five turns, during which non-[]{type:ice} Pokémon are damaged for 1/16 their max [HP]{mechanic:hp} at the end of every turn.
If the user is holding []{item:icy-rock}, this effect lasts for eight turns.
@ -498,7 +498,7 @@ If the target is forced to attempt a repeated move due to []{item:choice-band},
168,9,Burns the target.,[Burns]{mechanic:burns} the target.
169,9,Lowers the target's Attack and Special Attack by two stages. User faints.,Lowers the target's [Attack]{mechanic:attack} and [Special Attack]{mechanic:special-attack} by two [stages]{mechanic:stage}. User faints.
170,9,"Power doubles if user is burned, paralyzed, or poisoned.","Inflicts [regular damage]{mechanic:regular-damage}. If the user is [burned]{mechanic:burned}, [paralyzed]{mechanic:paralyzed}, or [poisoned]{mechanic:poisoned}, this move has double power."
171,9,"If the user takes damage before attacking, the attack is canceled.","Inflicts [regular damage]{mechanic:regular-damage}. If the user takes damage this turn before hitting, this move will fail.
171,9,"If the user takes damage before attacking, the attack is canceled.","Inflicts [regular damage]{mechanic:regular-damage}. If the user takes damage this turn before hitting, this move will [fail]{mechanic:fail}.
This move cannot be copied by []{move:mirror-move}, nor selected by []{move:assist}, []{move:metronome}, or []{move:sleep-talk}."
172,9,"If the target is paralyzed, inflicts double damage and cures the paralysis.","Inflicts [regular damage]{mechanic:regular-damage}. If the user is [paralyzed]{mechanic:paralyzed}, this move has double power, and the user is cured of its [paralysis]{mechanic:paralysis}."
@ -549,9 +549,9 @@ This move cannot be copied by []{move:mirror-move}."
177,9,Ally's next move inflicts half more damage.,"Boosts the power of the target's moves by 50% until the end of this turn.
This move cannot be copied by []{move:mirror-move}, nor selected by []{move:assist} or []{move:metronome}."
178,9,User and target swap items.,"User and target permanently swap [held item]{mechanic:held-item}s. Works even if one of the Pokémon isn't holding anything. If either Pokémon is holding mail, this move will fail.
178,9,User and target swap items.,"User and target permanently swap [held item]{mechanic:held-item}s. Works even if one of the Pokémon isn't holding anything. If either Pokémon is holding mail, this move will [fail]{mechanic:fail}.
If either Pokémon has []{ability:multitype} or []{ability:sticky-hold}, this move will fail.
If either Pokémon has []{ability:multitype} or []{ability:sticky-hold}, this move will [fail]{mechanic:fail}.
If this move results in a Pokémon obtaining []{item:choice-band}, []{item:choice-scarf}, or []{item:choice-specs}, and that Pokémon was the latter of the pair to move this turn, then the move it used this turn becomes its chosen forced move. This applies even if both Pokémon had a choice item before this move was used. If the first of the two Pokémon gains a choice item, it may select whatever choice move it wishes next turn.
@ -560,11 +560,11 @@ Neither the user nor the target can recover its item with []{move:recycle}.
This move cannot be selected by []{move:assist} or []{move:metronome}."
179,9,Copies the target's ability.,"User's ability is replaced with the target's until the user leaves the [field]{mechanic:field}. Ignores [accuracy]{mechanic:accuracy} and [evasion]{mechanic:evasion} modifiers.
If the target has []{ability:wonder-guard}, this move will fail.
If the target has []{ability:wonder-guard}, this move will [fail]{mechanic:fail}.
This move cannot be copied by []{move:mirror-move}."
180,9,User will recover half its max HP at the end of the next turn.,"At the end of the next turn, user will be healed for half its max [HP]{mechanic:hp}. If the user is [switched out]{mechanic:switched-out}, its replacement will be healed instead for half of the user's max HP. If the user [faint]{mechanic:faint}s or is forcefully switched by []{move:roar} or []{move:whirlwind}, this effect will not activate."
181,9,Randomly selects and uses one of the trainer's other Pokémon's moves.,"Uses a move from another Pokémon in the user's party, both selected at random. Moves from fainted Pokémon can be used. If there are no eligible Pokémon or moves, this move will fail.
181,9,Randomly selects and uses one of the trainer's other Pokémon's moves.,"Uses a move from another Pokémon in the user's party, both selected at random. Moves from fainted Pokémon can be used. If there are no eligible Pokémon or moves, this move will [fail]{mechanic:fail}.
This move will not select []{move:assist}, []{move:chatter}, []{move:circle-throw}, []{move:copycat}, []{move:counter}, []{move:covet}, []{move:destiny-bond}, []{move:detect}, []{move:dragon-tail}, []{move:endure}, []{move:feint}, []{move:focus-punch}, []{move:follow-me}, []{move:helping-hand}, []{move:me-first}, []{move:metronome}, []{move:mimic}, []{move:mirror-coat}, []{move:mirror-move}, []{move:protect}, []{move:quick-guard}, []{move:sketch}, []{move:sleep-talk}, []{move:snatch}, []{move:struggle}, []{move:switcheroo}, []{move:thief}, []{move:trick}, or []{move:wide-guard}.
@ -584,29 +584,29 @@ This effect can be passed with []{move:baton-pass}."
[]{move:attract}, []{move:flatter}, []{move:gastro-acid}, []{move:leech-seed}, []{move:swagger}, []{move:worry-seed}, and []{move:yawn} are reflected.
This move cannot be copied by []{move:mirror-move}."
185,9,User recovers the item it last used up.,"User recovers the last item consumed by the user or a Pokémon in its position on the [field]{mechanic:field}. The item must be used again before it can be recovered by this move again. If the user is holding an item, this move fails.
185,9,User recovers the item it last used up.,"User recovers the last item consumed by the user or a Pokémon in its position on the [field]{mechanic:field}. The item must be used again before it can be recovered by this move again. If the user is holding an item, this move [fail]{mechanic:fail}s.
Items taken or given away by []{move:covet}, []{move:knock-off}, []{move:switcheroo}, []{move:thief}, or []{move:trick} may not be recovered."
186,9,Inflicts double damage if the user takes damage before attacking this turn.,"Inflicts [regular damage]{mechanic:regular-damage}. If the target damaged the user this turn and was the last to do so, this move has double power.
[]{move:pain-split} does not count as damaging the user."
187,9,Destroys Reflect and Light Screen.,"Destroys any []{move:light-screen} or []{move:reflect} on the target's side of the [field]{mechanic:field}, then inflicts [regular damage]{mechanic:regular-damage}. The barriers are destroyed even if this move has [no effect]{mechanic:no-effect}."
188,9,Target sleeps at the end of the next turn.,"Puts the target to [sleep]{mechanic:sleep} at the end of the next turn. Ignores [accuracy]{mechanic:accuracy} and [evasion]{mechanic:evasion} modifiers. If the target leaves the [field]{mechanic:field}, this effect is canceled. If the target has a status effect when this move is used, this move will fail.
188,9,Target sleeps at the end of the next turn.,"Puts the target to [sleep]{mechanic:sleep} at the end of the next turn. Ignores [accuracy]{mechanic:accuracy} and [evasion]{mechanic:evasion} modifiers. If the target leaves the [field]{mechanic:field}, this effect is canceled. If the target has a status effect when this move is used, this move will [fail]{mechanic:fail}.
If the target is protected by []{move:safeguard} when this move is used, this move will fail.
If the target is protected by []{move:safeguard} when this move is used, this move will [fail]{mechanic:fail}.
[]{ability:insomnia} and []{ability:vital-spirit} prevent the [sleep]{mechanic:sleep} if the target has either at the end of the next turn, but will not cause this move to fail on use."
[]{ability:insomnia} and []{ability:vital-spirit} prevent the [sleep]{mechanic:sleep} if the target has either at the end of the next turn, but will not cause this move to [fail]{mechanic:fail} on use."
189,9,Target drops its held item.,"Inflicts [regular damage]{mechanic:regular-damage}. Target loses its [held item]{mechanic:held-item}.
Neither the user nor the target can recover its item with []{move:recycle}.
If the target has []{ability:multitype} or []{ability:sticky-hold}, it will take damage but not lose its item."
190,9,Lowers the target's HP to equal the user's.,"Inflicts exactly enough damage to lower the target's [HP]{mechanic:hp} to equal the user's. If the target's HP is not higher than the user's, this move has no effect. Type immunity applies, but other type effects are ignored. This effect counts as damage for moves that respond to damage."
191,9,"Inflicts more damage when the user has more HP remaining, with a maximum of 150 power.","Inflicts [regular damage]{mechanic:regular-damage}. Power increases with the user's remaining [HP]{mechanic:hp} and is given by `150 * HP / max HP`, to a maximum of 150 when the user has full [HP]{mechanic:hp}."
191,9,"Inflicts more damage when the user has more HP remaining, with a maximum of 150 power.","Inflicts [regular damage]{mechanic:regular-damage}. Power increases with the user's remaining [HP]{mechanic:hp} and is given by `150 * HP / max HP`, to a maximum of 150 when the user has full HP."
192,9,User and target swap abilities.,"User and target switch abilities. Ignores [accuracy]{mechanic:accuracy} and [evasion]{mechanic:evasion} modifiers.
If either Pokémon has []{ability:multitype} or []{ability:wonder-guard}, this move will fail."
193,9,Prevents the target from using any moves that the user also knows.,"Prevents any Pokémon on the opposing side of the [field]{mechanic:field} from using any move the user knows until the user leaves the [field]{mechanic:field}. This effect is live; if the user obtains new moves while on the [field]{mechanic:field}, these moves become restricted. If no opposing Pokémon knows any of the user's moves when this move is used, this move will fail."
If either Pokémon has []{ability:multitype} or []{ability:wonder-guard}, this move will [fail]{mechanic:fail}."
193,9,Prevents the target from using any moves that the user also knows.,"Prevents any Pokémon on the opposing side of the [field]{mechanic:field} from using any move the user knows until the user leaves the [field]{mechanic:field}. This effect is live; if the user obtains new moves while on the [field]{mechanic:field}, these moves become restricted. If no opposing Pokémon knows any of the user's moves when this move is used, this move will [fail]{mechanic:fail}."
194,9,"Cleanses the user of a burn, paralysis, or poison.","Removes a [burn]{mechanic:burn}, [paralysis]{mechanic:paralysis}, or [poison]{mechanic:poison} from the user."
195,9,"If the user faints this turn, the PP of the move that fainted it drops to 0.","If the user [faint]{mechanic:faint}s before it next acts, the move that fainted it will have its [PP]{mechanic:pp} dropped to 0. End-of-turn damage does not trigger this effect."
196,9,"Steals the target's move, if it's self-targeted.","The next time a Pokémon uses a beneficial move on itself or itself and its ally this turn, the user of this move will steal the move and use it itself. Moves which may be stolen by this move are identified by the ""snatchable"" flag.
@ -718,7 +718,7 @@ Specifically, []{type:flying} Pokémon and those with []{ability:levitate} or th
220,9,"Power raises when the user has lower Speed, up to a maximum of 150.","Inflicts [regular damage]{mechanic:regular-damage}. Power increases with the target's current [Speed]{mechanic:speed} compared to the user, given by `1 + 25 * target Speed / user Speed`, capped at 150."
221,9,User faints. Its replacement has its HP fully restored and any major status effect removed.,"User faints. Its replacement's [HP]{mechanic:hp} is fully restored, and any [major status effect]{mechanic:major-status-effect} is removed. If the replacement Pokémon is immediately fainted by a switch-in effect, the next replacement is healed by this move instead."
222,9,Has double power against Pokémon that have less than half their max HP remaining.,"Inflicts [regular damage]{mechanic:regular-damage}. If the target has less than half its max [HP]{mechanic:hp} remaining, this move has double power."
223,9,Power and type depend on the held berry.,"Inflicts [regular damage]{mechanic:regular-damage}. Power and type are determined by the user's held berry. The berry is consumed. If the user is not holding a berry, this move will fail."
223,9,Power and type depend on the held berry.,"Inflicts [regular damage]{mechanic:regular-damage}. Power and type are determined by the user's held berry. The berry is consumed. If the user is not holding a berry, this move will [fail]{mechanic:fail}."
224,9,Hits through Protect and Detect.,"Inflicts [regular damage]{mechanic:regular-damage}. Removes the effects of []{move:detect} or []{move:protect} from the target before hitting.
This move cannot be copied by []{move:mirror-move}, nor selected by []{move:assist} or []{move:metronome}."
@ -728,7 +728,7 @@ If the target is holding a []{item:jaboca-berry} or []{item:rowap-berry}, the be
If this move is [super effective]{mechanic:super-effective} and the target is holding a berry that can reduce this move's damage, it will do so, and will not be stolen."
226,9,"For three turns, friendly Pokémon have doubled Speed.","For the next three turns, all Pokémon on the user's side of the [field]{mechanic:field} have their original [Speed]{mechanic:speed} doubled. This effect remains if the user leaves the [field]{mechanic:field}."
227,9,Raises one of a friendly Pokémon's stats at random by two stages.,"Raises one of the target's stats by two [stages]{mechanic:stage}. The raised stat is chosen at random from any stats that can be raised by two stages. If no stat is eligible, this move will fail.
227,9,Raises one of a friendly Pokémon's stats at random by two stages.,"Raises one of the target's stats by two [stages]{mechanic:stage}. The raised stat is chosen at random from any stats that can be raised by two stages. If no stat is eligible, this move will [fail]{mechanic:fail}.
If the target has a []{move:substitute}, this move will have no effect, even if the user is the target.
@ -744,14 +744,14 @@ This move may be used even if the user is under the effect of []{move:ingrain}.
232,9,Power is doubled if the target has already received damage this turn.,"Inflicts [regular damage]{mechanic:regular-damage}. If the target takes damage this turn for any reason before this move is used, this move has double power."
233,9,Target cannot use held items.,"Target cannot use its held item for five turns. If the target leaves the [field]{mechanic:field}, this effect ends.
If a Pokémon under this effect uses []{move:bug-bite} or []{move:pluck} on a Pokémon holding a berry, the berry is destroyed but not used. If a Pokémon under this effect uses []{move:fling}, it will fail.
If a Pokémon under this effect uses []{move:bug-bite} or []{move:pluck} on a Pokémon holding a berry, the berry is destroyed but not used. If a Pokémon under this effect uses []{move:fling}, it will [fail]{mechanic:fail}.
This effect is passed by []{move:baton-pass}."
234,9,Throws held item at the target; power depends on the item.,"Inflicts [regular damage]{mechanic:regular-damage}. Power and type are determined by the user's [held item]{mechanic:held-item}. The item is consumed. If the user is not holding an item, or its item has no set type and power, this move will fail.
234,9,Throws held item at the target; power depends on the item.,"Inflicts [regular damage]{mechanic:regular-damage}. Power and type are determined by the user's [held item]{mechanic:held-item}. The item is consumed. If the user is not holding an item, or its item has no set type and power, this move will [fail]{mechanic:fail}.
This move ignores []{ability:sticky-hold}.
If the user is under the effect of []{move:embargo}, this move will fail."
If the user is under the effect of []{move:embargo}, this move will [fail]{mechanic:fail}."
235,9,Transfers the user's major status effect to the target.,"If the user has a [major status effect]{mechanic:major-status-effect} and the target does not, the user's status is transferred to the target."
236,9,"Power increases when this move has less PP, up to a maximum of 200.","Inflicts [regular damage]{mechanic:regular-damage}. Power is determined by the [PP]{mechanic:pp} remaining for this move, after its [PP]{mechanic:pp} cost is deducted. Ignores [accuracy]{mechanic:accuracy} and [evasion]{mechanic:evasion} modifiers.
@ -775,7 +775,7 @@ This effect is passed on by []{move:baton-pass}."
241,9,Prevents the target from scoring critical hits for five turns.,"For five turns, opposing Pokémon cannot score [critical hits]{mechanic:critical-hit}."
242,9,"Uses the target's move against it before it attacks, with power increased by half.","If the target has selected a damaging move this turn, the user will copy that move and use it against the target, with a 50% increase in power.
If the target moves before the user, this move will fail.
If the target moves before the user, this move will [fail]{mechanic:fail}.
This move cannot be copied by []{move:mirror-move}, nor selected by []{move:assist}, []{move:metronome}, or []{move:sleep-talk}."
243,9,Uses the target's last used move.,"Uses the last move that was used successfully by any Pokémon, including the user.
@ -786,11 +786,11 @@ This move cannot be copied by []{move:mirror-move}, nor selected by []{move:assi
244,9,User swaps Attack and Special Attack changes with the target.,User swaps its [Attack]{mechanic:attack} and [Special Attack]{mechanic:special-attack} [stat modifiers]{mechanic:stat-modifiers} modifiers with the target.
245,9,User swaps Defense and Special Defense changes with the target.,User swaps its [Defense]{mechanic:defense} and [Special Defense]{mechanic:special-defense} modifiers with the target.
246,9,"Power increases against targets with more raised stats, up to a maximum of 200.","Inflicts [regular damage]{mechanic:regular-damage}. Power starts at 60 and is increased by 20 for every [stage]{mechanic:stage} any of the target's stats has been raised, capping at 200. [Accuracy]{mechanic:accuracy} and [evasion]{mechanic:evasion} modifiers do not increase this move's power."
247,9,Can only be used after all of the user's other moves have been used.,"Inflicts [regular damage]{mechanic:regular-damage}. This move can only be used if each of the user's other moves has been used at least once since the user entered the [field]{mechanic:field}. If this is the user's only move, this move will fail."
247,9,Can only be used after all of the user's other moves have been used.,"Inflicts [regular damage]{mechanic:regular-damage}. This move can only be used if each of the user's other moves has been used at least once since the user entered the [field]{mechanic:field}. If this is the user's only move, this move will [fail]{mechanic:fail}."
248,9,Changes the target's ability to Insomnia.,"Changes the target's ability to []{ability:insomnia}.
If the target's ability is []{ability:truant} or []{ability:multitype}, this move will fail."
249,9,Only works if the target is about to use a damaging move.,"Inflicts [regular damage]{mechanic:regular-damage}. If the target has not selected a damaging move this turn, or if the target has already acted this turn, this move will fail.
If the target's ability is []{ability:truant} or []{ability:multitype}, this move will [fail]{mechanic:fail}."
249,9,Only works if the target is about to use a damaging move.,"Inflicts [regular damage]{mechanic:regular-damage}. If the target has not selected a damaging move this turn, or if the target has already acted this turn, this move will [fail]{mechanic:fail}.
This move is not affected by []{ability:iron-fist}."
250,9,"Scatters poisoned spikes, poisoning opposing Pokémon that switch in.","Scatters poisoned spikes around the opposing [field]{mechanic:field}, which [poison]{mechanic:poison} opposing Pokémon that enter the [field]{mechanic:field}. A second layer of these spikes may be laid down, in which case Pokémon will be [badly poison]{mechanic:badly-poison}ed instead. Pokémon immune to either []{type:ground} moves or being [poison]{mechanic:poison}ed are immune to this effect. Pokémon otherwise immune to []{type:ground} moves are affected during []{move:gravity}.
@ -808,7 +808,7 @@ Pokémon entering the [field]{mechanic:field} due to []{move:baton-pass} are not
This effect is passed on by []{move:baton-pass}."
253,9,User is immune to Ground moves and effects for five turns.,"For five turns, the user is immune to []{type:ground} moves.
If the user is under the effect of []{move:ingrain} or has []{ability:levitate}, this move will fail.
If the user is under the effect of []{move:ingrain} or has []{ability:levitate}, this move will [fail]{mechanic:fail}.
This effect is temporarily disabled by and cannot be used during []{move:gravity}.
@ -864,7 +864,7 @@ The user may be hit during its immune turn if under the effect of []{move:lock-o
This move cannot be used while []{move:gravity} is in effect.
This move cannot be selected by []{move:sleep-talk}."
266,9,Lowers the target's Special Attack by two stages if it's the opposite gender.,"Lowers the target's [Special Attack]{mechanic:special-attack} by two [stages]{mechanic:stage}. If the user and target are the same gender, or either is genderless, this move will fail."
266,9,Lowers the target's Special Attack by two stages if it's the opposite gender.,"Lowers the target's [Special Attack]{mechanic:special-attack} by two [stages]{mechanic:stage}. If the user and target are the same gender, or either is genderless, this move will [fail]{mechanic:fail}."
267,9,Causes damage when opposing Pokémon switch in.,"Spreads sharp rocks around the opposing [field]{mechanic:field}, damaging any Pokémon that enters the [field]{mechanic:field} for 1/8 its max [HP]{mechanic:hp}. This damage is affected by the entering Pokémon's susceptibility to []{type:rock} moves.
[]{move:rapid-spin} removes this effect from its user's side of the [field]{mechanic:field}."
@ -887,9 +887,9 @@ This move cannot be selected by []{move:sleep-talk}."
276,9,Has a $effect_chance% chance to paralyze the target and a $effect_chance% chance to make the target flinch.,Inflicts [regular damage]{mechanic:regular-damage}. Has a $effect_chance% chance to [paralyze]{mechanic:paralyze} the target and a separate $effect_chance% chance to make the target [flinch]{mechanic:flinch}.
277,9,Has a $effect_chance% chance to raise the user's Special Attack by one stage.,Inflicts [regular damage]{mechanic:regular-damage}. Has a $effect_chance% chance to raise the user's [Special Attack]{mechanic:special-attack} by one [stage]{mechanic:stage}.
278,9,Raises the user's Attack and accuracy by one stage.,Raises the user's [Attack]{mechanic:attack} and [accuracy]{mechanic:accuracy} by one [stage]{mechanic:stage}.
279,9,Prevents any multi-target moves from hitting friendly Pokémon this turn.,"Moves with multiple targets will not hit friendly Pokémon for the remainder of this turn. If the user is last to act this turn, this move will fail.
279,9,Prevents any multi-target moves from hitting friendly Pokémon this turn.,"Moves with multiple targets will not hit friendly Pokémon for the remainder of this turn. If the user is last to act this turn, this move will [fail]{mechanic:fail}.
If the user successfully used []{move:detect}, []{move:endure}, []{move:protect}, []{move:quick-guard}, or []{move:wide-guard} on the last turn, this move has a 50% chance to fail.
If the user successfully used []{move:detect}, []{move:endure}, []{move:protect}, []{move:quick-guard}, or []{move:wide-guard} on the last turn, this move has a 50% chance to [fail]{mechanic:fail}.
This move cannot be selected by []{move:assist} or []{move:metronome}."
280,9,Averages Defense and Special Defense with the target.,Averages the user's unmodified [Defense]{mechanic:defense} with the target's unmodified Defense; the value becomes the unmodified Defense for both Pokémon. Unmodified [Special Defense]{mechanic:special-defense} is averaged the same way.
@ -902,11 +902,11 @@ This effect applies before any other persistent changes to unmodified Attack or
285,9,Raises the user's Speed by two stages and halves the user's weight.,Raises the user's [Speed]{mechanic:speed} by two [stages]{mechanic:stage}. Halves the user's weight; this effect does not stack.
286,9,Moves have 100% accuracy against the target for three turns.,"For three turns (including this one), moves used against the target have 100% [accuracy]{mechanic:accuracy}, but the target is immune to []{type:ground} damage. Accuracy of one-hit KO moves is exempt from this effect.
This effect is removed by []{move:gravity}. If Gravity is already in effect, this move will fail."
This effect is removed by []{move:gravity}. If Gravity is already in effect, this move will [fail]{mechanic:fail}."
287,9,Negates held items for five turns.,"For five turns (including this one), passive effects of held items are ignored, and Pokémon will not use their held items."
288,9,Removes any immunity to Ground damage.,"Inflicts [regular damage]{mechanic:regular-damage}. Removes the target's [immunity]{mechanic:immune} to []{type:ground}-type damage. This effect removes any existing Ground immunity due to []{ability:levitate}, []{move:magnet-rise}, or []{move:telekinesis}, and causes the target's []{type:flying} type to be ignored when it takes Ground damage.
If the target isn't immune to Ground damage, this move will fail.
If the target isn't immune to Ground damage, this move will [fail]{mechanic:fail}.
This move can hit Pokémon under the effect of []{move:bounce}, []{move:fly}, or []{move:sky-drop}, and ends the effect of Bounce or Fly."
289,9,Always scores a critical hit.,Inflicts [regular damage]{mechanic:regular-damage}. Always scores a [critical hit]{mechanic:critical-hit}.
@ -932,26 +932,26 @@ Up to 3× the target's Speed | 80
Up to 4× the target's Speed | 120
More than 4× the target's Speed | 150
"
295,9,Changes the target's type to Water.,"Changes the target to pure []{type:water}-type until it leaves the field. If the target has []{ability:multitype}, this move will fail."
295,9,Changes the target's type to Water.,"Changes the target to pure []{type:water}-type until it leaves the field. If the target has []{ability:multitype}, this move will [fail]{mechanic:fail}."
296,9,Inflicts regular damage. Raises the user's Speed by one stage.,Inflicts [regular damage]{mechanic:regular-damage}. Raises the user's [Speed]{mechanic:speed} by one [stage]{mechanic:stage}.
297,9,Lowers the target's Special Defense by two stages.,Inflicts [regular damage]{mechanic:regular-damage}. Lowers the target's [Special Defense]{mechanic:special-defense} by two [stages]{mechanic:stage}.
298,9,Calculates damage with the target's attacking stat.,Inflicts [regular damage]{mechanic:regular-damage}. Damage is calculated using the target's attacking stat rather than the user's.
299,9,Changes the target's ability to Simple.,Changes the target's ability to []{ability:simple}.
300,9,Copies the user's ability onto the target.,Changes the target's ability to match the user's. This effect ends when the target leaves battle.
301,9,Makes the target act next this turn.,"The target will act next this turn, regardless of [Speed]{mechanic:speed} or move priority.
If the target has already acted this turn, this move will fail."
If the target has already acted this turn, this move will [fail]{mechanic:fail}."
302,9,Has double power if it's used more than once per turn.,"Inflicts [regular damage]{mechanic:regular-damage}. If []{move:round} has already been used this turn, this move's power is doubled. After this move is used, any other Pokémon using it this turn will immediately do so (in the order they would otherwise act), regardless of [Speed]{mechanic:speed} or priority. Pokémon using other moves will then continue to act as usual."
303,9,"Power increases by 100% for each consecutive use by any friendly Pokémon, to a maximum of 200.","Inflicts [regular damage]{mechanic:regular-damage}. If any friendly Pokémon used this move earlier this turn or on the previous turn, that use's power is added to this move's power, to a maximum of 200."
304,9,Ignores the target's stat modifiers.,"Inflicts [regular damage]{mechanic:regular-damage}. Damage calculation ignores the target's [stat modifiers]{mechanic:stat-modifiers}, including [evasion]{mechanic:evasion}."
305,9,Removes all of the target's stat modifiers.,Inflicts [regular damage]{mechanic:regular-damage}. All of the target's [stat modifiers]{mechanic:stat-modifiers} are reset to zero.
306,9,"Power is higher the more the user's stats have been raised, to a maximum of 31×.","Inflicts [regular damage]{mechanic:regular-damage}. Power is increased by 100% its original value for every [stage]{mechanic:stage} any of the user's stats have been raised. [Accuracy]{mechanic:accuracy}, [evasion]{mechanic:evasion}, and lowered stats do not affect this move's power. For a Pokémon with all five stats modified to +6, this move's power is 31×."
307,9,Prevents any priority moves from hitting friendly Pokémon this turn.,"Moves with priority greater than 0 will not hit friendly Pokémon for the remainder of this turn. If the user is last to act this turn, this move will fail.
307,9,Prevents any priority moves from hitting friendly Pokémon this turn.,"Moves with priority greater than 0 will not hit friendly Pokémon for the remainder of this turn. If the user is last to act this turn, this move will [fail]{mechanic:fail}.
If the user successfully used []{move:detect}, []{move:endure}, []{move:protect}, []{move:quick-guard}, or []{move:wide-guard} on the last turn, this move has a 50% chance to fail.
If the user successfully used []{move:detect}, []{move:endure}, []{move:protect}, []{move:quick-guard}, or []{move:wide-guard} on the last turn, this move has a 50% chance to [fail]{mechanic:fail}.
This move cannot be selected by []{move:assist} or []{move:metronome}.
"
308,9,User switches places with the friendly Pokémon opposite it.,"User switches position on the field with the friendly Pokémon opposite it. If the user is in the middle position in a triple battle, or there are no other friendly Pokémon, this move will fail."
308,9,User switches places with the friendly Pokémon opposite it.,"User switches position on the field with the friendly Pokémon opposite it. If the user is in the middle position in a triple battle, or there are no other friendly Pokémon, this move will [fail]{mechanic:fail}."
309,9,"Raises user's Attack, Special Attack, and Speed by two stages. Lower user's Defense and Special Defense by one stage.","Raises the user's [Attack]{mechanic:attack}, [Special Attack]{mechanic:special-attack}, and [Speed]{mechanic:speed} by two [stages]{mechanic:stage} each. Lowers the user's [Defense]{mechanic:defense} and [Special Defense]{mechanic:special-defense} by one []{mechanic:stage} each."
310,9,Heals the target for half its max HP.,Heals the target for half its max [HP]{mechanic:hp}.
311,9,Has double power if the target has a major status ailment.,"Inflicts [regular damage]{mechanic:regular-damage}. If the target has a [major status ailment]{mechanic:major-status-ailment}, this move has double power."
@ -975,7 +975,7 @@ This move cannot be selected by []{move:sleep-talk}.
If the target is under the effect of []{move:ingrain} or []{ability:suction-cups}, or it has a []{move:substitute}, or its Trainer has no more usable Pokémon, it will not be switched out. If the target is a wild Pokémon, the battle ends instead."
315,9,Destroys the target's held berry.,"Inflicts [regular damage]{mechanic:regular-damage}. If the target is [holding]{mechanic:held-item} a [berry]{mechanic:berry}, it's destroyed and cannot be used in response to this move."
316,9,Makes the target act last this turn.,"Forces the target to act last this turn, regardless of [Speed]{mechanic:speed} or move [priority]{mechanic:priority}. If the target has already acted this turn, this move will fail."
316,9,Makes the target act last this turn.,"Forces the target to act last this turn, regardless of [Speed]{mechanic:speed} or move [priority]{mechanic:priority}. If the target has already acted this turn, this move will [fail]{mechanic:fail}."
317,9,Raises the user's Attack and Special Attack by one stage.,"Raises the user's [Attack]{mechanic:attack} and [Special Attack]{mechanic:special-attack} by one [stage]{mechanic:stage} each. During []{move:sunny-day}, raises both stats by two stages."
318,9,Has double power if the user has no held item.,"Inflicts [regular damage]{mechanic:regular-damage}. If the user has no [held item]{mechanic:held-item}, this move has double power."
319,9,User becomes the target's type.,User's type changes to match the target's.
@ -983,7 +983,7 @@ If the target is under the effect of []{move:ingrain} or []{ability:suction-cups
321,9,Inflicts damage equal to the user's remaining HP. User faints.,Inflicts damage equal to the user's remaining [HP]{mechanic:hp}. User faints.
322,9,Raises the user's Special Attack by three stages.,Raises the user's [Special Attack]{mechanic:special-attack} by three [stages]{mechanic:stage}.
323,9,"Raises the user's Attack, Defense, and accuracy by one stage each.","Raises the user's [Attack]{mechanic:attack}, [Defense]{mechanic:defense}, and [accuracy]{mechanic:accuracy} by one [stage]{mechanic:stage} each."
324,9,Gives the user's held item to the target.,"Transfers the user's [held item]{mechanic:held-item} to the target. If the user has no held item, or the target already has a held item, this move will fail."
324,9,Gives the user's held item to the target.,"Transfers the user's [held item]{mechanic:held-item} to the target. If the user has no held item, or the target already has a held item, this move will [fail]{mechanic:fail}."
325,9,"With [Grass Pledge]{move:grass-pledge}, halves opposing Pokémon's Speed for four turns.","Inflicts [regular damage]{mechanic:regular-damage}. If a friendly Pokémon used []{move:grass-pledge} earlier this turn, all opposing Pokémon have halved [Speed]{mechanic:speed} for four turns (including this one)."
326,9,"With [Water Pledge]{move:water-pledge}, doubles the effect chance of friendly Pokémon's moves for four turns.","Inflicts [regular damage]{mechanic:regular-damage}. If a friendly Pokémon used []{move:water-pledge} earlier this turn, moves used by any friendly Pokémon have doubled effect chance for four turns (including this one)."
327,9,"With [Fire Pledge]{move:fire-pledge}, damages opposing Pokémon for 1/8 their max HP every turn for four turns.","Inflicts [regular damage]{mechanic:regular-damage}. If a friendly Pokémon used []{move:fire-pledge} earlier this turn, all opposing Pokémon will take 1/8 their max [HP]{mechanic:hp} in damage at the end of every turn for four turns (including this one)."

1 move_effect_id local_language_id short_effect effect
2 1 9 Inflicts regular damage with no additional effect. Inflicts [regular damage]{mechanic:regular-damage}.
3 2 9 Puts the target to sleep. Puts the target to [sleep]{mechanic:sleep}.
4 3 9 Has a $effect_chance% chance to [poison]{mechanic:poison} the target. Inflicts [regular damage]{mechanic:regular-damage}. Has a $effect_chance% chance to [poison]{mechanic:poison} the target.
5 4 9 Heals the user by half the damage inflicted. Drains half the damage inflicted to heal the user. Inflicts [regular damage]{mechanic:regular-damage}. Heals the user for half the damage inflicted. Inflicts [regular damage]{mechanic:regular-damage}. [Drains]{mechanic:drain} half the damage inflicted to heal the user.
6 5 9 Has a $effect_chance% chance to [burn]{mechanic:burn} the target. Inflicts [regular damage]{mechanic:regular-damage}. Has a $effect_chance% chance to [burn]{mechanic:burn} the target.
7 6 9 Has a $effect_chance% chance to [freeze]{mechanic:freeze} the target. Inflicts [regular damage]{mechanic:regular-damage}. Has a $effect_chance% chance to [freeze]{mechanic:freeze} the target.
8 7 9 Has a $effect_chance% chance to [paralyze]{mechanic:paralysis} the target. Inflicts [regular damage]{mechanic:regular-damage}. Has a $effect_chance% chance to [paralyze]{mechanic:paralyze} the target.
9 8 9 User faints. User [faint]{mechanic:faint}s, even if the attack [fail]{mechanic:fail}s or [miss]{mechanic:miss}es. Inflicts [regular damage]{mechanic:regular-damage}.
10 9 9 Only works on sleeping Pokémon. Heals the user by half the damage inflicted. Only works on sleeping Pokémon. Drains half the damage inflicted to heal the user. Only works on [sleep]{mechanic:sleep}ing Pokémon. Inflicts [regular damage]{mechanic:regular-damage}. Heals the user for half the damage inflicted. [Fails]{mechanic:fail} if not used on a [sleep]{mechanic:sleep}ing Pokémon. Inflicts [regular damage]{mechanic:regular-damage}. [Drains]{mechanic:drain} half the damage inflicted to heal the user.
11 10 9 Uses the target's last used move. Uses the last move targeted at the user by a Pokémon still on the [field]{mechanic:field}. A move counts as targeting the user even if it hit multiple Pokémon, as long as the user was one of them; however, moves targeting the [field]{mechanic:field} itself do not count. If the user has not been targeted by an appropriate move since entering the [field]{mechanic:field}, or if no Pokémon that targeted the user remains on the [field]{mechanic:field}, this move will [fail]{mechanic:fail}. Moves that [fail]{mechanic:fail}ed, [miss]{mechanic:miss}ed, had [no effect]{mechanic:no-effect}, or were [block]{mechanic:block}ed are still copied. Assist moves, time-delayed moves, “meta” moves that operate on other moves/Pokémon/abilities, and some other special moves cannot be copied and are ignored; if the last move to hit the user was such a move, the previous move will be used instead. The full list of ignored moves is: []{move:acupressure}, []{move:assist}, []{move:chatter}, []{move:copycat}, []{move:counter}, []{move:curse}, []{move:doom-desire}, []{move:feint}, []{move:focus-punch}, []{move:future-sight}, []{move:helping-hand}, []{move:magic-coat}, []{move:me-first}, []{move:metronome}, []{move:mimic}, []{move:mirror-coat}, []{move:mirror-move}, []{move:nature-power}, []{move:perish-song}, []{move:psych-up}, []{move:role-play}, []{move:sketch}, []{move:sleep-talk}, []{move:snatch}, []{move:spit-up}, []{move:struggle}, and []{move:transform}. This move cannot be selected by []{move:assist}, []{move:metronome}, or []{move:sleep-talk}, nor forced by []{move:encore}.
12 11 9 Raises the user's Attack by one stage. Raises the user's [Attack]{mechanic:attack} by one [stage]{mechanic:stage}.
13 12 9 Raises the user's Defense by one stage. Raises the user's [Defense]{mechanic:defense} by one [stage]{mechanic:stage}.
40 44 9 Has an increased chance for a critical hit. Inflicts [regular damage]{mechanic:regular-damage}. User's [critical hit]{mechanic:critical-hit} rate is one level higher when using this move.
41 45 9 Hits twice in one turn. Inflicts [regular damage]{mechanic:regular-damage}. Hits twice in one turn.
42 46 9 If the user misses, it takes half the damage it would have inflicted in recoil. Inflicts [regular damage]{mechanic:regular-damage}. If this move misses, is blocked by []{move:protect} or []{move:detect}, or has no effect, the user takes half the damage it would have inflicted in recoil. This recoil damage will not exceed half the user's max HP. This move cannot be used while []{move:gravity} is in effect.
43 47 9 Protects the user's stats from being changed by enemy moves. Pokémon on the user's side of the [field]{mechanic:field} are immune to stat-lowering effects for five turns. []{move:guard-swap}, []{move:heart-swap}, and []{move:power-swap} may still be used. []{move:defog} used by an opponent will end this effect.
44 48 9 Increases the user's chance to score a critical hit. User's [critical hit]{mechanic:critical-hit} rate is two levels higher until it leaves the field. If the user has already used []{move:focus-energy} since entering the field, this move will fail. This effect is passed on by []{move:baton-pass}. User's [critical hit]{mechanic:critical-hit} rate is two levels higher until it leaves the field. If the user has already used []{move:focus-energy} since entering the field, this move will [fail]{mechanic:fail}. This effect is passed on by []{move:baton-pass}.
45 49 9 User receives 1/4 the damage it inflicts in recoil. Inflicts [regular damage]{mechanic:regular-damage}. User takes 1/4 the damage it inflicts in recoil.
46 50 9 Confuses the target. [Confuse]{mechanic:confuse}s the target.
53 59 9 Lowers the target's Attack by two stages. Lowers the target's [Attack]{mechanic:attack} by two [stages]{mechanic:stage}.
54 60 9 Lowers the target's Defense by two stages. Lowers the target's [Defense]{mechanic:defense} by two [stages]{mechanic:stage}.
55 61 9 Lowers the target's Speed by two stages. Lowers the target's [Speed]{mechanic:speed} by two [stages]{mechanic:stage}.
56 63 9 Lowers the target's Special Defense by two stages. Lowers the target's [Special Defense]{mechanic:special-defense} by two [stages]{mechanic:stage}.
57 66 9 Reduces damage from physical attacks by half. Erects a barrier around the user's side of the field that reduces damage from [physical]{mechanic:physical} attacks by half for five turns. In double battles, the reduction is 1/3. [Critical hit]{mechanic:critical-hit}s are not affected by the barrier. If the user is holding []{item:light-clay}, the barrier lasts for eight turns. []{move:brick-break} or []{move:defog} used by an opponent will destroy the barrier.
58 67 9 Poisons the target. [Poisons]{mechanic:poisons} the target.
59 68 9 Paralyzes the target. [Paralyzes]{mechanic:paralyzes} the target.
79 89 9 Inflicts damage between 50% and 150% of the user's level. Inflicts [typeless]{mechanic:typeless} damage between 50% and 150% of the user's level, selected at random in increments of 10%.
80 90 9 Inflicts twice the damage the user received from the last physical hit it took. Targets the last opposing Pokémon to hit the user with a [physical]{mechanic:physical} move this turn. Inflicts twice the damage that move did to the user. If there is no eligible target, this move will [fail]{mechanic:fail}. Type immunity applies, but other type effects are ignored. This move cannot be copied by []{move:mirror-move}, nor selected by []{move:assist} or []{move:metronome}.
81 91 9 Forces the target to repeat its last used move every turn for 2 to 6 turns. The next 4–8 times (selected at random) the target attempts to move, it is forced to repeat its last used move. If the selected move allows the trainer to select a target, an opponent will be selected at random each turn. If the target is prevented from using the selected move by some other effect, []{move:struggle} will be used instead. This effect ends if the selected move runs out of [PP]{mechanic:pp}. If the target hasn't used a move since entering the [field]{mechanic:field}, if it tried to use a move this turn and [failed]{mechanic:failed}, if it does not know the selected move, or if the selected move has 0 [PP]{mechanic:pp} remaining, this move will fail. If the target's last used move was []{move:encore}, []{move:mimic}, []{move:mirror-move}, []{move:sketch}, []{move:struggle}, or []{move:transform}, this move will fail.
82 92 9 Sets the user's and targets's HP to the average of their current HP. Changes the user's and target's remaining [HP]{mechanic:hp} to the average of their current remaining [HP]{mechanic:hp}. Ignores [accuracy]{mechanic:accuracy} and [evasion]{mechanic:evasion} modifiers. This effect does not count as inflicting damage for other moves and effects that respond to damage taken. This effect fails against a []{move:substitute}. Changes the user's and target's remaining [HP]{mechanic:hp} to the average of their current remaining [HP]{mechanic:hp}. Ignores [accuracy]{mechanic:accuracy} and [evasion]{mechanic:evasion} modifiers. This effect does not count as inflicting damage for other moves and effects that respond to damage taken. This effect [fail]{mechanic:fail}s against a []{move:substitute}.
83 93 9 Has a $effect_chance% chance to make the target flinch. Only works if the user is sleeping. Only usable if the user is [sleep]{mechanic:sleep}ing. Inflicts [regular damage]{mechanic:regular-damage}. Has a $effect_chance% chance to make the target []{mechanic:flinch}.
84 94 9 Changes the user's type to a random type either resistant or immune to the last move used against it. Changes the user's type to a type either resistant or immune to the last damaging move that hit it. The new type is selected at random and cannot be a type the user already is. If there is no eligible new type, this move will fail. Changes the user's type to a type either resistant or immune to the last damaging move that hit it. The new type is selected at random and cannot be a type the user already is. If there is no eligible new type, this move will [fail]{mechanic:fail}.
85 95 9 Ensures that the user's next move will hit the target. If the user targets the same target again before the end of the next turn, the move it uses is guaranteed to hit. This move itself also ignores [accuracy]{mechanic:accuracy} and [evasion]{mechanic:evasion} modifiers. One-hit KO moves are also guaranteed to hit, as long as the user is equal or higher level than the target. This effect also allows the user to hit Pokémon that are off the field due to moves such as []{move:dig} or []{move:fly}. If the target uses []{move:detect} or []{move:protect} while under the effect of this move, the user is not guaranteed to hit, but has a (100 - accuracy)% chance to break through the protection. This effect is passed on by []{move:baton-pass}.
117 129 9 Has double power against, and can hit, Pokémon attempting to switch out. Inflicts [regular damage]{mechanic:regular-damage}. If the target attempts to [switch out]{mechanic:switch-out} this turn before the user acts, this move hits the target before it leaves and has double power. This effect can still hit a Pokémon that [switches out]{mechanic:switches-out} when it has a []{move:substitute} up or when an ally has used []{move:follow-me}.
118 130 9 Frees the user from binding moves, removes Leech Seed, and blows away Spikes. Inflicts [regular damage]{mechanic:regular-damage}. Removes []{move:leech-seed} from the user, frees the user from []{move:bind}, []{move:clamp}, []{move:fire-spin}, []{move:magma-storm}, []{move:sand-tomb}, []{move:whirlpool}, and []{move:wrap}, and clears []{move:spikes}, []{move:stealth-rock}, and []{move:toxic-spikes} from the user's side of the [field]{mechanic:field}. If this move misses or has [no effect]{mechanic:no-effect}, its effect doesn't activate.
119 131 9 Inflicts 20 points of damage. Inflicts exactly 20 damage.
120 133 9 Heals the user by half its max HP. Affected by weather. Heals the user for half its max [HP]{mechanic:hp}. During []{move:sunny-day}, the healing is increased to 2/3 max [HP]{mechanic:hp}. During []{move:hail}, []{move:rain-dance}, or []{move:sandstorm}, the healing is decreased to 1/4 max [HP]{mechanic:hp}.
121 136 9 Power and type depend upon user's IVs. Power can range from 30 to 70. Inflicts [regular damage]{mechanic:regular-damage}. Power and type are determined by the user's [IV]{mechanic:iv}s. Power is given by `x * 40 / 63 + 30`. `x` is obtained by arranging bit 1 from the [IV]{mechanic:iv} for each of [Special Defense]{mechanic:special-defense}, [Special Attack]{mechanic:special-attack}, [Speed]{mechanic:speed}, [Defense]{mechanic:defense}, [Attack]{mechanic:attack}, and [HP]{mechanic:hp} in that order. (Bit 1 is 1 if the [IV]{mechanic:iv} is of the form `4n + 2` or `4n + 3`. `x` is then 64 * [Special Defense]{mechanic:special-defense} [IV]{mechanic:iv} bit 1, plus 32 * [Special Attack]{mechanic:special-attack} [IV]{mechanic:iv} bit 1, etc.) Power is always between 30 and 70, inclusive. Average power is 49.5. Type is given by `y * 15 / 63`, where `y` is similar to `x` above, except constructed from bit 0. (Bit 0 is 1 if the [IV]{mechanic:iv} is odd.) The result is looked up in the following table. Value | Type ----: | -------- 0 | []{type:fighting} 1 | []{type:flying} 2 | []{type:poison} 3 | []{type:ground} 4 | []{type:rock} 5 | []{type:bug} 6 | []{type:ghost} 7 | []{type:steel} 8 | []{type:fire} 9 | []{type:water} 10 | []{type:grass} 11 | []{type:electric} 12 | []{type:psychic} 13 | []{type:ice} 14 | []{type:dragon} 15 | []{type:dark} This move thus cannot be []{type:normal}. Most other types have an equal 1/16 chance to be selected, given random [IV]{mechanic:iv}s. However, due to the flooring used here, []{type:bug}, []{type:fighting}, and []{type:grass} appear 5/64 of the time, and []{type:dark} only 1/64 of the time.
122 137 9 Changes the weather to rain for five turns. Changes the weather to rain for five turns, during which []{type:water} moves inflict 50% extra damage, and []{type:fire} moves inflict half damage. If the user is holding []{item:damp-rock}, this effect lasts for eight turns. []{move:thunder} has 100% accuracy. If the target has used []{move:detect} or []{move:protect}, []{move:thunder} has a (100 - accuracy)% chance to break through the protection. []{move:solarbeam} has half power. []{move:moonlight}, []{move:morning-sun}, and []{move:synthesis} heal only 1/4 of the user's max [HP]{mechanic:hp}. Pokémon with []{ability:swift-swim} have doubled original [Speed]{mechanic:speed}. Pokémon with []{ability:forecast} become []{type:water}. Pokémon with []{ability:dry-skin} heal 1/8 max [HP]{mechanic:hp}, Pokémon with []{ability:hydration} are cured of [major status effects]{mechanic:major-status-effects}, and Pokémon with []{ability:rain-dish} heal 1/16 max [HP]{mechanic:hp} at the end of each turn.
123 138 9 Changes the weather to sunny for five turns. Changes the weather to sunshine for five turns, during which []{type:fire} moves inflict 50% extra damage, and []{type:water} moves inflict half damage. If the user is holding []{item:heat-rock}, this effect lasts for eight turns. Pokémon cannot become [frozen]{mechanic:frozen}. []{move:thunder} has 50% accuracy. []{move:solarbeam} skips its charge turn. []{move:moonlight}, []{move:morning-sun}, and []{move:synthesis} heal 2/3 of the user's max [HP]{mechanic:hp}. Pokémon with []{ability:chlorophyll} have doubled original [Speed]{mechanic:speed}. Pokémon with []{ability:forecast} become []{type:fire}. Pokémon with []{ability:leaf-guard} are not affected by [major status effects]{mechanic:major-status-effects}. Pokémon with []{ability:flower-gift} change form; every Pokémon on their side of the [field]{mechanic:field} have their original [Attack]{mechanic:attack} and [Special Attack]{mechanic:special-attack} increased by 50%. Pokémon with []{ability:dry-skin} lose 1/8 max [HP]{mechanic:hp} at the end of each turn. Pokémon with []{ability:solar-power} have their original [Special Attack]{mechanic:special-attack} raised by 50% but lose 1/8 their max [HP]{mechanic:hp} at the end of each turn.
138 154 9 Immediately ends wild battles. No effect otherwise. Does nothing. Wild battles end immediately.
139 155 9 Hits once for every conscious Pokémon the trainer has. Inflicts [typeless]{mechanic:typeless} [regular damage]{mechanic:regular-damage}. Every Pokémon in the user's party, excepting those that have fainted or have a [major status effect]{mechanic:major-status-effect}, attacks the target. Calculated stats are ignored; the base stats for the target and assorted attackers are used instead. The random factor in the damage formula is not used. []{type:dark} Pokémon still get [STAB]{mechanic:stab}. This effect breaks through []{ability:wonder-guard}.
140 156 9 User flies high into the air, dodging all attacks, and hits next turn. Inflicts [regular damage]{mechanic:regular-damage}. User flies high into the air for one turn, becoming immune to attack, and hits on the second turn. During the immune turn, []{move:gust}, []{move:hurricane}, []{move:sky-uppercut}, []{move:smack-down}, []{move:thunder}, []{move:twister}, and []{move:whirlwind} still hit the user normally. []{move:gust} and []{move:twister} also have double power against the user. The damage from []{move:hail} and []{move:sandstorm} still applies during the immune turn. The user may be hit during its immune turn if under the effect of []{move:lock-on}, []{move:mind-reader}, or []{ability:no-guard}. This move cannot be used while []{move:gravity} is in effect. This move cannot be selected by []{move:sleep-talk}.
141 157 9 Raises user's Defense by one stage. Raises user's [Defense]{mechanic:defense} by one [stage]{mechanic:stage}. After this move is used, the power of []{move:ice-ball} and []{move:rollout} are doubled until the user leaves the [field]{mechanic:field}.
142 159 9 Can only be used as the first move after the user enters battle. Causes the target to flinch. Inflicts [regular damage]{mechanic:regular-damage}. Causes the target to []{mechanic:flinch}. Can only be used on the user's first turn after entering the [field]{mechanic:field}.
143 160 9 Forced to use this move for several turns. Pokémon cannot fall asleep in that time. Inflicts [regular damage]{mechanic:regular-damage}. User is forced to use this move for 2–5 turns, selected at random. All Pokémon on the [field]{mechanic:field} wake up, and none can fall to [sleep]{mechanic:sleep} until the lock-in ends. Pokémon cannot use []{move:rest} during this effect. This move cannot be selected by []{move:sleep-talk}.
144 161 9 Stores energy up to three times for use with Spit Up and Swallow. Raises the user's [Defense]{mechanic:defense} and [Special Defense]{mechanic:special-defense} by one [stage]{mechanic:stage} each. Stores energy for use with []{move:spit-up} and []{move:swallow}. Up to three levels of energy can be stored, and all are lost if the user leaves the [field]{mechanic:field}. Energy is still stored even if the stat boosts cannot be applied. If the user uses []{move:baton-pass}, the stat boosts are passed as normal, but the stored energy is not.
145 162 9 Power is 100 times the amount of energy Stockpiled. Inflicts [regular damage]{mechanic:regular-damage}. Power is equal to 100 times the amount of energy stored by []{move:stockpile}. Ignores the random factor in the damage formula. Stored energy is consumed, and the user's [Defense]{mechanic:defense} and [Special Defense]{mechanic:special-defense} are reset to what they would be if []{move:stockpile} had not been used. If the user has no energy stored, this move will fail. This move cannot be copied by []{move:mirror-move}. Inflicts [regular damage]{mechanic:regular-damage}. Power is equal to 100 times the amount of energy stored by []{move:stockpile}. Ignores the random factor in the damage formula. Stored energy is consumed, and the user's [Defense]{mechanic:defense} and [Special Defense]{mechanic:special-defense} are reset to what they would be if []{move:stockpile} had not been used. If the user has no energy stored, this move will [fail]{mechanic:fail}. This move cannot be copied by []{move:mirror-move}.
146 163 9 Recovers 1/4 HP after one Stockpile, 1/2 HP after two Stockpiles, or full HP after three Stockpiles. Heals the user depending on the amount of energy stored by []{move:stockpile}: 1/4 its max [HP]{mechanic:hp} after one use, 1/2 its max [HP]{mechanic:hp} after two uses, or fully after three uses. Stored energy is consumed, and the user's [Defense]{mechanic:defense} and [Special Defense]{mechanic:special-defense} are reset to what they would be if []{move:stockpile} had not been used. If the user has no energy stored, this move will fail. Heals the user depending on the amount of energy stored by []{move:stockpile}: 1/4 its max [HP]{mechanic:hp} after one use, 1/2 its max [HP]{mechanic:hp} after two uses, or fully after three uses. Stored energy is consumed, and the user's [Defense]{mechanic:defense} and [Special Defense]{mechanic:special-defense} are reset to what they would be if []{move:stockpile} had not been used. If the user has no energy stored, this move will [fail]{mechanic:fail}.
147 165 9 Changes the weather to a hailstorm for five turns. Changes the weather to hail for five turns, during which non-[]{type:ice} Pokémon are damaged for 1/16 their max [HP]{mechanic:hp} at the end of every turn. If the user is holding []{item:icy-rock}, this effect lasts for eight turns. []{move:blizzard} has 100% accuracy. If the target has used []{move:detect} or []{move:protect}, []{move:blizzard} has a (100 - accuracy)% chance to break through the protection. []{move:moonlight}, []{move:morning-sun}, and []{move:synthesis} heal only 1/4 of the user's max [HP]{mechanic:hp}. Pokémon with []{ability:snow-cloak} are exempt from this effect's damage.
148 166 9 Prevents the target from using the same move twice in a row. Prevents the target from attempting to use the same move twice in a row. When the target leaves the [field]{mechanic:field}, this effect ends. If the target is forced to attempt a repeated move due to []{item:choice-band}, []{item:choice-scarf}, []{item:choice-specs}, []{move:disable}, []{move:encore}, []{move:taunt}, only having [PP]{mechanic:pp} remaining for one move, or any other effect, the target will use []{move:struggle} instead. The target is then free to use the forced move next turn, as it didn't use that move this turn.
149 167 9 Raises the target's Special Attack by one stage and confuses the target. Raises the target's [Special Attack]{mechanic:special-attack} by one [stage]{mechanic:stage}, then [confuses]{mechanic:confuses} it.
150 168 9 Burns the target. [Burns]{mechanic:burns} the target.
151 169 9 Lowers the target's Attack and Special Attack by two stages. User faints. Lowers the target's [Attack]{mechanic:attack} and [Special Attack]{mechanic:special-attack} by two [stages]{mechanic:stage}. User faints.
152 170 9 Power doubles if user is burned, paralyzed, or poisoned. Inflicts [regular damage]{mechanic:regular-damage}. If the user is [burned]{mechanic:burned}, [paralyzed]{mechanic:paralyzed}, or [poisoned]{mechanic:poisoned}, this move has double power.
167 185 9 User recovers the item it last used up. User recovers the last item consumed by the user or a Pokémon in its position on the [field]{mechanic:field}. The item must be used again before it can be recovered by this move again. If the user is holding an item, this move fails. Items taken or given away by []{move:covet}, []{move:knock-off}, []{move:switcheroo}, []{move:thief}, or []{move:trick} may not be recovered. User recovers the last item consumed by the user or a Pokémon in its position on the [field]{mechanic:field}. The item must be used again before it can be recovered by this move again. If the user is holding an item, this move [fail]{mechanic:fail}s. Items taken or given away by []{move:covet}, []{move:knock-off}, []{move:switcheroo}, []{move:thief}, or []{move:trick} may not be recovered.
168 186 9 Inflicts double damage if the user takes damage before attacking this turn. Inflicts [regular damage]{mechanic:regular-damage}. If the target damaged the user this turn and was the last to do so, this move has double power. []{move:pain-split} does not count as damaging the user.
169 187 9 Destroys Reflect and Light Screen. Destroys any []{move:light-screen} or []{move:reflect} on the target's side of the [field]{mechanic:field}, then inflicts [regular damage]{mechanic:regular-damage}. The barriers are destroyed even if this move has [no effect]{mechanic:no-effect}.
170 188 9 Target sleeps at the end of the next turn. Puts the target to [sleep]{mechanic:sleep} at the end of the next turn. Ignores [accuracy]{mechanic:accuracy} and [evasion]{mechanic:evasion} modifiers. If the target leaves the [field]{mechanic:field}, this effect is canceled. If the target has a status effect when this move is used, this move will fail. If the target is protected by []{move:safeguard} when this move is used, this move will fail. []{ability:insomnia} and []{ability:vital-spirit} prevent the [sleep]{mechanic:sleep} if the target has either at the end of the next turn, but will not cause this move to fail on use. Puts the target to [sleep]{mechanic:sleep} at the end of the next turn. Ignores [accuracy]{mechanic:accuracy} and [evasion]{mechanic:evasion} modifiers. If the target leaves the [field]{mechanic:field}, this effect is canceled. If the target has a status effect when this move is used, this move will [fail]{mechanic:fail}. If the target is protected by []{move:safeguard} when this move is used, this move will [fail]{mechanic:fail}. []{ability:insomnia} and []{ability:vital-spirit} prevent the [sleep]{mechanic:sleep} if the target has either at the end of the next turn, but will not cause this move to [fail]{mechanic:fail} on use.
171 189 9 Target drops its held item. Inflicts [regular damage]{mechanic:regular-damage}. Target loses its [held item]{mechanic:held-item}. Neither the user nor the target can recover its item with []{move:recycle}. If the target has []{ability:multitype} or []{ability:sticky-hold}, it will take damage but not lose its item.
172 190 9 Lowers the target's HP to equal the user's. Inflicts exactly enough damage to lower the target's [HP]{mechanic:hp} to equal the user's. If the target's HP is not higher than the user's, this move has no effect. Type immunity applies, but other type effects are ignored. This effect counts as damage for moves that respond to damage.
173 191 9 Inflicts more damage when the user has more HP remaining, with a maximum of 150 power. Inflicts [regular damage]{mechanic:regular-damage}. Power increases with the user's remaining [HP]{mechanic:hp} and is given by `150 * HP / max HP`, to a maximum of 150 when the user has full [HP]{mechanic:hp}. Inflicts [regular damage]{mechanic:regular-damage}. Power increases with the user's remaining [HP]{mechanic:hp} and is given by `150 * HP / max HP`, to a maximum of 150 when the user has full HP.
174 192 9 User and target swap abilities. User and target switch abilities. Ignores [accuracy]{mechanic:accuracy} and [evasion]{mechanic:evasion} modifiers. If either Pokémon has []{ability:multitype} or []{ability:wonder-guard}, this move will fail. User and target switch abilities. Ignores [accuracy]{mechanic:accuracy} and [evasion]{mechanic:evasion} modifiers. If either Pokémon has []{ability:multitype} or []{ability:wonder-guard}, this move will [fail]{mechanic:fail}.
175 193 9 Prevents the target from using any moves that the user also knows. Prevents any Pokémon on the opposing side of the [field]{mechanic:field} from using any move the user knows until the user leaves the [field]{mechanic:field}. This effect is live; if the user obtains new moves while on the [field]{mechanic:field}, these moves become restricted. If no opposing Pokémon knows any of the user's moves when this move is used, this move will fail. Prevents any Pokémon on the opposing side of the [field]{mechanic:field} from using any move the user knows until the user leaves the [field]{mechanic:field}. This effect is live; if the user obtains new moves while on the [field]{mechanic:field}, these moves become restricted. If no opposing Pokémon knows any of the user's moves when this move is used, this move will [fail]{mechanic:fail}.
177 195 9 If the user faints this turn, the PP of the move that fainted it drops to 0. If the user [faint]{mechanic:faint}s before it next acts, the move that fainted it will have its [PP]{mechanic:pp} dropped to 0. End-of-turn damage does not trigger this effect.
178 196 9 Steals the target's move, if it's self-targeted. The next time a Pokémon uses a beneficial move on itself or itself and its ally this turn, the user of this move will steal the move and use it itself. Moves which may be stolen by this move are identified by the "snatchable" flag. If two Pokémon use this move on the same turn, the faster Pokémon will steal the first beneficial move, and the slower Pokémon will then steal it again—thus, only the slowest Pokémon using this move ultimately gains a stolen move's effect. If the user steals []{move:psych-up}, it will target the Pokémon that used []{move:psych-up}. If the user was the original target of []{move:psych-up}, and the Pokémon that originally used it's affected by []{ability:pressure}, it will only lose 1 [PP]{mechanic:pp}. This move cannot be copied by []{move:mirror-move}, nor selected by []{move:assist} or []{move:metronome}.
179 197 9 Inflicts more damage to heavier targets, with a maximum of 120 power. Inflicts [regular damage]{mechanic:regular-damage}. Power increases with the target's weight in kilograms, to a maximum of 120. Target's weight | Power --------------- | ----: Up to 10kg | 20 Up to 25kg | 40 Up to 50kg | 60 Up to 100kg | 80 Up to 200kg | 100 Above 200kg | 120
180 198 9 Has a $effect_chance% chance to inflict a status effect which depends upon the terrain. Inflicts [regular damage]{mechanic:regular-damage}. Has a $effect_chance% chance to inflict an effect chosen according to the terrain. Terrain | Effect -------------- | ------------------------------------------------------------- Building | [Paralyze]{mechanic:paralyze}s target Cave | Makes target [flinch]{mechanic:flinch} Deep water | Lowers target's [Attack]{mechanic:attack} by one [stage]{mechanic:stage} Desert | Lowers target's [accuracy]{mechanic:accuracy} by one [stage]{mechanic:stage} Grass | Puts target to [sleep]{mechanic:sleep} Mountain | Makes target [flinch]{mechanic:flinch} Road | Lowers target's [accuracy]{mechanic:accuracy} by one [stage]{mechanic:stage} Shallow water | Lowers target's [Attack]{mechanic:attack} by one [stage]{mechanic:stage} Snow | [Freezes]{mechanic:freezes} target Tall grass | Puts target to [sleep]{mechanic:sleep} In Pokémon Battle Revolution: Terrain | Effect -------------- | ------------------------------------------------------------- Courtyard | [Paralyze]{mechanic:paralyze}s target Crystal | Makes target [flinch]{mechanic:flinch} Gateway | Lowers target's [Attack]{mechanic:attack} by one [stage]{mechanic:stage} Magma | Makes target [flinch]{mechanic:flinch} Main Street | [Paralyze]{mechanic:paralyze}s target Neon | [Paralyze]{mechanic:paralyze}s target Stargazer | Makes target [flinch]{mechanic:flinch} Sunny Park | Puts target to [sleep]{mechanic:sleep} Sunset | Lowers target's [accuracy]{mechanic:accuracy} by one [stage]{mechanic:stage} Waterfall | Puts target to [sleep]{mechanic:sleep}
181 199 9 User receives 1/3 the damage inflicted in recoil. Inflicts [regular damage]{mechanic:regular-damage}. User takes 1/3 the damage it inflicts in recoil.
182 200 9 Confuses the target. [Confuse]{mechanic:confuse}s all targets.
183 201 9 Has an increased chance for a critical hit and a $effect_chance% chance to [burn]{mechanic:burn} the target. Inflicts [regular damage]{mechanic:regular-damage}. User's [critical hit]{mechanic:critical-hit} rate is one level higher when using this move. Has a $effect_chance% chance to [burn]{mechanic:burn} the target.
230 248 9 Changes the target's ability to Insomnia. Changes the target's ability to []{ability:insomnia}. If the target's ability is []{ability:truant} or []{ability:multitype}, this move will fail. Changes the target's ability to []{ability:insomnia}. If the target's ability is []{ability:truant} or []{ability:multitype}, this move will [fail]{mechanic:fail}.
231 249 9 Only works if the target is about to use a damaging move. Inflicts [regular damage]{mechanic:regular-damage}. If the target has not selected a damaging move this turn, or if the target has already acted this turn, this move will fail. This move is not affected by []{ability:iron-fist}. Inflicts [regular damage]{mechanic:regular-damage}. If the target has not selected a damaging move this turn, or if the target has already acted this turn, this move will [fail]{mechanic:fail}. This move is not affected by []{ability:iron-fist}.
232 250 9 Scatters poisoned spikes, poisoning opposing Pokémon that switch in. Scatters poisoned spikes around the opposing [field]{mechanic:field}, which [poison]{mechanic:poison} opposing Pokémon that enter the [field]{mechanic:field}. A second layer of these spikes may be laid down, in which case Pokémon will be [badly poison]{mechanic:badly-poison}ed instead. Pokémon immune to either []{type:ground} moves or being [poison]{mechanic:poison}ed are immune to this effect. Pokémon otherwise immune to []{type:ground} moves are affected during []{move:gravity}. If a []{type:poison} Pokémon not immune to []{type:ground} moves enters a [field]{mechanic:field} covered with poisoned spikes, the spikes are removed. []{move:rapid-spin} will remove this effect from its user's side of the [field]{mechanic:field}. []{move:defog} will remove this effect from its target's side of the [field]{mechanic:field}. This move does not trigger []{ability:synchronize}, unless the Pokémon with []{ability:synchronize} was forced to enter the [field]{mechanic:field} by another effect such as []{move:roar}. Pokémon entering the [field]{mechanic:field} due to []{move:baton-pass} are not affected by this effect.
233 251 9 User and target swap stat changes. User swaps its [stat modifiers]{mechanic:stat-modifiers} with the target.
234 252 9 Restores 1/16 of the user's max HP each turn. Restores 1/16 of the user's max [HP]{mechanic:hp} at the end of each turn. If the user leaves the [field]{mechanic:field}, this effect ends. This effect is passed on by []{move:baton-pass}.
235 253 9 User is immune to Ground moves and effects for five turns. For five turns, the user is immune to []{type:ground} moves. If the user is under the effect of []{move:ingrain} or has []{ability:levitate}, this move will fail. This effect is temporarily disabled by and cannot be used during []{move:gravity}. This effect is passed on by []{move:baton-pass}. For five turns, the user is immune to []{type:ground} moves. If the user is under the effect of []{move:ingrain} or has []{ability:levitate}, this move will [fail]{mechanic:fail}. This effect is temporarily disabled by and cannot be used during []{move:gravity}. This effect is passed on by []{move:baton-pass}.
236 254 9 User takes 1/3 the damage inflicted in recoil. Has a $effect_chance% chance to [burn]{mechanic:burn} the target. Inflicts [regular damage]{mechanic:regular-damage}. User takes 1/3 the damage it inflicts in recoil. Has a $effect_chance% chance to [burn]{mechanic:burn} the target. [Frozen]{mechanic:frozen} Pokémon may use this move, in which case they will thaw.
237 255 9 User takes 1/4 its max HP in recoil. Inflicts [typeless]{mechanic:typeless} [regular damage]{mechanic:regular-damage}. User takes 1/4 its max [HP]{mechanic:hp} in recoil. Ignores [accuracy]{mechanic:accuracy} and [evasion]{mechanic:evasion} modifiers. This move is used automatically when a Pokémon cannot use any other move legally, e.g., due to having no [PP]{mechanic:pp} remaining or being under the effect of both []{move:encore} and []{move:torment} at the same time. This move's recoil is not treated as recoil for the purposes of anything that affects recoil, such as the ability []{ability:rock-head}. It also is not prevented by []{ability:magic-guard}. This move cannot be copied by []{move:mimic}, []{move:mirror-move}, or []{move:sketch}, nor selected by []{move:assist} or []{move:metronome}, nor forced by []{move:encore}.
238 256 9 User dives underwater, dodging all attacks, and hits next turn. Inflicts [regular damage]{mechanic:regular-damage}. User dives underwater for one turn, becoming immune to attack, and hits on the second turn. During the immune turn, []{move:surf}, and []{move:whirlpool} still hit the user normally, and their power is doubled if appropriate. The user may be hit during its immune turn if under the effect of []{move:lock-on}, []{move:mind-reader}, or []{ability:no-guard}. This move cannot be selected by []{move:sleep-talk}.
268 287 9 Negates held items for five turns. For five turns (including this one), passive effects of held items are ignored, and Pokémon will not use their held items.
269 288 9 Removes any immunity to Ground damage. Inflicts [regular damage]{mechanic:regular-damage}. Removes the target's [immunity]{mechanic:immune} to []{type:ground}-type damage. This effect removes any existing Ground immunity due to []{ability:levitate}, []{move:magnet-rise}, or []{move:telekinesis}, and causes the target's []{type:flying} type to be ignored when it takes Ground damage. If the target isn't immune to Ground damage, this move will fail. This move can hit Pokémon under the effect of []{move:bounce}, []{move:fly}, or []{move:sky-drop}, and ends the effect of Bounce or Fly. Inflicts [regular damage]{mechanic:regular-damage}. Removes the target's [immunity]{mechanic:immune} to []{type:ground}-type damage. This effect removes any existing Ground immunity due to []{ability:levitate}, []{move:magnet-rise}, or []{move:telekinesis}, and causes the target's []{type:flying} type to be ignored when it takes Ground damage. If the target isn't immune to Ground damage, this move will [fail]{mechanic:fail}. This move can hit Pokémon under the effect of []{move:bounce}, []{move:fly}, or []{move:sky-drop}, and ends the effect of Bounce or Fly.
270 289 9 Always scores a critical hit. Inflicts [regular damage]{mechanic:regular-damage}. Always scores a [critical hit]{mechanic:critical-hit}.
271 290 9 Deals splash damage to Pokémon next to the target. Inflicts [regular damage]{mechanic:regular-damage}. If this move successfully hits the target, any Pokémon adjacent to the target are damaged for 1/16 their max [HP]{mechanic:hp}.
272 291 9 Raises the user's Special Attack, Special Defense, and Speed by one stage each. Raises the user's [Special Attack]{mechanic:special-attack}, [Special Defense]{mechanic:special-defense}, and [Speed]{mechanic:speed} by one [stage]{mechanic:stage} each.
273 292 9 Power is higher when the user weighs more than the target, up to a maximum of 120. Inflicts [regular damage]{mechanic:regular-damage}. The greater the user's weight compared to the target's, the higher power this move has, to a maximum of 120. User's weight | Power -------------------------------- | ----: Up to 2× the target's weight | 40 Up to 3× the target's weight | 60 Up to 4× the target's weight | 80 Up to 5× the target's weight | 100 More than 5× the target's weight | 120
274 293 9 Hits any Pokémon that shares a type with the user. Inflicts [regular damage]{mechanic:regular-damage}. Only Pokémon that share a type with the user will take damage from this move.
276 295 9 Changes the target's type to Water. Changes the target to pure []{type:water}-type until it leaves the field. If the target has []{ability:multitype}, this move will fail. Changes the target to pure []{type:water}-type until it leaves the field. If the target has []{ability:multitype}, this move will [fail]{mechanic:fail}.
277 296 9 Inflicts regular damage. Raises the user's Speed by one stage. Inflicts [regular damage]{mechanic:regular-damage}. Raises the user's [Speed]{mechanic:speed} by one [stage]{mechanic:stage}.
278 297 9 Lowers the target's Special Defense by two stages. Inflicts [regular damage]{mechanic:regular-damage}. Lowers the target's [Special Defense]{mechanic:special-defense} by two [stages]{mechanic:stage}.
279 298 9 Calculates damage with the target's attacking stat. Inflicts [regular damage]{mechanic:regular-damage}. Damage is calculated using the target's attacking stat rather than the user's.
280 299 9 Changes the target's ability to Simple. Changes the target's ability to []{ability:simple}.
281 300 9 Copies the user's ability onto the target. Changes the target's ability to match the user's. This effect ends when the target leaves battle.
282 301 9 Makes the target act next this turn. The target will act next this turn, regardless of [Speed]{mechanic:speed} or move priority. If the target has already acted this turn, this move will fail. The target will act next this turn, regardless of [Speed]{mechanic:speed} or move priority. If the target has already acted this turn, this move will [fail]{mechanic:fail}.
291 310 9 Heals the target for half its max HP. Heals the target for half its max [HP]{mechanic:hp}.
292 311 9 Has double power if the target has a major status ailment. Inflicts [regular damage]{mechanic:regular-damage}. If the target has a [major status ailment]{mechanic:major-status-ailment}, this move has double power.
293 312 9 Carries the target high into the air, dodging all attacks against either, and drops it next turn. Inflicts [regular damage]{mechanic:regular-damage}. User carries the target high into the air for one turn, during which no moves will hit either Pokémon and neither can act. On the following turn, the user drops the target, inflicting damage and ending the effect. If the target is []{type:flying}-type, this move will function as normal but inflict no damage. []{move:gust}, []{move:hurricane}, []{move:sky-uppercut}, []{move:smack-down}, []{move:thunder}, []{move:twister}, and []{move:whirlwind} can hit both the user and the target during this effect. []{move:gust} and []{move:twister} will additionally have double power. The damage from []{move:hail} and []{move:sandstorm} still applies during this effect. Either Pokémon may be hit during this effect if also under the effect of []{move:lock-on}, []{move:mind-reader}, or []{ability:no-guard}. This move cannot be used while []{move:gravity} is in effect. This move cannot be selected by []{move:sleep-talk}. *Bug*: If []{move:gravity} is used during a double or triple battle while this move is in effect, this move is not correctly canceled on the target, and it remains high in the air indefinitely. As this move prevents the target from acting, the only way to subsequently remove it from the field is to faint it.
294 313 9 Raises the user's Attack by one stage and its Speed by two stages. Raises the user's [Attack]{mechanic:attack} by one [stage]{mechanic:stage} and its [Speed]{mechanic:speed} by two stages.
295 314 9 Ends wild battles. Forces trainers to switch Pokémon. Inflicts [regular damage]{mechanic:regular-damage}, then [switches]{mechanic:switch-out} the target out for another of its trainer's Pokémon, selected at random. If the target is under the effect of []{move:ingrain} or []{ability:suction-cups}, or it has a []{move:substitute}, or its Trainer has no more usable Pokémon, it will not be switched out. If the target is a wild Pokémon, the battle ends instead.
296 315 9 Destroys the target's held berry. Inflicts [regular damage]{mechanic:regular-damage}. If the target is [holding]{mechanic:held-item} a [berry]{mechanic:berry}, it's destroyed and cannot be used in response to this move.
297 316 9 Makes the target act last this turn. Forces the target to act last this turn, regardless of [Speed]{mechanic:speed} or move [priority]{mechanic:priority}. If the target has already acted this turn, this move will fail. Forces the target to act last this turn, regardless of [Speed]{mechanic:speed} or move [priority]{mechanic:priority}. If the target has already acted this turn, this move will [fail]{mechanic:fail}.
408
409
410
411
412
413
414
428
429
430
431
432
433
434
478
479
480
481
482
483
484
485
486
487
498
499
500
501
502
503
504
549
550
551
552
553
554
555
556
557
560
561
562
563
564
565
566
567
568
569
570
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
718
719
720
721
722
723
724
728
729
730
731
732
733
734
744
745
746
747
748
749
750
751
752
753
754
755
756
757
775
776
777
778
779
780
781
786
787
788
789
790
791
792
793
794
795
796
808
809
810
811
812
813
814
864
865
866
867
868
869
870
887
888
889
890
891
892
893
894
895
902
903
904
905
906
907
908
909
910
911
912
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
975
976
977
978
979
980
981
983
984
985
986
987
988
989

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,494 @@
species_id,area_id,base_score,rate
1,2,50,30
2,2,80,10
3,2,90,3
4,2,50,30
5,2,80,10
6,2,90,3
7,4,50,30
8,4,80,10
9,4,90,3
10,1,30,50
11,1,50,30
12,1,70,20
13,1,30,50
14,1,50,30
15,1,70,20
16,2,30,50
17,2,50,30
18,2,70,20
19,2,30,50
20,2,50,30
21,2,30,50
22,2,50,30
23,1,30,50
24,1,50,30
25,1,80,10
26,1,90,3
27,3,50,30
28,3,70,20
29,2,30,50
30,2,50,30
31,2,70,20
32,2,30,50
33,2,50,30
34,2,70,20
35,3,80,10
36,3,90,3
37,2,70,20
38,2,80,10
39,2,80,10
40,2,90,3
41,3,30,50
42,3,50,30
43,1,30,50
44,1,50,30
45,1,70,20
46,1,30,50
47,1,50,30
48,1,30,50
49,1,50,30
50,3,30,50
51,3,50,30
52,2,50,30
53,2,70,20
54,4,50,30
55,4,70,20
56,3,50,30
57,3,70,20
58,2,70,20
59,2,80,10
60,4,50,30
61,4,80,10
62,4,90,3
63,2,50,30
64,2,80,10
65,2,90,3
66,3,50,30
67,3,80,10
68,3,90,3
69,1,30,50
70,1,50,30
71,1,70,20
72,5,30,50
73,5,50,30
74,3,30,50
75,3,50,30
76,3,70,20
77,2,50,30
78,2,70,20
79,4,50,30
80,4,70,20
81,3,50,30
82,3,70,20
83,2,70,20
84,2,50,30
85,2,70,20
86,5,50,30
87,5,70,20
88,2,50,30
89,2,70,20
90,5,50,30
91,5,70,20
92,1,50,30
93,1,80,10
94,1,90,3
95,3,80,10
96,1,50,30
97,1,70,20
98,5,50,30
99,5,70,20
100,2,50,30
101,2,70,20
102,1,50,30
103,1,70,20
104,3,50,30
105,3,70,20
106,3,80,10
107,3,80,10
108,2,70,20
109,3,50,30
110,3,70,20
111,3,50,30
112,3,70,20
113,2,90,3
114,1,50,30
115,2,70,20
116,5,50,30
117,5,70,20
118,4,50,30
119,4,70,20
120,5,50,30
121,5,70,20
122,2,70,20
123,2,70,20
124,2,70,20
125,3,70,20
126,3,70,20
127,1,70,20
128,2,70,20
129,4,30,50
130,4,90,3
131,5,90,3
132,2,70,20
133,2,90,3
134,2,90,3
135,2,90,3
136,2,90,3
137,2,80,10
138,5,50,30
139,5,70,20
140,5,50,30
141,5,70,20
142,3,70,20
143,2,80,10
144,3,90,3
145,3,90,3
146,3,90,3
147,4,70,20
148,4,80,10
149,3,90,3
150,2,90,3
151,1,100,1
152,2,50,30
153,2,80,10
154,2,90,3
155,2,50,30
156,2,80,10
157,2,90,3
158,4,50,30
159,4,80,10
160,3,90,3
161,2,30,50
162,2,50,30
163,1,30,50
164,1,50,30
165,2,30,50
166,2,50,30
167,2,30,50
168,2,50,30
169,3,90,3
170,5,50,30
171,5,70,20
172,2,80,10
173,2,80,10
174,2,80,10
175,2,80,10
176,2,90,3
177,1,50,30
178,1,70,20
179,2,50,30
180,2,70,20
181,2,80,10
182,1,80,10
183,4,50,30
184,4,70,20
185,3,70,20
186,4,80,10
187,2,50,30
188,2,70,20
189,2,80,10
190,1,70,20
191,2,50,30
192,2,70,20
193,2,80,10
194,4,50,30
195,4,70,20
196,2,90,3
197,2,90,3
198,1,70,20
199,4,80,10
200,1,70,20
201,1,70,20
202,2,80,10
203,2,70,20
204,1,50,30
205,1,70,20
206,1,90,3
207,3,50,30
208,3,90,3
209,2,50,30
210,2,70,20
211,5,80,10
212,2,90,3
213,5,80,10
214,1,80,10
215,3,50,30
216,1,50,30
217,1,70,20
218,3,50,30
219,3,70,20
220,3,50,30
221,3,70,20
222,5,70,20
223,5,50,30
224,5,70,20
225,3,70,20
226,5,70,20
227,3,70,20
228,3,50,30
229,3,70,20
230,5,80,10
231,3,50,30
232,3,70,20
233,2,80,10
234,2,50,30
235,2,80,10
236,3,80,10
237,3,80,10
238,2,80,10
239,3,80,10
240,3,80,10
241,2,70,20
242,2,90,3
243,3,90,3
244,3,90,3
245,3,90,3
246,3,70,20
247,3,80,10
248,3,90,3
249,3,90,3
250,3,90,3
251,1,100,1
252,1,50,30
253,1,80,10
254,1,90,3
255,2,50,30
256,2,80,10
257,2,90,3
258,4,50,30
259,4,80,10
260,4,90,3
261,2,30,50
262,2,50,30
263,2,30,50
264,2,50,30
265,1,30,50
266,1,50,30
267,1,70,20
268,1,50,30
269,1,70,20
270,4,30,50
271,4,50,30
272,4,80,10
273,1,30,50
274,1,50,30
275,1,80,10
276,2,30,50
277,2,50,30
278,5,30,50
279,5,50,30
280,2,50,30
281,2,70,20
282,2,80,10
283,4,50,30
284,4,70,20
285,1,50,30
286,1,70,20
287,1,50,30
288,1,70,20
289,1,80,10
290,1,50,30
291,1,70,20
292,1,80,10
293,3,50,30
294,3,70,20
295,3,80,10
296,3,50,30
297,3,70,20
298,4,80,10
299,3,70,20
300,2,50,30
301,2,70,20
302,3,70,20
303,3,70,20
304,3,50,30
305,3,70,20
306,3,80,10
307,3,50,30
308,3,70,20
309,2,50,30
310,2,70,20
311,2,90,3
312,2,90,3
313,3,70,20
314,3,70,20
315,2,70,20
316,1,50,30
317,1,70,20
318,5,50,30
319,5,70,20
320,5,50,30
321,5,80,10
322,3,50,30
323,3,70,20
324,3,70,20
325,2,50,30
326,2,70,20
327,2,50,30
328,3,50,30
329,3,70,20
330,3,80,10
331,3,50,30
332,3,70,20
333,2,50,30
334,2,80,10
335,2,70,20
336,1,70,20
337,3,70,20
338,3,70,20
339,4,50,30
340,4,70,20
341,4,50,30
342,4,70,20
343,3,50,30
344,3,70,20
345,5,70,20
346,5,80,10
347,5,70,20
348,5,80,10
349,5,70,20
350,5,90,3
351,2,80,10
352,1,70,20
353,1,50,30
354,1,70,20
355,1,50,30
356,1,70,20
357,1,70,20
358,3,80,10
359,3,80,10
360,2,80,10
361,3,50,30
362,3,70,20
363,5,50,30
364,5,70,20
365,5,80,10
366,5,50,30
367,5,80,10
368,5,80,10
369,5,80,10
370,5,50,30
371,3,50,30
372,3,70,20
373,3,80,10
374,3,70,20
375,3,80,10
376,3,90,3
377,3,90,3
378,3,90,3
379,3,90,3
380,2,90,3
381,2,90,3
382,5,90,3
383,3,90,3
384,2,90,3
385,3,100,1
386,3,100,1
387,1,50,30
388,1,80,10
389,1,90,3
390,2,50,30
391,2,80,10
392,2,90,3
393,4,50,30
394,4,80,10
395,4,90,3
396,2,30,50
397,2,50,30
398,2,70,20
399,2,30,50
400,2,50,30
401,1,50,30
402,1,70,20
403,2,50,30
404,2,70,20
405,2,80,10
406,2,80,10
407,2,80,10
408,3,70,20
409,3,80,10
410,3,70,20
411,3,80,10
412,1,50,30
413,1,70,20
414,1,70,20
415,1,50,30
416,1,70,20
417,1,50,30
418,1,70,20
419,3,70,20
420,3,80,10
421,2,90,3
422,5,50,30
423,5,70,20
424,4,50,30
425,4,70,20
426,1,80,10
427,2,50,30
428,2,70,20
429,1,80,10
430,1,80,10
431,2,50,30
432,2,70,20
433,2,70,20
434,3,80,10
435,3,50,30
436,3,70,20
437,3,80,10
438,2,90,3
439,2,90,3
440,2,50,30
441,2,70,20
442,2,80,10
443,3,50,30
444,3,70,20
445,4,50,30
446,4,70,20
447,2,70,20
448,2,50,30
449,2,70,20
450,5,80,10
451,5,50,30
452,5,70,20
453,1,90,3
454,3,50,30
455,3,70,20
456,3,80,10
457,3,90,3
458,3,90,3
459,3,50,30
460,3,70,20
461,3,80,10
462,3,80,10
463,2,80,10
464,3,80,10
465,1,80,10
466,3,80,10
467,3,80,10
468,2,80,10
469,2,80,10
470,2,90,3
471,2,90,3
472,3,80,10
473,3,80,10
474,2,80,10
475,2,80,10
476,3,80,10
477,1,80,10
478,3,80,10
479,2,90,3
480,2,90,3
481,2,90,3
482,2,90,3
483,3,90,3
484,3,90,3
485,3,90,3
486,3,90,3
487,3,90,3
488,1,90,3
489,5,90,3
490,5,100,1
491,3,100,1
492,2,100,1
493,3,100,1
1 species_id area_id base_score rate
2 1 2 50 30
3 2 2 80 10
4 3 2 90 3
5 4 2 50 30
6 5 2 80 10
7 6 2 90 3
8 7 4 50 30
9 8 4 80 10
10 9 4 90 3
11 10 1 30 50
12 11 1 50 30
13 12 1 70 20
14 13 1 30 50
15 14 1 50 30
16 15 1 70 20
17 16 2 30 50
18 17 2 50 30
19 18 2 70 20
20 19 2 30 50
21 20 2 50 30
22 21 2 30 50
23 22 2 50 30
24 23 1 30 50
25 24 1 50 30
26 25 1 80 10
27 26 1 90 3
28 27 3 50 30
29 28 3 70 20
30 29 2 30 50
31 30 2 50 30
32 31 2 70 20
33 32 2 30 50
34 33 2 50 30
35 34 2 70 20
36 35 3 80 10
37 36 3 90 3
38 37 2 70 20
39 38 2 80 10
40 39 2 80 10
41 40 2 90 3
42 41 3 30 50
43 42 3 50 30
44 43 1 30 50
45 44 1 50 30
46 45 1 70 20
47 46 1 30 50
48 47 1 50 30
49 48 1 30 50
50 49 1 50 30
51 50 3 30 50
52 51 3 50 30
53 52 2 50 30
54 53 2 70 20
55 54 4 50 30
56 55 4 70 20
57 56 3 50 30
58 57 3 70 20
59 58 2 70 20
60 59 2 80 10
61 60 4 50 30
62 61 4 80 10
63 62 4 90 3
64 63 2 50 30
65 64 2 80 10
66 65 2 90 3
67 66 3 50 30
68 67 3 80 10
69 68 3 90 3
70 69 1 30 50
71 70 1 50 30
72 71 1 70 20
73 72 5 30 50
74 73 5 50 30
75 74 3 30 50
76 75 3 50 30
77 76 3 70 20
78 77 2 50 30
79 78 2 70 20
80 79 4 50 30
81 80 4 70 20
82 81 3 50 30
83 82 3 70 20
84 83 2 70 20
85 84 2 50 30
86 85 2 70 20
87 86 5 50 30
88 87 5 70 20
89 88 2 50 30
90 89 2 70 20
91 90 5 50 30
92 91 5 70 20
93 92 1 50 30
94 93 1 80 10
95 94 1 90 3
96 95 3 80 10
97 96 1 50 30
98 97 1 70 20
99 98 5 50 30
100 99 5 70 20
101 100 2 50 30
102 101 2 70 20
103 102 1 50 30
104 103 1 70 20
105 104 3 50 30
106 105 3 70 20
107 106 3 80 10
108 107 3 80 10
109 108 2 70 20
110 109 3 50 30
111 110 3 70 20
112 111 3 50 30
113 112 3 70 20
114 113 2 90 3
115 114 1 50 30
116 115 2 70 20
117 116 5 50 30
118 117 5 70 20
119 118 4 50 30
120 119 4 70 20
121 120 5 50 30
122 121 5 70 20
123 122 2 70 20
124 123 2 70 20
125 124 2 70 20
126 125 3 70 20
127 126 3 70 20
128 127 1 70 20
129 128 2 70 20
130 129 4 30 50
131 130 4 90 3
132 131 5 90 3
133 132 2 70 20
134 133 2 90 3
135 134 2 90 3
136 135 2 90 3
137 136 2 90 3
138 137 2 80 10
139 138 5 50 30
140 139 5 70 20
141 140 5 50 30
142 141 5 70 20
143 142 3 70 20
144 143 2 80 10
145 144 3 90 3
146 145 3 90 3
147 146 3 90 3
148 147 4 70 20
149 148 4 80 10
150 149 3 90 3
151 150 2 90 3
152 151 1 100 1
153 152 2 50 30
154 153 2 80 10
155 154 2 90 3
156 155 2 50 30
157 156 2 80 10
158 157 2 90 3
159 158 4 50 30
160 159 4 80 10
161 160 3 90 3
162 161 2 30 50
163 162 2 50 30
164 163 1 30 50
165 164 1 50 30
166 165 2 30 50
167 166 2 50 30
168 167 2 30 50
169 168 2 50 30
170 169 3 90 3
171 170 5 50 30
172 171 5 70 20
173 172 2 80 10
174 173 2 80 10
175 174 2 80 10
176 175 2 80 10
177 176 2 90 3
178 177 1 50 30
179 178 1 70 20
180 179 2 50 30
181 180 2 70 20
182 181 2 80 10
183 182 1 80 10
184 183 4 50 30
185 184 4 70 20
186 185 3 70 20
187 186 4 80 10
188 187 2 50 30
189 188 2 70 20
190 189 2 80 10
191 190 1 70 20
192 191 2 50 30
193 192 2 70 20
194 193 2 80 10
195 194 4 50 30
196 195 4 70 20
197 196 2 90 3
198 197 2 90 3
199 198 1 70 20
200 199 4 80 10
201 200 1 70 20
202 201 1 70 20
203 202 2 80 10
204 203 2 70 20
205 204 1 50 30
206 205 1 70 20
207 206 1 90 3
208 207 3 50 30
209 208 3 90 3
210 209 2 50 30
211 210 2 70 20
212 211 5 80 10
213 212 2 90 3
214 213 5 80 10
215 214 1 80 10
216 215 3 50 30
217 216 1 50 30
218 217 1 70 20
219 218 3 50 30
220 219 3 70 20
221 220 3 50 30
222 221 3 70 20
223 222 5 70 20
224 223 5 50 30
225 224 5 70 20
226 225 3 70 20
227 226 5 70 20
228 227 3 70 20
229 228 3 50 30
230 229 3 70 20
231 230 5 80 10
232 231 3 50 30
233 232 3 70 20
234 233 2 80 10
235 234 2 50 30
236 235 2 80 10
237 236 3 80 10
238 237 3 80 10
239 238 2 80 10
240 239 3 80 10
241 240 3 80 10
242 241 2 70 20
243 242 2 90 3
244 243 3 90 3
245 244 3 90 3
246 245 3 90 3
247 246 3 70 20
248 247 3 80 10
249 248 3 90 3
250 249 3 90 3
251 250 3 90 3
252 251 1 100 1
253 252 1 50 30
254 253 1 80 10
255 254 1 90 3
256 255 2 50 30
257 256 2 80 10
258 257 2 90 3
259 258 4 50 30
260 259 4 80 10
261 260 4 90 3
262 261 2 30 50
263 262 2 50 30
264 263 2 30 50
265 264 2 50 30
266 265 1 30 50
267 266 1 50 30
268 267 1 70 20
269 268 1 50 30
270 269 1 70 20
271 270 4 30 50
272 271 4 50 30
273 272 4 80 10
274 273 1 30 50
275 274 1 50 30
276 275 1 80 10
277 276 2 30 50
278 277 2 50 30
279 278 5 30 50
280 279 5 50 30
281 280 2 50 30
282 281 2 70 20
283 282 2 80 10
284 283 4 50 30
285 284 4 70 20
286 285 1 50 30
287 286 1 70 20
288 287 1 50 30
289 288 1 70 20
290 289 1 80 10
291 290 1 50 30
292 291 1 70 20
293 292 1 80 10
294 293 3 50 30
295 294 3 70 20
296 295 3 80 10
297 296 3 50 30
298 297 3 70 20
299 298 4 80 10
300 299 3 70 20
301 300 2 50 30
302 301 2 70 20
303 302 3 70 20
304 303 3 70 20
305 304 3 50 30
306 305 3 70 20
307 306 3 80 10
308 307 3 50 30
309 308 3 70 20
310 309 2 50 30
311 310 2 70 20
312 311 2 90 3
313 312 2 90 3
314 313 3 70 20
315 314 3 70 20
316 315 2 70 20
317 316 1 50 30
318 317 1 70 20
319 318 5 50 30
320 319 5 70 20
321 320 5 50 30
322 321 5 80 10
323 322 3 50 30
324 323 3 70 20
325 324 3 70 20
326 325 2 50 30
327 326 2 70 20
328 327 2 50 30
329 328 3 50 30
330 329 3 70 20
331 330 3 80 10
332 331 3 50 30
333 332 3 70 20
334 333 2 50 30
335 334 2 80 10
336 335 2 70 20
337 336 1 70 20
338 337 3 70 20
339 338 3 70 20
340 339 4 50 30
341 340 4 70 20
342 341 4 50 30
343 342 4 70 20
344 343 3 50 30
345 344 3 70 20
346 345 5 70 20
347 346 5 80 10
348 347 5 70 20
349 348 5 80 10
350 349 5 70 20
351 350 5 90 3
352 351 2 80 10
353 352 1 70 20
354 353 1 50 30
355 354 1 70 20
356 355 1 50 30
357 356 1 70 20
358 357 1 70 20
359 358 3 80 10
360 359 3 80 10
361 360 2 80 10
362 361 3 50 30
363 362 3 70 20
364 363 5 50 30
365 364 5 70 20
366 365 5 80 10
367 366 5 50 30
368 367 5 80 10
369 368 5 80 10
370 369 5 80 10
371 370 5 50 30
372 371 3 50 30
373 372 3 70 20
374 373 3 80 10
375 374 3 70 20
376 375 3 80 10
377 376 3 90 3
378 377 3 90 3
379 378 3 90 3
380 379 3 90 3
381 380 2 90 3
382 381 2 90 3
383 382 5 90 3
384 383 3 90 3
385 384 2 90 3
386 385 3 100 1
387 386 3 100 1
388 387 1 50 30
389 388 1 80 10
390 389 1 90 3
391 390 2 50 30
392 391 2 80 10
393 392 2 90 3
394 393 4 50 30
395 394 4 80 10
396 395 4 90 3
397 396 2 30 50
398 397 2 50 30
399 398 2 70 20
400 399 2 30 50
401 400 2 50 30
402 401 1 50 30
403 402 1 70 20
404 403 2 50 30
405 404 2 70 20
406 405 2 80 10
407 406 2 80 10
408 407 2 80 10
409 408 3 70 20
410 409 3 80 10
411 410 3 70 20
412 411 3 80 10
413 412 1 50 30
414 413 1 70 20
415 414 1 70 20
416 415 1 50 30
417 416 1 70 20
418 417 1 50 30
419 418 1 70 20
420 419 3 70 20
421 420 3 80 10
422 421 2 90 3
423 422 5 50 30
424 423 5 70 20
425 424 4 50 30
426 425 4 70 20
427 426 1 80 10
428 427 2 50 30
429 428 2 70 20
430 429 1 80 10
431 430 1 80 10
432 431 2 50 30
433 432 2 70 20
434 433 2 70 20
435 434 3 80 10
436 435 3 50 30
437 436 3 70 20
438 437 3 80 10
439 438 2 90 3
440 439 2 90 3
441 440 2 50 30
442 441 2 70 20
443 442 2 80 10
444 443 3 50 30
445 444 3 70 20
446 445 4 50 30
447 446 4 70 20
448 447 2 70 20
449 448 2 50 30
450 449 2 70 20
451 450 5 80 10
452 451 5 50 30
453 452 5 70 20
454 453 1 90 3
455 454 3 50 30
456 455 3 70 20
457 456 3 80 10
458 457 3 90 3
459 458 3 90 3
460 459 3 50 30
461 460 3 70 20
462 461 3 80 10
463 462 3 80 10
464 463 2 80 10
465 464 3 80 10
466 465 1 80 10
467 466 3 80 10
468 467 3 80 10
469 468 2 80 10
470 469 2 80 10
471 470 2 90 3
472 471 2 90 3
473 472 3 80 10
474 473 3 80 10
475 474 2 80 10
476 475 2 80 10
477 476 3 80 10
478 477 1 80 10
479 478 3 80 10
480 479 2 90 3
481 480 2 90 3
482 481 2 90 3
483 482 2 90 3
484 483 3 90 3
485 484 3 90 3
486 485 3 90 3
487 486 3 90 3
488 487 3 90 3
489 488 1 90 3
490 489 5 90 3
491 490 5 100 1
492 491 3 100 1
493 492 2 100 1
494 493 3 100 1

View file

@ -0,0 +1,6 @@
pal_park_area_id,local_language_id,name
1,9,Forest
2,9,Field
3,9,Mountain
4,9,Pond
5,9,Sea
1 pal_park_area_id local_language_id name
2 1 9 Forest
3 2 9 Field
4 3 9 Mountain
5 4 9 Pond
6 5 9 Sea

View file

@ -0,0 +1,6 @@
id,identifier
1,forest
2,field
3,mountain
4,pond
5,sea
1 id identifier
2 1 forest
3 2 field
4 3 mountain
5 4 pond
6 5 sea

View file

@ -1,20 +0,0 @@
pokemon_id,is_battle_only
172,0
201,0
351,1
386,0
412,0
413,0
421,1
422,0
423,0
479,0
487,0
492,0
493,0
550,0
555,0
585,0
586,0
648,0
649,0
1 pokemon_id is_battle_only
2 172 0
3 201 0
4 351 1
5 386 0
6 412 0
7 413 0
8 421 1
9 422 0
10 423 0
11 479 0
12 487 0
13 492 0
14 493 0
15 550 0
16 555 0
17 585 0
18 586 0
19 648 0
20 649 0

File diff suppressed because it is too large Load diff

View file

@ -2362,10 +2362,40 @@ pokemon_id,version_id,item_id,rarity
655,16,134,100
655,17,134,100
655,18,134,100
662,7,220,100
662,8,220,100
662,9,220,100
662,10,220,100
662,11,220,100
662,12,220,100
662,13,220,100
662,14,220,100
662,15,220,100
662,16,220,100
662,17,220,100
662,18,220,100
663,7,220,100
663,8,220,100
663,9,220,100
663,10,220,100
663,11,220,100
663,12,220,100
663,13,220,100
663,14,220,100
663,15,220,100
663,16,220,100
663,17,220,100
663,18,220,100
664,7,220,100
664,8,220,100
664,9,220,100
664,10,220,100
664,11,220,100
664,12,220,100
664,13,220,100
664,14,220,100
664,15,220,100
664,16,220,100
664,17,220,100
664,18,220,100
665,17,204,5

1 pokemon_id version_id item_id rarity
2362 655 16 134 100
2363 655 17 134 100
2364 655 18 134 100
2365 662 7 220 100
2366 662 8 220 100
2367 662 9 220 100
2368 662 10 220 100
2369 662 11 220 100
2370 662 12 220 100
2371 662 13 220 100
2372 662 14 220 100
2373 662 15 220 100
2374 662 16 220 100
2375 662 17 220 100
2376 662 18 220 100
2377 663 7 220 100
2378 663 8 220 100
2379 663 9 220 100
2380 663 10 220 100
2381 663 11 220 100
2382 663 12 220 100
2383 663 13 220 100
2384 663 14 220 100
2385 663 15 220 100
2386 663 16 220 100
2387 663 17 220 100
2388 663 18 220 100
2389 664 7 220 100
2390 664 8 220 100
2391 664 9 220 100
2392 664 10 220 100
2393 664 11 220 100
2394 664 12 220 100
2395 664 13 220 100
2396 664 14 220 100
2397 664 15 220 100
2398 664 16 220 100
2399 664 17 220 100
2400 664 18 220 100
2401 665 17 204 5

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -150,9 +150,21 @@ def load(session, tables=[], directory=None, drop_tables=False, verbose=False, s
# Drop all tables if requested
if drop_tables:
bind = session.get_bind()
print_start('Dropping tables')
for n, table in enumerate(reversed(table_objs)):
table.drop(checkfirst=True)
# Drop columns' types if appropriate; needed for enums in
# postgresql
for column in table.c:
try:
drop = column.type.drop
except AttributeError:
pass
else:
drop(bind=bind, checkfirst=True)
print_status('%s/%s' % (n, len(table_objs)))
print_done()

View file

@ -1,16 +1,37 @@
from functools import partial
from sqlalchemy.ext.associationproxy import association_proxy
from sqlalchemy.ext.associationproxy import association_proxy, AssociationProxy
from sqlalchemy.orm import Query, aliased, mapper, relationship, synonym
from sqlalchemy.orm.collections import attribute_mapped_collection
from sqlalchemy.orm.scoping import ScopedSession
from sqlalchemy.orm.session import Session, object_session
from sqlalchemy.schema import Column, ForeignKey, Table
from sqlalchemy.sql.expression import and_, bindparam, select
from sqlalchemy.sql.expression import and_, bindparam, select, exists
from sqlalchemy.sql.operators import ColumnOperators
from sqlalchemy.types import Integer
from pokedex.db import markdown
class LocalAssociationProxy(AssociationProxy, ColumnOperators):
"""An association proxy for names in the default language
Over the regular association_proxy, this provides sorting and filtering
capabilities, implemented via SQL subqueries.
"""
def __clause_element__(self):
q = select([self.remote_attr])
q = q.where(self.target_class.foreign_id == self.owning_class.id)
q = q.where(self.target_class.local_language_id == bindparam('_default_language_id'))
return q
def operate(self, op, *other, **kwargs):
q = select([self.remote_attr])
q = q.where(self.target_class.foreign_id == self.owning_class.id)
q = q.where(self.target_class.local_language_id == bindparam('_default_language_id'))
q = q.where(op(self.remote_attr, *other))
return exists(q)
def _getset_factory_factory(column_name, string_getter):
"""Hello! I am a factory for creating getset_factory functions for SQLA.
I exist to avoid the closure-in-a-loop problem.
@ -97,6 +118,7 @@ def create_translation_table(_table_name, foreign_class, relation_name,
Translations = type(_table_name, (object,), {
'_language_identifier': association_proxy('local_language', 'identifier'),
'relation_name': relation_name,
})
# Create the table object
@ -165,7 +187,7 @@ def create_translation_table(_table_name, foreign_class, relation_name,
# Class.(column) -- accessor for the default language's value
setattr(foreign_class, name,
association_proxy(local_relation_name, name,
LocalAssociationProxy(local_relation_name, name,
getset_factory=getset_factory))
# Class.(column)_map -- accessor for the language dict

View file

@ -1020,6 +1020,39 @@ class NaturePokeathlonStat(TableBase):
max_change = Column(Integer, nullable=False,
info=dict(description="Maximum change"))
class PalPark(TableBase):
u"""Data for the Pal Park mini-game in Generation IV
"""
__tablename__ = 'pal_park'
__singlename__ = 'pal_park'
species_id = Column(Integer, ForeignKey('pokemon_species.id'), primary_key=True,
info=dict(description="The Pokémon species this data pertains to"))
area_id = Column(Integer, ForeignKey('pal_park_areas.id'), nullable=False,
info=dict(description="The area in which this Pokémon is found"))
base_score = Column(Integer, nullable=False,
info=dict(description="Used in calculating the player's score at the end of a Pal Park run"))
rate = Column(Integer, nullable=False,
info=dict(description="Base rate for encountering this Pokémon"))
class PalParkArea(TableBase):
u"""A distinct area of Pal Park in which Pokémon appear.
"""
__tablename__ = 'pal_park_areas'
__singlename__ = 'pal_park_area'
id = Column(Integer, primary_key=True, nullable=False,
info=dict(description="A numeric ID"))
identifier = Column(Unicode(8), nullable=False,
info=dict(description="An identifier", format='identifier'))
create_translation_table('pal_park_area_names', PalParkArea, 'names',
name = Column(Unicode(8), nullable=False, index=True,
info=dict(description="The name", format='plaintext', official=False)),
)
class PokeathlonStat(TableBase):
u"""A Pokéathlon stat, such as "Stamina" or "Jump".
"""
@ -1234,11 +1267,15 @@ class PokemonForm(TableBase):
info=dict(description=u'Set for exactly one form used as the default for each pokemon (not necessarily species).'))
is_battle_only = Column(Boolean, nullable=False,
info=dict(description=u'Set iff the form can only appear in battle.'))
form_order = Column(Integer, nullable=False, autoincrement=False,
info=dict(description=u"The order in which forms should be sorted within a species' forms. Multiple forms may have equal order, in which case they should fall back on sorting by name. "
u"Used in generating `pokemon_forms.order` and `pokemon.order`."))
order = Column(Integer, nullable=False, autoincrement=False,
info=dict(description=u'The order in which forms should be sorted. Multiple forms may have equal order, in which case they should fall back on sorting by name.'))
info=dict(description=u'The order in which forms should be sorted within all forms. Multiple forms may have equal order, in which case they should fall back on sorting by name.'))
@property
def name(self):
"""Name of this form: the form_name, if set; otherwise the species name"""
return self.pokemon_name or self.species.name
create_translation_table('pokemon_form_names', PokemonForm, 'names',
@ -1409,6 +1446,8 @@ class PokemonSpecies(TableBase):
info=dict(description="ID of the growth rate for this family"))
forms_switchable = Column(Boolean, nullable=False,
info=dict(description=u"True iff a particular individual of this species can switch beween its different forms."))
order = Column(Integer, nullable=False, index=True,
info=dict(description=u'The order in which species should be sorted. Based on National Dex order, except families are grouped together and sorted by stage.'))
create_translation_table('pokemon_species_names', PokemonSpecies, 'names',
relation_lazy='joined',
@ -1672,7 +1711,6 @@ ContestCombo.second = relationship(Move,
innerjoin=True, lazy='joined',
backref='contest_combo_second')
Encounter.condition_value_map = relationship(EncounterConditionValueMap,
backref='encounter')
Encounter.condition_values = association_proxy('condition_value_map', 'condition_value')
@ -1904,6 +1942,10 @@ NaturePokeathlonStat.pokeathlon_stat = relationship(PokeathlonStat,
backref='nature_effects')
PalPark.area = relationship(PalParkArea,
innerjoin=True, lazy='joined')
Pokedex.region = relationship(Region,
innerjoin=True,
backref='pokedexes')
@ -1917,10 +1959,8 @@ Pokemon.all_abilities = relationship(Ability,
secondary=PokemonAbility.__table__,
order_by=PokemonAbility.slot.asc(),
innerjoin=True,
backref=backref('all_pokemon',
order_by=Pokemon.order.asc(),
),
)
backref=backref('all_pokemon', order_by=Pokemon.order.asc()),
doc=u"All abilities the Pokémon can have, including the Hidden Ability")
Pokemon.abilities = relationship(Ability,
secondary=PokemonAbility.__table__,
primaryjoin=and_(
@ -1929,10 +1969,8 @@ Pokemon.abilities = relationship(Ability,
),
innerjoin=True,
order_by=PokemonAbility.slot.asc(),
backref=backref('pokemon',
order_by=Pokemon.order.asc(),
),
)
backref=backref('pokemon', order_by=Pokemon.order.asc()),
doc=u"Abilities the Pokémon can have in the wild")
Pokemon.dream_ability = relationship(Ability,
secondary=PokemonAbility.__table__,
primaryjoin=and_(
@ -1940,10 +1978,8 @@ Pokemon.dream_ability = relationship(Ability,
PokemonAbility.is_dream == True,
),
uselist=False,
backref=backref('dream_pokemon',
order_by=Pokemon.order,
),
)
backref=backref('dream_pokemon', order_by=Pokemon.order),
doc=u"The Pokémon's Hidden Ability")
Pokemon.forms = relationship(PokemonForm,
primaryjoin=Pokemon.id==PokemonForm.pokemon_id,
order_by=(PokemonForm.order.asc(), PokemonForm.form_identifier.asc()),
@ -1952,9 +1988,11 @@ Pokemon.default_form = relationship(PokemonForm,
primaryjoin=and_(
Pokemon.id==PokemonForm.pokemon_id,
PokemonForm.is_default==True),
uselist=False, lazy='joined')
uselist=False, lazy='joined',
doc=u"A representative form of this pokémon")
Pokemon.items = relationship(PokemonItem,
backref='pokemon')
backref='pokemon',
doc=u"Info about items this pokémon holds in the wild")
Pokemon.stats = relationship(PokemonStat,
innerjoin=True,
order_by=PokemonStat.stat_id.asc(),
@ -2040,7 +2078,9 @@ PokemonStat.stat = relationship(Stat,
PokemonSpecies.parent_species = relationship(PokemonSpecies,
primaryjoin=PokemonSpecies.evolves_from_species_id==PokemonSpecies.id,
remote_side=[PokemonSpecies.id],
backref='child_species')
backref=backref('child_species',
doc=u"The species to which this one evolves"),
doc=u"The species from which this one evolves")
PokemonSpecies.evolutions = relationship(PokemonEvolution,
primaryjoin=PokemonSpecies.id==PokemonEvolution.evolved_species_id,
backref=backref('evolved_species', innerjoin=True, lazy='joined'))
@ -2059,7 +2099,7 @@ PokemonSpecies.egg_groups = relationship(EggGroup,
secondary=PokemonEggGroup.__table__,
innerjoin=True,
order_by=PokemonEggGroup.egg_group_id.asc(),
backref=backref('species', order_by=Pokemon.order.asc()))
backref=backref('species', order_by=PokemonSpecies.order.asc()))
PokemonSpecies.forms = relationship(PokemonForm,
secondary=Pokemon.__table__,
primaryjoin=PokemonSpecies.id==Pokemon.species_id,
@ -2071,7 +2111,8 @@ PokemonSpecies.default_form = relationship(PokemonForm,
Pokemon.is_default==True),
secondaryjoin=and_(Pokemon.id==PokemonForm.pokemon_id,
PokemonForm.is_default==True),
uselist=False)
uselist=False,
doc=u"A representative form of this species")
PokemonSpecies.default_pokemon = relationship(Pokemon,
primaryjoin=and_(
PokemonSpecies.id==Pokemon.species_id,
@ -2090,6 +2131,9 @@ PokemonSpecies.generation = relationship(Generation,
PokemonSpecies.shape = relationship(PokemonShape,
innerjoin=True,
backref='species')
PokemonSpecies.pal_park = relationship(PalPark,
uselist=False,
backref='species')
PokemonSpeciesFlavorText.version = relationship(Version, innerjoin=True, lazy='joined')
PokemonSpeciesFlavorText.language = relationship(Language, innerjoin=True, lazy='joined')

0
pokedex/doc/__init__.py Normal file
View file

334
pokedex/doc/tabledoc.py Normal file
View file

@ -0,0 +1,334 @@
# Encoding: UTF-8
u"""Automatic documentation generation for pokédex tables
This adds a "dex-table" directive to Sphinx, which works like "autoclass",
but documents Pokédex mapped classes.
"""
# XXX: This assumes all the tables are in pokedex.db.tables
import functools
import textwrap
from docutils import nodes
from docutils.statemachine import ViewList
from sphinx.util.compat import Directive, make_admonition
from sphinx.locale import _
from sphinx.domains.python import PyClasslike
from sphinx.util.docfields import Field, GroupedField, TypedField
from sphinx.ext.autodoc import ClassLevelDocumenter
from sqlalchemy import types
from sqlalchemy.orm.attributes import InstrumentedAttribute
from sqlalchemy.orm.properties import RelationshipProperty
from sqlalchemy.orm import Mapper, configure_mappers
from sqlalchemy.ext.associationproxy import AssociationProxy
from pokedex.db.markdown import MoveEffectPropertyMap, MoveEffectProperty
from pokedex.db import tables, markdown
# Make sure all the backrefs are in place
configure_mappers()
column_to_cls = {}
for cls in tables.mapped_classes:
for column in cls.__table__.c:
column_to_cls[column] = cls
class dextabledoc(nodes.Admonition, nodes.Element):
pass
def visit_todo_node(self, node):
self.visit_admonition(node)
def depart_todo_node(self, node):
self.depart_admonition(node)
def column_type_str(column):
"""Extract the type name from a SQLA column
"""
type_ = column.type
# We're checking the specific type here: no issubclass
if type(type_) in (types.Integer, types.SmallInteger):
return 'int'
if type(type_) == types.Boolean:
return 'bool'
if type(type_) == types.Unicode:
return u'unicode %s' % column.info['format']
if type(type_) == types.Enum:
return 'enum: [%s]' % ', '.join(type_.enums)
if type(type_) == markdown.MarkdownColumn:
return 'markdown'
raise ValueError(repr(type_))
common_columns = 'id identifier name'.split()
def column_header(c, class_name=None, transl_name=None, show_type=True,
relation=None, relation_name=None):
"""Return the column header for the given column"""
result = []
if relation_name:
name = relation_name
else:
name = c.name
if class_name:
result.append(u'%s.\ **%s**' % (class_name, name))
else:
result.append(u'**%s**' % c.name)
if c.foreign_keys:
for fk in c.foreign_keys:
if fk.column in column_to_cls:
foreign_cls = column_to_cls[fk.column]
if relation_name and relation_name + '_id' == c.name:
result.append(u'(%s' % c.name)
elif relation_name:
result.append(u'(**%s** →' % c.name)
else:
result.append(u'(→')
result.append(u':class:`~pokedex.db.tables.%s`.%s)' % (
foreign_cls.__name__,
fk.column.name
))
break
elif show_type:
result.append(u'(*%s*)' % column_type_str(c))
if transl_name:
result.append(u'via *%s*' % transl_name)
return ' '.join(result)
def with_header(header=None):
"""Decorator that adds a section header if there's a any output
The decorated function should yield output lines; if there are any the
header gets added.
"""
def wrap(func):
@functools.wraps(func)
def wrapped(cls, remaining_attrs):
result = list(func(cls, remaining_attrs))
if result:
# Sphinx/ReST doesn't allow "-----" just anywhere :(
yield u''
yield u'.. raw:: html'
yield u''
yield u' <hr>'
yield u''
if header:
yield header + u':'
yield u''
for row in result:
yield row
return wrapped
return wrap
### Section generation functions
def generate_table_header(cls, remaining_attrs):
first_line, sep, next_lines = unicode(cls.__doc__).partition(u'\n')
yield first_line
for line in textwrap.dedent(next_lines).split('\n'):
yield line
yield ''
yield u'Table name: *%s*' % cls.__tablename__
try:
yield u'(single: *%s*)' % cls.__singlename__
except AttributeError:
pass
yield u''
yield u'Primary key: %s.' % u', '.join(
u'**%s**' % col.key for col in cls.__table__.primary_key.columns)
yield u''
def generate_common(cls, remaining_attrs):
common_col_headers = []
for c in cls.__table__.c:
if c.name in common_columns:
common_col_headers.append(column_header(c, show_type=False))
remaining_attrs.remove(c.name)
for translation_class in cls.translation_classes:
for c in translation_class.__table__.c:
if c.name in common_columns:
common_col_headers.append(column_header(c, None,
translation_class.__table__.name, show_type=False))
remaining_attrs.remove(c.name)
if common_col_headers:
if len(common_col_headers) > 1:
common_col_headers[-1] = 'and ' + common_col_headers[-1]
if len(common_col_headers) > 2:
separator = u', '
else:
separator = u' '
yield u'Has'
yield separator.join(common_col_headers) + '.'
yield u''
@with_header(u'Columns')
def generate_columns(cls, remaining_attrs):
name = cls.__name__
for c in [c for c in cls.__table__.c if c.name not in common_columns]:
remaining_attrs.remove(c.name)
relation_name = c.name[:-3]
if c.name.endswith('_id') and relation_name in remaining_attrs:
relation = getattr(cls, relation_name)
yield column_header(c, name,
relation=relation, relation_name=relation_name)
remaining_attrs.remove(relation_name)
else:
yield column_header(c, name) + ':'
yield u''
yield u' ' + unicode(c.info['description'])
yield u''
@with_header(u'Internationalized strings')
def generate_strings(cls, remaining_attrs):
for translation_class in cls.translation_classes:
for c in translation_class.__table__.c:
if 'format' in c.info:
remaining_attrs.discard(c.name)
remaining_attrs.discard(c.name + '_map')
if c.name in common_columns:
continue
yield column_header(c, cls.__name__,
translation_class.__table__.name)
yield u''
yield u' ' + unicode(c.info['description'])
yield u''
@with_header(u'Relationships')
def generate_relationships(cls, remaining_attrs):
def isrelationship(prop):
return isinstance(prop, InstrumentedAttribute) and isinstance(prop.property, RelationshipProperty)
for attr_name in sorted(remaining_attrs):
prop = getattr(cls, attr_name)
if not isrelationship(prop):
continue
rel = prop.property
yield u'%s.\ **%s**' % (cls.__name__, attr_name)
class_name = u':class:`~pokedex.db.tables.%s`' % rel.mapper.class_.__name__
if rel.uselist:
class_name = u'[%s]' % class_name
yield u'(→ %s)' % class_name
if rel.doc:
yield u''
yield u' ' + unicode(rel.doc)
if rel.secondary is not None:
yield u''
yield ' Association table: ``%s``' % rel.secondary
#if rel.primaryjoin is not None:
# yield u''
# yield ' Join condition: ``%s``' % rel.primaryjoin
# if rel.secondaryjoin is not None:
# yield ' , ``%s``' % rel.secondaryjoin
if rel.order_by:
yield u''
yield u' '
yield ' Ordered by: ' + u', '.join(
u'``%s``' % o for o in rel.order_by)
yield u''
remaining_attrs.remove(attr_name)
@with_header(u'Association Proxies')
def generate_associationproxies(cls, remaining_attrs):
for attr_name in sorted(remaining_attrs):
prop = getattr(cls, attr_name)
if isinstance(prop, AssociationProxy):
yield u'%s.\ **%s**:' % (cls.__name__, attr_name)
yield '``{prop.remote_attr.key}`` of ``self.{prop.local_attr.key}``'.format(
prop=prop)
'''if 'description' in info:
yield u''
yield u' ' + unicode(info['description'])'''
yield u''
remaining_attrs.remove(attr_name)
@with_header(u'Undocumented')
def generate_undocumented(cls, remaining_attrs):
for c in sorted([c for c in remaining_attrs if isinstance(getattr(cls, c),
(InstrumentedAttribute, AssociationProxy,
MoveEffectPropertyMap, MoveEffectProperty))]):
yield u''
yield u'%s.\ **%s**' % (cls.__name__, c)
remaining_attrs.remove(c)
@with_header(None)
def generate_other(cls, remaining_attrs):
for c in sorted(remaining_attrs):
yield u''
member = getattr(cls, c)
if callable(member):
yield '.. automethod:: %s.%s' % (cls.__name__, c)
else:
yield '.. autoattribute:: %s.%s' % (cls.__name__, c)
yield u''
remaining_attrs.clear()
class DexTable(PyClasslike):
"""The actual Sphinx documentation generation whatchamacallit
"""
doc_field_types = [
TypedField('field', label='Fields',
typerolename='obj', typenames=('fieldname', 'type')),
]
def get_signature_prefix(self, sig):
return ''
#return u'mapped class '
def run(self):
section = nodes.section()
super_result = super(DexTable, self).run()
title_text = self.names[0][0]
section += nodes.title(text=title_text)
section += super_result
section['ids'] = ['dex-table-%s' % title_text.lower()]
return [section]
def before_content(self):
name = self.names[0][0]
for cls in tables.mapped_classes:
if name == cls.__name__:
break
else:
raise ValueError('Table %s not found' % name)
table = cls.__table__
remaining_attrs = set(x for x in dir(cls) if not x.startswith('_'))
remaining_attrs.difference_update(['metadata', 'translation_classes',
'add_relationships', 'summary_column'])
for transl_class in cls.translation_classes:
remaining_attrs.difference_update([
transl_class.relation_name,
transl_class.relation_name + '_table',
transl_class.relation_name + '_local',
])
generated_content = [] # Just a list of lines!
generated_content.extend(generate_table_header(cls, remaining_attrs))
generated_content.extend(generate_common(cls, remaining_attrs))
generated_content.extend(generate_columns(cls, remaining_attrs))
generated_content.extend(generate_strings(cls, remaining_attrs))
generated_content.extend(generate_relationships(cls, remaining_attrs))
generated_content.extend(generate_associationproxies(cls, remaining_attrs))
generated_content.extend(generate_undocumented(cls, remaining_attrs))
generated_content.extend(generate_other(cls, remaining_attrs))
generated_content.append(u'')
self.content = ViewList(generated_content + list(self.content))
return super(DexTable, self).before_content()
def get_index_text(self, modname, name_cls):
return '%s (mapped class)' % name_cls[0]
def setup(app):
app.add_directive('dex-table', DexTable)
# XXX: Specify that this depends on pokedex.db.tables ...?

View file

@ -0,0 +1,22 @@
import os
import re
from pokedex.db.tables import mapped_classes
def test_main_tables():
"""Check that tables.py and main-tables.rst are in sync: every table should
be documented, and every documented table should exist."""
main_tables_path = os.path.join(os.path.dirname(__file__), '../../doc/main-tables.rst')
with open(main_tables_path) as f:
doc_class_names = set(
re.findall(r'^\.\. dex-table:: (\w+)$', f.read(), re.MULTILINE)
)
mapped_class_names = set(cls.__name__ for cls in mapped_classes)
# EXTRA ITEMS IN THE LEFT SET: tables defined but not documented
# EXTRA ITEMS IN THE RIGHT SET: tables documented but not defined
assert mapped_class_names == doc_class_names

67
scripts/palpark.py Executable file
View file

@ -0,0 +1,67 @@
#!/usr/bin/env python2
"""Dump /arc/ppark.narc.
This is an unmaintained one-shot script, only included in the repo for
reference.
"""
import sys
from struct import pack, unpack
import binascii
import pokedex.db
from pokedex.db.tables import PalPark
types = [
'',
'grass',
'fire',
'water',
'bug',
'normal',
'poison',
'electric',
'ground',
'fighting',
'psychic',
'rock',
'ghost',
'ice',
'steel',
'dragon',
'dark',
'flying',
]
areas = {
1: 'forest',
2: 'mountain',
3: 'field',
0x200: 'pond',
0x400: 'sea',
}
session = pokedex.db.connect()()
with open(sys.argv[1], "rb") as f:
f.seek(0x3C)
for i in range(0xb8e // 6):
data = f.read(6)
area, score, rate, t1, t2 = unpack("<HBBBB", data)
print(i+1, binascii.hexlify(data).decode(),
areas[area], score, rate, types[t1], types[t2])
obj = PalPark()
obj.species_id = i+1
obj.area = areas[area]
obj.base_score = score
obj.rate = rate
session.add(obj)
session.commit()

View file

@ -0,0 +1,55 @@
/*
Pokémon species order: National dex order, except that families are grouped
together around whichever member has the lowest National ID, with babies first.
Technically, the idea is to sort each evolutionary tree topologically, but
National ID with babies first does the right thing. The id column happens to
match Nat'l order, and the evolutionary chain IDs are in the right order too.
*/
UPDATE pokemon_species ps
SET "order" = ps_order."order"
FROM (
SELECT ps_sub.id, ROW_NUMBER() OVER (ORDER BY ps_sub.evolution_chain_id,
ps_sub.is_baby DESC, ps_sub.id) "order"
FROM pokemon_species ps_sub
) ps_order
WHERE ps.id = ps_order.id;
/*
Pokémon form order: Same as species order, with a species' forms ordered as
specified by pokemon_forms.form_order. Since form_order can have duplicate
orders to indicate that they should fall back on ordering by name, so can
pokemon_forms.order.
*/
UPDATE pokemon_forms pf
SET "order" = pf_order."order"
FROM (
SELECT pf_sub.id, DENSE_RANK() OVER (ORDER BY ps."order",
pf_sub.form_order) "order"
FROM pokemon_forms pf_sub
JOIN pokemon p ON pf_sub.pokemon_id = p.id
JOIN pokemon_species ps ON p.species_id = ps.id
) pf_order
WHERE pf.id = pf_order.id;
/*
[Functional] Pokémon order: Same as form order, except not all forms have their
own functional Pokémon, so we need to close the gaps.
These aren't supposed to have duplicate orders, but this query will give them
duplicate orders where applicable anyway so that the unique constraint can
complain if needed instead of the query silently ordering things arbitrarily.
*/
UPDATE pokemon p
SET "order" = p_order."order"
FROM (
SELECT p_sub.id, DENSE_RANK() OVER (ORDER BY pf."order") "order"
FROM pokemon p_sub
JOIN pokemon_forms pf ON p_sub.id = pf.pokemon_id AND pf.is_default = True
) p_order
WHERE p.id = p_order.id;

View file

@ -8,7 +8,7 @@ setup(
'pokedex': ['data/csv/*.csv']
},
install_requires=[
'SQLAlchemy>=0.7',
'SQLAlchemy>=0.7.3',
'whoosh>=2.2.2',
'markdown',
'construct',