Project

General

Profile

« Previous | Next » 

Revision bbc6471c

Added by Leszek Koltunski about 3 years ago

Change the automatic scramble API in the TwistyObject - in preparation for automatic scrambles in the Bandaged Objects.

View differences:

src/main/java/org/distorted/objects/TwistySkewb.java
37 37

  
38 38
import java.util.Random;
39 39

  
40
import static org.distorted.effects.scramble.ScrambleEffect.START_AXIS;
41

  
42 40
///////////////////////////////////////////////////////////////////////////////////////////////////
43 41

  
44 42
public class TwistySkewb extends TwistyObject
......
541 539

  
542 540
///////////////////////////////////////////////////////////////////////////////////////////////////
543 541

  
544
  public int randomizeNewRotAxis(Random rnd, int oldRotAxis)
542
  public void randomizeNewScramble(int[] scramble, Random rnd, int oldRotAxis, int oldRow,
543
                                   int numScramble, int remScrambles, int remDoubleScrambles)
545 544
    {
546
    int numAxis = ROTATION_AXIS.length;
547

  
548
    if( oldRotAxis == START_AXIS )
545
    if( numScramble==1 )
549 546
      {
550
      return rnd.nextInt(numAxis);
547
      scramble[0] = rnd.nextInt(ROTATION_AXIS.length);
551 548
      }
552 549
    else
553 550
      {
554
      int newVector = rnd.nextInt(numAxis-1);
555
      return (newVector>=oldRotAxis ? newVector+1 : newVector);
551
      int newVector = rnd.nextInt(ROTATION_AXIS.length-1);
552
      scramble[0] = (newVector>=oldRotAxis ? newVector+1 : newVector);
556 553
      }
557
    }
558

  
559
///////////////////////////////////////////////////////////////////////////////////////////////////
560 554

  
561
  public int randomizeNewRow(Random rnd, int oldRotAxis, int oldRow, int newRotAxis)
562
    {
563 555
    float rowFloat = rnd.nextFloat();
564 556

  
565 557
    for(int row=0; row<mRowChances.length; row++)
566 558
      {
567
      if( rowFloat<=mRowChances[row] ) return row;
559
      if( rowFloat<=mRowChances[row] )
560
        {
561
        scramble[1] = row;
562
        break;
563
        }
568 564
      }
569 565

  
570
    return 0;
566
    int random = rnd.nextInt(remScrambles);
567
    int result = random<remDoubleScrambles ? 2:1;
568
    int sign   = rnd.nextInt(2);
569

  
570
    scramble[2] = sign==0 ? result : -result;
571 571
    }
572 572

  
573 573
///////////////////////////////////////////////////////////////////////////////////////////////////

Also available in: Unified diff