Monday, January 26, 2009

Java: CharSi Update #17

Up to this point I have been ignoring any bonuses by having multiple pieces of a set equipped. Now that all equipment mods are stored and displayed correctly it is time to take these bonuses into account. I couldn't decide where to put the variables and methods needed to calculate what bonuses apply. So I created a whole new class file to hold these methods. The methods never get called inside this class file, only in the Stats and Character class files.

Each set evaluated in its own method, even though they are all called at the same time. The first thing to do is to determine how many set pieces are currently on the virtual character. Then the bonuses are applied depending on how many pieces are equipped and which ones they are.

static public void BerserkersCheck() {

for(int i = 0; i <>
berserkersArsenal[i] = 0;
berserkers = 0;

if(helm.compareTo(BERSERKERSHEAD) == 0) //detemrine which items are equipped
berserkersArsenal[0] = 1;
if(armor.compareTo(BERSERKERSHAU) == 0)
berserkersArsenal[1] = 1;
if(weaponOne.compareTo(BERSERKERSHAT) == 0)
berserkersArsenal[2] = 1;

berserkers = berserkersArsenal[0] + berserkersArsenal[1] + berserkersArsenal[2];

if(berserkers == 3){ //full set
charLevelMods[6] = charLevelMods[6] + 8;
charLevelDefOn[1] = charLevelDefOn[1] + 3;
eDmgOn = eDmgOn + 50;
stats[4] = stats[4] + 100;
specialMods[6] = specialMods[6] + 75;
modsOfNote[8] = modsOfNote[8] + 75;
poisonDamage[0] = poisonDamage[0] + 5;
poisonDamage[1] = poisonDamage[1] + 9;
itemStats[31] = itemStats[31] + 3;
}
if(berserkers == 2){
if(berserkersArsenal[0] == 1) //helm equipped
charLevelMods[6] = charLevelMods[6] + 8;
if(berserkersArsenal[1] == 1) //armor equipped
charLevelDefOn[1] = charLevelDefOn[1] + 3;
if(berserkersArsenal[2] == 1) //weapon equipped
eDmgOn = eDmgOn + 50;
stats[4] = stats[4] + 50;
}
}//end

First it is determined how many set pieces are equipped. Once that is determined each specific item is checked, if it is present the bonuses are added, if it isn't the item is skipped and the next item is checked. The arrays that contain the bonus information are then added along with the equipment arrays when everything is summed in the Stats class. This method is repeated for each of the other 31 sets. Most are a bit more complex, especially those that have more than three pieces to the set.

This ends the coding portion up to this point. Characters can be created, skills assigned, equipment worn and all of the bonuses and stats displayed appropriately. Now I need to run some checks to ensure everything really is displaying and no mods were left out. I checked everything as I added it to the program, but I'm sure some bugs slipped through. Case in point when putting this in I found out that the Barbarian mastery skill bonuses weren't being added to the displayed damage and attack rating values. So my next step is to create several text characters and see if their stats match up with what I am expecting.

No comments: