started combining CharacterV1 and CharacterV4
This commit is contained in:
parent
572ee8c3a1
commit
66d6910f91
|
@ -1,25 +1,11 @@
|
||||||
package com.bytezone.diskbrowser.wizardry;
|
package com.bytezone.diskbrowser.wizardry;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import com.bytezone.diskbrowser.applefile.AbstractFile;
|
import com.bytezone.diskbrowser.applefile.AbstractFile;
|
||||||
import com.bytezone.diskbrowser.utilities.Utility;
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------------//
|
// -----------------------------------------------------------------------------------//
|
||||||
class Character extends AbstractFile
|
public abstract class Character extends AbstractFile
|
||||||
// -----------------------------------------------------------------------------------//
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
private static char[] awardsText = ">!$#&*<?BCPKODG@".toCharArray ();
|
|
||||||
|
|
||||||
private final Attributes attributes;
|
|
||||||
private final Statistics stats;
|
|
||||||
int scenario;
|
|
||||||
|
|
||||||
private final List<Spell> spellBook = new ArrayList<> ();
|
|
||||||
private final List<Baggage> baggageList = new ArrayList<> ();
|
|
||||||
|
|
||||||
static String[] races = { "No race", "Human", "Elf", "Dwarf", "Gnome", "Hobbit" };
|
static String[] races = { "No race", "Human", "Elf", "Dwarf", "Gnome", "Hobbit" };
|
||||||
static String[] alignments = { "Unalign", "Good", "Neutral", "Evil" };
|
static String[] alignments = { "Unalign", "Good", "Neutral", "Evil" };
|
||||||
static String[] types =
|
static String[] types =
|
||||||
|
@ -27,338 +13,12 @@ class Character extends AbstractFile
|
||||||
static String[] statuses =
|
static String[] statuses =
|
||||||
{ "OK", "Afraid", "Asleep", "Paralyze", "Stoned", "Dead", "Ashes", "Lost" };
|
{ "OK", "Afraid", "Asleep", "Paralyze", "Stoned", "Dead", "Ashes", "Lost" };
|
||||||
|
|
||||||
|
int scenario;
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
Character (String name, byte[] buffer, int scenario)
|
Character (String name, byte[] buffer)
|
||||||
// ---------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
super (name, buffer);
|
super (name, buffer);
|
||||||
|
|
||||||
this.scenario = scenario;
|
|
||||||
|
|
||||||
attributes = new Attributes ();
|
|
||||||
stats = new Statistics ();
|
|
||||||
|
|
||||||
stats.race = races[buffer[34] & 0xFF];
|
|
||||||
stats.typeInt = buffer[36] & 0xFF;
|
|
||||||
stats.type = types[stats.typeInt];
|
|
||||||
stats.ageInWeeks = Utility.getShort (buffer, 38);
|
|
||||||
stats.statusValue = buffer[40];
|
|
||||||
stats.status = statuses[stats.statusValue];
|
|
||||||
stats.alignment = alignments[buffer[42] & 0xFF];
|
|
||||||
|
|
||||||
stats.gold = Utility.getShort (buffer, 52) + Utility.getShort (buffer, 54) * 10000
|
|
||||||
+ Utility.getShort (buffer, 56) * 100000000L;
|
|
||||||
stats.experience = Utility.getShort (buffer, 124) + Utility.getShort (buffer, 126) * 10000;
|
|
||||||
stats.level = Utility.getShort (buffer, 132);
|
|
||||||
|
|
||||||
stats.hitsLeft = Utility.getShort (buffer, 134);
|
|
||||||
stats.hitsMax = Utility.getShort (buffer, 136);
|
|
||||||
|
|
||||||
stats.armourClass = buffer[176];
|
|
||||||
|
|
||||||
attributes.strength = (buffer[44] & 0xFF) % 16;
|
|
||||||
if (attributes.strength < 3)
|
|
||||||
attributes.strength += 16;
|
|
||||||
attributes.array[0] = attributes.strength;
|
|
||||||
|
|
||||||
int i1 = (buffer[44] & 0xFF) / 16;
|
|
||||||
int i2 = (buffer[45] & 0xFF) % 4;
|
|
||||||
attributes.intelligence = i1 / 2 + i2 * 8;
|
|
||||||
attributes.array[1] = attributes.intelligence;
|
|
||||||
|
|
||||||
attributes.piety = (buffer[45] & 0xFF) / 4;
|
|
||||||
attributes.array[2] = attributes.piety;
|
|
||||||
|
|
||||||
attributes.vitality = (buffer[46] & 0xFF) % 16;
|
|
||||||
if (attributes.vitality < 3)
|
|
||||||
attributes.vitality += 16;
|
|
||||||
attributes.array[3] = attributes.vitality;
|
|
||||||
|
|
||||||
int a1 = (buffer[46] & 0xFF) / 16;
|
|
||||||
int a2 = (buffer[47] & 0xFF) % 4;
|
|
||||||
attributes.agility = a1 / 2 + a2 * 8;
|
|
||||||
attributes.array[4] = attributes.agility;
|
|
||||||
|
|
||||||
attributes.luck = (buffer[47] & 0xFF) / 4;
|
|
||||||
attributes.array[5] = attributes.luck;
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// ---------------------------------------------------------------------------------//
|
|
||||||
public void linkItems (List<Item> itemList)
|
|
||||||
// ---------------------------------------------------------------------------------//
|
|
||||||
{
|
|
||||||
boolean equipped;
|
|
||||||
boolean identified;
|
|
||||||
int totItems = buffer[58];
|
|
||||||
stats.assetValue = 0;
|
|
||||||
|
|
||||||
for (int ptr = 60; totItems > 0; ptr += 8, totItems--)
|
|
||||||
{
|
|
||||||
int itemID = buffer[ptr + 6] & 0xFF;
|
|
||||||
if (scenario == 3)
|
|
||||||
itemID = (itemID + 24) % 256;
|
|
||||||
if (itemID >= 0 && itemID < itemList.size ())
|
|
||||||
{
|
|
||||||
Item item = itemList.get (itemID);
|
|
||||||
equipped = (buffer[ptr] == 1);
|
|
||||||
identified = (buffer[ptr + 4] == 1);
|
|
||||||
baggageList.add (new Baggage (item, equipped, identified));
|
|
||||||
stats.assetValue += item.getCost ();
|
|
||||||
item.partyOwns++;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
System.out.println (
|
|
||||||
getName () + " ItemID : " + itemID + " is outside range 0:" + (itemList.size () - 1));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------//
|
|
||||||
public void linkSpells (List<Spell> spellList)
|
|
||||||
// ---------------------------------------------------------------------------------//
|
|
||||||
{
|
|
||||||
int index = 0;
|
|
||||||
for (int i = 138; i < 145; i++)
|
|
||||||
for (int bit = 0; bit < 8; bit++)
|
|
||||||
{
|
|
||||||
if (((buffer[i] >>> bit) & 0x01) != 0)
|
|
||||||
{
|
|
||||||
spellBook.add (spellList.get (index));
|
|
||||||
System.out.println (spellList.get (index));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (++index >= spellList.size ())
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------//
|
|
||||||
@Override
|
|
||||||
public String getText ()
|
|
||||||
// ---------------------------------------------------------------------------------//
|
|
||||||
{
|
|
||||||
StringBuilder text = new StringBuilder ();
|
|
||||||
|
|
||||||
text.append ("Character name ..... " + getName ());
|
|
||||||
text.append ("\n\nRace ............... " + stats.race);
|
|
||||||
text.append ("\nType ............... " + stats.type);
|
|
||||||
text.append ("\nAlignment .......... " + stats.alignment);
|
|
||||||
text.append ("\nStatus ............. " + stats.status);
|
|
||||||
// text.append ("\nType ............... " + stats.typeInt);
|
|
||||||
// text.append ("\nStatus ............. " + stats.statusValue);
|
|
||||||
text.append ("\nGold ............... " + String.format ("%,d", stats.gold));
|
|
||||||
text.append ("\nExperience ......... " + String.format ("%,d", stats.experience));
|
|
||||||
text.append ("\nNext level ......... " + String.format ("%,d", stats.nextLevel));
|
|
||||||
text.append ("\nLevel .............. " + stats.level);
|
|
||||||
text.append ("\nAge in weeks ....... "
|
|
||||||
+ String.format ("%,d (%d)", stats.ageInWeeks, (stats.ageInWeeks / 52)));
|
|
||||||
text.append ("\nHit points left .... " + stats.hitsLeft);
|
|
||||||
text.append ("\nMaximum hits ....... " + stats.hitsMax);
|
|
||||||
text.append ("\nArmour class ....... " + stats.armourClass);
|
|
||||||
text.append ("\nAsset value ........ " + String.format ("%,d", stats.assetValue));
|
|
||||||
text.append ("\nAwards ............. " + getAwardString ());
|
|
||||||
text.append ("\nOut ................ " + isOut ());
|
|
||||||
text.append ("\n\nStrength ........... " + attributes.strength);
|
|
||||||
text.append ("\nIntelligence ....... " + attributes.intelligence);
|
|
||||||
text.append ("\nPiety .............. " + attributes.piety);
|
|
||||||
text.append ("\nVitality ........... " + attributes.vitality);
|
|
||||||
text.append ("\nAgility ............ " + attributes.agility);
|
|
||||||
text.append ("\nLuck ............... " + attributes.luck);
|
|
||||||
|
|
||||||
int[] spellPoints = getMageSpellPoints ();
|
|
||||||
text.append ("\n\nMage spell points ..");
|
|
||||||
for (int i = 0; i < spellPoints.length; i++)
|
|
||||||
text.append (" " + spellPoints[i]);
|
|
||||||
|
|
||||||
spellPoints = getPriestSpellPoints ();
|
|
||||||
text.append ("\nPriest spell points ");
|
|
||||||
for (int i = 0; i < spellPoints.length; i++)
|
|
||||||
text.append (" " + spellPoints[i]);
|
|
||||||
|
|
||||||
text.append ("\n\nSpells :");
|
|
||||||
for (Spell s : spellBook)
|
|
||||||
text.append ("\n" + s);
|
|
||||||
|
|
||||||
text.append ("\n\nItems :");
|
|
||||||
for (Baggage b : baggageList)
|
|
||||||
text.append ("\n" + b);
|
|
||||||
|
|
||||||
return text.toString ();
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------//
|
|
||||||
public void linkExperience (ExperienceLevel exp)
|
|
||||||
// ---------------------------------------------------------------------------------//
|
|
||||||
{
|
|
||||||
stats.nextLevel = exp.getExperiencePoints (stats.level);
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------//
|
|
||||||
public int[] getMageSpellPoints ()
|
|
||||||
// ---------------------------------------------------------------------------------//
|
|
||||||
{
|
|
||||||
int[] spells = new int[7];
|
|
||||||
|
|
||||||
for (int i = 0; i < 7; i++)
|
|
||||||
spells[i] = buffer[146 + i * 2];
|
|
||||||
|
|
||||||
return spells;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------//
|
|
||||||
public int[] getPriestSpellPoints ()
|
|
||||||
// ---------------------------------------------------------------------------------//
|
|
||||||
{
|
|
||||||
int[] spells = new int[7];
|
|
||||||
|
|
||||||
for (int i = 0; i < 7; i++)
|
|
||||||
spells[i] = buffer[160 + i * 2];
|
|
||||||
|
|
||||||
return spells;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------//
|
|
||||||
public Long getNextLevel ()
|
|
||||||
// ---------------------------------------------------------------------------------//
|
|
||||||
{
|
|
||||||
return stats.nextLevel;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------//
|
|
||||||
public String getAwardString ()
|
|
||||||
// ---------------------------------------------------------------------------------//
|
|
||||||
{
|
|
||||||
StringBuilder text = new StringBuilder ();
|
|
||||||
|
|
||||||
int awards = Utility.getShort (buffer, 206);
|
|
||||||
|
|
||||||
for (int i = 0; i < 16; i++)
|
|
||||||
{
|
|
||||||
if ((awards & 0x01) != 0)
|
|
||||||
text.append (awardsText[i]);
|
|
||||||
awards >>>= 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return text.toString ();
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------//
|
|
||||||
public boolean isOut ()
|
|
||||||
// ---------------------------------------------------------------------------------//
|
|
||||||
{
|
|
||||||
return (buffer[32] == 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------//
|
|
||||||
public String getType ()
|
|
||||||
// ---------------------------------------------------------------------------------//
|
|
||||||
{
|
|
||||||
return stats.type;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------//
|
|
||||||
public String getRace ()
|
|
||||||
// ---------------------------------------------------------------------------------//
|
|
||||||
{
|
|
||||||
return stats.race;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------//
|
|
||||||
public String getAlignment ()
|
|
||||||
// ---------------------------------------------------------------------------------//
|
|
||||||
{
|
|
||||||
return stats.alignment;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------//
|
|
||||||
public Attributes getAttributes ()
|
|
||||||
// ---------------------------------------------------------------------------------//
|
|
||||||
{
|
|
||||||
return attributes;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------//
|
|
||||||
public Statistics getStatistics ()
|
|
||||||
// ---------------------------------------------------------------------------------//
|
|
||||||
{
|
|
||||||
return stats;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------//
|
|
||||||
public Iterator<Baggage> getBaggage ()
|
|
||||||
// ---------------------------------------------------------------------------------//
|
|
||||||
{
|
|
||||||
return baggageList.iterator ();
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------//
|
|
||||||
public Iterator<Spell> getSpells ()
|
|
||||||
// ---------------------------------------------------------------------------------//
|
|
||||||
{
|
|
||||||
return spellBook.iterator ();
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------//
|
|
||||||
@Override
|
|
||||||
public String toString ()
|
|
||||||
// ---------------------------------------------------------------------------------//
|
|
||||||
{
|
|
||||||
return getName ();
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------//
|
|
||||||
public class Baggage
|
|
||||||
// ---------------------------------------------------------------------------------//
|
|
||||||
{
|
|
||||||
public Item item;
|
|
||||||
public boolean equipped;
|
|
||||||
public boolean identified;
|
|
||||||
|
|
||||||
public Baggage (Item item, boolean equipped, boolean identified)
|
|
||||||
{
|
|
||||||
this.item = item;
|
|
||||||
this.equipped = equipped;
|
|
||||||
this.identified = identified;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString ()
|
|
||||||
{
|
|
||||||
return String.format ("%s%-15s %,10d", equipped ? "*" : " ", item.getName (),
|
|
||||||
item.getCost ());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------//
|
|
||||||
public class Statistics implements Cloneable
|
|
||||||
// ---------------------------------------------------------------------------------//
|
|
||||||
{
|
|
||||||
public String race;
|
|
||||||
public String type;
|
|
||||||
public String alignment;
|
|
||||||
public String status;
|
|
||||||
public int typeInt;
|
|
||||||
public int statusValue;
|
|
||||||
public long gold;
|
|
||||||
public int experience;
|
|
||||||
public long nextLevel;
|
|
||||||
public int level;
|
|
||||||
public int ageInWeeks;
|
|
||||||
public int hitsLeft;
|
|
||||||
public int hitsMax;
|
|
||||||
public int armourClass;
|
|
||||||
public int assetValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------//
|
|
||||||
public class Attributes
|
|
||||||
// ---------------------------------------------------------------------------------//
|
|
||||||
{
|
|
||||||
public int strength;
|
|
||||||
public int intelligence;
|
|
||||||
public int piety;
|
|
||||||
public int vitality;
|
|
||||||
public int agility;
|
|
||||||
public int luck;
|
|
||||||
public int[] array = new int[6];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -0,0 +1,355 @@
|
||||||
|
package com.bytezone.diskbrowser.wizardry;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.bytezone.diskbrowser.utilities.Utility;
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
|
class CharacterV1 extends Character
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
|
{
|
||||||
|
private static char[] awardsText = ">!$#&*<?BCPKODG@".toCharArray ();
|
||||||
|
|
||||||
|
private final Attributes attributes;
|
||||||
|
private final Statistics stats;
|
||||||
|
|
||||||
|
private final List<Spell> spellBook = new ArrayList<> ();
|
||||||
|
private final List<Baggage> baggageList = new ArrayList<> ();
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
|
CharacterV1 (String name, byte[] buffer, int scenario)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
|
{
|
||||||
|
super (name, buffer);
|
||||||
|
|
||||||
|
this.scenario = scenario;
|
||||||
|
|
||||||
|
attributes = new Attributes ();
|
||||||
|
stats = new Statistics ();
|
||||||
|
|
||||||
|
stats.race = races[buffer[34] & 0xFF];
|
||||||
|
stats.typeInt = buffer[36] & 0xFF;
|
||||||
|
stats.type = types[stats.typeInt];
|
||||||
|
stats.ageInWeeks = Utility.getShort (buffer, 38);
|
||||||
|
stats.statusValue = buffer[40];
|
||||||
|
stats.status = statuses[stats.statusValue];
|
||||||
|
stats.alignment = alignments[buffer[42] & 0xFF];
|
||||||
|
|
||||||
|
stats.gold = Utility.getShort (buffer, 52) + Utility.getShort (buffer, 54) * 10000
|
||||||
|
+ Utility.getShort (buffer, 56) * 100000000L;
|
||||||
|
stats.experience = Utility.getShort (buffer, 124) + Utility.getShort (buffer, 126) * 10000;
|
||||||
|
stats.level = Utility.getShort (buffer, 132);
|
||||||
|
|
||||||
|
stats.hitsLeft = Utility.getShort (buffer, 134);
|
||||||
|
stats.hitsMax = Utility.getShort (buffer, 136);
|
||||||
|
|
||||||
|
stats.armourClass = buffer[176];
|
||||||
|
|
||||||
|
attributes.strength = (buffer[44] & 0xFF) % 16;
|
||||||
|
if (attributes.strength < 3)
|
||||||
|
attributes.strength += 16;
|
||||||
|
attributes.array[0] = attributes.strength;
|
||||||
|
|
||||||
|
int i1 = (buffer[44] & 0xFF) / 16;
|
||||||
|
int i2 = (buffer[45] & 0xFF) % 4;
|
||||||
|
attributes.intelligence = i1 / 2 + i2 * 8;
|
||||||
|
attributes.array[1] = attributes.intelligence;
|
||||||
|
|
||||||
|
attributes.piety = (buffer[45] & 0xFF) / 4;
|
||||||
|
attributes.array[2] = attributes.piety;
|
||||||
|
|
||||||
|
attributes.vitality = (buffer[46] & 0xFF) % 16;
|
||||||
|
if (attributes.vitality < 3)
|
||||||
|
attributes.vitality += 16;
|
||||||
|
attributes.array[3] = attributes.vitality;
|
||||||
|
|
||||||
|
int a1 = (buffer[46] & 0xFF) / 16;
|
||||||
|
int a2 = (buffer[47] & 0xFF) % 4;
|
||||||
|
attributes.agility = a1 / 2 + a2 * 8;
|
||||||
|
attributes.array[4] = attributes.agility;
|
||||||
|
|
||||||
|
attributes.luck = (buffer[47] & 0xFF) / 4;
|
||||||
|
attributes.array[5] = attributes.luck;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
|
public void linkItems (List<Item> itemList)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
|
{
|
||||||
|
boolean equipped;
|
||||||
|
boolean identified;
|
||||||
|
int totItems = buffer[58];
|
||||||
|
stats.assetValue = 0;
|
||||||
|
|
||||||
|
for (int ptr = 60; totItems > 0; ptr += 8, totItems--)
|
||||||
|
{
|
||||||
|
int itemID = buffer[ptr + 6] & 0xFF;
|
||||||
|
if (scenario == 3)
|
||||||
|
itemID = (itemID + 24) % 256;
|
||||||
|
if (itemID >= 0 && itemID < itemList.size ())
|
||||||
|
{
|
||||||
|
Item item = itemList.get (itemID);
|
||||||
|
equipped = (buffer[ptr] == 1);
|
||||||
|
identified = (buffer[ptr + 4] == 1);
|
||||||
|
baggageList.add (new Baggage (item, equipped, identified));
|
||||||
|
stats.assetValue += item.getCost ();
|
||||||
|
item.partyOwns++;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
System.out.println (
|
||||||
|
getName () + " ItemID : " + itemID + " is outside range 0:" + (itemList.size () - 1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
|
public void linkSpells (List<Spell> spellList)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
|
{
|
||||||
|
int index = 0;
|
||||||
|
for (int i = 138; i < 145; i++)
|
||||||
|
for (int bit = 0; bit < 8; bit++)
|
||||||
|
{
|
||||||
|
if (((buffer[i] >>> bit) & 0x01) != 0)
|
||||||
|
{
|
||||||
|
spellBook.add (spellList.get (index));
|
||||||
|
// System.out.println (spellList.get (index));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (++index >= spellList.size ())
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
|
@Override
|
||||||
|
public String getText ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
|
{
|
||||||
|
StringBuilder text = new StringBuilder ();
|
||||||
|
|
||||||
|
text.append ("Character name ..... " + getName ());
|
||||||
|
text.append ("\n\nRace ............... " + stats.race);
|
||||||
|
text.append ("\nType ............... " + stats.type);
|
||||||
|
text.append ("\nAlignment .......... " + stats.alignment);
|
||||||
|
text.append ("\nStatus ............. " + stats.status);
|
||||||
|
// text.append ("\nType ............... " + stats.typeInt);
|
||||||
|
// text.append ("\nStatus ............. " + stats.statusValue);
|
||||||
|
text.append ("\nGold ............... " + String.format ("%,d", stats.gold));
|
||||||
|
text.append ("\nExperience ......... " + String.format ("%,d", stats.experience));
|
||||||
|
text.append ("\nNext level ......... " + String.format ("%,d", stats.nextLevel));
|
||||||
|
text.append ("\nLevel .............. " + stats.level);
|
||||||
|
text.append ("\nAge in weeks ....... "
|
||||||
|
+ String.format ("%,d (%d)", stats.ageInWeeks, (stats.ageInWeeks / 52)));
|
||||||
|
text.append ("\nHit points left .... " + stats.hitsLeft);
|
||||||
|
text.append ("\nMaximum hits ....... " + stats.hitsMax);
|
||||||
|
text.append ("\nArmour class ....... " + stats.armourClass);
|
||||||
|
text.append ("\nAsset value ........ " + String.format ("%,d", stats.assetValue));
|
||||||
|
text.append ("\nAwards ............. " + getAwardString ());
|
||||||
|
text.append ("\nOut ................ " + isOut ());
|
||||||
|
text.append ("\n\nStrength ........... " + attributes.strength);
|
||||||
|
text.append ("\nIntelligence ....... " + attributes.intelligence);
|
||||||
|
text.append ("\nPiety .............. " + attributes.piety);
|
||||||
|
text.append ("\nVitality ........... " + attributes.vitality);
|
||||||
|
text.append ("\nAgility ............ " + attributes.agility);
|
||||||
|
text.append ("\nLuck ............... " + attributes.luck);
|
||||||
|
|
||||||
|
int[] spellPoints = getMageSpellPoints ();
|
||||||
|
text.append ("\n\nMage spell points ..");
|
||||||
|
for (int i = 0; i < spellPoints.length; i++)
|
||||||
|
text.append (" " + spellPoints[i]);
|
||||||
|
|
||||||
|
spellPoints = getPriestSpellPoints ();
|
||||||
|
text.append ("\nPriest spell points ");
|
||||||
|
for (int i = 0; i < spellPoints.length; i++)
|
||||||
|
text.append (" " + spellPoints[i]);
|
||||||
|
|
||||||
|
text.append ("\n\nSpells :");
|
||||||
|
for (Spell s : spellBook)
|
||||||
|
text.append ("\n" + s);
|
||||||
|
|
||||||
|
text.append ("\n\nItems :");
|
||||||
|
for (Baggage b : baggageList)
|
||||||
|
text.append ("\n" + b);
|
||||||
|
|
||||||
|
return text.toString ();
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
|
public void linkExperience (ExperienceLevel exp)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
|
{
|
||||||
|
stats.nextLevel = exp.getExperiencePoints (stats.level);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
|
public int[] getMageSpellPoints ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
|
{
|
||||||
|
int[] spells = new int[7];
|
||||||
|
|
||||||
|
for (int i = 0; i < 7; i++)
|
||||||
|
spells[i] = buffer[146 + i * 2];
|
||||||
|
|
||||||
|
return spells;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
|
public int[] getPriestSpellPoints ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
|
{
|
||||||
|
int[] spells = new int[7];
|
||||||
|
|
||||||
|
for (int i = 0; i < 7; i++)
|
||||||
|
spells[i] = buffer[160 + i * 2];
|
||||||
|
|
||||||
|
return spells;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
|
public Long getNextLevel ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
|
{
|
||||||
|
return stats.nextLevel;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
|
public String getAwardString ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
|
{
|
||||||
|
StringBuilder text = new StringBuilder ();
|
||||||
|
|
||||||
|
int awards = Utility.getShort (buffer, 206);
|
||||||
|
|
||||||
|
for (int i = 0; i < 16; i++)
|
||||||
|
{
|
||||||
|
if ((awards & 0x01) != 0)
|
||||||
|
text.append (awardsText[i]);
|
||||||
|
awards >>>= 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return text.toString ();
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
|
public boolean isOut ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
|
{
|
||||||
|
return (buffer[32] == 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
|
public String getType ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
|
{
|
||||||
|
return stats.type;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
|
public String getRace ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
|
{
|
||||||
|
return stats.race;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
|
public String getAlignment ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
|
{
|
||||||
|
return stats.alignment;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
|
public Attributes getAttributes ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
|
{
|
||||||
|
return attributes;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
|
public Statistics getStatistics ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
|
{
|
||||||
|
return stats;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
|
public Iterator<Baggage> getBaggage ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
|
{
|
||||||
|
return baggageList.iterator ();
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
|
public Iterator<Spell> getSpells ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
|
{
|
||||||
|
return spellBook.iterator ();
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
|
@Override
|
||||||
|
public String toString ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
|
{
|
||||||
|
return getName ();
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
|
public class Baggage
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
|
{
|
||||||
|
public Item item;
|
||||||
|
public boolean equipped;
|
||||||
|
public boolean identified;
|
||||||
|
|
||||||
|
public Baggage (Item item, boolean equipped, boolean identified)
|
||||||
|
{
|
||||||
|
this.item = item;
|
||||||
|
this.equipped = equipped;
|
||||||
|
this.identified = identified;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString ()
|
||||||
|
{
|
||||||
|
return String.format ("%s%-15s %,10d", equipped ? "*" : " ", item.getName (),
|
||||||
|
item.getCost ());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
|
public class Statistics implements Cloneable
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
|
{
|
||||||
|
public String race;
|
||||||
|
public String type;
|
||||||
|
public String alignment;
|
||||||
|
public String status;
|
||||||
|
public int typeInt;
|
||||||
|
public int statusValue;
|
||||||
|
public long gold;
|
||||||
|
public int experience;
|
||||||
|
public long nextLevel;
|
||||||
|
public int level;
|
||||||
|
public int ageInWeeks;
|
||||||
|
public int hitsLeft;
|
||||||
|
public int hitsMax;
|
||||||
|
public int armourClass;
|
||||||
|
public int assetValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
|
public class Attributes
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
|
{
|
||||||
|
public int strength;
|
||||||
|
public int intelligence;
|
||||||
|
public int piety;
|
||||||
|
public int vitality;
|
||||||
|
public int agility;
|
||||||
|
public int luck;
|
||||||
|
public int[] array = new int[6];
|
||||||
|
}
|
||||||
|
}
|
|
@ -3,12 +3,11 @@ package com.bytezone.diskbrowser.wizardry;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import com.bytezone.diskbrowser.applefile.AbstractFile;
|
|
||||||
import com.bytezone.diskbrowser.utilities.HexFormatter;
|
import com.bytezone.diskbrowser.utilities.HexFormatter;
|
||||||
import com.bytezone.diskbrowser.utilities.Utility;
|
import com.bytezone.diskbrowser.utilities.Utility;
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------------//
|
// -----------------------------------------------------------------------------------//
|
||||||
public class CharacterV4 extends AbstractFile
|
public class CharacterV4 extends Character
|
||||||
// -----------------------------------------------------------------------------------//
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
private static int MAX_POSSESSIONS = 8;
|
private static int MAX_POSSESSIONS = 8;
|
||||||
|
@ -98,6 +97,7 @@ public class CharacterV4 extends AbstractFile
|
||||||
super (name, buffer);
|
super (name, buffer);
|
||||||
|
|
||||||
this.id = id;
|
this.id = id;
|
||||||
|
scenario = 4;
|
||||||
|
|
||||||
inMaze = Utility.getShort (buffer, 33) != 0;
|
inMaze = Utility.getShort (buffer, 33) != 0;
|
||||||
race = Race.values ()[Utility.getShort (buffer, 35)];
|
race = Race.values ()[Utility.getShort (buffer, 35)];
|
||||||
|
|
|
@ -18,8 +18,8 @@ import com.bytezone.diskbrowser.gui.DataSource;
|
||||||
import com.bytezone.diskbrowser.pascal.PascalDisk;
|
import com.bytezone.diskbrowser.pascal.PascalDisk;
|
||||||
import com.bytezone.diskbrowser.utilities.HexFormatter;
|
import com.bytezone.diskbrowser.utilities.HexFormatter;
|
||||||
import com.bytezone.diskbrowser.utilities.Utility;
|
import com.bytezone.diskbrowser.utilities.Utility;
|
||||||
import com.bytezone.diskbrowser.wizardry.Character.Attributes;
|
import com.bytezone.diskbrowser.wizardry.CharacterV1.Attributes;
|
||||||
import com.bytezone.diskbrowser.wizardry.Character.Statistics;
|
import com.bytezone.diskbrowser.wizardry.CharacterV1.Statistics;
|
||||||
import com.bytezone.diskbrowser.wizardry.Header.ScenarioData;
|
import com.bytezone.diskbrowser.wizardry.Header.ScenarioData;
|
||||||
import com.bytezone.diskbrowser.wizardry.Spell.SpellType;
|
import com.bytezone.diskbrowser.wizardry.Spell.SpellType;
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ public class WizardryScenarioDisk extends PascalDisk
|
||||||
|
|
||||||
public List<AbstractImage> images;
|
public List<AbstractImage> images;
|
||||||
public List<Item> items;
|
public List<Item> items;
|
||||||
public List<Character> characters;
|
public List<CharacterV1> characters;
|
||||||
public List<Spell> spells;
|
public List<Spell> spells;
|
||||||
public List<MessageV1> messages;
|
public List<MessageV1> messages;
|
||||||
public List<Monster> monsters;
|
public List<Monster> monsters;
|
||||||
|
@ -111,7 +111,7 @@ public class WizardryScenarioDisk extends PascalDisk
|
||||||
// makeNodeVisible (node);
|
// makeNodeVisible (node);
|
||||||
|
|
||||||
// add information about each characters' baggage, spells known etc.
|
// add information about each characters' baggage, spells known etc.
|
||||||
for (Character c : characters)
|
for (CharacterV1 c : characters)
|
||||||
{
|
{
|
||||||
c.linkItems (items);
|
c.linkItems (items);
|
||||||
c.linkSpells (spells);
|
c.linkSpells (spells);
|
||||||
|
@ -252,7 +252,7 @@ public class WizardryScenarioDisk extends PascalDisk
|
||||||
+ "HP St In Pi Vi Ag Lu Status\n");
|
+ "HP St In Pi Vi Ag Lu Status\n");
|
||||||
text.append ("------------- ---- -------- -------- ---------- "
|
text.append ("------------- ---- -------- -------- ---------- "
|
||||||
+ "-- -- -- -- -- -- -- ------\n");
|
+ "-- -- -- -- -- -- -- ------\n");
|
||||||
for (Character ch : characters)
|
for (CharacterV1 ch : characters)
|
||||||
{
|
{
|
||||||
Statistics stats = ch.getStatistics ();
|
Statistics stats = ch.getStatistics ();
|
||||||
Attributes att = ch.getAttributes ();
|
Attributes att = ch.getAttributes ();
|
||||||
|
@ -287,7 +287,7 @@ public class WizardryScenarioDisk extends PascalDisk
|
||||||
byte[] data2 = new byte[recLen];
|
byte[] data2 = new byte[recLen];
|
||||||
System.arraycopy (buffer, ptr, data2, 0, recLen);
|
System.arraycopy (buffer, ptr, data2, 0, recLen);
|
||||||
|
|
||||||
Character c = new Character (name, data2, scenarioHeader.scenarioID);
|
CharacterV1 c = new CharacterV1 (name, data2, scenarioHeader.scenarioID);
|
||||||
characters.add (c);
|
characters.add (c);
|
||||||
addToNode (c, node, blocks, characterSector);
|
addToNode (c, node, blocks, characterSector);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue