Skip to content

Commit

Permalink
refac: remove unused code
Browse files Browse the repository at this point in the history
  • Loading branch information
Markkop committed Feb 17, 2022
1 parent ee4e536 commit 484ad21
Show file tree
Hide file tree
Showing 15 changed files with 14 additions and 411 deletions.
19 changes: 4 additions & 15 deletions src/events/onPlayerInteraction.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,9 @@
import { ServerClientEventByCase, ServerClientEventContext } from "@gathertown/gather-game-client"
import { mirrorObjId, updateUserStatusWithRandomTitle } from "../interactions/titleGenerator"
import { boardObjId, updateCounterBoardObject } from "../interactions/counterBoard"
import { jukeboxObjId, playRandomMusic } from "../interactions/jukebox"
import { hologramObjId } from "../interactions/rpgLikeTalking"
import { getAccessKey } from "../interactions/getAccessKey"
import { rankInfoObjectId, updateMovementRanking } from "../interactions/movementRanking"
import { ServerClientEventContext } from "@gathertown/gather-game-client"
import { PlayerInteractsEventData } from "../types"

const actionsByObjectId: Record<string, Function> = {
[boardObjId]: updateCounterBoardObject,
[mirrorObjId]: updateUserStatusWithRandomTitle,
[jukeboxObjId]: playRandomMusic,
[hologramObjId]: getAccessKey,
[rankInfoObjectId] : updateMovementRanking
}
const actionsByObjectId: Record<string, Function> = {}

export function onPlayerInteraction (data: ServerClientEventByCase<'playerInteracts'>, context: ServerClientEventContext) {
export function onPlayerInteraction(data: PlayerInteractsEventData, context: ServerClientEventContext) {
const player = context?.player
const playerName = player?.name
const interactedObjId = data.playerInteracts.objId
Expand Down
30 changes: 3 additions & 27 deletions src/events/onPlayerMoves.ts
Original file line number Diff line number Diff line change
@@ -1,34 +1,10 @@
import { ServerClientEventByCase, ServerClientEventContext } from "@gathertown/gather-game-client"
import { plate1Location, setBossActivation, plate2Location, detectAndRegisterBossTrigger } from "../interactions/boss"
import { detectAndRegisterKonamiMovement } from "../interactions/konamiCode"
import { detectAndRegisterMovementRanking } from "../interactions/movementRanking"
import { ServerClientEventContext } from "@gathertown/gather-game-client"
import { registerUser } from "../interactions/playerMoves/registerUser"
import { trackSteps } from "../interactions/playerMoves/trackSteps"
import { detectAndTriggerRPGLikeTalking } from "../interactions/rpgLikeTalking"
import { detectAndTeleportUnauthorizedUser } from "../interactions/teleportUnauthorizedUser"
import { Position } from "../types"

const playerPosition: Record<string, Position> = {}

export function onPlayerMoves(data: ServerClientEventByCase<'playerMoves'>, context: ServerClientEventContext) {
const player = context?.player
const playerId = context?.playerId!
const mapId = player?.map as string
const playerNewPosition = {
x: data.playerMoves?.x,
y: data.playerMoves?.y,
direction: data.playerMoves?.direction,
}
import { PlayerMovesEventData } from "../types"

export function onPlayerMoves(data: PlayerMovesEventData, context: ServerClientEventContext) {
registerUser(data, context)
trackSteps(data, context)

detectAndRegisterKonamiMovement(playerNewPosition, playerPosition, playerId)
detectAndRegisterBossTrigger(playerNewPosition, mapId)
detectAndTriggerRPGLikeTalking(playerNewPosition, mapId)
detectAndTeleportUnauthorizedUser(playerNewPosition, mapId, playerId)
detectAndRegisterMovementRanking(playerNewPosition, playerPosition, mapId, playerId)
playerPosition[playerId] = playerNewPosition

}

4 changes: 1 addition & 3 deletions src/initialize.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import game from ".";
import { deactivateBossObject } from "./interactions/boss";

let hasInitialized = false

export function initializeInteractionStates(mapId: string) {
game.subscribeToEvent("mapSetObjects", (data, _context) => {
if (data.mapSetObjects.mapId !== mapId || hasInitialized) return
if (data.mapSetObjects.mapId !== mapId || hasInitialized) return
console.log(`Initializing interaction states for mapId: ${mapId}`)
deactivateBossObject(mapId)
hasInitialized = true
})
}
84 changes: 0 additions & 84 deletions src/interactions/boss.ts

This file was deleted.

38 changes: 0 additions & 38 deletions src/interactions/counterBoard.ts

This file was deleted.

8 changes: 0 additions & 8 deletions src/interactions/getAccessKey.ts

This file was deleted.

40 changes: 0 additions & 40 deletions src/interactions/jukebox.ts

This file was deleted.

44 changes: 0 additions & 44 deletions src/interactions/konamiCode.ts

This file was deleted.

47 changes: 0 additions & 47 deletions src/interactions/movementRanking.ts

This file was deleted.

4 changes: 2 additions & 2 deletions src/interactions/playerMoves/registerUser.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { ServerClientEventContext } from "@gathertown/gather-game-client";
import { createOrUpdateUser, getUser } from "../../services/database";
import { PlayerMovesEvent } from "../../types";
import { PlayerMovesEventData } from "../../types";

export async function registerUser(data: PlayerMovesEvent, context: ServerClientEventContext) {
export async function registerUser(data: PlayerMovesEventData, context: ServerClientEventContext) {
try {
const playerId = context.playerId
if (!playerId) return
Expand Down
4 changes: 2 additions & 2 deletions src/interactions/playerMoves/trackSteps.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { ServerClientEventContext } from "@gathertown/gather-game-client";
import { increaseSteps } from "../../services/database";
import { PlayerMovesEvent, Position } from "../../types";
import { PlayerMovesEventData, Position } from "../../types";
import { getMovement } from "../../utils/movement";

export const playerPosition: Record<string, Position> = {}

export async function trackSteps(data: PlayerMovesEvent, context: ServerClientEventContext) {
export async function trackSteps(data: PlayerMovesEventData, context: ServerClientEventContext) {
try {
const playerId = context?.playerId!
const playerNewPosition = {
Expand Down
Loading

0 comments on commit 484ad21

Please sign in to comment.