Skip to content

Commit

Permalink
more spell code
Browse files Browse the repository at this point in the history
  • Loading branch information
dmolony committed Jun 21, 2022
1 parent b19e89d commit 250c1a9
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 18 deletions.
9 changes: 9 additions & 0 deletions src/com/bytezone/diskbrowser/wizardry/Character.java
Expand Up @@ -7,6 +7,9 @@
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 =
Expand Down Expand Up @@ -78,6 +81,12 @@ void get2x5Bits (int[] attributes, int ptr, int value)
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;
Expand Down
18 changes: 6 additions & 12 deletions src/com/bytezone/diskbrowser/wizardry/CharacterV1.java
Expand Up @@ -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<> ();
Expand Down Expand Up @@ -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];
}

Expand Down Expand Up @@ -141,12 +135,12 @@ public String getText ()
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)
Expand Down
6 changes: 0 additions & 6 deletions src/com/bytezone/diskbrowser/wizardry/CharacterV4.java
Expand Up @@ -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);
Expand Down

0 comments on commit 250c1a9

Please sign in to comment.