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/TwistyDino6.java
29 29

  
30 30
import java.util.Random;
31 31

  
32
import static org.distorted.effects.scramble.ScrambleEffect.START_AXIS;
33

  
34 32
///////////////////////////////////////////////////////////////////////////////////////////////////
35 33

  
36 34
public class TwistyDino6 extends TwistyDino
......
68 66

  
69 67
///////////////////////////////////////////////////////////////////////////////////////////////////
70 68

  
71
  public int randomizeNewRow(Random rnd, int oldRotAxis, int oldRow, int newRotAxis)
69
  public void randomizeNewScramble(int[] scramble, Random rnd, int oldRotAxis, int oldRow,
70
                                   int numScramble, int remScrambles, int remDoubleScrambles)
72 71
    {
73
    return (oldRotAxis==START_AXIS) ? (rnd.nextFloat()<=0.5f ? 0:2) : (oldRotAxis+newRotAxis==3 ? 2-oldRow : oldRow);
72
    if( numScramble==1 )
73
      {
74
      scramble[0] = rnd.nextInt(ROTATION_AXIS.length);
75
      }
76
    else
77
      {
78
      int newVector = rnd.nextInt(ROTATION_AXIS.length-1);
79
      scramble[0] = (newVector>=oldRotAxis ? newVector+1 : newVector);
80
      }
81

  
82
    scramble[1] = (numScramble==1) ? (rnd.nextFloat()<=0.5f ? 0:2) : (oldRotAxis+scramble[0]==3 ? 2-oldRow : oldRow);
83

  
84
    int random = rnd.nextInt(remScrambles);
85
    int result = random<remDoubleScrambles ? 2:1;
86
    int sign   = rnd.nextInt(2);
87

  
88
    scramble[2] = sign==0 ? result : -result;
74 89
    }
75 90

  
76 91
///////////////////////////////////////////////////////////////////////////////////////////////////

Also available in: Unified diff