Skip to content

Commit 281f520

Browse files
Fixed bug cybernetics affects all specialized skills
1 parent 97660b4 commit 281f520

File tree

4 files changed

+26
-9
lines changed

4 files changed

+26
-9
lines changed

think-machine-pdf/src/main/java/com/softwaremagico/tm/pdf/small/SmallCharacterSheet.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ protected PdfPTable createCharacterContent(CharacterPlayer characterPlayer) thro
103103
infoCell.setBorderWidthBottom(1);
104104
mainTable.addCell(infoCell);
105105

106-
final PdfPTable learnedSkillsTable = LearnedSkillsTable.getSkillsTable(characterPlayer, getLanguage());
106+
final PdfPTable learnedSkillsTable = LearnedSkillsTable.getSkillsTable(characterPlayer);
107107
final PdfPCell learnedSkillsCell = new PdfPCell(learnedSkillsTable);
108108
learnedSkillsCell.setColspan(2);
109109
learnedSkillsCell.setRowspan(3);

think-machine-pdf/src/main/java/com/softwaremagico/tm/pdf/small/skills/LearnedSkillsTable.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,18 +41,17 @@ public class LearnedSkillsTable extends SkillsTable {
4141
private static final int MAX_SKILL_COLUMN_WIDTH = 115;
4242
private static final int MAX_SKILL_RANK_WIDTH = 15;
4343

44-
public static PdfPTable getSkillsTable(CharacterPlayer characterPlayer, String language)
44+
public static PdfPTable getSkillsTable(CharacterPlayer characterPlayer)
4545
throws InvalidXmlElementException {
4646
final float[] widths = { 1f };
4747
final PdfPTable table = new PdfPTable(widths);
4848
setTablePropierties(table);
4949
table.getDefaultCell().setBorder(0);
50-
table.addCell(getSkillsColumnTable(characterPlayer, language));
50+
table.addCell(getSkillsColumnTable(characterPlayer));
5151
return table;
5252
}
5353

54-
private static PdfPCell getSkillsColumnTable(CharacterPlayer characterPlayer, String language)
55-
throws InvalidXmlElementException {
54+
private static PdfPCell getSkillsColumnTable(CharacterPlayer characterPlayer) {
5655
final float[] widths = { 4f, 1f };
5756
final PdfPTable table = new PdfPTable(widths);
5857
setTablePropierties(table);

think-machine-pdf/src/test/java/com/softwaremagico/tm/export/pdf/CustomCharacters.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,11 @@ public void createPaolaCharacter() throws InvalidXmlElementException, TooManyBle
173173
player.addCybernetics(CyberneticDeviceFactory.getInstance().getElement("secondBrainThinkMachineLore", LANGUAGE,
174174
PathManager.DEFAULT_MODULE_FOLDER));
175175

176+
Assert.assertEquals((int) player.getSkillTotalRanks(AvailableSkillsFactory.getInstance().getElement("lore", "thinkMachineLore",
177+
LANGUAGE, PathManager.DEFAULT_MODULE_FOLDER)), 4);
178+
Assert.assertEquals((int) player.getSkillTotalRanks(AvailableSkillsFactory.getInstance().getElement("lore", "beastsLore",
179+
LANGUAGE, PathManager.DEFAULT_MODULE_FOLDER)), 0);
180+
176181
player.setShield(
177182
ShieldFactory.getInstance().getElement("duelingShield", player.getLanguage(), player.getModuleName()));
178183

think-machine-rules/src/main/java/com/softwaremagico/tm/character/CharacterPlayer.java

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -351,9 +351,21 @@ private Integer getCyberneticsValue(Skill<?> skill) {
351351
int maxValue = 0;
352352
for (final ICyberneticDevice device : cybernetics.getElements()) {
353353
for (final StaticValue staticValue : device.getStaticValues()) {
354-
if (Objects.equals(staticValue.getAffects().getId(), skill.getId())) {
355-
if (maxValue < staticValue.getValue()) {
356-
maxValue = staticValue.getValue();
354+
if (!(skill instanceof AvailableSkill) || ((AvailableSkill) skill).getSpecialization() == null) {
355+
if (Objects.equals(staticValue.getAffects().getId(), skill.getId())) {
356+
if (maxValue < staticValue.getValue()) {
357+
maxValue = staticValue.getValue();
358+
}
359+
}
360+
} else {
361+
//Check cybernetic skill specialization.
362+
if (staticValue.getAffects() instanceof AvailableSkill) {
363+
if (Objects.equals(((AvailableSkill) staticValue.getAffects()).getSpecialization().getId(),
364+
((AvailableSkill) skill).getSpecialization().getId())) {
365+
if (maxValue < staticValue.getValue()) {
366+
maxValue = staticValue.getValue();
367+
}
368+
}
357369
}
358370
}
359371
}
@@ -1096,7 +1108,8 @@ public List<AvailableSkill> getLearnedSkills() {
10961108
final List<AvailableSkill> learnedSkills = new ArrayList<>();
10971109
for (final AvailableSkill skill : AvailableSkillsFactory.getInstance().getLearnedSkills(getLanguage(),
10981110
getModuleName())) {
1099-
if (getSkillTotalRanks(skill) != null) {
1111+
final Integer skillRanks = getSkillTotalRanks(skill);
1112+
if (skillRanks != null && skillRanks > 0) {
11001113
learnedSkills.add(skill);
11011114
}
11021115
}

0 commit comments

Comments
 (0)