mirror of
https://github.com/dmolony/DiskBrowser.git
synced 2024-11-25 01:32:26 +00:00
added possessions to characters
This commit is contained in:
parent
2a14b7baad
commit
572ee8c3a1
@ -30,10 +30,10 @@ public class CharacterParty
|
||||
text.append ("\n\n");
|
||||
|
||||
for (CharacterV4 character : characters)
|
||||
text.append (
|
||||
String.format (" %3d %-15s %17s %13s %13s%n", character.id, character.getName (),
|
||||
character.getAttributeString (), character.getSpellsString (CharacterV4.MAGE_SPELLS),
|
||||
character.getSpellsString (CharacterV4.PRIEST_SPELLS)));
|
||||
text.append (String.format ("%3d %-15s %s %3d %3d %17s %13s %13s%n", character.id,
|
||||
character.getName (), character.getTypeString (), character.armourClass, character.hpLeft,
|
||||
character.getAttributeString (), character.getSpellsString (CharacterV4.MAGE_SPELLS),
|
||||
character.getSpellsString (CharacterV4.PRIEST_SPELLS)));
|
||||
|
||||
return text.toString ();
|
||||
}
|
||||
|
@ -39,7 +39,8 @@ public class CharacterV4 extends AbstractFile
|
||||
public final long gold;
|
||||
|
||||
public final int possessionsCount;
|
||||
public final List<Integer> possessions = new ArrayList<> (MAX_POSSESSIONS);
|
||||
public final List<Integer> possessionIds = new ArrayList<> (MAX_POSSESSIONS);
|
||||
public final List<ItemV4> possessions = new ArrayList<> (MAX_POSSESSIONS);
|
||||
|
||||
public final long experience;
|
||||
public final int maxlevac; // max level armour class?
|
||||
@ -50,7 +51,6 @@ public class CharacterV4 extends AbstractFile
|
||||
public final boolean mysteryBit; // first bit in spellsKnown
|
||||
public final boolean[] spellsKnown = new boolean[50];
|
||||
public final int[][] spellAllowance = new int[2][7];
|
||||
// public final int[] priestSpells = new int[7];
|
||||
|
||||
public final int hpCalCmd;
|
||||
public final int armourClass;
|
||||
@ -98,7 +98,6 @@ public class CharacterV4 extends AbstractFile
|
||||
super (name, buffer);
|
||||
|
||||
this.id = id;
|
||||
nextCharacterId = Utility.getShort (buffer, 0x7D);
|
||||
|
||||
inMaze = Utility.getShort (buffer, 33) != 0;
|
||||
race = Race.values ()[Utility.getShort (buffer, 35)];
|
||||
@ -136,10 +135,11 @@ public class CharacterV4 extends AbstractFile
|
||||
// boolean identified = Utility.getShort (buffer, 65 + i * 8) == 1;
|
||||
int itemNo = Utility.getShort (buffer, 67 + i * 8);
|
||||
// Possession p = new Possession (itemNo, equipped, cursed, identified);
|
||||
possessions.add (itemNo);
|
||||
possessionIds.add (itemNo);
|
||||
}
|
||||
|
||||
experience = 0;
|
||||
nextCharacterId = Utility.getShort (buffer, 125);
|
||||
maxlevac = Utility.getShort (buffer, 131);
|
||||
charlev = Utility.getShort (buffer, 133);
|
||||
hpLeft = Utility.getShort (buffer, 135);
|
||||
@ -174,6 +174,16 @@ public class CharacterV4 extends AbstractFile
|
||||
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
void addPossessions (List<ItemV4> items)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
for (int itemId : possessionIds)
|
||||
{
|
||||
possessions.add (items.get (itemId));
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
void setParty (CharacterParty party)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
@ -228,6 +238,13 @@ public class CharacterV4 extends AbstractFile
|
||||
return text.toString ();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
String getTypeString ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
return String.format ("%1.1s-%3.3s", alignment, characterClass);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
@Override
|
||||
public String getText ()
|
||||
@ -235,11 +252,25 @@ public class CharacterV4 extends AbstractFile
|
||||
{
|
||||
StringBuilder text = new StringBuilder ();
|
||||
|
||||
text.append (String.format ("Id ............. %3d%n", id));
|
||||
text.append (String.format ("Name ........... %s%n", name));
|
||||
text.append (String.format ("Attributes ..... %s%n", getAttributeString ()));
|
||||
text.append (String.format ("Mage spells .... %s%n", getSpellsString (MAGE_SPELLS)));
|
||||
text.append (String.format ("Priest spells .. %s%n", getSpellsString (PRIEST_SPELLS)));
|
||||
text.append (String.format ("Id ................ %d%n", id));
|
||||
text.append (String.format ("Name .............. %s%n", name));
|
||||
text.append (String.format ("Race .............. %s%n", race));
|
||||
text.append (String.format ("Character class ... %s%n", characterClass));
|
||||
text.append (String.format ("Alignment ......... %s%n", alignment));
|
||||
text.append (String.format ("Status ............ %s%n", status));
|
||||
text.append (String.format ("Level ? ........... %d%n", charlev));
|
||||
text.append (String.format ("Hit points ........ %d/%d%n", hpLeft, hpMax));
|
||||
text.append (String.format ("Armour class ...... %d%n", armourClass));
|
||||
text.append (String.format ("Attributes ........ %s%n", getAttributeString ()));
|
||||
text.append (String.format ("Mage spells ....... %s%n", getSpellsString (MAGE_SPELLS)));
|
||||
text.append (String.format ("Priest spells ..... %s%n", getSpellsString (PRIEST_SPELLS)));
|
||||
|
||||
if (possessionsCount > 0)
|
||||
{
|
||||
text.append ("\nPossessions:\n");
|
||||
for (ItemV4 item : possessions)
|
||||
text.append (" " + item + "\n");
|
||||
}
|
||||
|
||||
if (!party.slogan.isEmpty () || party.characters.size () > 1)
|
||||
{
|
||||
|
@ -7,11 +7,17 @@ import com.bytezone.diskbrowser.utilities.HexFormatter;
|
||||
public class ItemV4 extends AbstractFile
|
||||
// -----------------------------------------------------------------------------------//
|
||||
{
|
||||
String name;
|
||||
String nameGeneric;
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
ItemV4 (String[] names, byte[] buffer, int id)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
super (names[1], buffer);
|
||||
|
||||
name = names[1];
|
||||
nameGeneric = names[0];
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
@ -21,4 +27,12 @@ public class ItemV4 extends AbstractFile
|
||||
{
|
||||
return HexFormatter.format (buffer, 1, buffer[0] & 0xFF);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
@Override
|
||||
public String toString ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
@ -192,8 +192,8 @@ class Spell extends AbstractFile
|
||||
public String toString ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
return String.format ("%-16s %-6s %d %-20s %-20s %-20s %5d %<04X", getName (), spellType,
|
||||
level, translation, getArea (), getWhenCast (), value);
|
||||
return String.format ("%-16s %-6s %d %-20s %-20s %-20s", getName (), spellType, level,
|
||||
translation, getArea (), getWhenCast ());
|
||||
}
|
||||
|
||||
private static String[] spellNames = { "KALKI", "DIOS", "BADIOS", "MILWA", "PORFIC", "MATU",
|
||||
|
@ -29,6 +29,7 @@ public class Wizardry4BootDisk extends PascalDisk
|
||||
|
||||
private List<CharacterV4> characters = new ArrayList<> ();
|
||||
private List<CharacterParty> parties = new ArrayList<> ();
|
||||
private List<ItemV4> items = new ArrayList<> ();
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public Wizardry4BootDisk (AppleDisk[] dataDisks)
|
||||
@ -280,6 +281,7 @@ public class Wizardry4BootDisk extends PascalDisk
|
||||
}
|
||||
|
||||
ItemV4 item = new ItemV4 (itemNames, out, i);
|
||||
items.add (item);
|
||||
|
||||
List<DiskAddress> itemBlocks = new ArrayList<> ();
|
||||
DiskAddress da = blocks.get (ptr / 512);
|
||||
@ -294,6 +296,9 @@ public class Wizardry4BootDisk extends PascalDisk
|
||||
|
||||
DefaultAppleFileSource afs = (DefaultAppleFileSource) itemsNode.getUserObject ();
|
||||
afs.setSectors (allItemBlocks);
|
||||
|
||||
for (CharacterV4 character : characters)
|
||||
character.addPossessions (items);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
|
Loading…
Reference in New Issue
Block a user