mirror of
https://github.com/magefree/mage.git
synced 2025-12-24 04:22:01 -08:00
Add files via upload
This commit is contained in:
parent
a5f14d61dd
commit
f1df1aeebb
2 changed files with 23 additions and 36 deletions
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue