mirror of
https://github.com/magefree/mage.git
synced 2025-12-24 20:41:58 -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
|
* @author TheElk801
|
||||||
*/
|
*/
|
||||||
public class CardRun extends Rotater<String> {
|
public class CardRun extends Rotater<String> {
|
||||||
private int cardPos,stripeLen=0,stripeWidth,stripeDepth;
|
private int stripeLen=0,stripeWidth,stripeDepth;
|
||||||
// cardPos is used in place of private super.position for Striped Collation
|
|
||||||
|
|
||||||
public CardRun(boolean keepOrder, String... numbers) {
|
public CardRun(boolean keepOrder, String... numbers) {
|
||||||
super(keepOrder, numbers);
|
super(keepOrder, numbers);
|
||||||
|
|
@ -15,11 +14,9 @@ public class CardRun extends Rotater<String> {
|
||||||
|
|
||||||
public CardRun(int sLen, String... numbers) {
|
public CardRun(int sLen, String... numbers) {
|
||||||
super(true, numbers);
|
super(true, numbers);
|
||||||
cardPos= RandomUtil.nextInt( this.numItems() );
|
stripeLen= sLen;
|
||||||
stripeWidth= nextWidth();
|
stripeWidth= nextWidth();
|
||||||
stripeDepth= 1+ RandomUtil.nextInt( stripeWidth );
|
stripeDepth= 1+ RandomUtil.nextInt( stripeWidth );
|
||||||
// assert sLen >0;
|
|
||||||
// assert this.numItems() % sLen == 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// randomly choose a stripe width between 2 & 5 (inclusive)
|
// randomly choose a stripe width between 2 & 5 (inclusive)
|
||||||
|
|
@ -31,28 +28,15 @@ public class CardRun extends Rotater<String> {
|
||||||
public int iterate() {
|
public int iterate() {
|
||||||
if( stripeLen ==0 ){
|
if( stripeLen ==0 ){
|
||||||
return super.iterate();
|
return super.iterate();
|
||||||
}else{
|
if( stripeDepth < stripeWidth ){
|
||||||
int i = cardPos;
|
++stripeDepth;
|
||||||
if( stripeDepth < stripeWidth ){
|
return super.iterate(-stripeLen);
|
||||||
++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;
|
|
||||||
}
|
}
|
||||||
|
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() {
|
public boolean isEdge(int rowLen) {
|
||||||
return items.size();
|
return (position % rowLen)==0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getItem(int i) {
|
public int iterate(int offset) {
|
||||||
return items.get(i);
|
int i = position;
|
||||||
|
position += offset;
|
||||||
|
while (position <0) {
|
||||||
|
position += items.size();
|
||||||
|
}
|
||||||
|
position %= items.size();
|
||||||
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int iterate() {
|
public int iterate() {
|
||||||
int i = position;
|
return iterate(1)'
|
||||||
position++;
|
|
||||||
position %= items.size();
|
|
||||||
return i;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public T getNext() {
|
public T getNext() {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue