增加多段多倍切割的运算

This commit is contained in:
雪风 2025-03-19 11:39:45 +08:00
parent e491d2a2d6
commit f23371f563
2 changed files with 101 additions and 0 deletions

View File

@ -384,6 +384,7 @@ public class Equip extends Item implements IEquip, Serializable {
} }
public void setdd(String dd) { public void setdd(String dd) {
BigInteger bigInteger = new BigInteger(dd); BigInteger bigInteger = new BigInteger(dd);
if (bigInteger.compareTo(BigInteger.ZERO) < 0) { if (bigInteger.compareTo(BigInteger.ZERO) < 0) {
@ -391,6 +392,41 @@ public class Equip extends Item implements IEquip, Serializable {
} }
this.dd = dd; this.dd = dd;
} }
public void addDd(String num) {
BigInteger bigIntegernum = new BigInteger(num);
BigInteger bigIntegerdd = new BigInteger(this.dd);
BigInteger add = bigIntegerdd.add(bigIntegernum);
if (add.compareTo(BigInteger.ZERO) < 0) {
add = BigInteger.ZERO;
}
this.dd = add.toString();
}
public void multiplyDd(String num) {
BigInteger bigIntegernum = new BigInteger(num);
BigInteger bigIntegerdd = new BigInteger(this.dd);
BigInteger product = bigIntegerdd.multiply(bigIntegernum);
if (product.compareTo(BigInteger.ZERO) < 0) {
product = BigInteger.ZERO;
}
this.dd = product.toString();
}
public void divideDd(String num) {
BigInteger bigIntegernum = new BigInteger(num);
if (bigIntegernum.equals(BigInteger.ZERO)) {
throw new ArithmeticException("除数不能为零");
}
BigInteger bigIntegerdd = new BigInteger(this.dd);
BigInteger quotient = bigIntegerdd.divide(bigIntegernum);
if (quotient.compareTo(BigInteger.ZERO) < 0) {
quotient = BigInteger.ZERO;
}
this.dd = quotient.toString();
}
public void setdb(String db) { public void setdb(String db) {
BigInteger bigInteger = new BigInteger(db); BigInteger bigInteger = new BigInteger(db);
@ -407,7 +443,71 @@ public class Equip extends Item implements IEquip, Serializable {
} }
this.qg = qg; this.qg = qg;
} }
public void addDb(String num) {
BigInteger bigIntegernum = new BigInteger(num);
BigInteger bigIntegerdb = new BigInteger(this.db);
BigInteger add = bigIntegerdb.add(bigIntegernum);
if (add.compareTo(BigInteger.ZERO) < 0) {
add = BigInteger.ZERO;
}
this.db = add.toString();
}
public void multiplyDb(String num) {
BigInteger bigIntegernum = new BigInteger(num);
BigInteger bigIntegerdb = new BigInteger(this.db);
BigInteger product = bigIntegerdb.multiply(bigIntegernum);
if (product.compareTo(BigInteger.ZERO) < 0) {
product = BigInteger.ZERO;
}
this.db = product.toString();
}
public void divideDb(String num) {
BigInteger bigIntegernum = new BigInteger(num);
if (bigIntegernum.equals(BigInteger.ZERO)) {
throw new ArithmeticException("除数不能为零");
}
BigInteger bigIntegerdb = new BigInteger(this.db);
BigInteger quotient = bigIntegerdb.divide(bigIntegernum);
if (quotient.compareTo(BigInteger.ZERO) < 0) {
quotient = BigInteger.ZERO;
}
this.db = quotient.toString();
}
public void addQg(String num) {
BigInteger bigIntegernum = new BigInteger(num);
BigInteger bigIntegerqg = new BigInteger(this.qg);
BigInteger add = bigIntegerqg.add(bigIntegernum);
if (add.compareTo(BigInteger.ZERO) < 0) {
add = BigInteger.ZERO;
}
this.qg = add.toString();
}
public void multiplyQg(String num) {
BigInteger bigIntegernum = new BigInteger(num);
BigInteger bigIntegerqg = new BigInteger(this.qg);
BigInteger product = bigIntegerqg.multiply(bigIntegernum);
if (product.compareTo(BigInteger.ZERO) < 0) {
product = BigInteger.ZERO;
}
this.qg = product.toString();
}
public void divideQg(String num) {
BigInteger bigIntegernum = new BigInteger(num);
if (bigIntegernum.equals(BigInteger.ZERO)) {
throw new ArithmeticException("除数不能为零");
}
BigInteger bigIntegerqg = new BigInteger(this.qg);
BigInteger quotient = bigIntegerqg.divide(bigIntegernum);
if (quotient.compareTo(BigInteger.ZERO) < 0) {
quotient = BigInteger.ZERO;
}
this.qg = quotient.toString();
}
public void setUpgradeSlots(final byte upgradeSlots) { public void setUpgradeSlots(final byte upgradeSlots) {
this.upgradeSlots = upgradeSlots; this.upgradeSlots = upgradeSlots;

View File

@ -106,6 +106,7 @@ public class MaplePacketLittleEndianWriter {
if (s == null ||s.isEmpty()){ if (s == null ||s.isEmpty()){
s = "0"; s = "0";
} }
this.writeShort((int) (short)s.getBytes(StandardCharsets.UTF_8).length); this.writeShort((int) (short)s.getBytes(StandardCharsets.UTF_8).length);
this.write(s.getBytes(StandardCharsets.UTF_8)); this.write(s.getBytes(StandardCharsets.UTF_8));
} }