Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
addMessage(time, username, message)
{
Assert.instanceOf(time, Date);
Assert.string(username);
Assert.string(message);
let msgElement = this._doc.createElement('div');
msgElement.classList.add('message');
msgElement.innerHTML = MESSAGE_TEMPLATE
.replace(
'__TIME__',
this._format(time.getHours(), 2) + ':' + this._format(time.getMinutes(), 2) + ':' + this._format(time.getSeconds(), 2)
).replace('__USERNAME__', username)
.replace('__MESSAGE__', message);
this._packet.appendChild(msgElement);
this._chatContainer.scrollTop = this._chatContainer.scrollHeight;
}
getConnection(playerId)
{
Assert.string(playerId);
for (let connection of this._connections.values()) {
if (connection.hasPlayerId && connection.playerId === playerId) {
return connection;
}
}
throw `Can't find connection for player with id ${playerId}`;
}
getPlayer(playerId)
{
Assert.string(playerId);
if (!this._characters.has(playerId)) {
throw new Error(`Player with id ${playerId} does not exists.`);
}
return this._characters.get(playerId);
}
removeConnection(id)
{
Assert.string(id);
this._connections.delete(id);
}
attack(characterId)
{
Assert.string(characterId);
this._targetId = characterId;
}
constructor(gfxEngine, pathFinder)
{
Assert.instanceOf(gfxEngine, Engine);
Assert.instanceOf(pathFinder, PathFinder);
this._gfxEngine = gfxEngine;
this._pathFinder = pathFinder;
this._version = '1.0.0-DEV';
this._resetState();
}
constructor(position, ground, tileLayers, moveSpeedModifier = 0)
{
Assert.instanceOf(position, Position);
Assert.instanceOf(ground, Item);
Assert.instanceOf(tileLayers, TileLayers);
Assert.integer(moveSpeedModifier);
this._position = position;
this._ground = ground;
this._tileLayers = tileLayers;
this._moveSpeedModifier = moveSpeedModifier;
this._characters = new Map();
this._monster = null;
}
constructor(position, ground, tileLayers, moveSpeedModifier = 0)
{
Assert.instanceOf(position, Position);
Assert.instanceOf(ground, Item);
Assert.instanceOf(tileLayers, TileLayers);
Assert.integer(moveSpeedModifier);
this._position = position;
this._ground = ground;
this._tileLayers = tileLayers;
this._moveSpeedModifier = moveSpeedModifier;
this._characters = new Map();
this._monster = null;
}
constructor(character)
{
Assert.instanceOf(character, Character);
this._character = character;
this._incomeMessages = [];
}
constructor(kernel, accounts, characters, incomeMessages, broadcaster, logger)
{
Assert.instanceOf(kernel, Kernel);
Assert.instanceOf(accounts, Accounts);
Assert.instanceOf(characters, Characters);
Assert.instanceOf(incomeMessages, IncomeMessageQueue);
Assert.instanceOf(broadcaster, Broadcaster);
this._kernel = kernel;
this._accounts = accounts;
this._characters = characters;
this._incomeMessages = incomeMessages;
this._broadcaster = broadcaster;
this._logger = logger;
}