本文整理汇总了Java中com.trollworks.toolkit.utility.Dice类的典型用法代码示例。如果您正苦于以下问题:Java Dice类的具体用法?Java Dice怎么用?Java Dice使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Dice类属于com.trollworks.toolkit.utility包,在下文中一共展示了Dice类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: resolveDamage
import com.trollworks.toolkit.utility.Dice; //导入依赖的package包/类
private String resolveDamage(String damage, HashSet<WeaponBonus> bonuses) {
int maxST = getMinStrengthValue() * 3;
GURPSCharacter character = (GURPSCharacter) mOwner.getDataFile();
int st = character.getStrength() + character.getStrikingStrengthBonus();
Dice dice;
String savedDamage;
if (maxST > 0 && maxST < st) {
st = maxST;
}
dice = GURPSCharacter.getSwing(st);
do {
savedDamage = damage;
damage = resolveDamage(damage, "sw", dice); //$NON-NLS-1$
} while (!savedDamage.equals(damage));
dice = GURPSCharacter.getThrust(st);
do {
savedDamage = damage;
damage = resolveDamage(damage, "thr", dice); //$NON-NLS-1$
} while (!savedDamage.equals(damage));
return resolveDamageBonuses(damage, bonuses);
}
示例2: main
import com.trollworks.toolkit.utility.Dice; //导入依赖的package包/类
/**
* The main entry point for the character sheet.
*
* @param args Arguments to the program.
*/
public static void main(String[] args) {
App.setup(GCS.class);
Dice.setAssumedSideCount(6);
CmdLine cmdLine = new CmdLine();
cmdLine.addOptions(TEXT_OPTION, TEXT_TEMPLATE_OPTION, PDF_OPTION, PNG_OPTION, SIZE_OPTION, MARGIN_OPTION);
cmdLine.processArguments(args);
if (cmdLine.isOptionUsed(TEXT_OPTION) || cmdLine.isOptionUsed(PDF_OPTION) || cmdLine.isOptionUsed(PNG_OPTION)) {
System.setProperty("java.awt.headless", Boolean.TRUE.toString()); //$NON-NLS-1$
initialize();
Timing timing = new Timing();
System.out.println(BundleInfo.getDefault().getAppBanner());
System.out.println();
if (convert(cmdLine) < 1) {
System.out.println(NO_FILES_TO_PROCESS);
System.exit(1);
}
System.out.println(MessageFormat.format(FINISHED, timing));
System.exit(0);
} else {
LaunchProxy.configure(cmdLine.getArgumentsAsFiles());
if (GraphicsUtilities.areGraphicsSafeToUse()) {
initialize();
GCSApp.INSTANCE.startup(cmdLine);
} else {
System.err.println(GraphicsUtilities.getReasonForUnsafeGraphics());
System.exit(1);
}
}
}
示例3: updateStrengthInfo
import com.trollworks.toolkit.utility.Dice; //导入依赖的package包/类
private void updateStrengthInfo(int strength, int bonus, int liftingBonus, int strikingBonus) {
Dice thrust = getThrust();
Dice swing = getSwing();
WeightValue lift = getBasicLift();
boolean notifyST = mStrength != strength || mStrengthBonus != bonus;
Dice dice;
mStrength = strength;
mStrengthBonus = bonus;
mLiftingStrengthBonus = liftingBonus;
mStrikingStrengthBonus = strikingBonus;
startNotify();
if (notifyST) {
notify(ID_STRENGTH, Integer.valueOf(getStrength()));
notifyOfBaseHitPointChange();
}
WeightValue newLift = getBasicLift();
if (!newLift.equals(lift)) {
notify(ID_BASIC_LIFT, newLift);
notify(ID_ONE_HANDED_LIFT, getOneHandedLift());
notify(ID_TWO_HANDED_LIFT, getTwoHandedLift());
notify(ID_SHOVE_AND_KNOCK_OVER, getShoveAndKnockOver());
notify(ID_RUNNING_SHOVE_AND_KNOCK_OVER, getRunningShoveAndKnockOver());
notify(ID_CARRY_ON_BACK, getCarryOnBack());
notify(ID_SHIFT_SLIGHTLY, getShiftSlightly());
for (Encumbrance encumbrance : Encumbrance.values()) {
notify(MAXIMUM_CARRY_PREFIX + encumbrance.ordinal(), getMaximumCarry(encumbrance));
}
}
dice = getThrust();
if (!dice.equals(thrust)) {
notify(ID_BASIC_THRUST, dice);
}
dice = getSwing();
if (!dice.equals(swing)) {
notify(ID_BASIC_SWING, dice);
}
updateSkills();
mNeedAttributePointCalculation = true;
endNotify();
}
示例4: getThrust
import com.trollworks.toolkit.utility.Dice; //导入依赖的package包/类
/** @return The basic thrusting damage. */
public Dice getThrust() {
return getThrust(getStrength() + mStrikingStrengthBonus);
}
示例5: getSwing
import com.trollworks.toolkit.utility.Dice; //导入依赖的package包/类
/** @return The basic swinging damage. */
public Dice getSwing() {
return getSwing(getStrength() + mStrikingStrengthBonus);
}
示例6: adjustOptionalDiceRulesProperty
import com.trollworks.toolkit.utility.Dice; //导入依赖的package包/类
private static void adjustOptionalDiceRulesProperty(boolean use) {
Dice.setConvertModifiersToExtraDice(use);
}
示例7: resolveDamageBonuses
import com.trollworks.toolkit.utility.Dice; //导入依赖的package包/类
private String resolveDamageBonuses(String damage, HashSet<WeaponBonus> bonuses) {
int max = damage.length();
int start = 0;
while (true) {
int where = damage.indexOf('d', start);
if (where < 1) {
return damage;
}
char digit = damage.charAt(where - 1);
if (isDigit(digit)) {
while (where > 0 && isDigit(damage.charAt(where - 1))) {
where--;
}
StringBuffer buffer = new StringBuffer();
if (where > 0) {
buffer.append(damage.substring(0, where));
}
int[] dicePos = Dice.extractDicePosition(damage.substring(where));
Dice dice = new Dice(damage.substring(where + dicePos[0], where + dicePos[1] + 1));
if (mOwner instanceof Advantage) {
Advantage advantage = (Advantage) mOwner;
if (advantage.isLeveled()) {
dice.multiply(advantage.getLevels());
}
}
for (WeaponBonus bonus : bonuses) {
LeveledAmount lvlAmt = bonus.getAmount();
int amt = lvlAmt.getIntegerAmount();
if (lvlAmt.isPerLevel()) {
dice.add(amt * dice.getDieCount());
} else {
dice.add(amt);
}
}
buffer.append(dice.toString());
if (where + dicePos[1] + 1 < max) {
buffer.append(damage.substring(where + dicePos[1] + 1));
}
return buffer.toString();
}
start = where + 1;
}
}
示例8: stringToValue
import com.trollworks.toolkit.utility.Dice; //导入依赖的package包/类
@Override
public Object stringToValue(String text) throws ParseException {
return new Dice(text);
}
示例9: valueToString
import com.trollworks.toolkit.utility.Dice; //导入依赖的package包/类
@Override
public String valueToString(Object value) throws ParseException {
return value instanceof Dice ? value.toString() : ""; //$NON-NLS-1$
}