 |
Crossfire JXClient, Trunk
|
Go to the documentation of this file.
23 package com.realtime.crossfire.jxclient.items;
28 import org.jetbrains.annotations.NotNull;
42 private final int tag;
182 public CfItem(
final int location,
final int tag,
final int flags,
final int weight, @NotNull
final Face face, @NotNull
final String
name, @NotNull
final String
namePl,
final int anim,
final int animSpeed,
final int nrof,
final int type) {
201 if (this.flags !=
flags) {
212 if (this.weight !=
weight) {
223 if (this.face !=
face) {
235 if (!this.name.equals(
name) || !
this.namePl.equals(
namePl)) {
247 if (this.anim !=
anim) {
269 if (this.nrof !=
nrof) {
434 if (this.marked ==
marked) {
508 listener.itemModified();
538 final StringBuilder sb =
new StringBuilder(tooltipText1);
539 if (!tooltipText2.isEmpty()) {
541 sb.append(tooltipText2);
543 if (!tooltipText3.isEmpty()) {
545 sb.append(tooltipText3);
547 return sb.toString();
566 if (totalWeight <= 0) {
569 if (totalWeight < 1000) {
570 return totalWeight+
" g";
572 if (totalWeight < 10000) {
573 final int tmp = (totalWeight+50)/100;
574 return tmp/10+
"."+tmp%10+
" kg";
576 final int tmp = (totalWeight+500)/1000;
586 final StringBuilder sb =
new StringBuilder();
595 sb.append(
"(marked)");
597 return sb.toString();
606 private void appendFlag(@NotNull
final StringBuilder sb,
final int flag, @NotNull
final String ident) {
607 if ((
flags&flag) != 0) {
Face getFace()
Returns the face.
final EventListenerList2< CfItemListener > listeners
The listeners to be notified.
void update(final int updateFlags, final int flags, final int weight, @NotNull final Face face, @NotNull final String name, @NotNull final String namePl, final int anim, final int animSpeed, final int nrof, final boolean clearMarked)
Processes an "upditem" command.
boolean isMagic()
Returns whether this item is magical.
void removeCfItemModifiedListener(@NotNull final CfItemListener listener)
Remove a.
boolean isApplied()
Returns whether this item is applied.
static final int F_LOCKED
The flags value for locked items.
int UPD_FACE
The update flags value for face updates.
void setName(@NotNull final String name, @NotNull final String namePl)
Updates the name.
boolean isMarked()
Returns whether this item is marked.
boolean isLocked()
Returns whether this item is locked.
static final int F_UNIDENTIFIED
The flags value for unidentified items.
int getType()
Returns the type.
int UPD_ANIMSPEED
The update flags value for animation speed updates.
int UPD_NAME
The update flags value for name updates.
void setAnim(final int anim)
Updates the animation.
int location
The location.
int getWeight()
Returns the weight.
static final int F_DAMNED
The flags value for damned items.
int nrof
The number of objects in the stack.
Interface defining constants for the "upditem" Crossfire protocol message.
boolean marked
Whether this item is marked by the player.
Manages image information ("faces") needed to display the map view, items, and spell icons.
static final int F_BLESSED
The flags value for blessed items.
void fireModified()
Notify all listener.
String getTooltipText3()
Returns the third line of the tooltip text.
A list of event listeners.
Interface for listeners for attribute changes of CfItems.
String getTooltipText()
Returns a description suitable for a tooltip text.
boolean isOpen()
Returns whether this item is an opened container.
static final int F_UNPAID
The flags value for unpaid items.
static final int F_MAGIC
The flags value for magical items.
String getTooltipText2()
Returns the second line of the tooltip text.
int animSpeed
The animation speed.
The representation of a Crossfire Item, client-side.
boolean isItemGroupButton()
Returns whether this object is a fake object for selecting object groups in the ground view.
String getName()
Returns the name.
int getTag()
Returns the tag.
void setWeight(final int weight)
Updates the weight.
int UPD_FLAGS
The update flags value for flags updates.
boolean isUnidentified()
Returns whether this item is unidentified.
int getAnim()
Returns the animation.
boolean isCursed()
Returns whether this item is cursed.
void addCfItemModifiedListener(@NotNull final CfItemListener listener)
Add a.
String namePl
The plural name.
void setAnimSpeed(final int animSpeed)
Updates the animation speed.
int UPD_NROF
The update flags value for nrof updates.
void setNrOf(final int nrof)
Updates the number of objects in the stack.
static final int F_READ
The flags value for read items.
String name
The singular name.
void setFace(@NotNull final Face face)
Updates the face.
void setMarked(final boolean marked)
Sets whether this item is marked.
boolean isNoPick()
Returns whether this item cannot be picked up.
CfItem(final int location, final int tag, final int flags, final int weight, @NotNull final Face face, @NotNull final String name, @NotNull final String namePl, final int anim, final int animSpeed, final int nrof, final int type)
Creates a new instance.
int UPD_ANIM
The update flags value for animation updates.
boolean isDamned()
Returns whether this item is damned.
int getLocation()
Returns the location.
boolean isBlessed()
Returns whether this item is blessed.
void appendFlag(@NotNull final StringBuilder sb, final int flag, @NotNull final String ident)
Appends "(<ident>)" if this item has the flag.
int UPD_WEIGHT
The update flags value for weight updates.
static final int F_APPLIED
The flags mask for applied states.
void setLocation(final int location)
Updates the location.
static final int F_NOPICK
The flags value for non-pickable items.
static final int F_CURSED
The flags value for cursed items.
boolean isUnpaid()
Returns whether this item is unpaid.
static final int F_OPEN
The flags value for opened items.
void setFlags(final int flags)
Updates the flags.
boolean modified
Set if any attribute has changed since the last time listeners were notified.
int getAnimSpeed()
Returns the animation speed.
String getTooltipText1()
Returns the first line of the tooltip text.
int getNrOf()
Returns the number of objects in this item stack.