dmolony-DiskBrowser/src/com/bytezone/diskbrowser/wizardry/Item.java

105 lines
3.6 KiB
Java
Raw Normal View History

2020-02-11 07:29:55 +00:00
package com.bytezone.diskbrowser.wizardry;
import com.bytezone.diskbrowser.applefile.AbstractFile;
import com.bytezone.diskbrowser.utilities.Utility;
2020-02-11 07:29:55 +00:00
// -----------------------------------------------------------------------------------//
2022-05-31 07:44:41 +00:00
public class Item extends AbstractFile
2020-02-11 07:29:55 +00:00
// -----------------------------------------------------------------------------------//
{
2022-05-31 07:44:41 +00:00
int itemId;
2020-02-11 07:29:55 +00:00
String genericName;
2022-05-31 07:44:41 +00:00
protected long price;
public Dice wephpdam;
public int armourClass;
public int xtraSwing;
boolean cursed;
int changeTo;
int changeChance;
int special;
int boltac;
int spellPwr;
int classUseFlags;
int healPts;
int wepvstyFlags;
int wepvsty2Flags;
int wepvsty3Flags;
int wephitmd;
boolean crithitm;
ObjectType type;
Alignment alignment;
Item changeToItem;
Spell spell;
public enum Alignment
{
UNALIGN, GOOD, NEUTRAL, EVIL
}
public enum ObjectType
{
WEAPON, ARMOR, SHIELD, HELMET, GAUNTLET, SPECIAL, MISC
}
2020-02-11 07:29:55 +00:00
// ---------------------------------------------------------------------------------//
Item (String name, byte[] buffer)
// ---------------------------------------------------------------------------------//
{
super (name, buffer);
}
// ---------------------------------------------------------------------------------//
@Override
public String getText ()
// ---------------------------------------------------------------------------------//
{
StringBuilder text = new StringBuilder ();
2022-05-31 07:44:41 +00:00
text.append (String.format ("ID ............... %s%n%n", itemId));
text.append (String.format ("Name ............. %s%n", name));
text.append (String.format ("Generic name ..... %s%n", genericName));
2020-02-11 07:29:55 +00:00
2022-05-31 07:44:41 +00:00
text.append (String.format ("Cost ............. %,d%n", price));
text.append (String.format ("Damage ........... %s%n", wephpdam));
text.append (String.format ("Hit mod .......... %d%n", wephitmd));
text.append (String.format ("Critical hit ..... %s%n", crithitm));
2020-02-11 07:29:55 +00:00
2022-05-31 07:44:41 +00:00
text.append (String.format ("Type ............. %s%n", type));
text.append (String.format ("Alignment ........ %s%n", alignment));
text.append (String.format ("Armour class ..... %d%n", armourClass));
text.append (String.format ("Speed ............ %d%n", xtraSwing));
text.append (String.format ("Cursed? .......... %s%n", cursed));
2020-02-11 07:29:55 +00:00
2022-05-31 07:44:41 +00:00
String changeItemName = changeToItem == null ? "" : changeToItem.getName ();
text.append (String.format ("Decay odds ....... %d%%%n", changeChance));
text.append (String.format ("Decay to ......... %s%n", changeItemName));
2020-02-11 07:29:55 +00:00
2022-05-31 07:44:41 +00:00
text.append (String.format ("Special .......... %d%n", special));
text.append (String.format ("Boltac ........... %d%n", boltac));
2020-02-11 07:29:55 +00:00
2022-05-31 07:44:41 +00:00
String spellName = spell == null ? "" : spell.getName ();
text.append (String.format ("Spell ............ %s%n", spellName));
2020-02-11 07:29:55 +00:00
2022-05-31 07:44:41 +00:00
text.append (String.format ("Heal ............. %d%n", healPts));
text.append (String.format ("Class use ........ %d%n", classUseFlags));
text.append (String.format ("Flags ............ %d%n", wepvstyFlags));
text.append (String.format ("Flags2 ........... %d%n", wepvsty2Flags));
text.append (String.format ("Flags3 ........... %d%n", wepvsty3Flags));
2020-02-11 07:29:55 +00:00
2022-05-31 07:44:41 +00:00
return text.toString ();
2020-02-11 07:29:55 +00:00
}
// ---------------------------------------------------------------------------------//
2022-05-31 07:44:41 +00:00
int getWizLong (byte[] buffer, int offset)
2020-02-11 07:29:55 +00:00
// ---------------------------------------------------------------------------------//
{
2022-05-31 07:44:41 +00:00
int low = Utility.getShort (buffer, offset);
int mid = Utility.getShort (buffer, offset + 2);
int high = Utility.getShort (buffer, offset + 4);
2020-02-11 07:29:55 +00:00
2022-05-31 07:44:41 +00:00
return high * 100000000 + mid * 10000 + low;
2020-02-11 07:29:55 +00:00
}
2022-05-31 07:44:41 +00:00
}