@@ -288,27 +288,34 @@ public void randomizeMoves(boolean keepStage, boolean keepMoveAmount){
288288 ArrayList <Move > moveList = new ArrayList <Move >();
289289 ArrayList <MonCardData > monList = new ArrayList <MonCardData >();
290290
291+
292+
291293 for (int i = 0 ; i < monAmount ; i ++){
292294 moveList .add (mons [i ].move1 );
293295 if (mons [i ].move2 .isExists ())
294296 moveList .add (mons [i ].move2 );
295297 monList .add (mons [i ]);
296298 }
297299
298-
299300 Collections .shuffle (moveList , rand );
300301 Collections .shuffle (monList , rand );
302+
301303 for (int i = moveList .size ()-1 ; i >= 0 ; i --){
304+
302305 if (moveList .get (i ).isPokePower ()){
303- moveList .add (moveList .remove (i ++ ));//move it to the back of the list
306+ moveList .add (moveList .remove (i ));//move it to the back of the list
304307 }
305308 }
306309
310+
307311 for (int i = 0 ; i < monList .size (); i ++){
308312 MonCardData curr = monList .get (i );
309313 int stage = 0xFF & curr .stage ;
310314 // System.out.println(stage);
311315 boolean foundPokePower = false ;
316+
317+
318+
312319 for (int j = moveList .size ()-1 ; j >= 0 ; j --){
313320 Move currMove = moveList .get (j );
314321
@@ -341,14 +348,12 @@ public void randomizeMoves(boolean keepStage, boolean keepMoveAmount){
341348
342349
343350 }
344-
345351 if (foundPokePower ){
346352 //if after all that we got two moves (move + pokepower), remove self from list
347353 monList .remove (i --);
348354
349355 }
350356 }
351-
352357 //Alright so where are we now?
353358 //we have a list of mons with only one move, and a list of moves that still don't have a home
354359 for (int i = 0 ; i < monList .size (); i ++){
@@ -366,7 +371,6 @@ public void randomizeMoves(boolean keepStage, boolean keepMoveAmount){
366371
367372
368373 }
369-
370374 for (int i = 0 ; i < monList .size (); i ++){
371375 monList .get (i ).move2 = blankMove ;
372376
@@ -523,7 +527,96 @@ public void setInstantText(){
523527 rom [ldaLocation ] = 0x00 ;
524528 }
525529
526-
530+ public ArrayList <MonCardData > indicesOfPokemonFromNamePointer (Word namePointer , ArrayList <MonCardData > mons ){
531+ ArrayList <MonCardData > ret = new ArrayList <MonCardData >();
532+ for (int i = 0 ; i < mons .size (); i ++){
533+
534+ if (mons .get (i ).name .equals (namePointer ))
535+ ret .add (mons .get (i ));
536+ }
537+ return ret ;
538+ }
539+ public void randomizeEvolutions (int maxSize , boolean monoType ){
540+
541+ ArrayList <MonCardData > randMons = new ArrayList <MonCardData >(Arrays .asList (mons ));
542+ Collections .shuffle (randMons , rand );
543+ ArrayList <MonCardData > tempInd ; // used a few times for a short amount of time
544+ ArrayList <MonCardData > usedMons = new ArrayList <MonCardData >();
545+
546+ while (randMons .size () > 0 ){
547+
548+ MonCardData currMon = randMons .get (0 );
549+
550+ tempInd = indicesOfPokemonFromNamePointer (currMon .name , randMons );
551+ for (MonCardData mc : tempInd ){
552+ mc .stage = 0x0 ; // basic
553+ mc .preEvoName = new Word (); // no pre evo (default constructor returns 0000 word)
554+ usedMons .add (mc );
555+ randMons .remove (mc );
556+ }
557+
558+
559+
560+ int maxBound = maxSize ;
561+ if (randMons .size () < maxBound )
562+ maxBound = randMons .size ();
563+
564+
565+ //this lets us skip randomization and the for loop if we have no pokems left
566+ //we go straight to setting this mon to highest evo
567+ int rnum ;
568+ if (maxBound < 1 )
569+ rnum = 0 ;
570+ else
571+ rnum = rand .nextInt (maxBound );
572+
573+
574+ for (int i = rnum ; i > 0 ; i --){
575+
576+ boolean monFound = false ;
577+ int newMonNum ;
578+
579+ for (newMonNum = 0 ; newMonNum < randMons .size (); newMonNum ++){
580+ if (!monoType || randMons .get (newMonNum ).type == currMon .type ){
581+ monFound = true ;
582+ break ;
583+ }
584+ }
585+
586+ if (!monFound )
587+ break ;
588+
589+ MonCardData newMon = randMons .get (newMonNum );
590+
591+ if (currMon .stage > 0 )
592+ newMon .stage = 0x02 ;
593+ else
594+ newMon .stage = 0x01 ;
595+
596+
597+
598+ tempInd = indicesOfPokemonFromNamePointer (newMon .name , randMons );
599+ for (MonCardData mc : tempInd ){
600+ mc .stage = newMon .stage ;
601+ mc .preEvoName = currMon .name ;
602+ usedMons .add (mc );
603+ randMons .remove (mc );
604+ }
605+
606+
607+ currMon = newMon ;
608+ }
609+
610+ tempInd = indicesOfPokemonFromNamePointer (currMon .name , randMons );
611+ for (MonCardData mc : tempInd ){
612+ mc .highestStage = true ;
613+ }
614+
615+
616+ }
617+
618+
619+ }
527620
528621 public void setMoveTypeToMonType () {
529622 for ( MonCardData mon : mons ){
0 commit comments