Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Pokemon RPG in Ruby

Name: Anonymous 2010-12-07 21:26

Is there a more efficient way to do this? In terms of lines of code that is; I really don't want to have to do a fuck ton of case when case when shits again....

http://pastebin.com/gdTevCRJ

Name: Anonymous 2010-12-07 23:06

Not really; the data has to be written somewhere. You can also do something like this to make the expression of the data more concise:

enum type { NORMAL, FLYING, ROCK, /* ... */ NTYPES };
float damage_mod(enum type a, enum type b) {
  float m[NTYPES][NTYPES] = {
    [NORMAL][NORMAL] = 1,
    [NORMAL][FLYING] = 1,
    [NORMAL][ROCK] = 0.5,
    /* ... */
  };
  return m[a][b];
}

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List