Keeproll Modul für L5R

This commit is contained in:
Ocame
2021-03-05 16:29:22 +01:00
parent e28d8450fd
commit b0faab098b
2 changed files with 413 additions and 0 deletions

View File

@ -0,0 +1,105 @@
package Keeproll;
import java.util.Random;
public class result {
private StringBuilder text;
private int value;
private int diceart;
private Boolean reroll9;
private Boolean reroll1;
private Boolean maxReroll;
private Boolean noreroll;
public result() {
diceart = 10;
text = new StringBuilder();
value = 0;
reroll9 = false;
reroll1 = false;
maxReroll = false;
noreroll = false;
}
public String getText() {
return text.toString();
}
public void setText(String text) {
this.text = new StringBuilder();
this.text.append(text);
}
public void setMarket() {
String tmp = this.text.toString();
this.text = new StringBuilder();
this.text.append("**").append(tmp).append("**");
}
public int getValue() {
return value;
}
public void setValue(Integer value) {
this.value = value;
}
public result setReroll9(Boolean reroll9) {
this.reroll9 = reroll9;
return this;
}
public result setReroll1(Boolean reroll1) {
this.reroll1 = reroll1;
return this;
}
public result setMaxReroll(Boolean maxReroll) {
this.maxReroll = maxReroll;
return this;
}
public result setNoreroll(Boolean noreroll) {
this.noreroll = noreroll;
return this;
}
public result roll() {
int dice;
int rolls = 0;
Boolean reroll = false;
do{
reroll = false;
dice = new Random().nextInt(diceart);
dice++;
if(text.length() > 0) {
text.append("+");
}
if(reroll1 && dice == 1 && rolls <= 0) {
text.append("~~ ").append(dice).append(" ~~ ");
}
else {
text.append(dice);
}
value += dice;
if(!noreroll) {
if (dice == 10) {
reroll = rolls <= 0 || !maxReroll; // wenn maxRolls an und schon einmal gerollt wurde kein reroll
++rolls;
} else if (reroll9 && dice == 9) {
reroll = rolls <= 0 || !maxReroll;
} else if (reroll1 && dice == 1 && rolls <= 0) {
reroll = true;
value--;
}
}
} while(reroll);
return this;
}
}