 |
Crossfire JXClient, Trunk
|
Go to the documentation of this file.
23 package com.realtime.crossfire.jxclient.scripts;
44 import java.io.BufferedReader;
45 import java.io.IOException;
46 import java.io.StringReader;
47 import java.util.concurrent.Semaphore;
48 import java.util.concurrent.atomic.AtomicBoolean;
49 import java.util.regex.Matcher;
50 import java.util.regex.Pattern;
51 import org.jetbrains.annotations.NotNull;
52 import org.jetbrains.annotations.Nullable;
53 import org.junit.Assert;
71 private static final Pattern
PATTERN_MAP_SCROLL = Pattern.compile(
"@map_scroll (-?[0-9]+) (-?[0-9]+)");
77 private final StringBuilder
sb =
new StringBuilder();
89 private final BufferedReader
br;
95 private final Semaphore
sem =
new Semaphore(0);
127 protected FaceImages getFaceImages(
final int faceNum, @Nullable
final AtomicBoolean returnIsUnknownImage) {
128 throw new AssertionError(
"not implemented");
135 return new TestScriptProcess(0,
"",
commandQueue,
crossfireServerConnection,
stats,
floorView,
itemSet,
spellsManager,
mapUpdaterState,
skillSet, scriptCommands);
152 private TestScriptProcess(
final int scriptId, @NotNull
final String
filename, @NotNull
final CommandQueue commandQueue, @NotNull
final CrossfireServerConnection crossfireServerConnection, @NotNull
final Stats stats, @NotNull
final FloorView floorView, @NotNull
final ItemSet itemSet, @NotNull
final SpellsManager spellsManager, @NotNull
final MapUpdaterState mapUpdaterState, @NotNull
final SkillSet skillSet, @NotNull
final String scriptCommands) {
155 br =
new BufferedReader(
new StringReader(scriptCommands));
160 sb.append(
"killScript\n");
167 final String line =
br.readLine();
169 sb.append(
"readFromScript: EOF\n");
174 sb.append(
"readFromScript: ").append(line).append(
"\n");
176 if (matcherMapScroll.matches()) {
177 final int dx = Integer.parseInt(matcherMapScroll.group(1));
178 final int dy = Integer.parseInt(matcherMapScroll.group(2));
186 if (line.equals(
"@map_new")) {
194 if (line.startsWith(
"@")) {
195 Assert.fail(
"unrecognized command: "+line);
207 }
catch (
final InterruptedException ignored) {
208 return "current thread has been interrupted";
215 sb.append(
"writeToScript: ").append(data);
224 final String result =
sb.toString();
Maintains a mapping of face numbers to face data.
final String filename
The script command including arguments.
void mapScroll(final int dx, final int dy)
Part of "map2" parsing: scroll the map view.
TestScriptProcess(final int scriptId, @NotNull final String filename, @NotNull final CommandQueue commandQueue, @NotNull final CrossfireServerConnection crossfireServerConnection, @NotNull final Stats stats, @NotNull final FloorView floorView, @NotNull final ItemSet itemSet, @NotNull final SpellsManager spellsManager, @NotNull final MapUpdaterState mapUpdaterState, @NotNull final SkillSet skillSet, @NotNull final String scriptCommands)
Creates a new instance.
final CommandQueue commandQueue
The CommandQueue for sending commands.
Model class maintaining the CfItems known to the player.
A cache for Face instances.
final MapUpdaterState mapUpdaterState
The MapUpdaterState for updating the current map information.
Implements the map model which is shown in the map and magic map views.
Adds encoding/decoding of crossfire protocol packets to a ServerConnection.
String getAndClearEvents()
Returns the collected events.
Manages animations received from the server.
void newMap(final int mapWidth, final int mapHeight)
A "newmap" command has been received.
final BufferedReader br
The script commands not yet executed.
Manages image information ("faces") needed to display the map view, items, and spell icons.
void writeToScript(@NotNull final String data)
Sends some data to the script process.
Manages all known spells.
static TestScriptProcess newTestScriptProcess(@NotNull final String scriptCommands, @NotNull final CrossfireServerConnection crossfireServerConnection)
Creates a new instance.
final ItemSet itemSet
The ItemSet instance to use.
static TestScriptProcess newTestScriptProcess(@NotNull final String scriptCommands)
Creates a new instance.
Maintains pending movements of the character.
Maintains the current GuiState.
final int scriptId
The script ID identifying this script instance.
Object mapBegin()
Parsing of a "map2" command has been started.
final StringBuilder sb
Records all events.
final CrossfireServerConnection crossfireServerConnection
The connection instance.
This is the representation of all the statistics of a player, like its speed or its experience.
final Semaphore sem
Signals the end of the simulated script process.
Manages a set of animated faces.
A ScriptProcess for regression tests.
Runs the action directly.
final Stats stats
The Stats instance to watch.
Consists of three ImageIcons representing a Face.
void mapEnd()
Parsing of "map2" has been finished.
String waitForTermination()
Waits until the script has terminated.
Abstract base class for FacesManager implementations.
Stores experience <-> level mappings.
final FloorView floorView
The FloorView to use.
void killScript()
Kills the script process.
Implements CrossfireServerConnection for regression tests.
Default implementation for ScriptProcesses.
final SpellsManager spellsManager
The SpellsManager instance to use.
Provides a view to all items comprising the current floor view.
Maintain the set of skills as sent by the server.
Update a CfMap model from protocol commands.
String readFromScript()
Reads a line from the script process.
final SkillSet skillSet
The SkillSet for looking up skill names.
static final Pattern PATTERN_MAP_SCROLL
Matches the "@map_scroll" command.
Maintains the pending (ncom) commands sent to the server.