MCPcopy Create free account
hub / github.com/PCGen/pcgen / getCritToken

Method getCritToken

code/src/java/pcgen/io/exporttoken/WeaponToken.java:1142–1194  ·  view source on GitHub ↗

Get critical token @param pc @param eq @return critical token

(PlayerCharacter pc, Equipment eq)

Source from the content-addressed store, hash-verified

1140 * @return critical token
1141 */
1142 private static String getCritToken(PlayerCharacter pc, Equipment eq)
1143 {
1144 StringBuilder sb = new StringBuilder();
1145 String critRangeVar = ControlUtilities.getControlToken(Globals.getContext(), CControl.CRITRANGE);
1146 if (critRangeVar != null)
1147 {
1148 EquipmentHead head = eq.getEquipmentHead(1);
1149 return getCritRangeHead(pc, head, critRangeVar).toString();
1150 }
1151
1152 boolean isDouble = (eq.isDouble() && (eq.getLocation() == EquipmentLocation.EQUIPPED_TWO_HANDS));
1153 int rawCritRange = eq.getRawCritRange(true);
1154
1155 // see if the weapon has any crit range
1156 if (rawCritRange == 0)
1157 {
1158 // no crit range!
1159 return "none";
1160 }
1161
1162 String profName = getProfName(eq);
1163 int dbl = (int) pc.getTotalBonusTo("WEAPONPROF=" + profName, "CRITRANGEDOUBLE")
1164 + getWeaponProfTypeBonuses(pc, eq, "CRITRANGEDOUBLE", WPTYPEBONUS_PC);
1165 int iAdd = (int) pc.getTotalBonusTo("WEAPONPROF=" + profName, "CRITRANGEADD")
1166 + getWeaponProfTypeBonuses(pc, eq, "CRITRANGEADD", WPTYPEBONUS_PC);
1167 int eqDbl = dbl + (int) eq.bonusTo(pc, "EQMWEAPON", "CRITRANGEDOUBLE", true);
1168 int critrange = eq.getRawCritRange(true) * (eqDbl + 1);
1169 critrange = 21 - (critrange + iAdd + (int) eq.bonusTo(pc, "EQMWEAPON", "CRITRANGEADD", true));
1170 sb.append(String.valueOf(critrange));
1171 if (critrange < 20)
1172 {
1173 sb.append("-20");
1174 }
1175
1176 if (isDouble && (EqToken.getOldBonusedCritRange(pc, eq, false) > 0))
1177 {
1178 eqDbl = dbl + (int) eq.bonusTo(pc, "EQMWEAPON", "CRITRANGEDOUBLE", false);
1179
1180 int altCritRange = eq.getRawCritRange(false) * (eqDbl + 1);
1181 altCritRange = 21 - (altCritRange + iAdd + (int) eq.bonusTo(pc, "EQMWEAPON", "CRITRANGEADD", false));
1182
1183 if (altCritRange != critrange)
1184 {
1185 sb.append("/").append(altCritRange);
1186
1187 if (altCritRange < 20)
1188 {
1189 sb.append("-20");
1190 }
1191 }
1192 }
1193 return sb.toString();
1194 }
1195
1196 /**
1197 * Get damage token

Callers 1

getWeaponTokenMethod · 0.95

Calls 15

getControlTokenMethod · 0.95
getContextMethod · 0.95
getCritRangeHeadMethod · 0.95
getProfNameMethod · 0.95
getEquipmentHeadMethod · 0.80
isDoubleMethod · 0.80
getRawCritRangeMethod · 0.80
toStringMethod · 0.65
getLocationMethod · 0.65
getTotalBonusToMethod · 0.45

Tested by

no test coverage detected