more spell code

This commit is contained in:
Denis Molony 2022-06-21 13:59:42 +10:00
parent b19e89d7cf
commit 250c1a9bd9
3 changed files with 15 additions and 18 deletions

View File

@ -7,6 +7,9 @@ import com.bytezone.diskbrowser.utilities.Utility;
public abstract class Character extends AbstractFile
// -----------------------------------------------------------------------------------//
{
static int MAGE_SPELLS = 0;
static int PRIEST_SPELLS = 1;
static String[] races = { "No race", "Human", "Elf", "Dwarf", "Gnome", "Hobbit" };
static String[] alignments = { "Unalign", "Good", "Neutral", "Evil" };
static String[] types =
@ -78,6 +81,12 @@ public abstract class Character extends AbstractFile
protected void checkKnownSpells (byte[] buffer, int ptr)
// ---------------------------------------------------------------------------------//
{
for (int i = 0; i < 7; i++)
{
spellAllowance[MAGE_SPELLS][i] = Utility.getShort (buffer, ptr + 8 + i * 2);
spellAllowance[PRIEST_SPELLS][i] = Utility.getShort (buffer, ptr + 22 + i * 2);
}
int bit = 1; // skip first bit
int val = buffer[ptr];
mysteryBit = (val & 0x01) == 1;

View File

@ -24,8 +24,8 @@ class CharacterV1 extends Character
public int ageInWeeks;
public int assetValue;
int[] mageSpells = new int[7];
int[] priestSpells = new int[7];
// int[] mageSpells = new int[7];
// int[] priestSpells = new int[7];
private final List<Spell> spellBook = new ArrayList<> ();
private final List<Possession> possessions = new ArrayList<> ();
@ -80,12 +80,6 @@ class CharacterV1 extends Character
checkKnownSpells (buffer, 138);
for (int i = 0; i < 7; i++)
mageSpells[i] = buffer[146 + i * 2];
for (int i = 0; i < 7; i++)
priestSpells[i] = buffer[160 + i * 2];
armourClass = buffer[176];
}
@ -141,12 +135,12 @@ class CharacterV1 extends Character
text.append ("\nLuck ............... " + attributes[5]);
text.append ("\n\nMage spell points ..");
for (int i = 0; i < mageSpells.length; i++)
text.append (" " + mageSpells[i]);
for (int i = 0; i < spellAllowance[MAGE_SPELLS].length; i++)
text.append (" " + spellAllowance[MAGE_SPELLS][i]);
text.append ("\nPriest spell points ");
for (int i = 0; i < priestSpells.length; i++)
text.append (" " + priestSpells[i]);
for (int i = 0; i < spellAllowance[PRIEST_SPELLS].length; i++)
text.append (" " + spellAllowance[PRIEST_SPELLS][i]);
text.append ("\n\nSpells :");
for (Spell s : spellBook)

View File

@ -99,12 +99,6 @@ public class CharacterV4 extends Character
checkKnownSpells (buffer, 139);
for (int i = 0; i < 7; i++)
{
spellAllowance[MAGE_SPELLS][i] = Utility.getShort (buffer, 147 + i * 2);
spellAllowance[PRIEST_SPELLS][i] = Utility.getShort (buffer, 161 + i * 2);
}
hpCalCmd = Utility.getSignedShort (buffer, 175);
// armourClass = Utility.getSignedShort (buffer, 177); // see offset 39
healPts = Utility.getShort (buffer, 179);