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

Method getData

code/src/java/pcgen/core/doomsdaybook/RuleSet.java:92–139  ·  view source on GitHub ↗

Get the data @return A list of data @throws Exception

()

Source from the content-addressed store, hash-verified

90 * @throws Exception
91 */
92 @Override
93 public List<DataValue> getData() throws Exception
94 {
95 retList.clear();
96
97 int rangeTop = getRange();
98 int modifier;
99
100 try
101 {
102 modifier = Integer.parseInt(allVars.getVal(getId() + "modifier"));
103 }
104 catch (Exception e)
105 {
106 modifier = 0;
107 }
108
109 // Determine which entry to choose
110 Dice die = new Dice(1, rangeTop, 0);
111 int choice = die.roll();
112 choice += modifier;
113 choice = (choice < 0) ? rangeTop : choice;
114
115 //select the detail to return
116 int aWeight = 0;
117
118 // Iterate through the list of choices until the weights (from each DataValue)
119 // are greater the num chosen as the 'choice'
120 for (String key : this)
121 {
122 DataElement chkValue = allVars.getDataElement(key);
123 int valueWeight = chkValue.getWeight();
124
125 if (valueWeight > 0)
126 {
127 aWeight += valueWeight;
128
129 if (aWeight >= choice)
130 {
131 retList.addAll(chkValue.getData());
132
133 break;
134 }
135 }
136 }
137
138 return retList;
139 }
140
141 /**
142 * Set the id

Callers

nothing calls this directly

Calls 10

getRangeMethod · 0.95
getIdMethod · 0.95
getWeightMethod · 0.95
getDataMethod · 0.95
parseIntMethod · 0.80
getValMethod · 0.80
clearMethod · 0.65
rollMethod · 0.65
addAllMethod · 0.65
getDataElementMethod · 0.45

Tested by

no test coverage detected