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/TwistyIvy.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 TwistyIvy extends TwistyObject
......
283 281

  
284 282
///////////////////////////////////////////////////////////////////////////////////////////////////
285 283

  
286
  public int randomizeNewRotAxis(Random rnd, int oldRotAxis)
284
  public void randomizeNewScramble(int[] scramble, Random rnd, int oldRotAxis, int oldRow,
285
                                   int numScramble, int remScrambles, int remDoubleScrambles)
287 286
    {
288
    int numAxis = ROTATION_AXIS.length;
289

  
290
    if( oldRotAxis == START_AXIS )
287
    if( numScramble==1 )
291 288
      {
292
      return rnd.nextInt(numAxis);
289
      scramble[0] = rnd.nextInt(ROTATION_AXIS.length);
293 290
      }
294 291
    else
295 292
      {
296
      int newVector = rnd.nextInt(numAxis-1);
297
      return (newVector>=oldRotAxis ? newVector+1 : newVector);
293
      int newVector = rnd.nextInt(ROTATION_AXIS.length-1);
294
      scramble[0] = (newVector>=oldRotAxis ? newVector+1 : newVector);
298 295
      }
299
    }
300

  
301
///////////////////////////////////////////////////////////////////////////////////////////////////
302 296

  
303
  public int randomizeNewRow(Random rnd, int oldRotAxis, int oldRow, int newRotAxis)
304
    {
305 297
    float rowFloat = rnd.nextFloat();
306 298

  
307 299
    for(int row=0; row<mRowChances.length; row++)
308 300
      {
309
      if( rowFloat<=mRowChances[row] ) return row;
301
      if( rowFloat<=mRowChances[row] )
302
        {
303
        scramble[1] = row;
304
        break;
305
        }
310 306
      }
311 307

  
312
    return 0;
308
    int random = rnd.nextInt(remScrambles);
309
    int result = random<remDoubleScrambles ? 2:1;
310
    int sign   = rnd.nextInt(2);
311

  
312
    scramble[2] = sign==0 ? result : -result;
313 313
    }
314 314

  
315 315
///////////////////////////////////////////////////////////////////////////////////////////////////

Also available in: Unified diff