\documentclass[12pt,notitlepage]{report}

\newcommand{\version}{0.0.2}

\title{Sigmodr v\version}
\author{Ben Boeckel $<$\texttt{\href{mailto:mathStuf@gmail.com}%
    {MathStuf@gmail.com}}$>$}

\usepackage[unicode]{hyperref}
\hypersetup{%
    colorlinks=true,%
    citecolor=red,%
    urlcolor=red,%
    filecolor=red,%
    linkcolor=red,%
    pdfauthor={Ben Boeckel},%
    pdftitle={Sigmodr Documentation},%
}
\usepackage{listings}
\usepackage{color}
\usepackage{setspace}
\usepackage{multicol}
\usepackage{fontenc}
\usepackage{textcomp}
\usepackage[debugshow]{xtab}

% This gives syntax highlighting in the python/ruby/kjs environments
% Adapted from http://ubuntuforums.org/archive/index.php/t-331602.html
\renewcommand{\lstlistlistingname}{Code Listings}
\renewcommand{\lstlistingname}{Code Listing}
\definecolor{gray}{gray}{0.5}
\definecolor{green}{rgb}{0,0.5,0}

\lstset{%
    basicstyle=\ttfamily\small\setstretch{1},%
    stringstyle=\color{red},%
    showstringspaces=false,%
    alsoletter={1234567890},%
    otherkeywords={\ , \}, \{},%
    keywordstyle=\color{blue},%
    emphstyle=\color{black}\bfseries,%
    emphstyle=[2]\color{green},%
    emphstyle=[3]\color{blue},%
    upquote=true,%
    commentstyle=\color{gray}\slshape,%
    emph={[4]1,2,3,4,5,6,7,8,9,0},%
    emphstyle=[4]\color{blue},%
    literate=*{:}{{\textcolor{blue}:}}{1}%
        {?}{{\textcolor{blue}?}}{1}%
        {=}{{\textcolor{blue}=}}{1}%
        {-}{{\textcolor{blue}-}}{1}%
        {+}{{\textcolor{blue}+}}{1}%
        {*}{{\textcolor{blue}*}}{1}%
        {!}{{\textcolor{blue}!}}{1}%
        {(}{{\textcolor{blue}(}}{1}%
        {)}{{\textcolor{blue})}}{1}%
        {[}{{\textcolor{blue}[}}{1}%
        {]}{{\textcolor{blue}]}}{1}%
        {<}{{\textcolor{blue}<}}{1}%
        {>}{{\textcolor{blue}>}}{1},%
    framexleftmargin=1mm,%
    framextopmargin=1mm,%
    frame=shadowbox,%
    rulesepcolor=\color{blue}%
}

\lstnewenvironment{python}[1][]{%
\lstset{%
    language=python,%
    emph={access,and,break,class,continue,def,del,elif,else,except,%
        exec,finally,for,from,global,if,import,in,is,lambda,not,or,%
        pass,print,raise,return,try,while},%
    emph={[2]True,False,None,self},%
    emph={[3]from,import,as},%
    morecomment=[s]{"""}{"""},%
    #1%
}}{}

\lstnewenvironment{ruby}[1][]{%
\lstset{%
    language=ruby,%
    emph={alias,and,begin,break,case,class,def,defined,do,else,%
        elsif,end,ensure,for,if,in,module,next,not,or,redo,rescue,%
        retry,return,super,then,undef,unless,until,when,while,yield},%
    emph={[2]true,false,nil,self},%
    emph={[3]require,include},%
    #1%
}}{}

\lstnewenvironment{kjs}[1][]{%
\lstset{%
    language=javascript,%
    emph={abstract,break,case,catch,class,const,continue,debugger,%
        default,delete,do,else,enum,export,extends,final,finally,for,%
        function,goto,if,implements,in,instanceof,interface,native,%
        new,package,private,protected,public,return,static,super,%
        switch,synchronized,throw,throws,transient,try,typeof,%
        volatile,while,with},%
    emph={[2]true,false,null,this},%
    emph={[3]import},%
    #1%
}}{}

\lstnewenvironment{java}[1][]{%
\lstset{%
    language=java,%
    emph={abstract,assert,break,case,catch,class,continue,default,%
        do,else,enum,extends,final,finally,for,private,implements,%
        instanceof,interface,native,new,package,private,protected,%
        public,return,static,strictfp,super,switch,synchronized,%
        throw,throws,transient,try,volatile,while},%
    emph={[2]true,false,null,this},%
    emph={[3]import},%
    #1%
}}{}

\lstnewenvironment{falcon}[1][]{%
\lstset{%
%     language=falcon,%
    emph={and,attributes,break,case,catch,const,continue,default,%
        directive,dropping,elif,else,end,enum,for,firfirst,formiddle,%
        forlast,from,function,give,global,has,hasnt,if,in,init,%
        innerfunc,lambda,launch,loop,not,object,or,pass,provides,%
        return,select,static,switch,to,try,while},%
    emph={[2]true,false,nil,self,sender},%
    emph={[3]import,load,export},%
    #1%
}}{}

\lstnewenvironment{php}[1][]{%
\lstset{%
    language=PHP,%
    emph={},%
    emph={[2]true,false,nil,self,sender},%
    emph={[3]import,load,export},%
    #1%
}}{}

\lstnewenvironment{lua}[1][]{%
\lstset{%
    language=Lua,%
    emph={},%
    emph={[2]true,false,nil,self,sender},%
    emph={[3]import,load,export},%
    #1%
}}{}

\lstnewenvironment{c-sharp}[1][]{%
\lstset{%
    language=CSharp,%
    emph={},%
    emph={[2]true,false,nil,self,sender},%
    emph={[3]import,load,export},%
    #1%
}}{}

\begin{document}

\maketitle

\tableofcontents

\newpage
\chapter{What is Sigmodr?}


\chapter{Sigmod Classes}
\label{sigmod-classes}

\section{Ability}
\label{ability}

Abilities add an extra dimension to the battle system. Abilities can help turn the tide in a battle and balance species that are typically under-powered. Abilities were introduced to the original games in the third generation of the games.

Abilities are responsible for keeping track of any information they change during their execution and restoring it if necessary. Changing anything that is not local to the battle will persist after the battle is over (this allows status afflictions and moves that are permanently overwritten to persist). Take note that anything that is species-wide will not persist no matter what happens during the battle (i.e. types, base stats, effort values) since these are copied for the battle so that they can be modified for strategic purposes.

The APIs for the battle system will be under development in the near future with the beta release of Pok\'emodr.

\subsection{Variables}
\label{ability-variables}

\paragraph{Name}
\label{ability-name}
The name of the ability. This is how the player will see the ability in the game.

\paragraph{Description}
\label{ability-description}
A succinct description of what the ability does.

\paragraph{Script}
\label{ability-script}
The script contains functions that will be triggered by the game when appropriate. Only functions that are written will be called, so dummy functions are not needed for those the ability does not need. The following events can be used in an ability (these are in no way final, the battle system design will provide all of these):

\begin{multicols}{2}
\begin{itemize}
    \item \texttt{userSentOut}
    \item \texttt{userBeginTurn}
    \item \texttt{userAttack}
    \item \texttt{userHit}
    \item \texttt{userDamaged}
    \item \texttt{userStatusChanged}
    \item \texttt{userStatChanged}
    \item \texttt{userFlinch}
    \item \texttt{userFaint}
    \item \texttt{enemySentOut}
    \item \texttt{enemyBeginTurn}
    \item \texttt{enemyAttack}
    \item \texttt{enemyHit}
    \item \texttt{enemyStatusChanged}
    \item \texttt{enemyStatChanged}
    \item \texttt{enemyFlinch}
    \item \texttt{enemyFaint}
    \item \texttt{roundBegin}
    \item \texttt{roundEnd}
    \item \texttt{battleEnd}
    \item \texttt{heldItemUsed}
    \item \texttt{itemUsed}
    \item \texttt{userFlee}
    \item \texttt{userSwitch}
    \item \texttt{weatherChanged}
    \item \texttt{enemyAbilityTriggered}
    \item \texttt{mapEntered}
    \item \texttt{wildBattleStarted}
\end{itemize}
\end{multicols}

See chapter \ref{scripting} on page \pageref{scripting} for more infomation on scripting.

\subsection{Examples}
\label{ability-examples}

\paragraph{Note}
These examples are not guaranteed to work until an API has been made for the game and battle system.

\subsubsection{Changing types}

This script will change the user's first type depending on the type of the last move used. Since types do not persist outside of the battle, the type only needs to be reset when the owner of the ability switches out or faints.

\begin{python}[caption={Type changer},label=script:type-changer]
import sigmod # Data from the Sigmod
import owner  # The owner of the ability

# Get the first type of the user
originalType = owner.type(0)
# Set the type requested
ghost = sigmod.type("Ghost")

def setType():
    # Set the type
    owner.setType(0, ghost)

def retreat():
    # Reset the type
    owner.setType(0, originalType)

owner.connect("sentOut()", setType)
owner.connect("switch()", retreat)
owner.connect("faint()", retreat)
\end{python}

\subsubsection{Changing the weather}

This script will force the weather to be rainy all the time. Other weather effects can be in effect from the time it works until the beginning of the next turn where this ability will kick in and make it rain again.

\begin{python}[caption={Weather changer},label=script:weather-changer]
import arena  # The battle system
import client # Used for messaging
import sigmod # Data from the Sigmod
import owne   # The owner of the ability

# Get the handle for the "Rain" weather
rain = sigmod.weather("Rain")

# Local variable to keep track of when to force the weather
needChanging = False

def setWeather():
    # Set the weather to rain for unlimited turns
    arena.setWeather(rain, -1)
    # Let the player(s) know that it has started raining
    client.message("The skies have opened up!")

def sentOut():
    setWeather()

def weatherChanged():
    # Force the weather back next turn
    # if it the weather change wasn't to rain
    if not arena.weather() == rain:
        needChanging = True

def roundStart():
    # Reset the weather if needed
    if needChanging:
        setWeather()
        needChanging = False

def retreat():
    # If the owner of the ability is
    # no longer in the battle, set the rain to stop
    if arena.weather() == rain:
        arena.setWeatherDuration() = 2
        client.message("The skies are clearing!")

# Connect signals from the arena
arena.connect("roundStart()", roundStart)
# Connect signals from the owner
owner.connect("sentOut()", sentOut)
owner.connect("switch()", retreat)
owner.connect("faint()", retreat)
\end{python}

\section{Author}
\label{author}

This is where the authors of the Sigmod go. This class could be expanded to allow for something more detialed to allow the creation of credits, but it is simple for now.

\subsection{Variables}
\label{author-variables}

\paragraph{Name}
\label{author-name}
The name of the author.

\paragraph{Email}
\label{author-email}
The email address of the author.

\paragraph{Role}
\label{author-role}
What the person did.

\section{Badge}
\label{badge}

Badges are given to the player after accomplishing a task. In the original games, they were used to allow the player to use moves in the main world to gain access to new parts of the world. They also boosted the stats for in-game battles and allowed the player to train to higher levels without side effects.

\subsection{Variables}
\label{badge-variables}

\paragraph{Name}
\label{badge-name}
The name of the badge. This is the name that the player will see in-game.

\paragraph{Face}
\label{badge-face}
The image that will be used in the game for the badge before it is obtained.

\paragraph{Badge}
\label{badge-badge}
The image of the badge and will show up in the player's information window.

\paragraph{Obey}
\label{badge-obey}
The level that the player can train to without any side effects.

\paragraph{Stat}
\label{badge-stat}
The multiplier for each stat will be applied to in-game battles to give an extra edge to the player. It will not have any effect on battles between two games.

\section{Coin List}
\label{coinlist}

Coin lists are used as alternate places to aquire items and team members in exchange for coins that are won at slot machines and card flip games. These are typically much harder to afford than items in an item shop, but they are also usually more valuable.

\subsection{Variables}
\label{coinlist-variables}

\paragraph{Name}
\label{coinlist-name}
This is the internal name of the coin list. The player will not be told what this is.

\paragraph{Script}
\label{coinlist-script}
This script should interface with the user's items to determine the following:
\begin{itemize}
    \item Check to see if the player has an item that can buy the objects on the list
    \item If so:
    \begin{itemize}
        \item Set the \texttt{coinListMoney} object in \texttt{Game} to the amount of curreny that the player has for display
        \item Provide a \texttt{buy} function that takes the object to buy in the list
        \item It should handle giving the object to the player and erroring if anything happens
    \end{itemize}
    \item else:
    \begin{itemize}
        \item Set the \texttt{coinListMoney} object in \texttt{Game} to 0
        \item The game will take this as a signal that the player cannot buy things from this coin list and will not display it
        \item Any messages necessary must be handled in the script
    \end{itemize}
\end{itemize}

\section{Coin List Object}
\label{coinlistobject}

Coin list objects are either items or team members that can be bought from coin lists.

\subsection{Variables}
\label{coinlistobject-variables}

\paragraph{Type}
\label{coinlistobject-type}
Whether the value of the object points to a species for a team member or to an item.

\paragraph{Value}
\label{coinlistobject-value}
The ID number of the item or species.

\paragraph{Amount}
\label{coinlistobject-amount}
The number of the object that the player gets at a time.

\paragraph{Cost}
\label{coinlistobject-cost}
How much the object costs.

\section{Egg Group}
\label{egggroup}

An egg group is a group of species that can breed to create eggs. More details can be found in chapter \ref{breeding} on page \pageref{breeding}.

\subsection{Variables}
\label{egggroup-variables}

\paragraph{Name}
\label{egggroup-name}
The name of the egg group. Used internally only.

\section{Global Script}
\label{globalscript}

Global scripts are functions that are available on demand in any other script. They can do anything that the scripting API allows with the game or any common function that is used a lot in order to save space. They are loaded when the game is loaded and in the \texttt{scripts} action collection. See more on scripting in chapter \ref{scripting} on page \pageref{scripting}.

\subsection{Variables}
\label{globalscript-variables}

\subsubsection{Name}
\label{globalscript-name}
The name of the action in the collection.

\subsubsection{Script}
\label{globalscript-script}
The code of the script.

\section{Item}
\label{item}

Items are used in the game to heal, boost stats, and other similar things. They can be used during in-game battles and on the overworld maps.

\subsection{Variables}
\label{item-variables}

\subsubsection{Name}
The name of the item

\section{Item Type}
\label{itemtype}

Item types are used to group items into sections within the player's item storage.

\subsection{Variables}
\label{itemtype-variables}

\subsubsection{Name}
\label{itemtype-name}
The name of the item type. Used internally only.

\subsubsection{Computer}
\label{itemtype-computer}
How many of the item the computer can store.

\subsubsection{Player}
\label{itemtype-player}
How many of the item the player can carry at once.

\subsubsection{Count}
\label{itemtype-count}
Determines how the items are counted and grouped in its storage. If they can be grouped, multiples of an item will count as one towards the limit of the storage, otherwise duplicates are counted individually.

\section{Map}
\label{map}

Maps are view of the overworld for the game. When not battling, the player travels around the maps in search of other battles and quests.

\section{Map Effect}
\label{mapeffect}



\section{Map Trainer}
\label{maptrainer}

\section{Map Trainer Team Member}
\label{maptrainerteammember}

\section{Map Warp}
\label{mapwarp}

\section{Map Wild List}
\label{mapwildlist}

\section{Map Wild List Encounter}
\label{mapwildlistencounter}

\section{Move}
\label{move}

\section{Nature}
\label{nature}

\section{Sound}
\label{sound}

\section{Species}
\label{species}

\section{Species Ability}
\label{speciesability}

\section{Species Item}
\label{speciesitem}

\section{Species Move}
\label{speciesmove}

\section{Store}
\label{store}

\section{Tile}
\label{tile}

\section{Time}
\label{time}

\section{Trainer}
\label{trainer}

\section{Type}
\label{type}

\chapter{Scripting}
\label{scripting}

\section{Collections}
\label{scripting-collections}

\chapter{Battle System}
\label{battle-system}

\chapter{Breeding}
\label{breeding}

\end{document}
