Add files via upload

This commit is contained in:
tiera3 2024-10-02 15:48:02 +10:00 committed by GitHub
parent a5f14d61dd
commit f1df1aeebb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 23 additions and 36 deletions

View file

@ -6,8 +6,7 @@ import mage.util.RandomUtil;
* @author TheElk801
*/
public class CardRun extends Rotater<String> {
private int cardPos,stripeLen=0,stripeWidth,stripeDepth;
// cardPos is used in place of private super.position for Striped Collation
private int stripeLen=0,stripeWidth,stripeDepth;
public CardRun(boolean keepOrder, String... numbers) {
super(keepOrder, numbers);
@ -15,11 +14,9 @@ public class CardRun extends Rotater<String> {
public CardRun(int sLen, String... numbers) {
super(true, numbers);
cardPos= RandomUtil.nextInt( this.numItems() );
stripeLen= sLen;
stripeWidth= nextWidth();
stripeDepth= 1+ RandomUtil.nextInt( stripeWidth );
// assert sLen >0;
// assert this.numItems() % sLen == 0;
}
// randomly choose a stripe width between 2 & 5 (inclusive)
@ -31,28 +28,15 @@ public class CardRun extends Rotater<String> {
public int iterate() {
if( stripeLen ==0 ){
return super.iterate();
}else{
int i = cardPos;
if( stripeDepth < stripeWidth ){
++stripeDepth;
cardPos -= 10;
if (cardPos <0 ){
cardPos += this.numItems();
}
}else{
stripeDepth= 1;
if( (cardPos % stripeLen) >0 ){
cardPos += stripeLen * (stripeWidth-1);
cardPos %= this.numItems();
}else{
this.stripeWidth= this.nextWidth();
}
cardPos -= 1;
if (cardPos <0 ){
cardPos += this.numItems();
}
}
return i;
if( stripeDepth < stripeWidth ){
++stripeDepth;
return super.iterate(-stripeLen);
}
stripeDepth= 1;
if this.isEdge(stripeLen){
this.stripeWidth= this.nextWidth();
return super.iterate(-1);
}
return super.iterate((stripeLen * (stripeWidth-1)) -1);
}
}

View file

@ -37,19 +37,22 @@ public class Rotater<T> {
}
}
public int numItems() {
return items.size();
public boolean isEdge(int rowLen) {
return (position % rowLen)==0;
}
public String getItem(int i) {
return items.get(i);
public int iterate(int offset) {
int i = position;
position += offset;
while (position <0) {
position += items.size();
}
position %= items.size();
return i;
}
public int iterate() {
int i = position;
position++;
position %= items.size();
return i;
return iterate(1)'
}
public T getNext() {