forked from noxious/server
Don't attack if isMoving
This commit is contained in:
@ -11,8 +11,16 @@ export default class CharacterMove extends BaseEvent {
|
||||
|
||||
private async handleEvent(data: any, callback: (response: any) => void): Promise<void> {
|
||||
try {
|
||||
console.log('attack', this.socket.characterId)
|
||||
await this.characterAttackService.attack(this.socket.characterId)
|
||||
if (!this.socket.characterId) {
|
||||
this.logger.error('map:character:attack error: Character not found or not initialized')
|
||||
return
|
||||
}
|
||||
|
||||
// Don't attack if the character is already moving
|
||||
if (this.getMapCharacter()?.isMoving) return
|
||||
|
||||
// Start attack
|
||||
await this.characterAttackService.attack(this.socket.characterId!)
|
||||
} catch (error) {
|
||||
this.logger.error('map:character:attack error', error)
|
||||
return callback(false)
|
||||
|
Reference in New Issue
Block a user