grundlegente Umstellung + Earthdawn Implemntation

This commit is contained in:
Ocame
2025-07-06 16:22:48 +02:00
parent 10c8c9900f
commit e2b9694e09
48 changed files with 1488 additions and 638 deletions

View File

@ -0,0 +1,292 @@
package de.ocame.wuerfelbot.Earthdawn;
import java.util.Random;
public class step {
private int w4;
private int w6;
private int w8;
private int w10;
private int w12;
private int w20;
private int karma;
private int weiheA;
private int weiheJ;
private int weiheV;
private boolean glitches = true;
private String diceStructur = "";
private String diceResult = "";
private int resultInt = 0;
private int modifier = 0;
StringBuilder resultStructur = new StringBuilder();
public int getW4() {
return w4;
}
public step setW4(int w4) {
this.w4 = w4;
return this;
}
public int getW6() {
return w6;
}
public step setW6(int w6) {
this.w6 = w6;
return this;
}
public int getW8() {
return w8;
}
public step setW8(int w8) {
this.w8 = w8;
return this;
}
public int getW10() {
return w10;
}
public step setW10(int w10) {
this.w10 = w10;
return this;
}
public int getW12() {
return w12;
}
public step setW12(int w12) {
this.w12 = w12;
return this;
}
public int getW20() {
return w20;
}
public step setW20(int w20) {
this.w20 = w20;
return this;
}
public void addW4(int w4) {
this.w4 += w4;
}
public void addW6(int w6) {
this.w6 += w6;
}
public void addW8(int w8) {
this.w8 += w8;
}
public void addW10(int w10) {
this.w10 += w10;
}
public void addW12(int w12) {
this.w12 += w12;
}
public void addW20(int w20) {
this.w20 += w20;
}
public int getModifier() {
return modifier;
}
public int getKarma() {
return karma;
}
public step setKarma(int karma) {
this.karma = karma;
return this;
}
public step addKarma(int karma) {
this.karma += karma;
return this;
}
public step addWeiheJ(int weiheJ) {
this.weiheJ += weiheJ;
return this;
}
public step addWeiheA(int weiheA) {
this.weiheA += weiheA;
return this;
}
public step addWeiheV(int weiheV) {
this.weiheV += weiheV;
return this;
}
public step setModifier(int modifier) {
this.modifier = modifier;
return this;
}
public step addModifier(int modifier) {
this.modifier += modifier;
return this;
}
public boolean isGlitches() {
return glitches;
}
public String getDiceStructur() {
return diceStructur;
}
public String getDiceResult() {
return diceResult;
}
public int getResultInt() {
return resultInt;
}
public String getResultStructur() {
return resultStructur.toString();
}
public step reset() {
w4 = 0;
w6 = 0;
w8 = 0;
w10 = 0;
w12 = 0;
w20 = 0;
karma = 0;
weiheJ = 0;
weiheA = 0;
weiheV = 0;
modifier = 0;
glitches = true;
diceStructur = "";
diceResult = "";
resultInt = 0;
resultStructur = new StringBuilder();
return this;
}
public void roll() {
StringBuilder resultConstruction = new StringBuilder();
if(w4 > 0) {
rollDice(w4, 4);
if(resultConstruction.length() > 0)
resultConstruction.append("+");
resultConstruction.append(w4).append("w4");
}
if(w6 > 0) {
rollDice(w6, 6);
if(resultConstruction.length() > 0)
resultConstruction.append("+");
resultConstruction.append(w6).append("w6");
}
if(w8 > 0) {
rollDice(w8, 8);
if(resultConstruction.length() > 0)
resultConstruction.append("+");
resultConstruction.append(w8).append("w8");
}
if(w10 > 0) {
rollDice(w10, 10);
if(resultConstruction.length() > 0)
resultConstruction.append("+");
resultConstruction.append(w10).append("w10");
}
if(w12 > 0) {
rollDice(w12, 12);
if(resultConstruction.length() > 0)
resultConstruction.append("+");
resultConstruction.append(w12).append("w12");
}
if(w20 > 0) {
rollDice(w20, 20);
if(resultConstruction.length() > 0)
resultConstruction.append(" + ");
resultConstruction.append(w20).append("w20");
}
if(karma > 0) {
rollDice(karma, 6);
if(resultConstruction.length() > 0)
resultConstruction.append(" + ");
resultConstruction.append(karma).append("w6");
}
if(weiheJ > 0) {
rollDice(weiheJ, 4);
if(resultConstruction.length() > 0)
resultConstruction.append(" + ");
resultConstruction.append(weiheJ).append("w4");
}
if(weiheA > 0) {
rollDice(weiheA, 6);
if(resultConstruction.length() > 0)
resultConstruction.append(" + ");
resultConstruction.append(weiheA).append("w6");
}
if(weiheV > 0) {
rollDice(weiheV, 8);
if(resultConstruction.length() > 0)
resultConstruction.append(" + ");
resultConstruction.append(weiheV).append("w8");
}
if(modifier != 0) {
resultInt += modifier;
if(modifier > 0)
resultConstruction.append(" + ");
resultConstruction.append(modifier);
}
diceStructur = resultConstruction.toString();
if(resultInt <= 0)
resultInt = 1;
}
private void rollDice(int numberOfDice, int diceart) {
int dice;
for(int i = 0; i < numberOfDice; i++) {
dice = new Random().nextInt(diceart);
if(resultStructur.length() > 0) {
resultStructur.append(" ");
}
resultStructur.append(dice+1);
resultStructur.append("/");
resultStructur.append(diceart);
resultInt += dice+1;
if(dice+1 == diceart)
i--;
if(dice > 0)
glitches = false;
}
}
}