import java.util.*;
import java.io.*;
public class PidGen extends Prng32 {
private long seed;
private final long Af = 0X41C64E6D; //going forward
private final long Cf = 0X6073;
private final long Ar = 0xEEB9EB65; //reverse
private final long Cr = 0xA3561A1;
String nature;
Long PID, n;
long s;
String[] IVs = { "HP", "Atk", "Def", "SpA", "SpD", "Spe"};
private final String[] natureList =
{"Hardy","Lonely","Brave","Adamant","Naughty",
"Bold", "Docile","Relaxed","Impish","Lax",
"Timid","Hasty", "Serious", "Jolly","Naive",
"Modest","Mild","Quiet","Bashful","Rash",
"Calm","Gentle","Sassy","Careful","Quirky"};
public PidGen(long s) {
super(s);
seed = s;
}
public String getNature(long s){
seed = s;
calcPid(s, 1);
n = PID % 25;
Integer N = new Integer(n.intValue());
String nature = natureList[N];
return nature;
}
public long getSeed() {
return seed;
}
private long getNext(long s) {
long bitmask = 0xFFFFFFFFL;
seed = (Af*s + Cf) & bitmask;
return seed ;
}
public long next() {
return getNext(seed);
}
private long getPrev(long s) {
long bitmask = 0xFFFFFFFFL;
seed = (Ar*s + Cr) & bitmask;
return seed;
}
public long prev() {
return getPrev(seed);
}
public long setNext(long s) {
return s;
}
public void calcPid(long s, int method) {
switch (method) {
case 1: method1(s); break;
case 2: method2(s); break;
case 3: method3(s); break;
case 4: method4(s); break;
}
}
private void method1(long s) {
//do method 1 stuff
long Lid = s / 0x10000; //rng call 1
s = getNext(s);
long Hid = s / 0x10000; //rng call2
PID = Hid*0x10000 + Lid;
String Pid = Long.toHexString(PID);
System.out.print(" PID: "+Pid);
s = getNext(s);
long IVsHigh = s / 0x10000; //rng call 3 --> Defense, Attack, HP
s = getNext(s);
long IVsLow = s / 0x10000; //rng call 4 --> Speed, Special Attack, Special Defense
setIVs(IVsHigh,IVsLow);
}
private void method2(long s) {
//do method 2 stuff
}
private void method3(long s) {
//do method 3 stuff
}
private void method4(long s) {
//do method 4 stuff
}
private void setIVs(long high, long low) {
Long HP = high % 32;
high = high/32;
Long Atk = high % 32;
high = high/32;
Long Def = high % 32;
Long SpA = low % 32;
low = low/32;
Long SpD = low % 32;
low = low/32;
Long Spe = Math.abs(low % 32);
IVs[0] = Long.toString(HP);
IVs[1] = Long.toString(Atk);
IVs[2] = Long.toString(Def);
IVs[3] = Long.toString(SpA);
IVs[4] = Long.toString(SpD);
IVs[5] = Long.toString(Spe);
System.out.print(" "+IVs[0]+" / "+IVs[1]+" / "+IVs[2]+" / "+IVs[3]+" / "+IVs[4]+" / "+IVs[5]);
}
public static void main(String [] args) {
PidGen P = new PidGen(0xe2cca5ee);
}
}