Crossfire JXClient, Trunk  R20561
com.realtime.crossfire.jxclient.stats.PoisonWatcher Class Reference

Helper class to synthesize an "is poisoned" stat value. More...

+ Collaboration diagram for com.realtime.crossfire.jxclient.stats.PoisonWatcher:

Public Member Functions

 PoisonWatcher (@NotNull final Stats stats, @NotNull final CrossfireServerConnection crossfireServerConnection)
 Creates a new instance. More...
 

Private Member Functions

void check (@NotNull final String message)
 Examines a text message. More...
 
void setActive (final boolean active)
 Sets the current poisoned state. More...
 

Private Attributes

boolean active = true
 Whether poisoning is active. More...
 
final CrossfireDrawextinfoListener drawextinfoListener
 The drawextinfo listener to receive drawextinfo messages. More...
 
final CrossfireDrawinfoListener drawinfoListener = (text, type) -> check(text)
 The drawinfo listener to receive drawinfo messages. More...
 
final Stats stats
 The stats instance to notify. More...
 
final Object sync = new Object()
 The object used for synchronization. More...
 
final ActionListener timeoutEvent = e -> setActive(false)
 The timeout event used to turn off poisoning if the de-assert message was missed. More...
 
final Timer timer = new Timer(TIMEOUT_DE_ASSERT, timeoutEvent)
 The Timer for turning off the poison symbol. More...
 

Static Private Attributes

static final String ASSERT_MESSAGE = "You feel very sick..."
 The text message the server sends in poisoned state. More...
 
static final String CURE_MESSAGE = "Your body feels cleansed"
 The text message the server sends when the poison is cured via a spell. More...
 
static final String DE_ASSERT_MESSAGE = "You feel much better now."
 The text message the server sends when the poison wears off. More...
 
static final int TIMEOUT_DE_ASSERT = 10000
 Timeout after that the "poisoned" state is reset. More...
 

Detailed Description

Helper class to synthesize an "is poisoned" stat value.

The Crossfire server currently does not send this information, therefore drawinfo messages are tracked.

Author
Andreas Kirschbaum

Definition at line 37 of file PoisonWatcher.java.

Constructor & Destructor Documentation

◆ PoisonWatcher()

com.realtime.crossfire.jxclient.stats.PoisonWatcher.PoisonWatcher ( @NotNull final Stats  stats,
@NotNull final CrossfireServerConnection  crossfireServerConnection 
)

Creates a new instance.

Parameters
statsthe stats instance to notify
crossfireServerConnectionthe connection to watch

Definition at line 124 of file PoisonWatcher.java.

References com.realtime.crossfire.jxclient.stats.PoisonWatcher.drawextinfoListener, com.realtime.crossfire.jxclient.stats.PoisonWatcher.drawinfoListener, com.realtime.crossfire.jxclient.stats.PoisonWatcher.setActive(), and com.realtime.crossfire.jxclient.stats.PoisonWatcher.stats.

+ Here is the call graph for this function:

Member Function Documentation

◆ check()

void com.realtime.crossfire.jxclient.stats.PoisonWatcher.check ( @NotNull final String  message)
private

Examines a text message.

Parameters
messagethe text message

Definition at line 136 of file PoisonWatcher.java.

References com.realtime.crossfire.jxclient.stats.PoisonWatcher.setActive().

+ Here is the call graph for this function:

◆ setActive()

void com.realtime.crossfire.jxclient.stats.PoisonWatcher.setActive ( final boolean  active)
private

Member Data Documentation

◆ active

boolean com.realtime.crossfire.jxclient.stats.PoisonWatcher.active = true
private

Whether poisoning is active.

Definition at line 78 of file PoisonWatcher.java.

Referenced by com.realtime.crossfire.jxclient.stats.PoisonWatcher.setActive().

◆ ASSERT_MESSAGE

final String com.realtime.crossfire.jxclient.stats.PoisonWatcher.ASSERT_MESSAGE = "You feel very sick..."
staticprivate

The text message the server sends in poisoned state.

Definition at line 49 of file PoisonWatcher.java.

◆ CURE_MESSAGE

final String com.realtime.crossfire.jxclient.stats.PoisonWatcher.CURE_MESSAGE = "Your body feels cleansed"
staticprivate

The text message the server sends when the poison is cured via a spell.

Definition at line 61 of file PoisonWatcher.java.

◆ DE_ASSERT_MESSAGE

final String com.realtime.crossfire.jxclient.stats.PoisonWatcher.DE_ASSERT_MESSAGE = "You feel much better now."
staticprivate

The text message the server sends when the poison wears off.

Definition at line 55 of file PoisonWatcher.java.

◆ drawextinfoListener

final CrossfireDrawextinfoListener com.realtime.crossfire.jxclient.stats.PoisonWatcher.drawextinfoListener
private
Initial value:
= new CrossfireDrawextinfoListener() {
@Override
public void commandDrawextinfoReceived(final int color, final int type, final int subtype, @NotNull final String message) {
check(message);
}
@Override
public void setDebugMode(final boolean printMessageTypes) {
}
}

The drawextinfo listener to receive drawextinfo messages.

Definition at line 92 of file PoisonWatcher.java.

Referenced by com.realtime.crossfire.jxclient.stats.PoisonWatcher.PoisonWatcher().

◆ drawinfoListener

final CrossfireDrawinfoListener com.realtime.crossfire.jxclient.stats.PoisonWatcher.drawinfoListener = (text, type) -> check(text)
private

The drawinfo listener to receive drawinfo messages.

Definition at line 85 of file PoisonWatcher.java.

Referenced by com.realtime.crossfire.jxclient.stats.PoisonWatcher.PoisonWatcher().

◆ stats

final Stats com.realtime.crossfire.jxclient.stats.PoisonWatcher.stats
private

The stats instance to notify.

Definition at line 73 of file PoisonWatcher.java.

Referenced by com.realtime.crossfire.jxclient.stats.PoisonWatcher.PoisonWatcher().

◆ sync

final Object com.realtime.crossfire.jxclient.stats.PoisonWatcher.sync = new Object()
private

The object used for synchronization.

Definition at line 67 of file PoisonWatcher.java.

Referenced by com.realtime.crossfire.jxclient.stats.PoisonWatcher.setActive().

◆ TIMEOUT_DE_ASSERT

final int com.realtime.crossfire.jxclient.stats.PoisonWatcher.TIMEOUT_DE_ASSERT = 10000
staticprivate

Timeout after that the "poisoned" state is reset.

This allow to prevent a stuck poison warning if the de-assertion was missed for any reason.

Definition at line 43 of file PoisonWatcher.java.

◆ timeoutEvent

final ActionListener com.realtime.crossfire.jxclient.stats.PoisonWatcher.timeoutEvent = e -> setActive(false)
private

The timeout event used to turn off poisoning if the de-assert message was missed.

Definition at line 111 of file PoisonWatcher.java.

◆ timer

final Timer com.realtime.crossfire.jxclient.stats.PoisonWatcher.timer = new Timer(TIMEOUT_DE_ASSERT, timeoutEvent)
private

The Timer for turning off the poison symbol.

Definition at line 117 of file PoisonWatcher.java.


The documentation for this class was generated from the following file: