From 45a7e9331b46b85bf1f81e87728a68043c0d7fa7 Mon Sep 17 00:00:00 2001 From: Hanusiak Piotr Date: Wed, 2 Feb 2022 13:30:49 +0100 Subject: [PATCH] ran prettier --- .../Components/ActionsMenu/ActionsMenu.svelte | 23 +++++++------ front/src/Components/MainLayout.svelte | 6 ++-- front/src/Phaser/Entity/Character.ts | 4 +-- front/src/Phaser/Entity/RemotePlayer.ts | 34 ++++++------------- front/src/Phaser/Game/ActivatableInterface.ts | 3 +- front/src/Phaser/Game/ActivatablesManager.ts | 15 ++++---- front/src/Phaser/Game/GameScene.ts | 14 ++++---- front/src/Phaser/Game/OutlineableInterface.ts | 17 +++++----- front/src/Phaser/Items/ActionableItem.ts | 6 ++-- .../UserInput/GameSceneUserInputHandler.ts | 6 ++-- front/src/Stores/ActionsMenuStore.ts | 7 ++-- front/src/Stores/OutlineColorStore.ts | 2 +- front/src/Utils/CustomTypeGuards.ts | 2 +- 13 files changed, 62 insertions(+), 77 deletions(-) diff --git a/front/src/Components/ActionsMenu/ActionsMenu.svelte b/front/src/Components/ActionsMenu/ActionsMenu.svelte index a04caab8..d660a570 100644 --- a/front/src/Components/ActionsMenu/ActionsMenu.svelte +++ b/front/src/Components/ActionsMenu/ActionsMenu.svelte @@ -1,9 +1,9 @@ @@ -42,17 +41,19 @@ - {/each} + {/each} {/if} \ No newline at end of file + diff --git a/front/src/Components/MainLayout.svelte b/front/src/Components/MainLayout.svelte index 238fbf67..54fa9d3b 100644 --- a/front/src/Components/MainLayout.svelte +++ b/front/src/Components/MainLayout.svelte @@ -36,8 +36,8 @@ import LimitRoomModal from "./Modal/LimitRoomModal.svelte"; import ShareLinkMapModal from "./Modal/ShareLinkMapModal.svelte"; import { LayoutMode } from "../WebRtc/LayoutManager"; -import { actionsMenuStore } from '../Stores/ActionsMenuStore'; -import ActionsMenu from './ActionsMenu/ActionsMenu.svelte'; + import { actionsMenuStore } from "../Stores/ActionsMenuStore"; + import ActionsMenu from "./ActionsMenu/ActionsMenu.svelte"; let mainLayout: HTMLDivElement; @@ -107,7 +107,7 @@ import ActionsMenu from './ActionsMenu/ActionsMenu.svelte'; {#if $followStateStore !== "off" || $peerStore.size > 0} {/if} - + {#if $actionsMenuStore} {/if} diff --git a/front/src/Phaser/Entity/Character.ts b/front/src/Phaser/Entity/Character.ts index 378db15d..4465a6b6 100644 --- a/front/src/Phaser/Entity/Character.ts +++ b/front/src/Phaser/Entity/Character.ts @@ -15,7 +15,7 @@ import { TexturesHelper } from "../Helpers/TexturesHelper"; import type { PictureStore } from "../../Stores/PictureStore"; import { Unsubscriber, Writable, writable } from "svelte/store"; import { createColorStore } from "../../Stores/OutlineColorStore"; -import type { OutlineableInterface } from '../Game/OutlineableInterface'; +import type { OutlineableInterface } from "../Game/OutlineableInterface"; import type CancelablePromise from "cancelable-promise"; const playerNameY = -25; @@ -155,7 +155,7 @@ export abstract class Character extends Container implements OutlineableInterfac return this.clickable; } - public getPosition(): { x: number, y: number } { + public getPosition(): { x: number; y: number } { return { x: this.x, y: this.y }; } diff --git a/front/src/Phaser/Entity/RemotePlayer.ts b/front/src/Phaser/Entity/RemotePlayer.ts index 5937b4c1..df496896 100644 --- a/front/src/Phaser/Entity/RemotePlayer.ts +++ b/front/src/Phaser/Entity/RemotePlayer.ts @@ -1,23 +1,21 @@ - import { requestVisitCardsStore } from "../../Stores/GameStore"; -import { ActionsMenuData, actionsMenuStore } from '../../Stores/ActionsMenuStore'; +import { ActionsMenuData, actionsMenuStore } from "../../Stores/ActionsMenuStore"; import { Character } from "../Entity/Character"; import type { GameScene } from "../Game/GameScene"; import type { PointInterface } from "../../Connexion/ConnexionModels"; import type { PlayerAnimationDirections } from "../Player/Animation"; -import type { Unsubscriber } from 'svelte/store'; -import type { ActivatableInterface } from '../Game/ActivatableInterface'; +import type { Unsubscriber } from "svelte/store"; +import type { ActivatableInterface } from "../Game/ActivatableInterface"; import type CancelablePromise from "cancelable-promise"; /** * Class representing the sprite of a remote player (a player that plays on another computer) */ export class RemotePlayer extends Character implements ActivatableInterface { - public userId: number; public readonly activationRadius: number; - - private registeredActions: { actionName: string, callback: Function }[]; + + private registeredActions: { actionName: string; callback: Function }[]; private visitCardUrl: string | null; private isActionsMenuInitialized: boolean = false; private actionsMenuStoreUnsubscriber: Unsubscriber; @@ -34,21 +32,9 @@ export class RemotePlayer extends Character implements ActivatableInterface { visitCardUrl: string | null, companion: string | null, companionTexturePromise?: Promise, - activationRadius?: number, + activationRadius?: number ) { - super( - Scene, - x, - y, - texturesPromise, - name, - direction, - moving, - 1, - true, - companion, - companionTexturePromise - ); + super(Scene, x, y, texturesPromise, name, direction, moving, 1, true, companion, companionTexturePromise); //set data this.userId = userId; @@ -76,13 +62,13 @@ export class RemotePlayer extends Character implements ActivatableInterface { } } - public registerActionsMenuAction(action: { actionName: string, callback: Function }): void { + public registerActionsMenuAction(action: { actionName: string; callback: Function }): void { this.registeredActions.push(action); this.updateIsClickable(); } public unregisterActionsMenuAction(actionName: string) { - const index = this.registeredActions.findIndex(action => action.actionName === actionName); + const index = this.registeredActions.findIndex((action) => action.actionName === actionName); if (index !== -1) { this.registeredActions.splice(index, 1); } @@ -125,7 +111,7 @@ export class RemotePlayer extends Character implements ActivatableInterface { callback: () => { requestVisitCardsStore.set(this.visitCardUrl); actionsMenuStore.clear(); - } + }, }); } } diff --git a/front/src/Phaser/Game/ActivatableInterface.ts b/front/src/Phaser/Game/ActivatableInterface.ts index dda53c89..809a09b6 100644 --- a/front/src/Phaser/Game/ActivatableInterface.ts +++ b/front/src/Phaser/Game/ActivatableInterface.ts @@ -1,7 +1,6 @@ - export interface ActivatableInterface { readonly activationRadius: number; isActivatable: () => boolean; activate: () => void; - getPosition: () => { x: number, y: number }; + getPosition: () => { x: number; y: number }; } diff --git a/front/src/Phaser/Game/ActivatablesManager.ts b/front/src/Phaser/Game/ActivatablesManager.ts index ee801167..60e967d9 100644 --- a/front/src/Phaser/Game/ActivatablesManager.ts +++ b/front/src/Phaser/Game/ActivatablesManager.ts @@ -1,17 +1,16 @@ -import { isOutlineable } from '../../Utils/CustomTypeGuards'; -import { MathUtils } from '../../Utils/MathUtils'; -import type { Player } from '../Player/Player'; -import type { ActivatableInterface } from './ActivatableInterface'; +import { isOutlineable } from "../../Utils/CustomTypeGuards"; +import { MathUtils } from "../../Utils/MathUtils"; +import type { Player } from "../Player/Player"; +import type { ActivatableInterface } from "./ActivatableInterface"; export class ActivatablesManager { - // The item that can be selected by pressing the space key. private selectedActivatableObjectByDistance?: ActivatableInterface; private selectedActivatableObjectByPointer?: ActivatableInterface; private activatableObjectsDistances: Map = new Map(); private currentPlayer: Player; - + constructor(currentPlayer: Player) { this.currentPlayer = currentPlayer; } @@ -54,7 +53,7 @@ export class ActivatablesManager { // update value but do not change the outline if (this.selectedActivatableObjectByPointer) { this.selectedActivatableObjectByDistance = newNearestObject; - return; + return; } if (isOutlineable(this.selectedActivatableObjectByDistance)) { this.selectedActivatableObjectByDistance?.characterFarAwayOutline(); @@ -88,7 +87,7 @@ export class ActivatablesManager { public updateDistanceForSingleActivatableObject(object: ActivatableInterface): void { this.activatableObjectsDistances.set( object, - MathUtils.distanceBetween(this.currentPlayer.getPosition(), object.getPosition()), + MathUtils.distanceBetween(this.currentPlayer.getPosition(), object.getPosition()) ); } } diff --git a/front/src/Phaser/Game/GameScene.ts b/front/src/Phaser/Game/GameScene.ts index 6bf251c8..242d97c8 100644 --- a/front/src/Phaser/Game/GameScene.ts +++ b/front/src/Phaser/Game/GameScene.ts @@ -49,7 +49,7 @@ import { GameMapPropertiesListener } from "./GameMapPropertiesListener"; import { analyticsClient } from "../../Administration/AnalyticsClient"; import { GameMapProperties } from "./GameMapProperties"; import { PathfindingManager } from "../../Utils/PathfindingManager"; -import { ActivatablesManager } from './ActivatablesManager'; +import { ActivatablesManager } from "./ActivatablesManager"; import type { GroupCreatedUpdatedMessageInterface, MessageUserMovedInterface, @@ -805,10 +805,9 @@ export class GameScene extends DirtyScene { this.simplePeer = new SimplePeer(this.connection); userMessageManager.setReceiveBanListener(this.bannedUser.bind(this)); - this.CurrentPlayer.on( - hasMovedEventName, - (event: HasPlayerMovedEvent) => { this.handleCurrentPlayerHasMovedEvent(event); }, - ); + this.CurrentPlayer.on(hasMovedEventName, (event: HasPlayerMovedEvent) => { + this.handleCurrentPlayerHasMovedEvent(event); + }); // Set up variables manager this.sharedVariablesManager = new SharedVariablesManager( @@ -1685,7 +1684,10 @@ ${escapedMessage} //listen event to share position of user this.pushPlayerPosition(event); this.gameMap.setPosition(event.x, event.y); - this.activatablesManager.updateActivatableObjectsDistances([...Array.from(this.MapPlayersByKey.values()), ...this.actionableItems.values()]); + this.activatablesManager.updateActivatableObjectsDistances([ + ...Array.from(this.MapPlayersByKey.values()), + ...this.actionableItems.values(), + ]); this.activatablesManager.deduceSelectedActivatableObjectByDistance(); } diff --git a/front/src/Phaser/Game/OutlineableInterface.ts b/front/src/Phaser/Game/OutlineableInterface.ts index b73b2413..bee560cc 100644 --- a/front/src/Phaser/Game/OutlineableInterface.ts +++ b/front/src/Phaser/Game/OutlineableInterface.ts @@ -1,11 +1,10 @@ - export interface OutlineableInterface { - setFollowOutlineColor(color: number): void - removeFollowOutlineColor(): void - setApiOutlineColor(color: number): void - removeApiOutlineColor(): void - pointerOverOutline(): void - pointerOutOutline(): void - characterCloseByOutline(): void - characterFarAwayOutline(): void + setFollowOutlineColor(color: number): void; + removeFollowOutlineColor(): void; + setApiOutlineColor(color: number): void; + removeApiOutlineColor(): void; + pointerOverOutline(): void; + pointerOutOutline(): void; + characterCloseByOutline(): void; + characterFarAwayOutline(): void; } diff --git a/front/src/Phaser/Items/ActionableItem.ts b/front/src/Phaser/Items/ActionableItem.ts index 417c6973..ff85e232 100644 --- a/front/src/Phaser/Items/ActionableItem.ts +++ b/front/src/Phaser/Items/ActionableItem.ts @@ -5,11 +5,11 @@ import Sprite = Phaser.GameObjects.Sprite; import type { GameScene } from "../Game/GameScene"; import type OutlinePipelinePlugin from "phaser3-rex-plugins/plugins/outlinepipeline-plugin.js"; -import type { ActivatableInterface } from '../Game/ActivatableInterface'; +import type { ActivatableInterface } from "../Game/ActivatableInterface"; type EventCallback = (state: unknown, parameters: unknown) => void; -export class ActionableItem implements ActivatableInterface{ +export class ActionableItem implements ActivatableInterface { private readonly activationRadiusSquared: number; private isSelectable: boolean = false; private callbacks: Map> = new Map>(); @@ -41,7 +41,7 @@ export class ActionableItem implements ActivatableInterface{ } } - public getPosition(): { x: number, y: number } { + public getPosition(): { x: number; y: number } { return { x: this.sprite.x, y: this.sprite.y }; } diff --git a/front/src/Phaser/UserInput/GameSceneUserInputHandler.ts b/front/src/Phaser/UserInput/GameSceneUserInputHandler.ts index 489abbd2..6ffd69db 100644 --- a/front/src/Phaser/UserInput/GameSceneUserInputHandler.ts +++ b/front/src/Phaser/UserInput/GameSceneUserInputHandler.ts @@ -1,5 +1,5 @@ -import { Player } from '../Player/Player'; -import { RemotePlayer } from '../Entity/RemotePlayer'; +import { Player } from "../Player/Player"; +import { RemotePlayer } from "../Entity/RemotePlayer"; import type { UserInputHandlerInterface } from "../../Interfaces/UserInputHandlerInterface"; import type { GameScene } from "../Game/GameScene"; @@ -55,7 +55,7 @@ export class GameSceneUserInputHandler implements UserInputHandlerInterface { public handleSpaceKeyUpEvent(event: Event): Event { const activatable = this.gameScene.getActivatablesManager().getSelectedActivatableObject(); if (activatable && activatable.isActivatable()) { - activatable.activate(); + activatable.activate(); } return event; } diff --git a/front/src/Stores/ActionsMenuStore.ts b/front/src/Stores/ActionsMenuStore.ts index d2d7ae9a..f891dad8 100644 --- a/front/src/Stores/ActionsMenuStore.ts +++ b/front/src/Stores/ActionsMenuStore.ts @@ -2,11 +2,10 @@ import { writable } from "svelte/store"; export interface ActionsMenuData { playerName: string; - actions: {actionName: string, callback: Function }[]; + actions: { actionName: string; callback: Function }[]; } function createActionsMenuStore() { - const { subscribe, update, set } = writable(undefined); return { @@ -25,7 +24,7 @@ function createActionsMenuStore() { }, removeAction: (actionName: string) => { update((data) => { - const actionIndex = data?.actions.findIndex(action => action.actionName === actionName); + const actionIndex = data?.actions.findIndex((action) => action.actionName === actionName); if (actionIndex !== undefined && actionIndex != -1) { data?.actions.splice(actionIndex, 1); } @@ -37,7 +36,7 @@ function createActionsMenuStore() { */ clear: () => { set(undefined); - } + }, }; } diff --git a/front/src/Stores/OutlineColorStore.ts b/front/src/Stores/OutlineColorStore.ts index 1bb6fd66..a35cc9c9 100644 --- a/front/src/Stores/OutlineColorStore.ts +++ b/front/src/Stores/OutlineColorStore.ts @@ -5,7 +5,7 @@ export function createColorStore() { let followColor: number | undefined = undefined; let apiColor: number | undefined = undefined; - + let pointedByPointer: boolean = false; let pointedByCharacter: boolean = false; diff --git a/front/src/Utils/CustomTypeGuards.ts b/front/src/Utils/CustomTypeGuards.ts index 7c2c9f21..f2bdb0f9 100644 --- a/front/src/Utils/CustomTypeGuards.ts +++ b/front/src/Utils/CustomTypeGuards.ts @@ -1,4 +1,4 @@ -import type { OutlineableInterface } from '../Phaser/Game/OutlineableInterface'; +import type { OutlineableInterface } from "../Phaser/Game/OutlineableInterface"; export function isOutlineable(object: unknown): object is OutlineableInterface { return (object as OutlineableInterface)?.pointerOverOutline !== undefined;