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/TwistyDiamond.java
35 35

  
36 36
import java.util.Random;
37 37

  
38
import static org.distorted.effects.scramble.ScrambleEffect.START_AXIS;
39

  
40 38
///////////////////////////////////////////////////////////////////////////////////////////////////
41 39

  
42 40
public class TwistyDiamond extends TwistyObject
......
293 291

  
294 292
///////////////////////////////////////////////////////////////////////////////////////////////////
295 293

  
296
  public int randomizeNewRotAxis(Random rnd, int oldRotAxis)
294
  public void randomizeNewScramble(int[] scramble, Random rnd, int oldRotAxis, int oldRow,
295
                                   int numScramble, int remScrambles, int remDoubleScrambles)
297 296
    {
298
    int numAxis = ROTATION_AXIS.length;
299

  
300
    if( oldRotAxis == START_AXIS )
297
    if( numScramble==1 )
301 298
      {
302
      return rnd.nextInt(numAxis);
299
      scramble[0] = rnd.nextInt(ROTATION_AXIS.length);
303 300
      }
304 301
    else
305 302
      {
306
      int newVector = rnd.nextInt(numAxis-1);
307
      return (newVector>=oldRotAxis ? newVector+1 : newVector);
303
      int newVector = rnd.nextInt(ROTATION_AXIS.length-1);
304
      scramble[0] = (newVector>=oldRotAxis ? newVector+1 : newVector);
308 305
      }
309
    }
310 306

  
311
///////////////////////////////////////////////////////////////////////////////////////////////////
312

  
313
  public int randomizeNewRow(Random rnd, int oldRotAxis, int oldRow, int newRotAxis)
314
    {
315 307
    float rowFloat = rnd.nextFloat();
316 308

  
317 309
    for(int row=0; row<mRowChances.length; row++)
318 310
      {
319
      if( rowFloat<=mRowChances[row] ) return row;
311
      if( rowFloat<=mRowChances[row] )
312
        {
313
        scramble[1] = row;
314
        break;
315
        }
320 316
      }
321 317

  
322
    return 0;
318
    int random = rnd.nextInt(remScrambles);
319
    int result = random<remDoubleScrambles ? 2:1;
320
    int sign   = rnd.nextInt(2);
321

  
322
    scramble[2] = sign==0 ? result : -result;
323 323
    }
324 324

  
325 325
///////////////////////////////////////////////////////////////////////////////////////////////////

Also available in: Unified diff