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

Method getAbilityScoreCost

code/src/java/pcgen/core/GameMode.java:1410–1447  ·  view source on GitHub ↗

Get the cost for an ability score. @return the cost for an ability score

()

Source from the content-addressed store, hash-verified

1408 * @return the cost for an ability score
1409 */
1410 public int[] getAbilityScoreCost()
1411 {
1412 if (!isPurchaseStatModeAllowed())
1413 {
1414 //better to return a Zero length array than null.
1415 return null;
1416 }
1417
1418 // Only build this list once
1419 if (abilityScoreCost != null)
1420 {
1421 return abilityScoreCost;
1422 }
1423 // Should be 1 value for each stat in range
1424 abilityScoreCost = new int[getPurchaseScoreMax() - getPurchaseScoreMin() + 1];
1425 int i = 0;
1426 int lastStat = Integer.MIN_VALUE;
1427 int lastCost = 0;
1428
1429 for (int statValue : pointBuyStatCosts.keySet())
1430 {
1431 // Fill in any holes in the stat list by using the previous stat cost
1432 if ((lastStat != Integer.MIN_VALUE) && (lastStat + 1 != statValue))
1433 {
1434 for (int x = lastStat + 1; x < statValue; ++x)
1435 {
1436 abilityScoreCost[i++] = lastCost;
1437 }
1438 }
1439
1440 final int statCost = pointBuyStatCosts.get(statValue).getBuyCost();
1441 lastStat = statValue;
1442 lastCost = statCost;
1443 abilityScoreCost[i++] = lastCost;
1444 }
1445
1446 return abilityScoreCost;
1447 }
1448
1449 /**
1450 * Get the cost for an ability score.

Callers 3

initValuesMethod · 0.80

Calls 6

getPurchaseScoreMaxMethod · 0.95
getPurchaseScoreMinMethod · 0.95
getBuyCostMethod · 0.80
getMethod · 0.65
keySetMethod · 0.45

Tested by

no test coverage detected