other files

master
Coleman 2008-07-03 00:57:12 -05:00
parent 12f259fc76
commit 873033ea70
34 changed files with 23773 additions and 0 deletions

View File

@ -0,0 +1,13 @@
/List.cpp/1.1.1.1/Tue Nov 2 07:22:47 2004//
/List.h/1.1.1.1/Tue Nov 2 07:22:47 2004//
/PokeDex.h/1.1.1.1/Tue Nov 2 07:22:47 2004//
/Pokemon.cpp/1.1.1.1/Tue Nov 2 07:22:47 2004//
/Pokemon.h/1.1.1.1/Tue Nov 2 07:22:47 2004//
/Skill.cpp/1.1.1.1/Tue Nov 2 07:22:47 2004//
/Skill.h/1.1.1.1/Tue Nov 2 07:22:47 2004//
/StrToke.cpp/1.1.1.1/Tue Nov 2 07:22:47 2004//
/StrToke.h/1.1.1.1/Tue Nov 2 07:22:47 2004//
/crystal.pkmn/1.1.1.1/Tue Nov 2 07:22:51 2004//
/main.cpp/1.1.1.1/Tue Nov 2 07:22:52 2004//
/test.cpp/1.1.1.1/Tue Nov 2 07:22:52 2004//
D

View File

@ -0,0 +1 @@
PokeDex/PokeDexC++ GNU

1
PokeDexC++ GNU/CVS/Root Normal file
View File

@ -0,0 +1 @@
/home/andrew/Projects/penguincoder/cvs

85
PokeDexC++ GNU/List.cpp Executable file
View File

@ -0,0 +1,85 @@
#ifndef LIST_CPP
#define LIST_CPP
List::List()
{
maxsize = 50;
strings = new string[maxsize];
cursize = 0;
}
List::List ( int initialsize )
{
strings = new string[initialsize];
maxsize = initialsize;
cursize = 0;
}
void List::add ( string newentry, int pos, int rflag )
{
if ( pos == -1 )
pos = cursize;
if ( pos < maxsize && pos >= 0 )
{
if ( !rflag )
for ( int i = pos; i < cursize; i++ )
strings[i + 1] = strings[i];
strings[pos] = newentry;
cursize++;
if ( cursize == maxsize )
resize();
}
}
void List::add ( char* newentry, int pos, int rflag )
{
string s(newentry);
List::add ( s, pos, rflag );
}
void List::resize ( int newsize )
{
if ( newsize == -1 )
newsize = maxsize;
if ( newsize > maxsize )
{
strings = new string[newsize - cursize];
maxsize = newsize;
}
}
void List::remove ( string entry )
{
for ( int i = 0; i < cursize; i++ )
if ( strings[i] == entry )
{
for ( int j = i; j < cursize - 1; j++ )
strings[j] = strings[j + 1];
cursize--;
break;
}
}
void List::remove ( int pos )
{
if ( pos >= 0 && pos < cursize )
{
for ( int i = pos; i < cursize - 1; i++ )
strings[i] = strings[i + 1];
cursize--;
}
}
string List::get ( int pos )
{
if ( pos >= 0 && pos < cursize )
return strings[pos];
return 0;
}
int List::size() const
{
return cursize;
}
#endif /* end LIST_CPP */

24
PokeDexC++ GNU/List.h Executable file
View File

@ -0,0 +1,24 @@
#ifndef LIST_H
#define LIST_H
class List
{
string* strings;
int cursize;
int maxsize;
void resize ( int newsize = -1 );
public:
List();
List ( int initialsize );
//~List();
void add ( string newentry, int pos = -1, int rflag = 0 );
void add ( char* newentry, int pos = -1, int rflag = 0 );
void remove ( string entry );
void remove ( int pos );
int size() const;
string get ( int pos );
};
#include "List.cpp"
#endif /* end LIST_H */

154
PokeDexC++ GNU/PokeDex.h Executable file
View File

@ -0,0 +1,154 @@
#ifndef POKEDEX_H
#define POKEDEX_H
#include <iostream>
class PokeDex
{
public:
static void alert ( string alertmsg )
{
StrToke t ( alertmsg, "|" );
if ( t.hasTokens() )
{
while ( t.hasTokens() )
cout << t.nextToken() << endl;
}
else
{
cout << alertmsg << endl;
}
cout << endl;
}
static string ask ( string question )
{
cout << question << ": ";
string result;
cin >> result;
cout << endl;
return result;
}
static string askPokemon()
{
string field, query;
string fields[] = { "number", "name", "type", "location", "evolution", "tmhm", "attack", "breed", "moves" };
cout << "Searching for Pokemon..." << endl;
for ( int i = 0; i < 9; i++ )
cout << fields[i] << " ";
cout << endl << "Search field: ";
cin >> field;
bool flag = false;
for ( int i = 0; i < 9; i++ )
if ( fields[i] == field )
flag = true;
if ( !flag )
{
cout << "Invalid Field!" << endl << "Search field: ";
cin >> field;
flag = false;
for ( int i = 0; i < 9; i++ )
if ( fields[i] == field )
flag = true;
if ( !flag )
{
field = "name";
cout << "Field defaulted to: " << field << endl;
}
}
cout << "Search query: ";
cin >> query;
cout << endl;
return field + '|' + query;
}
static string askSkill()
{
string field, query;
string fields[] = { "name", "type", "descr" };
cout << "Searching for skills..." << endl;
for ( int i = 0; i < 3; i++ )
cout << fields[i] << " ";
cout << endl << "Search field: ";
cin >> field;
bool flag = false;
for ( int i = 0; i < 3; i++ )
if ( fields[i] == field )
flag = true;
if ( !flag )
{
cout << "Invalid Field!" << endl << "Search field: ";
cin >> field;
flag = false;
for ( int i = 0; i < 3; i++ )
if ( fields[i] == field )
flag = true;
if ( !flag )
{
field = "name";
cout << "Field defaulted to: " << field << endl;
}
}
cout << "Search query: ";
cin >> query;
cout << endl;
return field + '|' + query;
}
static void addResult ( Pokemon pkmn, bool longdescr )
{
int rowsize = 5;
cout << "# " << pkmn.getNumber() << " " << pkmn.getName() << endl;
cout << " Type: " << pkmn.getType() << endl;
cout << " Found at: " << pkmn.getLocation() << endl;
cout << " Attacks learned:" << endl;
List atk = pkmn.getAttack();
for ( int i = 0; i < atk.size(); i++ )
cout << " " << atk.get ( i ) << endl;
cout << " TM / HM Compatibility:" << endl;
List th = pkmn.getTMHM();
for ( int i = 0; i <= (int) th.size() / rowsize; i++ )
{
cout << " ";
for ( int j = 0; j < rowsize; j++ )
if ( j + (i * rowsize) < th.size() )
cout << th.get ( j + (i * rowsize) ) << ", ";
cout << endl;
}
cout << " Evolution(s):" << endl;
List evolution = pkmn.getEvolution();
for ( int i = 0; i < evolution.size(); i++ )
cout << " " << evolution.get ( i ) << endl;
if ( longdescr )
{
cout << " Breeding compatability:" << endl;
List breed = pkmn.getBreed();
for ( int i = 0; i <= (int) breed.size() / rowsize; i++ )
{
cout << " ";
for ( int j = 0; j < rowsize; j++ )
if ( (j + (i * rowsize)) < breed.size() )
cout << breed.get ( j + (i * rowsize) ) << ", ";
cout << endl;
}
cout << " Breeding moves:" << endl;
List moves = pkmn.getMoves();
for ( int i = 0; i < moves.size(); i++ )
cout << " " << moves.get ( i ) << endl;
}
cout << "|-<\"^-> End Pokemon <-^\">-|" << endl << endl;
}
static void addResult ( Skill skill )
{
cout << "Name: " << skill.getName() << endl;
cout << "Type: " << skill.getType() << endl;
cout << "Description: " << skill.getDescr() << endl;
cout << "Power: " << skill.getPower() << '\t' << "PP: " << skill.getPP() << endl;
cout << endl;
}
};
#endif /* END POKEDEX_H */

82
PokeDexC++ GNU/Pokemon.cpp Executable file
View File

@ -0,0 +1,82 @@
#ifndef POKEMON_CPP
#define POKEMON_CPP
Pokemon::Pokemon()
{
number = 0;
name = "";
type = "";
location = "";
}
Pokemon::Pokemon ( int num, string nm, string tp, string loc, List atk, List brd, List mvs, List th, List evo )
{
number = num;
name = nm;
type = tp;
location = loc;
attack = atk;
breed = brd;
moves = mvs;
tmhm = th;
evolution = evo;
}
Pokemon::Pokemon ( const Pokemon &pkmn )
{
number = pkmn.getNumber();
name = pkmn.getName();
type = pkmn.getType();
location = pkmn.getLocation();
attack = pkmn.getAttack();
breed = pkmn.getBreed();
moves = pkmn.getMoves();
tmhm = pkmn.getTMHM();
evolution = pkmn.getEvolution();
}
int Pokemon::getNumber() const
{
return number;
}
string Pokemon::getName() const
{
return name;
}
string Pokemon::getType() const
{
return type;
}
string Pokemon::getLocation() const
{
return location;
}
List Pokemon::getAttack() const
{
return attack;
}
List Pokemon::getBreed() const
{
return breed;
}
List Pokemon::getMoves() const
{
return moves;
}
List Pokemon::getTMHM() const
{
return tmhm;
}
List Pokemon::getEvolution() const
{
return evolution;
}
#endif /* end POKEMON_CPP */

26
PokeDexC++ GNU/Pokemon.h Executable file
View File

@ -0,0 +1,26 @@
#ifndef POKEMON_H
#define POKEMON_H
class Pokemon
{
string name, type, location;
List attack, breed, moves, tmhm, evolution;
int number;
public:
Pokemon();
Pokemon ( int number, string name, string type, string location, List attack, List breed, List moves, List tmhm, List evolution );
Pokemon ( const Pokemon& pkmn );
string getName() const;
string getType() const;
string getLocation() const;
int getNumber() const;
List getAttack() const;
List getBreed() const;
List getMoves() const;
List getTMHM() const;
List getEvolution() const;
};
#include "Pokemon.cpp"
#endif /* end POKEMON_H */

52
PokeDexC++ GNU/Skill.cpp Executable file
View File

@ -0,0 +1,52 @@
#ifndef SKILL_CPP
#define SKILL_CPP
Skill::Skill()
{
name = "";type = "";descr = "";pwr = 0; pp = 0;
}
Skill::Skill ( string n, string t, string d, int pw, int p )
{
name = n;
type = t;
descr = d;
pwr = pw;
pp = p;
}
Skill::Skill ( const Skill &newskill )
{
name = newskill.getName();
type = newskill.getType();
descr = newskill.getDescr();
pwr = newskill.getPower();
pp = newskill.getPP();
}
string Skill::getName() const
{
return name;
}
string Skill::getType() const
{
return type;
}
string Skill::getDescr() const
{
return descr;
}
int Skill::getPower() const
{
return pwr;
}
int Skill::getPP() const
{
return pp;
}
#endif /* END SKILL_CPP */

21
PokeDexC++ GNU/Skill.h Executable file
View File

@ -0,0 +1,21 @@
#ifndef SKILL_H
#define SKILL_H
class Skill
{
string name, type, descr;
int pwr, pp;
public:
Skill();
Skill ( string n, string t, string d, int pwr, int p );
Skill ( const Skill &newskill );
string getName() const;
string getType() const;
string getDescr() const;
int getPower() const;
int getPP() const;
};
#include "Skill.cpp"
#endif /* END SKILL_H */

35
PokeDexC++ GNU/StrToke.cpp Executable file
View File

@ -0,0 +1,35 @@
#ifndef STRTOKE_CPP
#define STRTOKE_CPP
StrToke::StrToke ( string s, string d )
{
string str = s;
tokes = 0;
while ( str.find ( d ) != -1 )
{
int index = str.find ( d );
string newstr = str.substr ( 0, index );
tokens.add ( newstr );
str = str.substr ( index + 1, str.length() - index );
tokes++;
}
tokens.add ( str );
tokes++;
}
bool StrToke::hasTokens()
{
return (tokes > 0);
}
string StrToke::nextToken()
{
if ( tokes > 0 )
{
tokes--;
return tokens.get ( tokens.size() - tokes - 1 );
}
return "Out of tokens";
}
#endif /* END STRTOKE_CPP */

16
PokeDexC++ GNU/StrToke.h Executable file
View File

@ -0,0 +1,16 @@
#ifndef STRTOKE_H
#define STRTOKE_H
class StrToke
{
List tokens;
int tokes;
public:
StrToke ( string s, string d );
bool hasTokens();
string nextToken();
};
#include "StrToke.cpp"
#endif /* END STRTOKE_H */

22264
PokeDexC++ GNU/crystal.pkmn Executable file

File diff suppressed because it is too large Load Diff

256
PokeDexC++ GNU/main.cpp Executable file
View File

@ -0,0 +1,256 @@
#include <fstream>
#include <string> // because i'm lazy and i don't know enough about char *'s
#include <cstdlib> // used for atoi, will replace later possibly with custom atoi
using namespace std;
#include "List.h"
#include "StrToke.h" // uses List
#include "Pokemon.h" // uses List
#include "Skill.h" // uses List
#include "PokeDex.h" // uses StrToke
int main ( int argc, char* argv )
{
ifstream inpkmn ( "crystal.pkmn", ios::in );
if ( inpkmn.fail() )
{
PokeDex::alert ( "Could not load the database: crystal.pkmn" );
return 1;
}
Pokemon pokemon[251];
for ( int i = 0; i < 251; i++ )
{
char tmp[256];
inpkmn.getline ( tmp, 50 );
string name = tmp;
inpkmn.getline ( tmp, 50 );
int number = atoi ( tmp );
inpkmn.getline ( tmp, 50 );
string type = tmp;
inpkmn.getline ( tmp, 50 );
int max = atoi ( tmp );
List evo(max);
for ( int j = 0; j < max; j++ )
{
inpkmn.getline ( tmp, 50 );
evo.add ( tmp );
}
inpkmn.getline ( tmp, 50 );
max = atoi ( tmp );
List attack(max);
for ( int j = 0; j < max; j++ )
{
inpkmn.getline ( tmp, 50 );
attack.add ( tmp );
}
inpkmn.getline ( tmp, 50 );
max = atoi ( tmp );
List tmhm(max);
for ( int j = 0; j < max; j++ )
{
inpkmn.getline ( tmp, 50 );
tmhm.add ( tmp );
}
inpkmn.getline ( tmp, 50 );
max = atoi ( tmp );
List breed(max);
for ( int j = 0; j < max; j++ )
{
inpkmn.getline ( tmp, 50 );
breed.add ( tmp );
}
inpkmn.getline ( tmp, 50 );
max = atoi ( tmp );
List moves(max);
for ( int j = 0; j < max; j++ )
{
inpkmn.getline ( tmp, 50 );
moves.add ( tmp );
}
inpkmn.getline ( tmp, 100 );
string location = tmp;
if ( inpkmn.fail() || inpkmn.bad() || inpkmn.eof() )
{
PokeDex::alert ( "Fatal database error at Pokemon #" + i );
return 1;
}
pokemon[i] = Pokemon ( number, name, type, location, attack, breed, moves, tmhm, evo );
}
Skill skill[251];
for ( int i = 0; i < 251; i++ )
{
char tmp[256];
inpkmn.getline ( tmp, 50 );
string name = tmp;
inpkmn.getline ( tmp, 50 );
string type = tmp;
inpkmn.getline ( tmp, 100 );
string descr = tmp;
inpkmn.getline ( tmp, 10 );
int pp = atoi ( tmp );
inpkmn.getline ( tmp, 10 );
int power = atoi ( tmp );
if ( inpkmn.fail() || inpkmn.bad() || inpkmn.eof() )
{
PokeDex::alert ( "Fatal database error at Skill #" + i );
return 1;
}
skill[i] = Skill ( name, type, descr, power, pp );
}
inpkmn.close();
string command = "";
bool longdescr = false;
while ( command != "q" )
{
command = PokeDex::ask ( "PokeDex" );
if ( command == "h" || command == "?" )
{
string tmp = "PokeDexC++ 1.0|Search [P]okemon|Search [S]kills|Toggle [L]ong Descriptions (";
tmp += (longdescr)?"On":"Off";
tmp += ")|Display [?] [H]elp|[Q]uit PokeDex";
PokeDex::alert ( tmp );
}
else if ( command == "l" )
{
longdescr = !longdescr;
}
else if ( command == "p" )
{
StrToke t ( PokeDex::askPokemon(), "|" );
string field = t.nextToken();
string query = t.nextToken();
for ( int i = 0; i < 251; i++ )
{
if ( field == "name" )
{
string search = pokemon[i].getName();
if ( search.find ( query ) != -1 )
PokeDex::addResult ( pokemon[i], longdescr );
}
else if ( field == "number" )
{
int x = atoi ( query.c_str() );
if ( x == i + 1 )
PokeDex::addResult ( pokemon[i], longdescr );
}
else if ( field == "type" )
{
string search = pokemon[i].getType();
if ( search.find ( query ) != -1 )
PokeDex::addResult ( pokemon[i], longdescr );
}
else if ( field == "location" )
{
string search = pokemon[i].getLocation();
if ( search.find ( query ) != -1 )
PokeDex::addResult ( pokemon[i], longdescr );
}
else if ( field == "attack" )
{
List attack = pokemon[i].getAttack();
for ( int j = 0; j < attack.size(); j++ )
{
string search = attack.get ( j );
if ( search.find ( query ) != -1 )
{
PokeDex::addResult ( pokemon[i], longdescr );
break;
}
}
}
else if ( field == "breed" )
{
List breed = pokemon[i].getBreed();
for ( int j = 0; j < breed.size(); j++ )
{
string search = breed.get ( j );
if ( search.find ( query ) != -1 )
{
PokeDex::addResult ( pokemon[i], longdescr );
break;
}
}
}
else if ( field == "tmhm" )
{
List tmhm = pokemon[i].getTMHM();
for ( int j = 0; j < tmhm.size(); j++ )
{
string search = tmhm.get ( j );
if ( search.find ( query ) != -1 )
{
PokeDex::addResult ( pokemon[i], longdescr );
break;
}
}
}
else if ( field == "moves" )
{
List moves = pokemon[i].getMoves();
for ( int j = 0; j < moves.size(); j++ )
{
string search = moves.get ( j );
if ( search.find ( query ) != -1 )
{
PokeDex::addResult ( pokemon[i], longdescr );
break;
}
}
}
else if ( field == "evolution" )
{
List evo = pokemon[i].getEvolution();
for ( int j = 0; j < evo.size(); j++ )
{
string search = evo.get ( j );
if ( search.find ( query ) != -1 )
{
PokeDex::addResult ( pokemon[i], longdescr );
break;
}
}
}
else if ( field == "tmhm" )
{
List tmhm = pokemon[i].getTMHM();
for ( int j = 0; j < tmhm.size(); j++ )
{
string search = tmhm.get ( j );
if ( search.find ( query ) != -1 )
{
PokeDex::addResult ( pokemon[i], longdescr );
break;
}
}
}
}
}
else if ( command == "s" )
{
StrToke t ( PokeDex::askSkill(), "|" );
string field = t.nextToken();
string query = t.nextToken();
for ( int i = 0; i < 251; i++ )
{
if ( field == "name" )
{
string search = skill[i].getName();
if ( search.find ( query ) != -1 )
PokeDex::addResult ( skill[i] );
}
else if ( field == "type" )
{
string search = skill[i].getType();
if ( search.find ( query ) != -1 )
PokeDex::addResult ( skill[i] );
}
else if ( field == "descr" )
{
string search = skill[i].getDescr();
if ( search.find ( query ) != -1 )
PokeDex::addResult ( skill[i] );
}
}
}
}
}

37
PokeDexC++ GNU/test.cpp Executable file
View File

@ -0,0 +1,37 @@
#include <iostream>
#include <string>
using namespace std;
#include "List.h"
#include "StrToke.h"
#include "Pokemon.h"
#include "Skill.h"
#include "PokeDex.h"
int main ( int argc, char* argv[] )
{
List atk(4);
atk.add ( "kick" );
atk.add ( "punch" );
atk.add ( "scream" );
atk.add ( "bite" );
List breed(2);
breed.add ( "suicine" );
breed.add ( "bob" );
List mv(1);
mv.add ( "None" );
List tmhm(4);
tmhm.add ( "kiss" );
tmhm.add ( "flash" );
tmhm.add ( "moon" );
tmhm.add ( "blow" );
List evo(1);
evo.add ( "Shyrac" );
Pokemon p( 133, "Eevee", "Normal", "Bob's House", atk, breed, mv, tmhm, evo );
//p.printLongDescription();
string what = PokeDex::ask ( "What" );
PokeDex::alert ( "You said " + what );
PokeDex::askPokemon();
PokeDex::askSkill();
PokeDex::addResult ( p, true );
}

17
attic/CVS/Entries Normal file
View File

@ -0,0 +1,17 @@
/Instructions.txt/1.1.1.1/Tue Nov 2 07:22:52 2004//
/PokeData.class/1.1.1.1/Tue Nov 2 07:22:52 2004//
/PokeData.java/1.1.1.1/Tue Nov 2 07:22:52 2004//
/PokeDex.class/1.1.1.1/Tue Nov 2 07:22:52 2004//
/PokeDex.jar/1.1.1.1/Tue Nov 2 07:22:52 2004//
/PokeDex.java/1.1.1.1/Tue Nov 2 07:22:52 2004//
/PokeDex_src_2.zip/1.1.1.1/Tue Nov 2 07:22:55 2004//
/PokeSkill.class/1.1.1.1/Tue Nov 2 07:22:55 2004//
/PokeSkill.java/1.1.1.1/Tue Nov 2 07:22:55 2004//
/PokeSkillData.class/1.1.1.1/Tue Nov 2 07:22:55 2004//
/PokeSkillData.java/1.1.1.1/Tue Nov 2 07:22:55 2004//
/Pokemon.class/1.1.1.1/Tue Nov 2 07:22:55 2004//
/Pokemon.java/1.1.1.1/Tue Nov 2 07:22:55 2004//
/crystal-skill.pkmn/1.1.1.1/Tue Nov 2 07:22:56 2004//
/crystal.pkmn/1.1.1.1/Tue Nov 2 07:23:02 2004//
/manifest.txt/1.1.1.1/Tue Nov 2 07:23:02 2004//
D

1
attic/CVS/Repository Normal file
View File

@ -0,0 +1 @@
PokeDex/attic

1
attic/CVS/Root Normal file
View File

@ -0,0 +1 @@
/home/andrew/Projects/penguincoder/cvs

13
attic/Instructions.txt Executable file
View File

@ -0,0 +1,13 @@
PokeDex v 2.0
First you need to have a Java runtime/sd kit installed. Get this from http://java.sun.com
You need to set your paths, and then run
java -jar PokeDex.jar
At the command prompt. Case matters. If you are really good, you can make a shortcut to this by putting
"%javapath&\bin\java -jar PokeDex.jar"
As the program to run, where %javapath% is the path to the installed java kit. You should also set the start in folder to wherever you keep the *.jar and *.pkmn files.

BIN
attic/PokeData.class Executable file

Binary file not shown.

131
attic/PokeData.java Executable file
View File

@ -0,0 +1,131 @@
import java.io.*;
import java.util.StringTokenizer;
import java.util.NoSuchElementException;
public class PokeData {
public static void main ( String[] args ) {
try {
BufferedReader inpoke = new BufferedReader ( new FileReader ( "pokemon.txt" ) );
BufferedReader index = new BufferedReader ( new FileReader ( "pokedex.txt" ) );
ObjectOutputStream objectout = new ObjectOutputStream ( new FileOutputStream ( "crystal.pkmn" ) );
StringTokenizer token = new StringTokenizer("");
String line = inpoke.readLine();
int number;
String name = "", type1 = "", type2 = "", location = "";
String[] attack, breedcompat, breedingmoves, tmhm, evolution;
int attacks = 0, breedcompats = 0, breedingmovess = 0, tmhms = 0, evolutions = 0;
while ( line != null ) {
attack = new String[15];
breedcompat = new String[150];
breedingmoves = new String[50];
tmhm = new String[100];
evolution = new String[5];
number = Integer.parseInt ( line.substring ( 1, 5 ).trim() );
name = line.substring ( 8, 20 ).trim();
String types = line.substring ( 21, 36 ).trim();
token = new StringTokenizer ( types, "/" );
type1 = token.nextToken();
if ( token.hasMoreTokens() )
type2 = token.nextToken();
else
type2 = "None";
String finalevo = line.substring ( 44 ).trim();
token = new StringTokenizer ( finalevo, " " );
finalevo = token.nextToken();
evolution[evolutions] = finalevo;
if ( !finalevo.equals ( "None" ) )
evolution[evolutions] += " - " + line.substring ( 44 + finalevo.length() + 1 );
evolutions++;
line = inpoke.readLine();
while ( line != null && line.startsWith ( " " ) ) {
token = new StringTokenizer ( line.substring ( 44 ).trim(), " " );
String tempevo = token.nextToken();
evolution[evolutions] = tempevo + " - " + line.substring ( 44 + tempevo.length() + 1 ).trim();
evolutions++;
line = inpoke.readLine();
}
String otherline = index.readLine();
while ( !otherline.startsWith("-") ) {
if ( otherline.startsWith ( "Attacks: " ) ) {
while ( !otherline.equals ( "" ) ) {
if ( otherline.endsWith ( "-" ) )
attack[attacks] = otherline.substring ( 9, 22 ).trim();
else if ( otherline.endsWith ( "None" ) )
attack[attacks] = "None";
else
attack[attacks] = otherline.substring ( 9, 22 ).trim() + " at " + otherline.substring ( 23 ).trim();
attacks++;
otherline = index.readLine();
}
otherline = index.readLine();
while ( !otherline.equals("") ) {
token = new StringTokenizer ( otherline.substring ( 13 ).trim(), "," );
do {
String tmmove = token.nextToken().trim();
if ( tmmove.endsWith ( ")" ) )
//tmmove = tmmove.substring ( tmmove.indexOf ( "(" ) + 1, tmmove.indexOf ( ")" ) ) + " " + tmmove.substring ( 0, tmmove.indexOf ( "(" ) - 1 );
tmmove = tmmove.substring ( 0, tmmove.indexOf ( "(" ) ).trim();
tmhm[tmhms] = tmmove;
tmhms++;
} while ( token.hasMoreTokens() );
otherline = index.readLine();
}
otherline = index.readLine();
while ( !otherline.equals ( "" ) ) {
token = new StringTokenizer ( otherline.substring ( 15 ).trim(), "," );
do {
breedingmoves[breedingmovess] = token.nextToken().trim();
breedingmovess++;
} while ( token.hasMoreTokens() );
otherline = index.readLine();
}
otherline = index.readLine();
while ( !otherline.equals ( "" ) ) {
token = new StringTokenizer ( otherline.substring ( 24 ).trim(), "," );
do {
breedcompat[breedcompats] = token.nextToken().trim();
breedcompats++;
} while ( token.hasMoreTokens() );
otherline = index.readLine();
}
while ( !otherline.startsWith ( "Found at:" ) )
otherline = index.readLine();
location = otherline.substring ( 9 );
}
otherline = index.readLine();
}
String[] finalattack, finalcompat, finalmoves, finaltmhm, finalevolution;
finalattack = new String[attacks];
for ( int i = 0; i < attacks; i++ )
finalattack[i] = attack[i];
finalcompat = new String[breedcompats];
for ( int i = 0; i < breedcompats; i++ )
finalcompat[i] = breedcompat[i];
finalmoves = new String[breedingmovess];
for ( int i = 0; i < breedingmovess; i++ )
finalmoves[i] = breedingmoves[i];
finaltmhm = new String[tmhms];
for ( int i = 0; i < tmhms; i++ )
finaltmhm[i] = tmhm[i];
finalevolution = new String[evolutions];
for ( int i = 0; i < evolutions; i++ )
finalevolution[i] = evolution[i];
String finaltype = type1;
if ( !type2.toLowerCase().equals ( "none" ) )
finaltype += " / " + type2;
objectout.writeObject ( new Pokemon ( number, name, finaltype, finalevolution, finalattack, finaltmhm, finalmoves, finalcompat, location ) );
System.out.println ( number + " " + name );
attacks = 0;
tmhms = 0;
breedingmovess = 0;
breedcompats = 0;
evolutions = 0;
}
objectout.close();
}
catch ( IOException e ) {
System.out.println (e);
System.exit ( 0 );
}
}
}

BIN
attic/PokeDex.class Executable file

Binary file not shown.

BIN
attic/PokeDex.jar Executable file

Binary file not shown.

230
attic/PokeDex.java Executable file
View File

@ -0,0 +1,230 @@
import java.io.*;
import java.util.*;
public class PokeDex {
private static Pokemon[] pokemon;
private static PokeSkill[] pokeskill;
private final static String version = "2.1";
private final static InputStream systemin = System.in;
private static boolean longdescr = true;
private final static String[] types = new String[] { "pokemon", "skill" };
private final static String[][] fields = new String[][] { { "name", "number", "type", "evolution", "attack", "tmhm", "location", "breedmatch", "breedmove" }, { "name", "type", "description" } };
public static void main ( String[] args ) {
pokemon = new Pokemon[251];
pokeskill = new PokeSkill[251];
try {
ObjectInputStream instream = new ObjectInputStream ( new FileInputStream ( "crystal.pkmn" ) );
ObjectInputStream inskill = new ObjectInputStream ( new FileInputStream ( "crystal-skill.pkmn" ) );
System.out.println ( " Loading Pokemon" );
System.out.println ( "0% 100%");
for ( int i = 0; i < 251; i++ ) {
pokemon[i] = (Pokemon) instream.readObject();
pokeskill[i] = (PokeSkill) inskill.readObject();
if ( (i / 12) == (i / 12.0) )
System.out.print ( "." );
}
System.out.println();
instream.close();
inskill.close();
}
catch ( FileNotFoundException exception ) {
System.out.println ( "Could not find the databases!" );
System.exit ( 0 );
}
catch ( ClassNotFoundException exception ) {
System.out.println ( "Class error: " + exception );
System.exit ( 0 );
}
catch ( IOException exception ) {
System.out.println ( "Database I/O error!" + exception );
System.exit ( 0 );
}
String currentcommand = "";
do {
System.out.print ( "PokeDex> " );
try {
BufferedReader instream = new BufferedReader ( new InputStreamReader ( systemin ) );
currentcommand = instream.readLine().toLowerCase().trim();
if ( validate ( currentcommand, types ) )
searchField ( currentcommand );
else if ( currentcommand.equals ( "help" ) || currentcommand.equals ( "?" ) || currentcommand.equals ( "info" ) )
dispHelp();
else if ( currentcommand.equals ( "long" ) ) {
longdescr = !longdescr;
if ( longdescr )
System.out.println ( "Long descriptions turned on.\n" );
else
System.out.println ( "Long descriptions turned off.\n" );
}
else if ( !currentcommand.equals ( "quit" ) )
System.out.println ( "Invalid command (type help for usage)\n" );
}
catch ( IOException exception ) {
System.out.println ( "IO Stream error! " + exception );
currentcommand = "quit";
}
} while ( !currentcommand.equals ( "quit" ) );
}
private static boolean validate ( String test, String[] fields ) {
for ( int i = 0; i < fields.length; i++ )
if ( test.equals ( fields[i] ) )
return true;
return false;
}
private static void dispHelp() {
System.out.println ( "PokeDex " + version );
System.out.println ( "Released by Coleman under the GPL" );
System.out.println();
System.out.println ( "Commands:" );
System.out.println();
System.out.println ( " help, ?, info Display Help Message" );
System.out.println ( " pokemon, p Search for a Pokemon" );
System.out.println ( " skill, s Search for a Skill" );
System.out.println ( " long Toggle long descriptions" );
System.out.println();
System.out.println ( " Valid Pokemon search fields:" );
String temp = "";
for ( int i = 0; i < fields[0].length; i++ ) {
if ( i != fields[0].length - 1 )
temp += fields[0][i] + ", ";
else
temp += fields[0][i];
}
System.out.println ( " " + temp );
//System.out.println ( " name, number, type, attack, tmhm, location," );
//System.out.println ( " breedmatch, breedmove, evolution");
System.out.println();
System.out.println ( " Valid Skill search fields:" );
//System.out.println ( " name, type, description" );
temp = "";
for ( int i = 0; i < fields[1].length; i++ ) {
if ( i != fields[1].length - 1 )
temp += fields[1][i] + ", ";
else
temp += fields[1][i];
}
System.out.println ( " " + temp );
System.out.println();
System.out.println ( " All queries are case-insensitive." );
System.out.println();
System.out.println();
}
private static void searchField ( String type ) {
String field = "";
System.out.print ( "Enter search field: " );
try {
BufferedReader instream = new BufferedReader ( new InputStreamReader ( systemin ) );
field = instream.readLine().trim().toLowerCase();
}
catch ( IOException exception ) {
System.out.println ( "IO Stream error!" + exception );
field = "";
}
int typenum = 0;
for ( int i = 0; i < types.length; i++ )
if ( type.equals ( types[i] ) ) {
typenum = i;
break;
}
if ( !field.equals ( "" ) && validate ( field, fields[typenum] ) )
searchQuery ( field, typenum );
}
private static void searchQuery ( String field, int typenum ) {
String query = "";
System.out.print ( "Enter search query: " );
try {
BufferedReader instream = new BufferedReader ( new InputStreamReader ( systemin ) );
query = instream.readLine().trim().toLowerCase();
}
catch ( IOException exception ) {
System.out.println ( "IO Stream error!" + exception );
query = "";
}
if ( !query.equals ( "" ) ) {
System.out.println ( "\n==================" );
System.out.println ( " Begin search " );
System.out.println ( "==================\n" );
for ( int current = 0; current < 251; current++ ) {
if ( containsQuery ( query, field, typenum, current ) ) {
if ( longdescr && typenum == 0 )
System.out.println ( pokemon[current].longDescription() );
else if ( longdescr && typenum == 1 )
System.out.println ( pokeskill[current].longDescription() );
else if ( !longdescr && typenum == 0 )
System.out.println ( pokemon[current] );
else if ( !longdescr && typenum == 1 )
System.out.println ( pokeskill[current] );
}
}
System.out.println ( "\n==================" );
System.out.println ( " End Search" );
System.out.println ( "==================\n" );
}
}
private static boolean containsQuery ( String query, String field, int typenum, int current ) {
boolean result = false;
String searchresult = "";
if ( typenum == 0 ) {
if ( field.equals ( "name" ) )
searchresult = pokemon[current].getName();
else if ( field.equals ( "number" ) )
searchresult = (new Integer ( pokemon[current].getNumber() )).toString();
else if ( field.equals ( "location" ) )
searchresult = pokemon[current].foundAt();
else if ( field.equals ( "type" ) )
searchresult = pokemon[current].getType();
if ( field.equals ( "attack" ) ) {
String[] temp = pokemon[current].getAttack();
for ( int i = 0; i < temp.length; i++ )
searchresult += temp[i] + " ";
}
if ( field.equals ( "tmhm" ) ) {
String[] temp = pokemon[current].getTMHM();
for ( int i = 0; i < temp.length; i++ )
searchresult += temp[i] + " ";
}
if ( field.equals ( "breedmatch" ) ) {
String[] temp = pokemon[current].getBreedingList();
for ( int i = 0; i < temp.length; i++ )
searchresult += temp[i] + " ";
}
if ( field.equals ( "breedmove" ) ) {
String[] temp = pokemon[current].getBreedingMoves();
for ( int i = 0; i < temp.length; i++ )
searchresult += temp[i] + " ";
}
if ( field.equals ( "evolution" ) ) {
String[] temp = pokemon[current].getEvolution();
for ( int i = 0; i < temp.length; i++ )
searchresult += temp[i] + " ";
}
}
else if ( typenum == 1 ) {
if ( field.equals ( "name" ) )
searchresult = pokeskill[current].getName();
else if ( field.equals ( "description" ) )
searchresult = pokeskill[current].getDescription();
else if ( field.equals ( "type" ) )
searchresult = pokeskill[current].getType();
}
if ( searchresult.toLowerCase().indexOf ( query ) > -1 )
result = true;
return result;
}
}

BIN
attic/PokeDex_src_2.zip Executable file

Binary file not shown.

BIN
attic/PokeSkill.class Executable file

Binary file not shown.

63
attic/PokeSkill.java Executable file
View File

@ -0,0 +1,63 @@
import java.io.*;
public class PokeSkill implements Serializable {
private String name, type, descr;
private int pp, power;
public PokeSkill ( String name, String type, String descr, int pp, int power ) {
this.name = name;
this.type = type;
this.descr = descr;
this.pp = pp;
this.power = power;
}
public void setName ( String name ) {
this.name = name;
}
public void setType ( String type ) {
this.type = type;
}
public void setDescription ( String descr ) {
this.descr = descr;
}
public void setPP ( int pp ) {
this.pp = pp;
}
public void setPower ( int power ) {
this.power = power;
}
public String getName() {
return name;
}
public String getType() {
return type;
}
public String getDescription() {
return descr;
}
public int getPP() {
return pp;
}
public int getPower() {
return power;
}
public String toString() {
return name + " - " + descr;
}
public String longDescription() {
return "Name: " + name + "\nType: " + type + "\nPP: " + pp + "\nPower: " + power + "\nDescription: " + descr;
}
}

BIN
attic/PokeSkillData.class Executable file

Binary file not shown.

48
attic/PokeSkillData.java Executable file
View File

@ -0,0 +1,48 @@
import java.io.*;
public class PokeSkillData {
public static void main ( String[] args ) {
String name = "", type = "", descr = "";
int pp = 0, power = 0;
try {
BufferedReader inskill = new BufferedReader ( new FileReader ( "pokeskill.txt" ) );
ObjectOutputStream objectout = new ObjectOutputStream ( new FileOutputStream ( "crystal-skill.pkmn" ) );
String line = inskill.readLine();
while ( line != null ) {
name = line.substring ( 0, 13 ).trim();
type = line.substring ( 14, 22 ).trim();
pp = 0;
try {
pp = Integer.parseInt ( line.substring ( 23, 25 ).trim() );
}
catch ( NumberFormatException exception ){}
power = 0;
try {
power = Integer.parseInt ( line.substring ( 26, 28 ).trim() );
}
catch ( NumberFormatException exception ) {}
descr = line.substring ( 33 );
PokeSkill skill = new PokeSkill ( name, type, descr, pp, power );
//System.out.println ( skill );
objectout.writeObject ( skill );
System.out.println ( "name: " + name );
System.out.println ( "type: " + type );
System.out.println ( "descr: " + descr );
System.out.println ( "pp: " + pp );
System.out.println ( "power: " + power );
System.out.println();
line = inskill.readLine();
}
objectout.close();
}
catch ( IOException e ) {
System.out.println ( "Error: " + e );
System.out.println ( "name: " + name );
System.out.println ( "type: " + type );
System.out.println ( "descr: " + descr );
System.out.println ( "pp: " + pp );
System.out.println ( "power: " + power );
System.out.println();
}
}
}

BIN
attic/Pokemon.class Executable file

Binary file not shown.

199
attic/Pokemon.java Executable file
View File

@ -0,0 +1,199 @@
import java.io.*;
public class Pokemon implements Serializable {
private int number;
private String name, type;
private String[] attack, breedingmoves, breedcompat, tmhm, evolution;
private String location;
public Pokemon ( int number ) {
this.number = number;
name = null;
type = null;
evolution = null;
attack = null;
breedingmoves = null;
breedcompat = null;
location = null;
}
public Pokemon ( int number, String name, String type, String[] evolution, String[] attack, String[] tmhm, String[] breedingmoves, String[] breedcompat, String location ) {
this.number = number;
this.name = name;
this.type = type;
this.evolution = evolution;
this.attack = attack;
this.tmhm = tmhm;
this.breedingmoves = breedingmoves;
this.breedcompat = breedcompat;
this.location = location;
}
public int getNumber() {
return number;
}
public void setNameType ( String name, String type ) {
this.name = name;
this.type = type;
}
public void setType ( String type ) {
this.type = type;
}
public String getName() {
return name;
}
public String getType() {
return type;
}
public void setEvolution ( String[] evolution ) {
this.evolution = evolution;
}
public String[] getEvolution() {
return evolution;
}
public void setAttack ( String[] attacks ) {
this.attack = attacks;
}
public void setTMHM ( String[] tmhm ) {
this.tmhm = tmhm;
}
public void setBreedingMoves ( String[] breedingmoves ) {
this.breedingmoves = breedingmoves;
}
public void setBreedingCompatibility ( String[] breedcompat ) {
this.breedcompat = breedcompat;
}
public String[] getAttack() {
return attack;
}
public String[] getTMHM() {
return tmhm;
}
public String[] getBreedingMoves() {
return breedingmoves;
}
public String[] getBreedingList() {
return breedcompat;
}
public void foundAt ( String l ) {
location = l;
}
public String foundAt() {
return location;
}
public String longDescription() {
String result;
result = "#" + number + "\t" + name + "\n" + "Type: " + type + "\n" + "Evolves: ";
for ( int i = 0; i < evolution.length; i++ ) {
result += evolution[i];
if ( i != evolution.length - 1 )
result += ", ";
}
result += "\n\n" + "Attacks: ";
for ( int i = 0; i < attack.length; i++) {
result += attack[i];
if ( i != attack.length - 1 )
result += ", ";
}
result += "\n\n" + "TM/HM Compatability: ";
for ( int i = 0; i < tmhm.length; i++) {
result += tmhm[i];
if ( i != tmhm.length - 1 )
result += ", ";
}
result += "\n\n" + "Breeding Compatibility: ";
for ( int i = 0; i < breedcompat.length; i++) {
result += breedcompat[i];
if ( i != breedcompat.length - 1 )
result += ", ";
}
result += "\n\n" + "Breeding Moves: ";
for ( int i = 0; i < breedingmoves.length; i++) {
result += breedingmoves[i];
if ( i != breedingmoves.length - 1 )
result += ", ";
}
result += "\n\n" + "Found: " + location + "\n";
return result;
}
public String toString() {
return number + " " + name;
}
public void writeObject ( OutputStream out ) {
try {
PrintWriter outstream = new PrintWriter ( out );
outstream.println ( name );
outstream.println ( number );
outstream.println ( type );
outstream.println ( evolution.length );
for ( int i = 0; i < evolution.length; i++ )
outstream.println ( evolution[i] );
outstream.println ( attack.length );
for ( int i = 0; i < attack.length; i++ )
outstream.println ( attack[i] );
outstream.println ( tmhm.length );
for ( int i = 0; i < tmhm.length; i++ )
outstream.println ( tmhm[i] );
outstream.println ( breedcompat.length );
for ( int i = 0; i < breedcompat.length; i++ )
outstream.println ( breedcompat[i] );
outstream.println ( breedingmoves.length );
for ( int i = 0; i < breedingmoves.length; i++ )
outstream.println ( breedingmoves );
outstream.println ( location );
outstream.flush();
}
catch ( Exception exception ) {
System.out.println ( "Error: " + exception );
System.exit ( 0 );
}
}
public void readObject ( InputStream in ) {
try {
BufferedReader instream = new BufferedReader ( new InputStreamReader ( in ) );
name = instream.readLine();
number = Integer.parseInt ( instream.readLine() );
type = instream.readLine();
evolution = new String[Integer.parseInt ( instream.readLine() )];
for ( int i = 0; i < evolution.length; i++ )
evolution[i] = instream.readLine();
attack = new String[Integer.parseInt ( instream.readLine() )];
for ( int i = 0; i < attack.length; i++ )
attack[i] = instream.readLine();
tmhm = new String[Integer.parseInt ( instream.readLine() )];
for ( int i = 0; i < tmhm.length; i++ )
tmhm[i] = instream.readLine();
breedcompat = new String[Integer.parseInt ( instream.readLine() )];
for ( int i = 0; i < breedcompat.length; i++ )
breedcompat[i] = instream.readLine();
breedingmoves = new String[Integer.parseInt ( instream.readLine() )];
for ( int i = 0; i < breedingmoves.length; i++ )
breedingmoves[i] = instream.readLine();
location = instream.readLine();
}
catch ( Exception exception ) {
System.out.println ( "Error: " + exception );
System.exit ( 0 );
}
}
}

BIN
attic/crystal-skill.pkmn Executable file

Binary file not shown.

BIN
attic/crystal.pkmn Executable file

Binary file not shown.

3
attic/manifest.txt Executable file
View File

@ -0,0 +1,3 @@
Manifest-Version: 1.0
Main-Class: PokeDex
Created-By: 1.4.0 (Sun Microsystems Inc.)