# Omnimaga

## Calculator Community => Discontinued => Major Community Projects => Pokemon Red => Topic started by: BuckeyeDude on June 26, 2010, 01:22:18 am

Title: Pokemon Stats Generator
Post by: BuckeyeDude on June 26, 2010, 01:22:18 am
I thought you guys might be interested in a little program I whipped up a while back. I used it to check my math in assembly, when working out some of the stats generation (and still use it because I think some stuff is wrong). Its not fully complete, but still pretty useful. Anyway check it out, just a simple C# app.
Title: Re: Pokemon Stats Generator
Post by: DJ Omnimaga on June 26, 2010, 01:25:49 am
Mhmm interesting. I assume this is useful mostly to know in advance what will be the stats of one of your Pokémon depending of certain parameters, right?
Title: Re: Pokemon Stats Generator
Post by: BuckeyeDude on June 26, 2010, 01:27:44 am
Correct. For example I just used it to check the maximum amount of damage a level 5 pidgey can do to a level 5 charmander. Which is 4 fyi
Title: Re: Pokemon Stats Generator
Post by: DJ Omnimaga on June 26, 2010, 01:40:37 am
Nice :D
Title: Re: Pokemon Stats Generator
Post by: Magic Banana on June 26, 2010, 08:22:35 am
That's pretty nice. I was bored so I decided to do some error checking.

-In the attack list you have a couple attacks that have a different name such as:
9 gun = water gun
3 powder = poisonpowder
5 throw = rock throw

-For the attack calculator tab, I noticed that the IV/EV numberbox goes to 100 instead of 15/65535.
-If you crank the EV numberbox to anything over 32750, it will crash the program, but that's probably just because it's set to 16bit signed.
-For calculating the stats, If they go over 255, they will overflow and reset back to 0.
-Also, it doesn't look like the IVs get calculated into the stats, but they do for the damage.

It looks like this was made in Visual Studio 2010, seeing as how it's 'unknown version' in 2008. Did you use any 2010 specific tools to make this? if not I could probably find a way to open it in 2008 and make a couple fixes.

EDIT:Fixed it up. I also built it in Release as well as Debug.

EDIT2:Just wondering, how come you commented out the entire 'Moves Learned' code? It looks like you cover all of the pokemon and their moves.
Title: Re: Pokemon Stats Generator
Post by: BuckeyeDude on June 26, 2010, 01:01:13 pm
Cool thanks magic banana.
For the attack list stuff, thats because I stole this from my asm macros and had to do a find and replace on the equates, because C# you can't define stuff :( (although now that I think of it not sure why I didn't make them constants)
Good call on the other stuff, although the IVs would get calculated, the stats just wouldnt get updated :P.
As for why I commented out the moves learned code, I was too lazy to get it working. You can just select the move you want for the damage calculation :P. It works in the real game :P
Title: Re: Pokemon Stats Generator
Post by: Magic Banana on June 26, 2010, 01:40:35 pm
No problem. :)

The only thing I couldn't figure out was how to organize a class by type so that I can get the attacks to be in alphabetical order. I've never worked in C# so I was just going off of what I knew in C and VB.NET to fix the other things. I've tried to use the normal Array.Sort( but it's not a 1 dimensional array. I tried to figure out how to use IComparable and CompareTo but I had no luck on it. If I can get that working, then I can just attach them to radio buttons so you can sort by index or name.
Title: Re: Pokemon Stats Generator
Post by: BuckeyeDude on June 26, 2010, 01:49:23 pm
Just going off memory, you should override the Equals( method of the move class, compare the strings (string.Equals), then i think you can just say combobox.sorted = true;

EDIT: maybe combobox.sort() or combobox.items.sort() if any of those exist
Title: Re: Pokemon Stats Generator
Post by: Magic Banana on June 26, 2010, 03:18:25 pm
Well, the combobox does have a sorted property, but using that just tears the program apart. I'm trying to think of a way to tell it which type it should be looking at when sorting the list before putting it into the combobox, because the normal Sort( commands just moves the name of the item and not all of the other members of that class. (I'm pretty sure Psychic isn't a normal move with 40 power and 30 pp).

I know CompareTo can be used to compare multiple data types, which can be changed using a public enum for the members in a class, but I don't know how to implement it.

If anything else, I can always make a second list and just replace the old one in the combobox, but that just seems like a waste of space for the program. Either that, or I can just rip out the index of the attacks since most people would probably prefer attacks to be sorted alphabetically while the pokemon are still sorted by index.
Title: Re: Pokemon Stats Generator
Post by: BuckeyeDude on June 26, 2010, 03:22:15 pm
Well, the combobox does have a sorted property, but using that just tears the program apart. I'm trying to think of a way to tell it which type it should be looking at when sorting the list before putting it into the combobox, because the normal Sort( commands just moves the name of the item and not all of the other members of that class. (I'm pretty sure Psychic isn't a normal move with 40 power and 30 pp).
When using the sorted property, the sorting uses the Equals() method to compare items.

add this to the Moves class
Code: [Select]
`public override bool Equals(object obj){    return string.Equals(name, obj);}`and then you can use the sorted property of the combobox
Title: Re: Pokemon Stats Generator
Post by: Magic Banana on June 26, 2010, 03:35:58 pm
The code seems to change nothing at all. The sorted property for the combobox just doesn't do what we are trying to do here. Name changes only. Plus, if an item is currently selected when sorting it, the program crashes. I've even reset the selected index and it still happens. That, plus it never 'unsorts' it after it has been sorted means that the combobox sort isn't the best way to do this. I think I may have an idea though ...
Title: Re: Pokemon Stats Generator
Post by: BuckeyeDude on June 26, 2010, 05:21:52 pm
Ah my bad, I set this up horribly. A couple things had to be changed to fix this. One in addition to overriding the Equals() method, the ToString() method needed to be overridden too (I thought I had already done this).
Code: [Select]
` public override string ToString()        {            return name;        }`Then in the New_Move() method, comboBox.Item.Add() needs to add the move, not just the name.
Code: [Select]
`allMoves[index] = new Move(index, name, type, pp, power, accuracy);            movesComboBox.Items.Add(allMoves[index]);`Finally you need to call InitMoves() whenever you resort the list so they are added properly. There is a better way to do this, which I can explain if you want. Also make sure you add a comboBox.Items.Clear() in InitMoves() so you don't keep adding to the items already there.
Title: Re: Pokemon Stats Generator
Post by: Magic Banana on June 26, 2010, 05:42:15 pm
Well, for now I just took the cheap and ridiculously repetitive path by just making a second list.  ;D

I'm going to be busy for a while today so this will have to do until I hash out the details. You can feel free to work on it if you want, seeing as it's your program. I'm pretty sure it will convert from 2008 to 2010 pretty smoothly, especially if I was able to make it backwards compatible.