Wednesday, July 1, 2009

Java: CharSi Update #24

While using the program I, and others, ran into a few equipment pieces that didn't add the bonuses they should. This was due to either typos on my part or miswording of the mod itself, such as the "+2 to Combat skills" mod was spelled "+2 to Combat" instead. These were all very minor changes to about a half dozen different text files. There might be more out there, but I haven't found them yet.

A code clean-up was also performed to remove some unused variables and code pieces as well as remove all of the "public" identifiers from the variables and methods, as it wasn't necessary. This shortened the number of code lines a bit, not extremely noticable but more a personal preference than anything else.

Next on my To-Do list was to add some additional checks to the system to ensure that when creating items in the generator or selecting a value for a variable mod the value input was valid. Up to this point a Breast Plate could technically have a defense value of 100k. That is no longer possible. Now there is a check that will only allow values that fall between the given minimum and maximum mod values. This required a couple code lines addition to the DetermineRangeValue method in all of the class files.

if(CharSi.userInput){
while(rangeWrong){
userInput = Integer.parseInt(JOptionPane.showInputDialog(helmBackPanel, "Choose a value between " + start + " and " + end, modName, JOptionPane.PLAIN_MESSAGE));
if(userInput > Integer.parseInt(end) || userInput <>
JOptionPane.showMessageDialog(helmBackPanel, "Value given outside the allowed range. Retry.", "Input Error", JOptionPane.ERROR_MESSAGE);
rangeWrong = true;
}else
rangeWrong = false;
}
}

This piece is only active if the user is manually inputting values for variable mods. The rangeWrong boolean variable is initially set to True until the check is made. The user input is then compared to the given minimum and maximum values and if it passes is accepted, otherwise the error appears and the user has to try again until a valid input is given.

Lastly I wanted to ensure that runewords could not be created in the generator in illegal base items, such as a Spirit shield in a buckler that allows less than 4 sockets. This required several changes to the GenerateRunewords class file. First I had to decide how to store the information for how many sockets each piece of equipment allows. This I did with several array of arrays. Each sub-array was two values long, the first for the name of the item and the second for the maximum number of sockets. The array of arrays were grouped by item type available in the item generator, so one for armor, another for hammers and so forth. This method was called when the GUI is created.

Next I needed to be able to obtain the number of sockets the runeword required. To do this I altered the text file of each runeword item so that it displayed the number of runes used in the description in parentheses.

Runes(3):
Thul + Io + Nef

When the runeword is selected in the GUI this number is saved in a variable in integer form for later comparison.

Lastly I needed a way to compare this rune number with the number of sockets that each item could have, then eliminate from the available list those items that don't qualify. This was done with another method, ComapreSocketNumbers. Basically this method would see which JRadioButton was selected in the GUI and compare the rune number with each available item. Those that had less sockets than runes needed were removed from the DefaultListModel.

if(shieldFlag){ //if shield radiobutton marked
for(int i = 0; i <>
if(Integer.parseInt(shieldSocketArray[i][1]) <>
if(baseListModel.contains(shieldSocketArray[i][0])){
int index = baseListModel.indexOf(shieldSocketArray[i][0]);
baseListModel.remove(index);
}
}
}
}

This method is called when either the Display Base JButton is pressed or a runeword is selected from the available list. However to ensure that items removed from the baseListModel can be returned a doClick() call is made on the Display Base JButton to repopulate the listModel fully before it is checked for illegal items. Otherwise once an item is removed, it is gone until the program is closed and reopened, which isn't too convenient.

My next projected changes to the program is to take into account aura bonuses from equipment and also the +O skill mods.

1 comment:

- T said...

Nobody can find a copy of the current version of CharSi. Do you still have it?