├── .github └── FUNDING.yml ├── .gitignore ├── .gitpod.Dockerfile ├── .gitpod.yml ├── .vscode └── settings.json ├── Dockerfile ├── LICENSE ├── Procfile ├── README.md ├── client ├── .eslintrc.json ├── .prettierrc ├── .vscode │ └── settings.json ├── .yarnrc.yml ├── package.json ├── public │ ├── bundle.js │ ├── favicon.ico │ ├── index.html │ └── web_neutral_rd_ctn@1x.png ├── src │ ├── board │ │ ├── BackgroundLayers.ts │ │ ├── Board.ts │ │ ├── layers │ │ │ ├── BackgroundLayer.ts │ │ │ ├── SolidLayer.ts │ │ │ └── SpritesLayer.ts │ │ └── map │ │ │ ├── Map.ts │ │ │ ├── MapBuilder.ts │ │ │ ├── Room.ts │ │ │ └── tiles │ │ │ ├── Color.ts │ │ │ ├── Tile.ts │ │ │ └── Tiles.ts │ ├── contextMenu │ │ └── ContextMenu.ts │ ├── drawingCanvas │ │ └── DrawingCanvas.ts │ ├── entities │ │ ├── Misc.ts │ │ ├── Npc.ts │ │ ├── Npcs.ts │ │ ├── Player.ts │ │ └── items │ │ │ ├── Bag.ts │ │ │ ├── BagItem.ts │ │ │ ├── Gear.ts │ │ │ ├── GearItem.ts │ │ │ ├── IconCanvas.ts │ │ │ ├── Item.ts │ │ │ ├── ItemCanvas.ts │ │ │ ├── Items.ts │ │ │ ├── Store.ts │ │ │ └── StoreItem.ts │ ├── index.ts │ ├── models │ │ └── configs │ │ │ ├── ClientConfig.ts │ │ │ ├── PlayerConfig.ts │ │ │ └── index.ts │ ├── parser │ │ ├── ParseBoughtItem.ts │ │ ├── ParseChat.ts │ │ ├── ParseDialog.ts │ │ ├── ParseEntityInfo.ts │ │ ├── ParseError.ts │ │ ├── ParseGoldDroped.ts │ │ ├── ParseHidePlayer.ts │ │ ├── ParseItemDrop.ts │ │ ├── ParseItemDroped.ts │ │ ├── ParseItemPick.ts │ │ ├── ParseItemRemove.ts │ │ ├── ParseItemUse.ts │ │ ├── ParseItemWear.ts │ │ ├── ParseItemsInRoom.ts │ │ ├── ParseLoad.ts │ │ ├── ParseLoadBag.ts │ │ ├── ParseLogin.ts │ │ ├── ParseMessage.ts │ │ ├── ParseMove.ts │ │ ├── ParseNpcMove.ts │ │ ├── ParseNpcsInRoom.ts │ │ ├── ParseOpenStore.ts │ │ ├── ParsePlayerIdUpdate.ts │ │ ├── ParsePlayerSellItems.ts │ │ ├── ParsePlayersInRoom.ts │ │ ├── ParsePve.ts │ │ ├── ParseRank.ts │ │ ├── ParseSave.ts │ │ ├── ParseSoldPlayerItem.ts │ │ ├── ParseStats.ts │ │ ├── ParseStoreItems.ts │ │ └── Parser.ts │ └── startup │ │ ├── Game.ts │ │ ├── GameClient.ts │ │ └── Main.ts ├── tsconfig.json ├── webpack.config.js └── yarn.lock ├── deps.ts ├── main.ts ├── runtime.txt ├── server.ts ├── server ├── clientHandler.ts ├── data │ ├── admins.ts │ ├── badWords.ts │ ├── connectionManager.ts │ └── dataManager.ts ├── entities │ ├── items │ │ ├── adamantArmour.ts │ │ ├── adamantDagger.ts │ │ ├── adamantHelm.ts │ │ ├── adamantLegs.ts │ │ ├── adamantSword.ts │ │ ├── bag.ts │ │ ├── bank │ │ │ └── bank.ts │ │ ├── bluriteArmour.ts │ │ ├── bluriteDagger.ts │ │ ├── bluriteHelm.ts │ │ ├── bluriteLegs.ts │ │ ├── bluriteSword.ts │ │ ├── bronzeArmour.ts │ │ ├── bronzeDagger.ts │ │ ├── bronzeHelm.ts │ │ ├── bronzeLegs.ts │ │ ├── bronzeSword.ts │ │ ├── coins.ts │ │ ├── consumable │ │ │ ├── bread.ts │ │ │ ├── cactusJuice.ts │ │ │ ├── coffee.ts │ │ │ ├── largeHp.ts │ │ │ └── smallHp.ts │ │ ├── fireArmour.ts │ │ ├── fireDagger.ts │ │ ├── fireHelm.ts │ │ ├── fireLegs.ts │ │ ├── fireSword.ts │ │ ├── gear.ts │ │ ├── ironArmour.ts │ │ ├── ironDagger.ts │ │ ├── ironHelm.ts │ │ ├── ironLegs.ts │ │ ├── ironSword.ts │ │ ├── itemBase.ts │ │ ├── itemPrices.ts │ │ ├── jamulsGuitar.ts │ │ ├── jamulsMachete.ts │ │ ├── sacredFireSword.ts │ │ ├── sacredStone.ts │ │ ├── woodenArmour.ts │ │ ├── woodenDagger.ts │ │ ├── woodenHelm.ts │ │ ├── woodenLegs.ts │ │ └── woodenSword.ts │ ├── npc.ts │ ├── npcs │ │ ├── adamantGhost.ts │ │ ├── bee.ts │ │ ├── butterflew.ts │ │ ├── camel.ts │ │ ├── chicken.ts │ │ ├── cow.ts │ │ ├── cursedCactus.ts │ │ ├── demon.ts │ │ ├── demon2.ts │ │ ├── document.ts │ │ ├── dog.ts │ │ ├── evilEye.ts │ │ ├── fireBlob.ts │ │ ├── goblin.ts │ │ ├── goblin2.ts │ │ ├── goblin3.ts │ │ ├── grassSnake.ts │ │ ├── horse.ts │ │ ├── horse2.ts │ │ ├── impArcher.ts │ │ ├── impMage.ts │ │ ├── impMeelee.ts │ │ ├── ligneus.ts │ │ ├── npcBase.ts │ │ ├── ogre.ts │ │ ├── passive │ │ │ ├── dialogs │ │ │ │ ├── abidDialog.ts │ │ │ │ ├── achmedDialog.ts │ │ │ │ ├── beatriceDialog.ts │ │ │ │ ├── borisDialog.ts │ │ │ │ ├── castleGuardDialog.ts │ │ │ │ ├── celineDialog.ts │ │ │ │ ├── cityGuardDialog.ts │ │ │ │ ├── cooperDialog.ts │ │ │ │ ├── deriDialog.ts │ │ │ │ ├── dialogBase.ts │ │ │ │ ├── ediogDialog.ts │ │ │ │ ├── edmondDialog.ts │ │ │ │ ├── edwardDialog.ts │ │ │ │ ├── elexiusDialog.ts │ │ │ │ ├── ephanDialog.ts │ │ │ │ ├── feemlunkDialog.ts │ │ │ │ ├── francisDialog.ts │ │ │ │ ├── horvynDialog.ts │ │ │ │ ├── jamesDialog.ts │ │ │ │ ├── jamulDialog.ts │ │ │ │ ├── jasmineDialog.ts │ │ │ │ ├── kingZanderDialog.ts │ │ │ │ ├── kinleyDialog.ts │ │ │ │ ├── lissyDialog.ts │ │ │ │ ├── lugrusDialog.ts │ │ │ │ ├── marcusDialog.ts │ │ │ │ ├── martyDialog.ts │ │ │ │ ├── mathuisDialog.ts │ │ │ │ ├── miahDialog.ts │ │ │ │ ├── michaelDialog.ts │ │ │ │ ├── mytklashDialog.ts │ │ │ │ ├── mytklashsFlowerDialog.ts │ │ │ │ ├── nestorDialog.ts │ │ │ │ ├── oswaldDialog.ts │ │ │ │ ├── peterDialog.ts │ │ │ │ ├── reevesDialog.ts │ │ │ │ ├── rogerDialog.ts │ │ │ │ ├── updatesDogDialog.ts │ │ │ │ ├── vardanDialog.ts │ │ │ │ └── zeroDialog.ts │ │ │ ├── gnomes │ │ │ │ ├── deri.ts │ │ │ │ ├── feemlunk.ts │ │ │ │ ├── horvyn.ts │ │ │ │ ├── mytklash.ts │ │ │ │ ├── mytklashsFlower.ts │ │ │ │ └── nestor.ts │ │ │ ├── humans │ │ │ │ ├── deepLake │ │ │ │ │ ├── edmond.ts │ │ │ │ │ ├── lissy.ts │ │ │ │ │ ├── miah.ts │ │ │ │ │ ├── roger.ts │ │ │ │ │ └── vardan.ts │ │ │ │ ├── kharjid │ │ │ │ │ ├── abid.ts │ │ │ │ │ ├── achmed.ts │ │ │ │ │ ├── jamul.ts │ │ │ │ │ └── mathuis.ts │ │ │ │ ├── mages │ │ │ │ │ ├── ediog.ts │ │ │ │ │ ├── edward.ts │ │ │ │ │ └── elexius.ts │ │ │ │ ├── merchants │ │ │ │ │ ├── kinley.ts │ │ │ │ │ └── peter.ts │ │ │ │ └── subitnof │ │ │ │ │ ├── beatrice.ts │ │ │ │ │ ├── boris.ts │ │ │ │ │ ├── castleGuard.ts │ │ │ │ │ ├── celine.ts │ │ │ │ │ ├── cityGuard.ts │ │ │ │ │ ├── cooper.ts │ │ │ │ │ ├── ephan.ts │ │ │ │ │ ├── francis.ts │ │ │ │ │ ├── james.ts │ │ │ │ │ ├── jasmine.ts │ │ │ │ │ ├── kingZander.ts │ │ │ │ │ ├── lugrus.ts │ │ │ │ │ ├── marcus.ts │ │ │ │ │ ├── marty.ts │ │ │ │ │ ├── michael.ts │ │ │ │ │ ├── oswald.ts │ │ │ │ │ └── reeves.ts │ │ │ └── zero.ts │ │ ├── quests │ │ │ ├── gnomes │ │ │ │ └── flowerForMytklash.ts │ │ │ ├── humans │ │ │ │ ├── deepLake │ │ │ │ │ └── helpTheLakeVillage.ts │ │ │ │ ├── kharjid │ │ │ │ │ ├── jamulsMachete.ts │ │ │ │ │ └── zombieKiller.ts │ │ │ │ ├── mages │ │ │ │ │ └── theSacredStone.ts │ │ │ │ └── subitnof │ │ │ │ │ ├── damnRats.ts │ │ │ │ │ ├── somebodyOnceToldMe.ts │ │ │ │ │ └── warriorSomeday.ts │ │ │ ├── itemsToHave.ts │ │ │ ├── itemsToHaveBase.ts │ │ │ ├── monstersToKill.ts │ │ │ ├── monstersToKillBase.ts │ │ │ ├── quest.ts │ │ │ ├── questBase.ts │ │ │ ├── step.ts │ │ │ └── stepBase.ts │ │ ├── rat.ts │ │ ├── sandCat.ts │ │ ├── sandSnake.ts │ │ ├── sandSpirit.ts │ │ ├── sandTotem.ts │ │ ├── skeleton.ts │ │ ├── skeletonKnight.ts │ │ ├── slime.ts │ │ ├── spider.ts │ │ ├── waterBlob.ts │ │ ├── witch.ts │ │ └── zombie.ts │ └── player.ts ├── map │ ├── doorSpawns.ts │ ├── map.ts │ ├── mapBuilder.ts │ ├── npcSpawns.ts │ └── rooms │ │ ├── door.ts │ │ ├── doorConditions.ts │ │ ├── exits.ts │ │ └── room.ts └── pve │ └── pveData.ts ├── shared ├── Enums.ts └── solidLayers.ts └── yarn.lock /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: [diguifi] 4 | patreon: # Replace with a single Patreon username 5 | open_collective: # Replace with a single Open Collective username 6 | ko_fi: # Replace with a single Ko-fi username 7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel 8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry 9 | liberapay: # Replace with a single Liberapay username 10 | issuehunt: # Replace with a single IssueHunt username 11 | otechie: # Replace with a single Otechie username 12 | lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry 13 | custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] 14 | -------------------------------------------------------------------------------- /.gitpod.Dockerfile: -------------------------------------------------------------------------------- 1 | FROM gitpod/workspace-full 2 | 3 | USER gitpod 4 | 5 | ENV DENO_DIR=/workspace/.deno 6 | ENV DENO_INSTALL=$HOME/.deno 7 | ENV PATH=$DENO_INSTALL/bin:$PATH 8 | 9 | RUN curl -fsSL https://deno.land/x/install/install.sh | sh -s v1.0.0 10 | RUN npm install heroku -g 11 | 12 | # Install custom tools, runtime, etc. using apt-get 13 | # For example, the command below would install "bastet" - a command line tetris clone: 14 | # 15 | # RUN sudo apt-get -q update && # sudo apt-get install -yq bastet && # sudo rm -rf /var/lib/apt/lists/* 16 | # 17 | # More information: https://www.gitpod.io/docs/config-docker/ 18 | -------------------------------------------------------------------------------- /.gitpod.yml: -------------------------------------------------------------------------------- 1 | tasks: 2 | - init: echo "Replace me with a build script for the project." 3 | command: echo "Replace me with something that should run on every start, or just 4 | remove me entirely." 5 | image: 6 | file: .gitpod.Dockerfile 7 | vscode: 8 | extensions: 9 | - axetroy.vscode-deno@3.7.0:YlA2jgY/k6sHhu6khQB+gw== -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "deno.enable": true, 3 | "deno.suggest.imports.hosts": { 4 | "https://deno.land": true 5 | } 6 | } -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM denoland/deno:alpine 2 | 3 | EXPOSE 1995 4 | 5 | WORKDIR /app 6 | 7 | # Prefer not to run as root. 8 | USER deno 9 | 10 | # Cache the dependencies as a layer (this is re-run only when deps.ts is modified). 11 | # Ideally this will download and compile _all_ external files used in mod.ts. 12 | COPY deps.ts . 13 | RUN deno cache deps.ts 14 | 15 | # These steps will be re-run upon each file change in your working directory: 16 | # COPY . . 17 | ADD . . 18 | # Compile the main app so that it doesn't need to be compiled each startup/entry. 19 | RUN deno cache main.ts 20 | 21 | ENV SHELL /bin/sh 22 | 23 | # These are passed as deno arguments when run with docker: 24 | CMD ["run", "--allow-all", "main.ts"] -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Tiny-Devs 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Procfile: -------------------------------------------------------------------------------- 1 | web: deno run --allow-net --allow-read --allow-env main.ts --port=${PORT} 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # [Tiny Land Online](https://diguifi.itch.io/tiny-land) 2 | A Tiny Minimalistic Online RPG Game 🎲 3 | **[Play Now!](https://diguifi.itch.io/tiny-land)** 4 | ![tiny land](https://user-images.githubusercontent.com/31022286/106227466-fc0c9000-61c7-11eb-875e-b1b16aa6425e.png) 5 | 6 | 7 | 8 | ### Getting started 9 | [How to play](https://github.com/tiny-devs/tiny-dungeon-online/wiki/How-to-Play) 10 | [Dev Wiki](https://github.com/tiny-devs/tiny-dungeon-online/wiki) 11 | 12 | Enjoy! 13 | 14 | --- 15 | ⚙️ [Test branch](https://tinyland-dev.herokuapp.com/) 16 | 17 | Deploy commands: 18 | `docker build -t app .` 19 | `heroku container:push web -a=tinyland-dev` 20 | `heroku container:release web -a=tinyland-dev` -------------------------------------------------------------------------------- /client/.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "browser": true, 4 | "es2020": true 5 | }, 6 | "extends": ["plugin:@typescript-eslint/recommended", "standart"], 7 | "parser": "@typescript-eslint/parser", 8 | "parserOptions": { 9 | "ecmaVersion": 11, 10 | "sourceType": "module" 11 | }, 12 | "plugins": ["@typescript-eslint"], 13 | "rules": {} 14 | } 15 | -------------------------------------------------------------------------------- /client/.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "tabWidth": 4, 3 | "semi": false, 4 | "singleQuote": true, 5 | "printWidth": 500 6 | } 7 | -------------------------------------------------------------------------------- /client/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "deno.enable": false 3 | } -------------------------------------------------------------------------------- /client/.yarnrc.yml: -------------------------------------------------------------------------------- 1 | nodeLinker: node-modules 2 | -------------------------------------------------------------------------------- /client/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "tiny-dungeon-online", 3 | "version": "1.1.5", 4 | "main": "src/index.ts", 5 | "repository": "https://github.com/tiny-devs/tiny-dungeon-online", 6 | "license": "MIT", 7 | "scripts": { 8 | "start": "webpack --watch --mode development", 9 | "build": "webpack --mode production" 10 | }, 11 | "devDependencies": { 12 | "@typescript-eslint/eslint-plugin": "^8.12.2", 13 | "@typescript-eslint/parser": "^8.12.2", 14 | "eslint": "^9.13.0", 15 | "ts-loader": "^9.5.1", 16 | "typescript": "^5.6.3", 17 | "webpack": "^5.96.0", 18 | "webpack-cli": "^5.1.4" 19 | }, 20 | "packageManager": "yarn@4.5.1" 21 | } 22 | -------------------------------------------------------------------------------- /client/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiny-devs/tiny-dungeon-online/eb891ea81ed2ad429530506f8249c1002b1b1c20/client/public/favicon.ico -------------------------------------------------------------------------------- /client/public/web_neutral_rd_ctn@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiny-devs/tiny-dungeon-online/eb891ea81ed2ad429530506f8249c1002b1b1c20/client/public/web_neutral_rd_ctn@1x.png -------------------------------------------------------------------------------- /client/src/board/Board.ts: -------------------------------------------------------------------------------- 1 | import { Game } from '../startup/Game' 2 | 3 | export class Board { 4 | private game: Game 5 | private layer: any 6 | 7 | constructor(game: Game, layer: any) { 8 | this.game = game 9 | this.layer = layer 10 | } 11 | 12 | public draw() { 13 | this.layer.clear() 14 | this.layer.ctx.beginPath() 15 | this.layer.ctx.rect(0, 0, this.game.gridConfig.width, this.game.gridConfig.height) 16 | this.layer.ctx.stroke() 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /client/src/board/layers/BackgroundLayer.ts: -------------------------------------------------------------------------------- 1 | import { Game } from '../../startup/Game' 2 | 3 | export class BackgroundLayer { 4 | private game: Game 5 | private ctx: CanvasRenderingContext2D 6 | 7 | constructor(game: Game) { 8 | this.game = game 9 | 10 | const canvas = document.getElementById('background-layer') as HTMLCanvasElement 11 | this.ctx = canvas.getContext('2d')! 12 | this.ctx.shadowOffsetX = 0 13 | this.ctx.shadowOffsetY = 0 14 | this.ctx.shadowBlur = 0 15 | this.ctx.shadowColor = '' 16 | this.ctx.canvas.width = this.game.gridConfig.width 17 | this.ctx.canvas.height = this.game.gridConfig.height 18 | } 19 | 20 | public clear() { 21 | this.ctx.clearRect(0, 0, this.game.gridConfig.width, this.game.gridConfig.height) 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /client/src/board/layers/SolidLayer.ts: -------------------------------------------------------------------------------- 1 | import { Game } from '../../startup/Game' 2 | 3 | export class SolidLayer { 4 | private game: Game 5 | private ctx: CanvasRenderingContext2D 6 | 7 | constructor(game: Game) { 8 | this.game = game 9 | 10 | const canvas = document.getElementById('solid-layer') as HTMLCanvasElement 11 | this.ctx = canvas.getContext('2d')! 12 | this.ctx.shadowOffsetX = 0 13 | this.ctx.shadowOffsetY = 0 14 | this.ctx.shadowBlur = 0 15 | this.ctx.shadowColor = '' 16 | this.ctx.canvas.width = this.game.gridConfig.width 17 | this.ctx.canvas.height = this.game.gridConfig.height 18 | } 19 | 20 | public clear() { 21 | this.ctx.clearRect(0, 0, this.game.gridConfig.width, this.game.gridConfig.height) 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /client/src/board/map/Map.ts: -------------------------------------------------------------------------------- 1 | import { Game } from '../../startup/Game' 2 | import { Direction, Rooms } from '../../../../shared/Enums' 3 | import { MapBuilder } from './MapBuilder' 4 | 5 | export class Map { 6 | public rooms: Array 7 | public mapBuilder: MapBuilder 8 | 9 | constructor(game: Game) { 10 | this.mapBuilder = new MapBuilder(game) 11 | this.rooms = this.mapBuilder.buildMap() 12 | } 13 | 14 | public getRoomById(roomId: Rooms) { 15 | return this.rooms.find((room) => room.id === roomId) || this.rooms[roomId] 16 | } 17 | 18 | public getDirectionMovedByRoomIds(fromRoomId: Rooms, toRoomId: Rooms) { 19 | if (fromRoomId + 1 == toRoomId) 20 | return Direction.Right 21 | if (fromRoomId - 1 == toRoomId) 22 | return Direction.Left 23 | if (fromRoomId < toRoomId) 24 | return Direction.Up 25 | return Direction.Down 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /client/src/board/map/MapBuilder.ts: -------------------------------------------------------------------------------- 1 | import { Game } from '../../startup/Game' 2 | import { Rooms, RoomsInsides } from '../../../../shared/Enums' 3 | import { Room } from './Room' 4 | import { BackgroundLayers, BackgroundLayersInsides } from '../BackgroundLayers' 5 | import { SolidLayers, SolidLayersInsides } from '../../../../shared/solidLayers' 6 | 7 | export class MapBuilder { 8 | private game: Game 9 | 10 | constructor(game: Game) { 11 | this.game = game 12 | } 13 | 14 | public buildMap() { 15 | const map = [] 16 | const solidLayerAny = SolidLayers as any 17 | const enumRoomsAny = Rooms as any 18 | 19 | const solidLayerInsidesAny = SolidLayersInsides as any 20 | const enumRoomsInsidesAny = RoomsInsides as any 21 | 22 | for (const [key, value] of Object.entries(BackgroundLayers)) { 23 | const roomId = enumRoomsAny[key] 24 | const backgroundLayer = value 25 | const solidLayer = solidLayerAny[key] 26 | 27 | map.push(new Room(this.game, roomId, backgroundLayer, solidLayer)) 28 | } 29 | 30 | for (const [key, value] of Object.entries(BackgroundLayersInsides)) { 31 | const roomId = enumRoomsInsidesAny[key] 32 | const backgroundLayer = value 33 | const solidLayer = solidLayerInsidesAny[key] 34 | 35 | map.push(new Room(this.game, roomId, backgroundLayer, solidLayer)) 36 | } 37 | 38 | return map 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /client/src/board/map/Room.ts: -------------------------------------------------------------------------------- 1 | import { Game } from '../../startup/Game' 2 | import { Direction, Rooms } from '../../../../shared/Enums' 3 | import { SolidTiles } from './tiles/Tiles' 4 | import { Tile } from './tiles/Tile' 5 | import { Color } from './tiles/Color' 6 | 7 | export class Room { 8 | public id: Rooms 9 | public backgroundLayerShape: Color[][][][] 10 | public solidLayerShape: (number | (number | Color)[][])[][] 11 | public tiles: Tile[] 12 | 13 | private game: Game 14 | 15 | constructor(game: Game, id: Rooms, backgroundLayer: Color[][][][], solidLayer: (number | (number | Color)[][])[][]) { 16 | this.game = game 17 | this.id = id 18 | 19 | this.backgroundLayerShape = backgroundLayer 20 | this.solidLayerShape = solidLayer 21 | this.tiles = [] 22 | 23 | this.initTiles() 24 | } 25 | 26 | initTiles() { 27 | for (let column = 0; column < this.game.gridConfig.columns; column++) { 28 | const columnTiles = [] 29 | 30 | for (let line = 0; line < this.game.gridConfig.rows; line++) { 31 | let backTile: Tile | null = null 32 | let solidTile: Tile | null = null 33 | 34 | const tileToDrawBackground = this.backgroundLayerShape[line][column] as any 35 | if (tileToDrawBackground != 0) { 36 | backTile = new Tile(this.game, this.game.backgroundLayer, column, line, tileToDrawBackground) 37 | this.tiles.push(backTile) 38 | } 39 | 40 | const tileToDraw = this.solidLayerShape[line][column] as number 41 | if (tileToDraw != 0 && tileToDraw != -1) { 42 | const tiles = SolidTiles as any 43 | const tile = tiles[Object.keys(SolidTiles)[tileToDraw-1]] 44 | 45 | solidTile = new Tile(this.game, this.game.solidLayer, column, line, tile) 46 | this.tiles.push(solidTile) 47 | } 48 | 49 | if (backTile != null) { 50 | columnTiles.push(backTile) 51 | } 52 | if (solidTile != null) { 53 | columnTiles.push(solidTile) 54 | } 55 | 56 | } 57 | } 58 | } 59 | 60 | async draw(lastRoom: Room | undefined = undefined, direction: Direction = 0, isMobile = false) { 61 | if (lastRoom && direction != Direction.None) { 62 | let xModifier = -1 63 | let yModifier = 0 64 | let animationSize = 2.0 65 | 66 | if (direction == Direction.Left) { 67 | yModifier = 0 68 | xModifier = 1 69 | } 70 | if (direction == Direction.Up) { 71 | yModifier = -1 72 | xModifier = 0 73 | } 74 | if (direction == Direction.Down) { 75 | yModifier = 1 76 | xModifier = 0 77 | } 78 | if (isMobile) { 79 | animationSize = 1.0 80 | } 81 | let lastRoomAxisPosition = 0 82 | let currentRoomAxisPosition = this.game.gridConfig.columns 83 | const sleepTime = 32/animationSize 84 | const axisStep = 1.0/animationSize 85 | for (let axisPosition = this.game.gridConfig.columns * animationSize; axisPosition >= 0; axisPosition--) { 86 | 87 | for (let i = 0; i < this.tiles.length; i++) { 88 | this.tiles[i].draw(xModifier * currentRoomAxisPosition, yModifier * currentRoomAxisPosition) 89 | 90 | if (lastRoom.tiles[i]) { 91 | lastRoom.tiles[i].draw(xModifier * lastRoomAxisPosition, yModifier * lastRoomAxisPosition) 92 | } 93 | } 94 | 95 | await this.sleep(sleepTime) 96 | if (axisPosition != 0) { 97 | this.game.solidLayer.clear() 98 | } 99 | lastRoomAxisPosition = lastRoomAxisPosition - axisStep 100 | currentRoomAxisPosition = currentRoomAxisPosition - axisStep 101 | } 102 | } 103 | else { 104 | this.clear() 105 | for (const tile of this.tiles) { 106 | tile.draw() 107 | } 108 | } 109 | } 110 | 111 | sleep(ms: number) { 112 | return new Promise(resolve => setTimeout(resolve, ms)); 113 | } 114 | 115 | clear() { 116 | this.game.backgroundLayer.clear() 117 | this.game.solidLayer.clear() 118 | } 119 | } 120 | -------------------------------------------------------------------------------- /client/src/board/map/tiles/Color.ts: -------------------------------------------------------------------------------- 1 | export enum Color { 2 | White = '#FCFCFC', 3 | White2 = '#F8F8F8', 4 | LightGrey = '#bcbcbc', 5 | Grey = '#787878', 6 | DarkGrey = '#7c7c7c', 7 | Black = '#000000', 8 | 9 | LightRed = '#e40058', 10 | Red = '#a80020', 11 | DarkRed = '#a81000', 12 | Wine = '#881400', 13 | 14 | LightBrown = '#ac7c00', 15 | Brown = '#503000', 16 | 17 | LightOrange = '#f87858', 18 | Orange = '#e45c10', 19 | DarkOrange = '#f83800', 20 | 21 | LightYellow = '#f0d0b0', 22 | LightYellow2 = '#fce0a8', 23 | LightYellow3 = '#f8d878', 24 | Yellow = '#f8b800', 25 | DarkYellow = '#fca044', 26 | 27 | LightGreen = '#b8f8d8', 28 | LightGreen2 = '#b8f8b8', 29 | LightGreen3 = '#d8f878', 30 | LightGreen4 = '#b8f818', 31 | LightGreen5 = '#58f898', 32 | LightGreen6 = '#58d854', 33 | Green = '#00b800', 34 | Green2 = '#00a800', 35 | Green3 = '#00a844', 36 | Green4 = '#007800', 37 | DarkGreen = '#006800', 38 | DarkGreen2 = '#005800', 39 | 40 | GreenBlue = '#00fcfc', 41 | GreenBlue2 = '#00e8d8', 42 | GreenBlue3 = '#008888', 43 | DarkGreenBlue = '#004058', 44 | 45 | LightBlue = '#a4e4fc', 46 | Blue = '#3cbcfc', 47 | Blue2 = '#6888fc', 48 | Blue3 = '#0078f8', 49 | Blue4 = '#0058f8', 50 | DarkBlue = '#0000fc', 51 | DarkBlue2 = '#0000bc', 52 | 53 | LightPurple = '#b8b8f8', 54 | LightPurple2 = '#9878f8', 55 | Purple = '#6844fc', 56 | DarkPurple = '#4428bc', 57 | 58 | LightPink = '#f8d8f8', 59 | LightPink2 = '#d8b8f8', 60 | LightPink3 = '#f8b8f8', 61 | Pink = '#f8a4c0', 62 | Pink2 = '#f878f8', 63 | Pink3 = '#f85898', 64 | DarkPink = '#d800cc', 65 | DarkPink2 = '#940084', 66 | } 67 | 68 | export const PlayerColors = [ 69 | Color.Black, 70 | Color.DarkBlue, 71 | Color.DarkPurple, 72 | Color.Wine, 73 | ] 74 | -------------------------------------------------------------------------------- /client/src/board/map/tiles/Tile.ts: -------------------------------------------------------------------------------- 1 | import { Game } from '../../../startup/Game' 2 | 3 | export class Tile { 4 | public id: number 5 | public x: number 6 | public y: number 7 | 8 | private game: Game | null 9 | private layer: any 10 | private tileMatrix: number[][] 11 | private tileSize: number 12 | 13 | constructor(game: Game, layer: any, x: number, y: number, tile: number[][]) { 14 | this.game = game 15 | this.layer = layer 16 | 17 | this.id = 0 18 | this.x = x 19 | this.y = y 20 | this.tileSize = 8 21 | this.tileMatrix = tile 22 | } 23 | 24 | draw(xOffset: number = 0, yOffset: number = 0) { 25 | this.layer.ctx.beginPath() 26 | 27 | for (let column = 0; column < this.tileSize; column++) { 28 | for (let line = 0; line < this.tileSize; line++) { 29 | const tileColor = this.tileMatrix[line][column] 30 | if (tileColor !== 0) { 31 | this.layer.ctx.fillStyle = tileColor 32 | const startX = ((column * this.game!.gridConfig.cellWidth) / this.tileSize + (this.x - xOffset) * this.game!.gridConfig.cellWidth) | 0 33 | const startY = ((line * this.game!.gridConfig.cellHeight) / this.tileSize + (this.y - yOffset) * this.game!.gridConfig.cellHeight) | 0 34 | const width = this.game!.gridConfig.cellWidth / this.tileSize 35 | const height = this.game!.gridConfig.cellHeight / this.tileSize 36 | this.layer.ctx.fillRect(startX, startY, width, height) 37 | } 38 | } 39 | } 40 | 41 | this.layer.ctx.fill() 42 | } 43 | 44 | clear() { 45 | this.layer.ctx.clearRect(this.x, this.y, this.game!.gridConfig.cellWidth, this.game!.gridConfig.cellHeight) 46 | } 47 | 48 | destroy() { 49 | this.clear() 50 | this.game = null 51 | this.layer = null 52 | this.id = 0 53 | this.x = 0 54 | this.y = 0 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /client/src/contextMenu/ContextMenu.ts: -------------------------------------------------------------------------------- 1 | import { ItemsIds } from "../../../shared/Enums" 2 | import { GameClient } from "../startup/GameClient" 3 | 4 | export default class ContextMenu { 5 | public contextMenuEl: HTMLElement 6 | public contextMenuOptionEls: NodeListOf 7 | public menuVisible: boolean 8 | private client: GameClient 9 | private originTop: number = 0 10 | private originLeft: number = 0 11 | private currentItemId: ItemsIds | null 12 | 13 | constructor(client: GameClient) { 14 | this.client = client 15 | this.contextMenuEl = document.querySelector(".menu")! 16 | this.contextMenuOptionEls = document.querySelectorAll(".menu-option")! 17 | this.menuVisible = false; 18 | this.currentItemId = null 19 | 20 | window.addEventListener("click", _ => { 21 | this.hideMenu() 22 | }) 23 | 24 | this.contextMenuOptionEls.forEach(x => { 25 | x.addEventListener("click", e => { 26 | const eAny = e as any 27 | this.handleOptionSelected(eAny.target.innerHTML) 28 | }) 29 | }) 30 | 31 | window.addEventListener("contextmenu", e => { 32 | e.preventDefault(); 33 | return false; 34 | }) 35 | 36 | window.addEventListener("mousemove", e => { 37 | this.originTop = e.pageY 38 | this.originLeft = e.pageX 39 | }) 40 | } 41 | 42 | public openMenu(itemId: ItemsIds) { 43 | this.currentItemId = itemId 44 | this.setPosition(this.originTop, this.originLeft) 45 | } 46 | 47 | private handleOptionSelected(optionSelected: string) { 48 | if (this.currentItemId != null) { 49 | if (optionSelected == 'Drop') { 50 | this.client.dropItem(this.currentItemId) 51 | } 52 | if (optionSelected == 'Inspect') { 53 | this.client.sendItemInfo(this.currentItemId) 54 | } 55 | } 56 | 57 | this.hideMenu() 58 | } 59 | 60 | private toggleMenu(command: string) { 61 | this.contextMenuEl.style.display = command === "show" ? "block" : "none"; 62 | this.menuVisible = !this.menuVisible; 63 | } 64 | 65 | private setPosition(top: number, left: number) { 66 | this.contextMenuEl.style.left = `${left}px`; 67 | this.contextMenuEl.style.top = `${top}px`; 68 | this.toggleMenu("show"); 69 | } 70 | 71 | private hideMenu() { 72 | this.currentItemId = null 73 | this.toggleMenu("hide") 74 | } 75 | } -------------------------------------------------------------------------------- /client/src/entities/Misc.ts: -------------------------------------------------------------------------------- 1 | import { Color } from '../board/map/tiles/Color' 2 | 3 | export const Misc = { 4 | Exclamation: [[0,0,0,Color.DarkRed,Color.DarkRed,0,0,0], 5 | [0,0,0,Color.DarkRed,Color.DarkRed,0,0,0], 6 | [0,0,0,Color.DarkRed,Color.DarkRed,0,0,0], 7 | [0,0,0,Color.DarkRed,Color.DarkRed,0,0,0], 8 | [0,0,0,Color.DarkRed,Color.DarkRed,0,0,0], 9 | [0,0,0,0,0,0,0,0], 10 | [0,0,0,Color.DarkRed,Color.DarkRed,0,0,0], 11 | [0,0,0,Color.DarkRed,Color.DarkRed,0,0,0],], 12 | } -------------------------------------------------------------------------------- /client/src/entities/items/Bag.ts: -------------------------------------------------------------------------------- 1 | import { ItemsIds } from '../../../../shared/Enums' 2 | import BagItem from "./BagItem" 3 | import { Items } from "./Items" 4 | import { GameClient } from "../../startup/GameClient" 5 | import ContextMenu from '../../contextMenu/ContextMenu' 6 | 7 | export default class Bag { 8 | public items: any[] = [] 9 | public coins: number = 0 10 | public size: number = 24 11 | public playerId: string = '' 12 | public itemsHolderEl: HTMLElement 13 | public coinsEl: HTMLElement 14 | private client: GameClient 15 | private itemsCount: number = 0 16 | private contextMenu: ContextMenu 17 | 18 | constructor(client: GameClient) { 19 | this.contextMenu = new ContextMenu(client) 20 | this.itemsHolderEl = document.getElementById('items')! 21 | this.coinsEl = document.getElementById('coins')! 22 | this.client = client 23 | } 24 | 25 | public drawItems() { 26 | for (const item of this.items) { 27 | item.draw() 28 | } 29 | } 30 | 31 | public addGold(amount: number) { 32 | this.coins += amount 33 | this.coinsEl.innerHTML = `GP: ${this.coins}` 34 | } 35 | 36 | public setGold(currentGold: number) { 37 | this.coins = currentGold 38 | this.coinsEl.innerHTML = `GP: ${this.coins}` 39 | } 40 | 41 | public addItem(itemId: ItemsIds, coins: number, playerId: string) { 42 | if (this.playerId == playerId) { 43 | if (itemId == ItemsIds.Coin) { 44 | this.addGold(coins) 45 | } else { 46 | if (this.items.length < this.size) { 47 | this.itemsCount++ 48 | const itemSprite = this.getItemSprite(itemId) 49 | const canvasId = this.addCanvasNode(itemId) 50 | this.items.push(new BagItem(this,itemId,itemSprite,canvasId)) 51 | this.drawItems() 52 | } 53 | } 54 | } 55 | } 56 | 57 | public clickItem(e: Partial, itemId: ItemsIds) { 58 | if (e.type === 'mouseup') { 59 | if (e.type === 'mouseup') { 60 | if (e.button == 0) { 61 | this.client.useItem(itemId) 62 | } else if (e.button == 2) { 63 | this.contextMenu.openMenu(itemId) 64 | } 65 | } else { 66 | this.client.useItem(itemId) 67 | } 68 | } else if (e.type === 'touchmove') { 69 | this.contextMenu.openMenu(itemId) 70 | } 71 | } 72 | 73 | public removeItem(itemId: ItemsIds) { 74 | if (itemId != ItemsIds.Empty) { 75 | const index = this.items.map(item => { return item.itemId; }).indexOf(itemId); 76 | const canvasId = this.items[index]?.layer.canvasId 77 | if (index > -1) { 78 | this.items.splice(index, 1); 79 | } 80 | if (canvasId) { 81 | const canvasBtn = document.getElementById(canvasId)! 82 | this.itemsHolderEl.removeChild(canvasBtn) 83 | } 84 | } 85 | } 86 | 87 | public removeAllItems() { 88 | for (let i=0; i < this.size; i++) { 89 | const anyItemAtPosition = this.items[i] != undefined && this.items[i] != null 90 | if (anyItemAtPosition) { 91 | const canvasId = this.items[i].layer.canvasId 92 | const canvasBtn = document.getElementById(canvasId)! 93 | this.itemsHolderEl.removeChild(canvasBtn) 94 | } 95 | } 96 | this.items.splice(0); 97 | } 98 | 99 | public getItemSprite(itemId: ItemsIds) { 100 | let keyOfItemId = ItemsIds[itemId] 101 | let items = Items as any 102 | return items[keyOfItemId] 103 | } 104 | 105 | private addCanvasNode(itemId: ItemsIds): string { 106 | let elementId = `${itemId}-${this.itemsCount}` 107 | let newButton = document.createElement('canvas') 108 | newButton.classList.add('item-btn'); 109 | newButton.id = elementId 110 | newButton.onmouseup = (e) => this.clickItem(e, itemId) 111 | newButton.ontouchstart = (e) => this.clickItem(e, itemId) 112 | newButton.ontouchmove = (e) => this.clickItem(e, itemId) 113 | newButton.oncontextmenu = () => false 114 | this.itemsHolderEl.appendChild(newButton) 115 | this.organizeBag(); 116 | return elementId 117 | } 118 | 119 | private organizeBag(): void { 120 | const inventoryList = Array.from(this.itemsHolderEl.childNodes); 121 | 122 | this.itemsHolderEl.textContent = ''; 123 | 124 | inventoryList.sort((a, b) => +a.id.split('-')[0] - +b.id.split('-')[0]).forEach(item => { 125 | this.itemsHolderEl.appendChild(item); 126 | }); 127 | } 128 | } -------------------------------------------------------------------------------- /client/src/entities/items/BagItem.ts: -------------------------------------------------------------------------------- 1 | import { ItemsIds } from '../../../../shared/Enums' 2 | import Bag from "./Bag" 3 | import ItemCanvas from "./ItemCanvas" 4 | 5 | export default class BagItem { 6 | public itemId: number 7 | public bag: Bag 8 | public item: any 9 | public tileSize: number = 8 10 | public layer: ItemCanvas 11 | 12 | constructor(bag: any, itemId: ItemsIds, item: any, itemCanvasId: string) { 13 | this.bag = bag 14 | this.itemId = itemId 15 | this.item = item 16 | this.layer = new ItemCanvas(itemCanvasId) 17 | } 18 | 19 | draw() { 20 | this.layer.ctx.beginPath(); 21 | 22 | for (let column = 0; column < this.tileSize; column++) { 23 | for (let line = 0; line < this.tileSize; line++) { 24 | const tileColor = this.item[line][column] 25 | if (tileColor !== 0) { 26 | this.layer.ctx.fillStyle = tileColor 27 | const startX = (column * this.layer.cellWidth / this.tileSize) | 0 28 | const startY = (line * this.layer.cellHeight / this.tileSize) | 0 29 | const width = (this.layer.cellWidth / this.tileSize) 30 | const height = (this.layer.cellHeight / this.tileSize) 31 | this.layer.ctx.fillRect(startX, startY, width, height) 32 | } 33 | } 34 | } 35 | 36 | this.layer.ctx.fill() 37 | } 38 | 39 | destroy() { 40 | this.layer = null! 41 | this.itemId = null! 42 | this.draw = null! 43 | } 44 | } -------------------------------------------------------------------------------- /client/src/entities/items/Gear.ts: -------------------------------------------------------------------------------- 1 | import { ItemsIds, GearType } from '../../../../shared/Enums' 2 | import { Items } from "./Items" 3 | import { GameClient } from "../../startup/GameClient" 4 | import GearItem from "./GearItem" 5 | 6 | export default class Gear { 7 | public head: GearItem 8 | public torso: GearItem 9 | public legs: GearItem 10 | public weapon: GearItem 11 | public playerId: string = '' 12 | private client: GameClient 13 | 14 | constructor(client: GameClient) { 15 | this.head = new GearItem(this,ItemsIds.Empty,Items.Empty,'head') 16 | this.torso = new GearItem(this,ItemsIds.Empty,Items.Empty,'torso') 17 | this.legs = new GearItem(this,ItemsIds.Empty,Items.Empty,'legs') 18 | this.weapon = new GearItem(this,ItemsIds.Empty,Items.Empty,'weapon') 19 | 20 | this.head.layer.c.onmousedown = (e) => this.clickItem(e, this.head) 21 | this.torso.layer.c.onmousedown = (e) => this.clickItem(e, this.torso) 22 | this.legs.layer.c.onmousedown = (e) => this.clickItem(e, this.legs) 23 | this.weapon.layer.c.onmousedown = (e) => this.clickItem(e, this.weapon) 24 | 25 | this.head.layer.c.ontouchstart = (e) => this.clickItem(e, this.head) 26 | this.torso.layer.c.ontouchstart = (e) => this.clickItem(e, this.torso) 27 | this.legs.layer.c.ontouchstart = (e) => this.clickItem(e, this.legs) 28 | this.weapon.layer.c.ontouchstart = (e) => this.clickItem(e, this.weapon) 29 | 30 | this.head.layer.c.oncontextmenu = () => false 31 | this.torso.layer.c.oncontextmenu = () => false 32 | this.legs.layer.c.oncontextmenu = () => false 33 | this.weapon.layer.c.oncontextmenu = () => false 34 | 35 | this.client = client 36 | this.drawGear() 37 | } 38 | 39 | public drawGear() { 40 | this.head.draw() 41 | this.torso.draw() 42 | this.legs.draw() 43 | this.weapon.draw() 44 | } 45 | 46 | public addGear(itemId: ItemsIds, gearType: GearType) { 47 | switch (gearType) { 48 | case GearType.Head: 49 | if (this.head.itemId == ItemsIds.Empty) { 50 | this.head.changeGear(itemId, this.getItemSprite(itemId)) 51 | } 52 | break; 53 | case GearType.Torso: 54 | if (this.torso.itemId == ItemsIds.Empty) { 55 | this.torso.changeGear(itemId, this.getItemSprite(itemId)) 56 | } 57 | break; 58 | case GearType.Legs: 59 | if (this.legs.itemId == ItemsIds.Empty) { 60 | this.legs.changeGear(itemId, this.getItemSprite(itemId)) 61 | } 62 | break; 63 | case GearType.Weapon: 64 | if (this.weapon.itemId == ItemsIds.Empty) { 65 | this.weapon.changeGear(itemId, this.getItemSprite(itemId)) 66 | } 67 | break; 68 | default: 69 | break; 70 | } 71 | this.drawGear() 72 | } 73 | 74 | public clickItem(e: Partial, item: any) { 75 | if (item.itemId != ItemsIds.Empty) { 76 | if ( 77 | e.type === 'mousedown' || 78 | e.type === 'touchstart' || 79 | e.type === 'touchmove' 80 | ) { 81 | if (e.type === 'mousedown') { 82 | if (e.button == 0) { 83 | this.client.removeGear(item.itemId) 84 | } 85 | } else { 86 | this.client.removeGear(item.itemId) 87 | } 88 | } 89 | } 90 | } 91 | 92 | public removeGear(itemId: ItemsIds) { 93 | if (this.head.itemId == itemId) { 94 | this.head.changeGear(ItemsIds.Empty, this.getItemSprite(ItemsIds.Empty)) 95 | } 96 | if (this.torso.itemId == itemId) { 97 | this.torso.changeGear(ItemsIds.Empty, this.getItemSprite(ItemsIds.Empty)) 98 | } 99 | if (this.legs.itemId == itemId) { 100 | this.legs.changeGear(ItemsIds.Empty, this.getItemSprite(ItemsIds.Empty)) 101 | } 102 | if (this.weapon.itemId == itemId) { 103 | this.weapon.changeGear(ItemsIds.Empty, this.getItemSprite(ItemsIds.Empty)) 104 | } 105 | this.drawGear() 106 | } 107 | 108 | private getItemSprite(itemId: ItemsIds) { 109 | let keyOfItemId = ItemsIds[itemId] 110 | let items = Items as any 111 | return items[keyOfItemId] 112 | } 113 | } -------------------------------------------------------------------------------- /client/src/entities/items/GearItem.ts: -------------------------------------------------------------------------------- 1 | import { ItemsIds } from '../../../../shared/Enums' 2 | import Gear from "./Gear" 3 | import IconCanvas from "./IconCanvas" 4 | 5 | export default class GearItem { 6 | public itemId: number 7 | public item: any 8 | public gear: Gear 9 | public tileSize: number = 8 10 | public layer: IconCanvas 11 | 12 | constructor(gear: any, itemId: ItemsIds, item: any, itemCanvasId: string) { 13 | this.gear = gear 14 | this.itemId = itemId 15 | this.item = item 16 | this.layer = new IconCanvas(itemCanvasId) 17 | } 18 | 19 | draw() { 20 | this.layer.ctx.beginPath(); 21 | 22 | for (let column = 0; column < this.tileSize; column++) { 23 | for (let line = 0; line < this.tileSize; line++) { 24 | const tileColor = this.item[line][column] 25 | if (tileColor !== 0) { 26 | this.layer.ctx.fillStyle = tileColor 27 | const startX = (column * this.layer.cellWidth / this.tileSize) | 0 28 | const startY = (line * this.layer.cellHeight / this.tileSize) | 0 29 | const width = (this.layer.cellWidth / this.tileSize) 30 | const height = (this.layer.cellHeight / this.tileSize) 31 | this.layer.ctx.fillRect(startX, startY, width, height) 32 | } 33 | } 34 | } 35 | 36 | this.layer.ctx.fill() 37 | } 38 | 39 | clear() { 40 | this.layer.ctx.clearRect(0, 0, this.layer.cellWidth, this.layer.cellHeight) 41 | } 42 | 43 | changeGear(itemId: ItemsIds, item: any) { 44 | this.clear() 45 | this.itemId = itemId 46 | this.item = item 47 | } 48 | 49 | destroy() { 50 | this.layer = null! 51 | this.itemId = null! 52 | this.draw = null! 53 | } 54 | } -------------------------------------------------------------------------------- /client/src/entities/items/IconCanvas.ts: -------------------------------------------------------------------------------- 1 | export default class IconCanvas { 2 | public c: HTMLCanvasElement 3 | public ctx: CanvasRenderingContext2D 4 | public width: number = 32 5 | public height: number = 32 6 | public boardRows: number = 1 7 | public boardColumns: number = 1 8 | public cellWidth: number 9 | public cellHeight: number 10 | public canvasId: string 11 | 12 | constructor(canvasId: string) { 13 | this.canvasId = canvasId 14 | this.c = document.getElementById(canvasId) as HTMLCanvasElement 15 | this.ctx = this.c.getContext('2d')! 16 | this.ctx.canvas.width = this.width 17 | this.ctx.canvas.height = this.height 18 | this.boardRows = 1 19 | this.boardColumns = 1 20 | this.ctx.canvas.width = this.width 21 | this.ctx.canvas.height = this.height 22 | this.cellWidth = this.width/this.boardRows 23 | this.cellHeight = this.height/this.boardColumns 24 | this.c.oncontextmenu = (e) => {return false} 25 | } 26 | } -------------------------------------------------------------------------------- /client/src/entities/items/Item.ts: -------------------------------------------------------------------------------- 1 | import { Game } from '../../startup/Game' 2 | import { Rooms } from '../../../../shared/Enums' 3 | import { ItemsIds } from '../../../../shared/Enums' 4 | 5 | export class Item { 6 | public id: number 7 | public itemId: ItemsIds 8 | public roomId: Rooms 9 | public x: number 10 | public y: number 11 | public itemMatrix: any[] 12 | private game: Game 13 | private layer: any 14 | private tileSize: number 15 | 16 | constructor(game: Game, layer: any, itemData: Partial, itemMatrix: any[]) { 17 | this.game = game 18 | this.layer = layer 19 | 20 | this.id = itemData.id! 21 | this.itemId = itemData.itemId! 22 | this.roomId = itemData.roomId! 23 | this.x = itemData.x! 24 | this.y = itemData.y! 25 | this.tileSize = 8 26 | this.itemMatrix = [...itemMatrix] 27 | } 28 | 29 | draw() { 30 | this.layer.ctx.beginPath() 31 | 32 | for (let column = 0; column < this.tileSize; column++) { 33 | for (let line = 0; line < this.tileSize; line++) { 34 | const tileColor = this.itemMatrix[line][column] 35 | if (tileColor !== 0) { 36 | this.layer.ctx.fillStyle = tileColor 37 | const startX = ((column * this.game.gridConfig.cellWidth) / this.tileSize + this.x * this.game.gridConfig.cellWidth) | 0 38 | const startY = ((line * this.game.gridConfig.cellHeight) / this.tileSize + this.y * this.game.gridConfig.cellHeight) | 0 39 | const width = this.game.gridConfig.cellWidth / this.tileSize 40 | const height = this.game.gridConfig.cellHeight / this.tileSize 41 | this.layer.ctx.fillRect(startX, startY, width, height) 42 | } 43 | } 44 | } 45 | 46 | this.layer.ctx.fill() 47 | } 48 | 49 | clear() { 50 | this.layer.ctx.clearRect(this.x * this.game.gridConfig.cellWidth, this.y * this.game.gridConfig.cellHeight, this.game.gridConfig.cellWidth, this.game.gridConfig.cellHeight) 51 | } 52 | 53 | destroy() { 54 | this.clear() 55 | this.layer = null 56 | this.id = 0 57 | this.x = 0 58 | this.y = 0 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /client/src/entities/items/ItemCanvas.ts: -------------------------------------------------------------------------------- 1 | export default class ItemCanvas { 2 | public c: HTMLCanvasElement 3 | public ctx: CanvasRenderingContext2D 4 | public width: number = 32 5 | public height: number = 32 6 | public boardRows: number = 1 7 | public boardColumns: number = 1 8 | public cellWidth: number 9 | public cellHeight: number 10 | public canvasId: string 11 | 12 | constructor(canvasId: string) { 13 | this.canvasId = canvasId 14 | this.c = document.getElementById(canvasId) as HTMLCanvasElement 15 | this.ctx = this.c.getContext('2d')! 16 | this.ctx.canvas.width = this.width 17 | this.ctx.canvas.height = this.height 18 | this.boardRows = 1 19 | this.boardColumns = 1 20 | this.ctx.canvas.width = this.width 21 | this.ctx.canvas.height = this.height 22 | this.cellWidth = this.width/this.boardRows 23 | this.cellHeight = this.height/this.boardColumns 24 | this.c.oncontextmenu = (e) => {return false} 25 | } 26 | } -------------------------------------------------------------------------------- /client/src/entities/items/StoreItem.ts: -------------------------------------------------------------------------------- 1 | import { Color } from "../../board/map/tiles/Color" 2 | import { ItemsIds } from '../../../../shared/Enums' 3 | import ItemCanvas from "./ItemCanvas" 4 | import Store from "./Store" 5 | 6 | export default class StoreItem { 7 | public itemId: number 8 | public itemPrice: number 9 | public store: Store 10 | public item: any 11 | public tileSize: number = 8 12 | public layer: ItemCanvas 13 | 14 | constructor(bag: any, itemId: ItemsIds, item: any, itemCanvasId: string, itemPrice: number) { 15 | this.store = bag 16 | this.itemId = itemId 17 | this.itemPrice = itemPrice 18 | this.item = item 19 | this.layer = new ItemCanvas(itemCanvasId) 20 | } 21 | 22 | draw(isPlayerBuying: boolean) { 23 | this.layer.ctx.beginPath(); 24 | 25 | for (let column = 0; column < this.tileSize; column++) { 26 | for (let line = 0; line < this.tileSize; line++) { 27 | const tileColor = this.item[line][column] 28 | if (tileColor !== 0) { 29 | this.layer.ctx.fillStyle = tileColor 30 | const startX = (column * this.layer.cellWidth / this.tileSize) | 0 31 | const startY = (line * this.layer.cellHeight / this.tileSize) | 0 32 | const width = (this.layer.cellWidth / this.tileSize) 33 | const height = (this.layer.cellHeight / this.tileSize) 34 | this.layer.ctx.fillRect(startX, startY, width, height) 35 | } 36 | } 37 | } 38 | 39 | this.layer.ctx.fill() 40 | 41 | let priceTag = document.createElement('div') 42 | priceTag.innerHTML = `${this.itemPrice}` 43 | priceTag.style.textAlign = 'center' 44 | priceTag.style.maxWidth = '32px' 45 | priceTag.style.marginBottom = '5px' 46 | if (isPlayerBuying) { 47 | priceTag.style.color = Color.Red 48 | } else { 49 | priceTag.style.color = Color.Green 50 | } 51 | 52 | this.layer.c.parentNode!.appendChild(priceTag) 53 | } 54 | 55 | destroy() { 56 | this.layer = null! 57 | this.itemId = null! 58 | this.draw = null! 59 | } 60 | } -------------------------------------------------------------------------------- /client/src/index.ts: -------------------------------------------------------------------------------- 1 | import { Main } from './startup/Main' 2 | import { ClientConfig, GridConfig } from './models/configs' 3 | 4 | const gameConfig: ClientConfig = { 5 | game: { 6 | width: 512, 7 | height: 512, 8 | }, 9 | drawingGrid: new GridConfig({ 10 | width: 160, 11 | height: 160, 12 | rows: 8, 13 | columns: 8, 14 | }), 15 | } 16 | 17 | new Main(gameConfig) 18 | -------------------------------------------------------------------------------- /client/src/models/configs/ClientConfig.ts: -------------------------------------------------------------------------------- 1 | import IconCanvas from "../../entities/items/IconCanvas" 2 | 3 | export class ClientConfig { 4 | public game = new DimensionsConfig() 5 | public drawingGrid = new GridConfig() 6 | } 7 | 8 | export class DimensionsConfig { 9 | public width = 0 10 | public height = 0 11 | } 12 | 13 | export class GridConfig { 14 | public width = 0 15 | public height = 0 16 | public rows = 0 17 | public columns = 0 18 | 19 | constructor(init?: Partial) { 20 | Object.assign(this, init) 21 | } 22 | 23 | public get cellWidth(): number { 24 | return this.width / this.rows 25 | } 26 | 27 | public get cellHeight(): number { 28 | return this.height / this.columns 29 | } 30 | } 31 | 32 | export default class TinyIcon { 33 | public matrix: any 34 | public tileSize: number = 8 35 | public layer: IconCanvas 36 | public defaultColor: string 37 | 38 | constructor(matrix: any, canvasId: string, defaultColor: string) { 39 | this.defaultColor = defaultColor 40 | this.matrix = matrix 41 | this.layer = new IconCanvas(canvasId) 42 | this.draw() 43 | } 44 | 45 | draw() { 46 | this.layer.ctx.beginPath(); 47 | 48 | for (let column = 0; column < this.tileSize; column++) { 49 | for (let line = 0; line < this.tileSize; line++) { 50 | const tileColor = this.matrix[line][column] 51 | if (tileColor !== 0) { 52 | this.layer.ctx.fillStyle = this.defaultColor ? this.defaultColor : tileColor 53 | const startX = (column * this.layer.cellWidth / this.tileSize) | 0 54 | const startY = (line * this.layer.cellHeight / this.tileSize) | 0 55 | const width = (this.layer.cellWidth / this.tileSize) 56 | const height = (this.layer.cellHeight / this.tileSize) 57 | this.layer.ctx.fillRect(startX, startY, width, height) 58 | } 59 | } 60 | } 61 | 62 | this.layer.ctx.fill() 63 | } 64 | 65 | clear() { 66 | this.layer.ctx.clearRect(0, 0, this.layer.cellWidth, this.layer.cellHeight) 67 | } 68 | 69 | destroy() { 70 | this.layer = null! 71 | this.draw = null! 72 | } 73 | } -------------------------------------------------------------------------------- /client/src/models/configs/PlayerConfig.ts: -------------------------------------------------------------------------------- 1 | export type PlayerConfig = { 2 | playerName: string 3 | playerMatrix: number[][] 4 | } 5 | -------------------------------------------------------------------------------- /client/src/models/configs/index.ts: -------------------------------------------------------------------------------- 1 | export * from './ClientConfig' 2 | export * from './PlayerConfig' 3 | -------------------------------------------------------------------------------- /client/src/parser/ParseBoughtItem.ts: -------------------------------------------------------------------------------- 1 | import { ItemsIds } from '../../../shared/Enums' 2 | 3 | export class ParseBoughtItem { 4 | public success: boolean 5 | public message: string 6 | public itemId: ItemsIds 7 | public currentCoins: number 8 | 9 | constructor(data: string) { 10 | const pickData = this.parseString(data) 11 | 12 | this.success = pickData[1] === 'true' 13 | if (this.success) { 14 | this.message = 'Success' 15 | this.itemId = +pickData[3] 16 | this.currentCoins = +pickData[4] 17 | } else { 18 | this.message = pickData[2] 19 | this.itemId = 0 20 | this.currentCoins = 0 21 | } 22 | } 23 | 24 | private parseString(eventDataString: string) { 25 | return eventDataString.split(',') 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /client/src/parser/ParseChat.ts: -------------------------------------------------------------------------------- 1 | export class ParseChat { 2 | public message: string 3 | public playerId: string 4 | 5 | constructor(data: string) { 6 | const chatData = this.parseString(data) 7 | 8 | this.playerId = chatData[0] 9 | this.message = chatData[1] 10 | } 11 | 12 | private parseString(eventDataString: string) { 13 | const indexFirstQuotes = eventDataString.indexOf(',"')+2 14 | const playerId = eventDataString.split(',')[1] 15 | const indexLastQuotes = eventDataString.split(',"')[1].indexOf('"')+indexFirstQuotes 16 | const returnData = [playerId, eventDataString.substring(indexFirstQuotes, indexLastQuotes)] 17 | return returnData 18 | } 19 | } -------------------------------------------------------------------------------- /client/src/parser/ParseDialog.ts: -------------------------------------------------------------------------------- 1 | export class ParseDialog { 2 | public message: string 3 | 4 | constructor(data: string) { 5 | const dialogData = this.parseString(data) 6 | 7 | this.message = dialogData 8 | } 9 | 10 | private parseString(eventDataString: string) { 11 | const indexFirstQuotes = eventDataString.indexOf(',"')+2 12 | const indexLastQuotes = eventDataString.split(',"')[1].indexOf('"')+indexFirstQuotes 13 | return eventDataString.substring(indexFirstQuotes, indexLastQuotes) 14 | } 15 | } -------------------------------------------------------------------------------- /client/src/parser/ParseEntityInfo.ts: -------------------------------------------------------------------------------- 1 | import { ItemsIds } from '../../../shared/Enums' 2 | 3 | export class ParseEntityInfo { 4 | public name: string 5 | public level: number 6 | public attack: number 7 | public defense: number 8 | public npcId: number 9 | public items: string[] 10 | public isNpc: boolean 11 | public isItem: boolean 12 | public itemType: number 13 | public healthRefuel: number 14 | 15 | constructor(data: string) { 16 | const entityInfoData = this.parseString(data) 17 | 18 | this.isItem = entityInfoData[1] == '-1' 19 | if (this.isItem) { 20 | this.name = ItemsIds[Number(entityInfoData[2])] 21 | this.level = Number(entityInfoData[3]) 22 | this.attack = Number(entityInfoData[4]) 23 | this.defense = Number(entityInfoData[5]) 24 | this.npcId = Number(entityInfoData[2]) 25 | this.isNpc = false 26 | this.items = [] 27 | this.itemType = Number(entityInfoData[6]) 28 | this.healthRefuel = Number(entityInfoData[7]) 29 | } else { 30 | this.name = entityInfoData[1] 31 | this.level = Number(entityInfoData[2]) 32 | this.attack = Number(entityInfoData[3]) 33 | this.defense = Number(entityInfoData[4]) 34 | this.npcId = Number(entityInfoData[5]) 35 | this.isNpc = Number(entityInfoData[6]) === 1 36 | this.items = entityInfoData.map(x => ItemsIds[Number(x)]).slice(7) 37 | this.itemType = 0 38 | this.healthRefuel = 0 39 | } 40 | } 41 | 42 | private parseString(eventDataString: string) { 43 | return eventDataString.split(',').filter(x => x !== '') 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /client/src/parser/ParseError.ts: -------------------------------------------------------------------------------- 1 | export class ParseError { 2 | public message: string 3 | 4 | constructor(data: string) { 5 | const errorData = this.parseString(data) 6 | 7 | this.message = errorData[1] 8 | } 9 | 10 | private parseString(eventDataString: string) { 11 | return eventDataString.split(',') 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /client/src/parser/ParseGoldDroped.ts: -------------------------------------------------------------------------------- 1 | export class ParseGoldDroped { 2 | public amount: number 3 | 4 | constructor(data: string) { 5 | const dropedData = this.parseString(data) 6 | 7 | this.amount = +dropedData[1] 8 | } 9 | 10 | private parseString(eventDataString: string) { 11 | return eventDataString.split(',') 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /client/src/parser/ParseHidePlayer.ts: -------------------------------------------------------------------------------- 1 | export class ParseHidePlayer { 2 | public playerId: string 3 | public roomId: number 4 | 5 | constructor(data: string) { 6 | const hideData = this.parseString(data) 7 | 8 | this.playerId = hideData[1] 9 | this.roomId = +hideData[2] 10 | } 11 | 12 | private parseString(eventDataString: string) { 13 | return eventDataString.split(',') 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /client/src/parser/ParseItemDrop.ts: -------------------------------------------------------------------------------- 1 | import { ItemsIds } from '../../../shared/Enums' 2 | 3 | export class ParseItemDrop { 4 | public id: number 5 | public itemId: ItemsIds 6 | public roomId: number 7 | public x: number 8 | public y: number 9 | 10 | constructor(data: string) { 11 | const dropData = this.parseString(data) 12 | 13 | this.id = +dropData[1] 14 | this.itemId = +dropData[2] 15 | this.roomId = +dropData[3] 16 | this.x = +dropData[4] 17 | this.y = +dropData[5] 18 | } 19 | 20 | private parseString(eventDataString: string) { 21 | return eventDataString.split(',') 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /client/src/parser/ParseItemDroped.ts: -------------------------------------------------------------------------------- 1 | import { ItemsIds } from '../../../shared/Enums' 2 | 3 | export class ParseItemDroped { 4 | public itemId: ItemsIds 5 | 6 | constructor(data: string) { 7 | const dropedData = this.parseString(data) 8 | 9 | this.itemId = +dropedData[1] 10 | } 11 | 12 | private parseString(eventDataString: string) { 13 | return eventDataString.split(',') 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /client/src/parser/ParseItemPick.ts: -------------------------------------------------------------------------------- 1 | import { ItemsIds } from '../../../shared/Enums' 2 | 3 | export class ParseItemPick { 4 | public playerId: string 5 | public itemId: ItemsIds 6 | public coins: number 7 | public x: number 8 | public y: number 9 | 10 | constructor(data: string) { 11 | const pickData = this.parseString(data) 12 | 13 | this.playerId = pickData[1] 14 | this.itemId = +pickData[2] 15 | this.coins = +pickData[3] 16 | this.x = +pickData[4] 17 | this.y = +pickData[5] 18 | } 19 | 20 | private parseString(eventDataString: string) { 21 | return eventDataString.split(',') 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /client/src/parser/ParseItemRemove.ts: -------------------------------------------------------------------------------- 1 | import { ItemsIds } from '../../../shared/Enums' 2 | 3 | export class ParseItemRemove { 4 | public itemId: ItemsIds 5 | 6 | constructor(data: string) { 7 | const removeData = this.parseString(data) 8 | 9 | this.itemId = +removeData[1] 10 | } 11 | 12 | private parseString(eventDataString: string) { 13 | return eventDataString.split(',') 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /client/src/parser/ParseItemUse.ts: -------------------------------------------------------------------------------- 1 | import { ItemsIds } from '../../../shared/Enums' 2 | 3 | export class ParseItemUse { 4 | public itemId: ItemsIds 5 | 6 | constructor(data: string) { 7 | const itemId = this.parseString(data) 8 | 9 | this.itemId = itemId 10 | } 11 | 12 | private parseString(eventDataString: string): ItemsIds { 13 | let itemIdString = eventDataString.split(',') 14 | let itemId = +itemIdString[1] 15 | 16 | return itemId 17 | } 18 | } -------------------------------------------------------------------------------- /client/src/parser/ParseItemWear.ts: -------------------------------------------------------------------------------- 1 | import { ItemsIds, GearType } from '../../../shared/Enums' 2 | 3 | export class ParseItemWear { 4 | public itemId: ItemsIds 5 | public gearType: GearType 6 | 7 | constructor(data: string) { 8 | const wearData = this.parseString(data) 9 | 10 | this.itemId = +wearData[1] 11 | this.gearType = +wearData[2] 12 | } 13 | 14 | private parseString(eventDataString: string) { 15 | return eventDataString.split(',') 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /client/src/parser/ParseItemsInRoom.ts: -------------------------------------------------------------------------------- 1 | export class ParseItemsInRoom { 2 | public items: ItemDto[] 3 | 4 | constructor(data: string) { 5 | this.items = this.parseString(data) 6 | } 7 | 8 | private parseString(eventDataString: string): ItemDto[] 9 | { 10 | const splitted = eventDataString.split(',') 11 | const npcsInRoomRaw = splitted.slice(2).filter(x => x !== '') 12 | const npcsInRoomRawMatrix = npcsInRoomRaw.map(x => x.split('@')) 13 | let npcsInRoomList: ItemDto[] = [] 14 | for (const u of npcsInRoomRawMatrix) { 15 | npcsInRoomList.push(new ItemDto( 16 | Number(u[0]), 17 | Number(u[1]), 18 | Number(splitted[1]), 19 | Number(u[2]), 20 | Number(u[3]))) 21 | } 22 | 23 | return npcsInRoomList 24 | } 25 | } 26 | 27 | export class ItemDto { 28 | constructor(public id: number, 29 | public itemId: number, 30 | public roomId: number, 31 | public x: number, 32 | public y: number) { 33 | this.id = id 34 | this.itemId = itemId 35 | this.roomId = roomId 36 | this.x = x 37 | this.y = y 38 | } 39 | } -------------------------------------------------------------------------------- /client/src/parser/ParseLoad.ts: -------------------------------------------------------------------------------- 1 | import { ItemsIds } from '../../../shared/Enums' 2 | 3 | export class ParseLoad { 4 | public id: string 5 | public hp: number 6 | public maxHp: number 7 | public attack: number 8 | public defense: number 9 | public level: number 10 | public xp: number 11 | public xpNeeded: number 12 | public gameVersion: number 13 | public totalCoins: number 14 | public itemsIds: ItemsIds[] 15 | public gearHead: ItemsIds | null 16 | public gearTorso: ItemsIds | null 17 | public gearLegs: ItemsIds | null 18 | public gearWeapon: ItemsIds | null 19 | 20 | constructor(data: string) { 21 | const parsedData = this.parseString(data) 22 | 23 | this.id = parsedData[0][1] 24 | this.hp = +parsedData[0][2] 25 | this.maxHp = +parsedData[0][3] 26 | this.attack = +parsedData[0][4] 27 | this.defense = +parsedData[0][5] 28 | this.level = +parsedData[0][6] 29 | this.xp = +parsedData[0][7] 30 | this.xpNeeded = +parsedData[0][8] 31 | this.gameVersion = +parsedData[0][9] 32 | 33 | this.totalCoins = +parsedData[3][0] 34 | this.itemsIds = parsedData[1] 35 | 36 | if (parsedData[2][0] != -1) { 37 | this.gearHead = parsedData[2][0] 38 | } else { 39 | this.gearHead = null 40 | } 41 | if (parsedData[2][1] != -1) { 42 | this.gearTorso = parsedData[2][1] 43 | } else { 44 | this.gearTorso = null 45 | } 46 | if (parsedData[2][2] != -1) { 47 | this.gearLegs = parsedData[2][2] 48 | } else { 49 | this.gearLegs = null 50 | } 51 | if (parsedData[2][3] != -1) { 52 | this.gearWeapon = parsedData[2][3] 53 | } else { 54 | this.gearWeapon = null 55 | } 56 | } 57 | 58 | private parseString(eventDataString: string): any[][] { 59 | const allData = eventDataString.split('@') 60 | 61 | const statsData = allData[0].split(',') 62 | 63 | const coins = allData[1].split(';')[0] 64 | const itemsDataString = allData[1].split(';')[1] 65 | let itemsData = [] 66 | if (itemsDataString) { 67 | const itemsDataStrings = itemsDataString.split(',') 68 | for (const itemId of itemsDataStrings) { 69 | if (itemId != '') { 70 | itemsData.push(+itemId) 71 | } 72 | } 73 | } 74 | 75 | let gearData = [] 76 | if (allData[2]) { 77 | for (let i=2; i<6;i++) { 78 | if (allData[i] != 'empty') { 79 | gearData.push(+allData[i]) 80 | } else { 81 | gearData.push(-1) 82 | } 83 | } 84 | } 85 | 86 | return [statsData,itemsData,gearData,[coins]] 87 | } 88 | } -------------------------------------------------------------------------------- /client/src/parser/ParseLoadBag.ts: -------------------------------------------------------------------------------- 1 | import { ItemsIds } from '../../../shared/Enums' 2 | 3 | export class ParseLoadBag { 4 | public id: string 5 | public itemsIds: ItemsIds[] 6 | 7 | constructor(data: string) { 8 | const parsedData = this.parseString(data) 9 | 10 | this.id = parsedData[0][1] 11 | this.itemsIds = parsedData[1] 12 | } 13 | 14 | private parseString(eventDataString: string): any[][] { 15 | const allData = eventDataString.split('@') 16 | 17 | const playerId = allData[0].split(',') 18 | 19 | let itemsData = [] 20 | if (allData[1]) { 21 | const itemsDataStrings = allData[1].split(',') 22 | for (const itemId of itemsDataStrings) { 23 | if (itemId != '') { 24 | itemsData.push(+itemId) 25 | } 26 | } 27 | } 28 | 29 | return [playerId,itemsData] 30 | } 31 | } -------------------------------------------------------------------------------- /client/src/parser/ParseLogin.ts: -------------------------------------------------------------------------------- 1 | export class ParseLogin { 2 | public playerId: string 3 | public serverRules: { boardRows: number; boardColumns: number } 4 | public players: PlayerDto[] 5 | 6 | constructor(data: string) { 7 | const loginData = this.parseString(data) 8 | 9 | this.playerId = loginData[0] 10 | this.serverRules = { 11 | boardRows: loginData[1], 12 | boardColumns: loginData[2], 13 | } 14 | this.players = loginData[3] 15 | } 16 | 17 | private parseString(eventDataString: string): [string, number, number, PlayerDto[]] 18 | { 19 | const splitted = eventDataString.split('$') 20 | const playersRaw = splitted.slice(3).filter(x => x !== '') 21 | const playersRawMatrix = playersRaw.map(x => x.split('@')) 22 | let playersList: PlayerDto[] = [] 23 | for (const u of playersRawMatrix) { 24 | playersList.push(new PlayerDto( 25 | u[0], 26 | u[1], 27 | u[2], 28 | Number(u[3]), 29 | Number(u[4]), 30 | Number(u[5]), 31 | Number(u[6]), 32 | Number(u[7]), 33 | Number(u[8]), 34 | Number(u[9]), 35 | Number(u[10]), 36 | u[11])) 37 | } 38 | 39 | return [splitted[0].split(',')[1], Number(splitted[1]), Number(splitted[2]), playersList] 40 | } 41 | } 42 | 43 | export class PlayerDto { 44 | constructor(public id: string, 45 | public name: string, 46 | public color: string, 47 | public x: number, 48 | public y: number, 49 | public currentRoomId: number, 50 | public hp: number, 51 | public maxHp: number, 52 | public atk: number, 53 | public def: number, 54 | public xpNeed: number, 55 | public matrix: any) { 56 | this.id = id 57 | this.name = name 58 | this.color = color 59 | this.x = x 60 | this.y = y 61 | this.currentRoomId = currentRoomId 62 | this.hp = hp 63 | this.maxHp = maxHp 64 | this.atk = atk 65 | this.def = def 66 | this.xpNeed = xpNeed 67 | this.matrix = JSON.parse(matrix) 68 | } 69 | } -------------------------------------------------------------------------------- /client/src/parser/ParseMessage.ts: -------------------------------------------------------------------------------- 1 | export class ParseMessage { 2 | public message: string 3 | 4 | constructor(data: string) { 5 | const message = this.parseString(data) 6 | 7 | this.message = message 8 | } 9 | 10 | private parseString(eventDataString: string) { 11 | const indexFirstQuotes = eventDataString.indexOf(',"')+2 12 | const indexLastQuotes = eventDataString.split(',"')[1].indexOf('"')+indexFirstQuotes 13 | return eventDataString.substring(indexFirstQuotes, indexLastQuotes) 14 | } 15 | } -------------------------------------------------------------------------------- /client/src/parser/ParseMove.ts: -------------------------------------------------------------------------------- 1 | export class ParseMove { 2 | public playerMovedId: string 3 | public movedX: number 4 | public movedY: number 5 | public currentMovedRoomId: number 6 | 7 | constructor(data: string) { 8 | const moveData = this.parseString(data) 9 | 10 | this.playerMovedId = moveData[1] 11 | this.movedX = +moveData[2] 12 | this.movedY = +moveData[3] 13 | this.currentMovedRoomId = +moveData[4] 14 | } 15 | 16 | private parseString(eventDataString: string) { 17 | return eventDataString.split(',') 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /client/src/parser/ParseNpcMove.ts: -------------------------------------------------------------------------------- 1 | export class ParseNpcMove { 2 | public id: number 3 | public npcId: number 4 | public x: number 5 | public y: number 6 | public roomId: number 7 | 8 | constructor(data: string) { 9 | const moveData = this.parseString(data) 10 | 11 | this.id = +moveData[1] 12 | this.npcId = +moveData[2] 13 | this.x = +moveData[3] 14 | this.y = +moveData[4] 15 | this.roomId = +moveData[5] 16 | } 17 | 18 | private parseString(eventDataString: string) { 19 | return eventDataString.split(',') 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /client/src/parser/ParseNpcsInRoom.ts: -------------------------------------------------------------------------------- 1 | export class ParseNpcsInRoom { 2 | public npcs: NpcDto[] 3 | 4 | constructor(data: string) { 5 | this.npcs = this.parseString(data) 6 | } 7 | 8 | private parseString(eventDataString: string): NpcDto[] 9 | { 10 | const splitted = eventDataString.split(',') 11 | const npcsInRoomRaw = splitted.slice(1).filter(x => x !== '') 12 | const npcsInRoomRawMatrix = npcsInRoomRaw.map(x => x.split('@')) 13 | let npcsInRoomList: NpcDto[] = [] 14 | for (const u of npcsInRoomRawMatrix) { 15 | npcsInRoomList.push(new NpcDto( 16 | Number(u[0]), 17 | Number(u[1]), 18 | Number(u[2]), 19 | Number(u[3]), 20 | Number(u[4]), 21 | Number(u[5]), 22 | Number(u[6]))) 23 | } 24 | 25 | return npcsInRoomList 26 | } 27 | } 28 | 29 | export class NpcDto { 30 | constructor(public id: number, 31 | public npcId: number, 32 | public x: number, 33 | public y: number, 34 | public roomId: number, 35 | public hp: number, 36 | public maxHp: number) { 37 | this.id = id 38 | this.npcId = npcId 39 | this.roomId = roomId 40 | this.x = x 41 | this.y = y 42 | this.hp = hp 43 | this.maxHp = maxHp 44 | } 45 | } -------------------------------------------------------------------------------- /client/src/parser/ParseOpenStore.ts: -------------------------------------------------------------------------------- 1 | export class ParseOpenStore { 2 | public merchantId: number 3 | 4 | constructor(data: string) { 5 | const merchantData = this.parseString(data) 6 | 7 | this.merchantId = Number(merchantData[1]) 8 | } 9 | 10 | private parseString(eventDataString: string) { 11 | return eventDataString.split(',') 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /client/src/parser/ParsePlayerIdUpdate.ts: -------------------------------------------------------------------------------- 1 | export class ParsePlayerIdUpdate { 2 | public oldId: string 3 | public newId: string 4 | 5 | constructor(data: string) { 6 | const playerIdData = this.parseString(data) 7 | 8 | this.oldId = playerIdData[1] 9 | this.newId = playerIdData[2] 10 | } 11 | 12 | private parseString(eventDataString: string) { 13 | return eventDataString.split(',') 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /client/src/parser/ParsePlayerSellItems.ts: -------------------------------------------------------------------------------- 1 | export class ParsePlayerSellItems { 2 | public itemsIdsAndPrice: any[] 3 | 4 | constructor(data: string) { 5 | const parsedData = this.parseString(data) 6 | 7 | this.itemsIdsAndPrice = parsedData 8 | } 9 | 10 | private parseString(eventDataString: string): any[] { 11 | const allData = eventDataString.split('@') 12 | 13 | let itemsData = [] 14 | if (allData[1]) { 15 | const itemsDataStrings = allData[1].split(',') 16 | for (const itemIdAndPrice of itemsDataStrings) { 17 | if (itemIdAndPrice != '') { 18 | const itemId = itemIdAndPrice.split('^')[0] 19 | const itemPrice = itemIdAndPrice.split('^')[1] 20 | itemsData.push([+itemId,+itemPrice]) 21 | } 22 | } 23 | } 24 | 25 | return itemsData 26 | } 27 | } -------------------------------------------------------------------------------- /client/src/parser/ParsePlayersInRoom.ts: -------------------------------------------------------------------------------- 1 | export class ParsePlayersInRoom { 2 | public roomId: number 3 | public playersInRoom: { id: string, x: number, y: number }[] 4 | 5 | constructor(data: string) { 6 | const playersData = this.parseString(data) 7 | 8 | this.roomId = +playersData[0] 9 | this.playersInRoom = playersData[1] 10 | } 11 | 12 | private parseString(eventDataString: string): any[] { 13 | const returnList = [] 14 | const splitted = eventDataString.split(',') 15 | const playersInRoomRaw = splitted.slice(2).filter(x => x !== '') 16 | const playersInRoomRawMatrix = playersInRoomRaw.map(x => x.split('@')) 17 | let playersInRoomList: { id: string, x: number, y: number }[] = [] 18 | for (const u of playersInRoomRawMatrix) { 19 | playersInRoomList.push({ 20 | id: u[0], 21 | x: +u[1], 22 | y: +u[2] 23 | }) 24 | } 25 | 26 | returnList.push(splitted[1]) 27 | returnList.push(playersInRoomList) 28 | 29 | return returnList 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /client/src/parser/ParsePve.ts: -------------------------------------------------------------------------------- 1 | export class ParsePve { 2 | public attacker: number 3 | public damageCaused: number 4 | public npcHp: number 5 | public npcId: number 6 | public playerHp: number 7 | public playerId: string 8 | public roomId: number 9 | public playerTargetingNpcId: number 10 | 11 | constructor(data: string) { 12 | const pveData = this.parseString(data) 13 | 14 | this.attacker = Number(pveData[1]) 15 | this.damageCaused = +pveData[2] 16 | this.npcHp = +pveData[3] 17 | this.npcId = Number(pveData[4]) 18 | this.playerHp = +pveData[5] 19 | this.playerId = pveData[6] 20 | this.roomId = Number(pveData[7]) 21 | this.playerTargetingNpcId = Number(pveData[8]) 22 | } 23 | 24 | private parseString(eventDataString: string) { 25 | return eventDataString.split(',') 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /client/src/parser/ParseRank.ts: -------------------------------------------------------------------------------- 1 | export class ParseRank { 2 | public top1Name: string 3 | public top1Level: number 4 | public top2Name: string 5 | public top2Level: number 6 | public top3Name: string 7 | public top3Level: number 8 | 9 | constructor(data: string) { 10 | const rankData = this.parseString(data) 11 | 12 | this.top1Name = rankData[1] 13 | this.top1Level = +rankData[2] 14 | this.top2Name = rankData[3] 15 | this.top2Level = +rankData[4] 16 | this.top3Name = rankData[5] 17 | this.top3Level = +rankData[6] 18 | } 19 | 20 | private parseString(eventDataString: string) { 21 | return eventDataString.split(',') 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /client/src/parser/ParseSave.ts: -------------------------------------------------------------------------------- 1 | export class ParseSave { 2 | public playerDataHex: string 3 | 4 | constructor(data: string) { 5 | const saveData = this.parseString(data) 6 | 7 | this.playerDataHex = saveData[1] 8 | } 9 | 10 | private parseString(eventDataString: string) { 11 | return eventDataString.split(',') 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /client/src/parser/ParseSoldPlayerItem.ts: -------------------------------------------------------------------------------- 1 | import { ItemsIds } from '../../../shared/Enums' 2 | 3 | export class ParseSoldPlayerItem { 4 | public success: boolean 5 | public message: string 6 | public itemId: ItemsIds 7 | public currentCoins: number 8 | 9 | constructor(data: string) { 10 | const pickData = this.parseString(data) 11 | 12 | this.success = pickData[1] === 'true' 13 | if (this.success) { 14 | this.message = 'Success' 15 | this.itemId = +pickData[3] 16 | this.currentCoins = +pickData[4] 17 | } else { 18 | this.message = pickData[2] 19 | this.itemId = 0 20 | this.currentCoins = 0 21 | } 22 | } 23 | 24 | private parseString(eventDataString: string) { 25 | return eventDataString.split(',') 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /client/src/parser/ParseStats.ts: -------------------------------------------------------------------------------- 1 | export class ParseStats { 2 | public hp: number 3 | public maxHp: number 4 | public attack: number 5 | public defense: number 6 | public level: number 7 | public xp: number 8 | public xpNeeded: number 9 | 10 | constructor(data: string) { 11 | const parsedData = this.parseString(data) 12 | 13 | this.hp = +parsedData[1] 14 | this.maxHp = +parsedData[2] 15 | this.attack = +parsedData[3] 16 | this.defense = +parsedData[4] 17 | this.level = +parsedData[5] 18 | this.xp = +parsedData[6] 19 | this.xpNeeded = +parsedData[7] 20 | } 21 | 22 | private parseString(eventDataString: string): string[] { 23 | const statsData = eventDataString.split(',') 24 | 25 | return statsData 26 | } 27 | } -------------------------------------------------------------------------------- /client/src/parser/ParseStoreItems.ts: -------------------------------------------------------------------------------- 1 | export class ParseStoreItems { 2 | public itemsIdsAndPrice: any[] 3 | 4 | constructor(data: string) { 5 | const parsedData = this.parseString(data) 6 | 7 | this.itemsIdsAndPrice = parsedData 8 | } 9 | 10 | private parseString(eventDataString: string): any[] { 11 | const allData = eventDataString.split('@') 12 | 13 | let itemsData = [] 14 | if (allData[1]) { 15 | const itemsDataStrings = allData[1].split(',') 16 | for (const itemIdAndPrice of itemsDataStrings) { 17 | if (itemIdAndPrice != '') { 18 | const itemId = itemIdAndPrice.split('^')[0] 19 | const itemPrice = itemIdAndPrice.split('^')[1] 20 | itemsData.push([+itemId,+itemPrice]) 21 | } 22 | } 23 | } 24 | 25 | return itemsData 26 | } 27 | } -------------------------------------------------------------------------------- /client/src/startup/Game.ts: -------------------------------------------------------------------------------- 1 | import { DimensionsConfig, GridConfig } from '../models/configs' 2 | import { Main } from './Main' 3 | import { BackgroundLayer } from '../board/layers/BackgroundLayer' 4 | import { SolidLayer } from '../board/layers/SolidLayer' 5 | import { SpritesLayer } from '../board/layers/SpritesLayer' 6 | import { Map } from '../board/map/Map' 7 | import { Board } from '../board/Board' 8 | import { Rooms } from '../../../shared/Enums' 9 | 10 | export class Game { 11 | public solidLayer: SolidLayer 12 | public backgroundLayer: BackgroundLayer 13 | public gridConfig: GridConfig 14 | public map: Map 15 | public spritesLayer: SpritesLayer 16 | public board: Board 17 | public playerId: string = '' 18 | 19 | constructor(gameConfigs: DimensionsConfig, mainElements: Main) { 20 | this.gridConfig = new GridConfig({ 21 | width: gameConfigs.width, 22 | height: gameConfigs.height, 23 | rows: 16, 24 | columns: 16, 25 | }) 26 | 27 | this.backgroundLayer = new BackgroundLayer(this) 28 | this.solidLayer = new SolidLayer(this) 29 | this.spritesLayer = new SpritesLayer(this) 30 | 31 | this.map = new Map(this) 32 | this.board = new Board(this, this.backgroundLayer) 33 | 34 | if (mainElements.isMobile()) { 35 | mainElements.mobileControls.style.display = 'block' 36 | } 37 | } 38 | 39 | public applyServerRules(serverRules: any) { 40 | this.gridConfig.rows = serverRules.boardRows 41 | this.gridConfig.columns = serverRules.boardColumns 42 | 43 | this.board.draw() 44 | this.map.rooms[Rooms.InitialRoom].draw() 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /client/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es6", 4 | "module": "es2020", 5 | "lib": ["es2020", "dom"], 6 | "allowJs": true, 7 | "sourceMap": true, 8 | "outDir": "./public/", 9 | "strict": true, 10 | "noImplicitAny": true, 11 | "moduleResolution": "node", 12 | "esModuleInterop": true 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /client/webpack.config.js: -------------------------------------------------------------------------------- 1 | const path = require('path') 2 | 3 | module.exports = { 4 | context: __dirname, 5 | entry: './src/index.ts', 6 | output: { 7 | path: path.resolve(__dirname, 'public'), 8 | publicPath: '/public', 9 | filename: 'bundle.js', 10 | }, 11 | module: { 12 | rules: [ 13 | { 14 | test: /\.ts?$/, 15 | exclude: /node_modules/, 16 | use: { 17 | loader: 'ts-loader', 18 | }, 19 | }, 20 | ], 21 | }, 22 | resolve: { 23 | extensions: ['.ts', '.js'], 24 | }, 25 | } 26 | -------------------------------------------------------------------------------- /deps.ts: -------------------------------------------------------------------------------- 1 | export { parseArgs } from "https://jsr.io/@std/cli/1.0.17/parse_args.ts" 2 | export { serveFile } from "https://jsr.io/@std/http/1.0.15/mod.ts" 3 | //export { Client } from "https://deno.land/x/mysql@v2.10.2/mod.ts"; -------------------------------------------------------------------------------- /main.ts: -------------------------------------------------------------------------------- 1 | import { Server } from './server.ts'; 2 | 3 | const serverConfigs = { 4 | defaultPort: 3000, 5 | boardRows: 16, 6 | boardColumns: 16, 7 | version: 7, 8 | } 9 | const server = new Server(serverConfigs); 10 | 11 | server.init(); -------------------------------------------------------------------------------- /runtime.txt: -------------------------------------------------------------------------------- 1 | v2.3.1 -------------------------------------------------------------------------------- /server.ts: -------------------------------------------------------------------------------- 1 | import { parseArgs } from "./deps.ts" 2 | import { serveFile } from "./deps.ts" 3 | import { ClientHandler } from "./server/clientHandler.ts" 4 | 5 | export class Server { 6 | private port: string 7 | private clientHandler: ClientHandler 8 | private publicFolder = "./client/public" 9 | private publicFiles: string[] = [] 10 | 11 | constructor(serverConfigs: any) { 12 | const argPort: number = parseArgs(Deno.args).port 13 | const herokuPort = Deno.env.get("PORT") 14 | this.port = herokuPort ? Number(herokuPort) : argPort ? Number(argPort) : serverConfigs.defaultPort 15 | this.clientHandler = new ClientHandler(serverConfigs) 16 | } 17 | 18 | public async reqHandler(req: Request) { 19 | if (req.headers.get("upgrade") != "websocket") { 20 | return await this.handleNonWsRequests(req) 21 | } 22 | const { socket: ws, response } = Deno.upgradeWebSocket(req) 23 | this.clientHandler.handleClient(ws) 24 | 25 | return response 26 | } 27 | 28 | public init(): void { 29 | const portInt = Number(this.port) 30 | this.setPublicFilesList(this.publicFolder) 31 | Deno.serve({ port: portInt }, this.reqHandler.bind(this)) 32 | } 33 | 34 | public async handleNonWsRequests(req: Request): Promise { 35 | const url = new URL(req.url) 36 | let cleanedUrl = url.pathname 37 | let response: Response = new Response() 38 | if(req.url.includes('?')) { 39 | cleanedUrl = req.url.split('?')[0] 40 | } 41 | 42 | if (req.method === "GET" && cleanedUrl === "/") { 43 | response = await serveFile(req, "./client/public/index.html") 44 | } 45 | 46 | if (req.method === "GET" && cleanedUrl === "/favicon.ico") { 47 | response = await serveFile(req, "./client/public/favicon.ico") 48 | } 49 | 50 | if (req.method === "GET" && cleanedUrl === "/web_neutral_rd_ctn@1x.png") { 51 | response = await serveFile(req, "./client/public/web_neutral_rd_ctn@1x.png") 52 | } 53 | 54 | for (const file of this.publicFiles) { 55 | if (req.method === "GET" && cleanedUrl === `/js/${file}`) { 56 | response = await serveFile(req, `./client/public/${file}`) 57 | } 58 | } 59 | 60 | return response 61 | } 62 | 63 | public setPublicFilesList(path: string): void { 64 | for (const dirEntry of Deno.readDirSync(path)) { 65 | if (dirEntry.isDirectory) { 66 | this.setPublicFilesList(`${path}/${dirEntry.name}`) 67 | } else { 68 | let pathToRemove = this.publicFolder 69 | let outputFile = dirEntry.name 70 | if (this.publicFolder !== path) { 71 | pathToRemove += "/" 72 | outputFile = `/${outputFile}` 73 | } 74 | const outputPath = path.replace(`${pathToRemove}`, "") 75 | this.publicFiles.push(`${outputPath}${outputFile}`) 76 | } 77 | } 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /server/data/admins.ts: -------------------------------------------------------------------------------- 1 | export const Admins = [{ 2 | name: "diguifi", 3 | code: "diguifi_access" 4 | }] -------------------------------------------------------------------------------- /server/data/badWords.ts: -------------------------------------------------------------------------------- 1 | //taken from https://github.com/LDNOOBW/List-of-Dirty-Naughty-Obscene-and-Otherwise-Bad-Words/blob/master/en 2 | 3 | export const badWords = ["2g1c", "acrotomophilia", "anal", "anilingus", "anus", "apeshit", "arsehole", "ass", "asshole", "assmunch", "autoerotic", "ballgag", "balllicking", "ballsack", "ballsucking", "bangbros", "bangbus", "bareback", "barelylegal", "barenaked", "bastard", "bastardo", "bbw", "bdsm", "beaner", "beaners", "beavercleaver", "beaverlips", "beastiality", "bestiality", "bigblack", "bigbreasts", "bigknockers", "bigtits", "bimbos", "birdlock", "bitch", "bitches", "blackcock", "blondeaction", "blowjob", "bluewaffle", "blumpkin", "bollocks", "bondage", "boner", "boob", "boobs", "bootycall", "bukkake", "bulldyke", "bullshit", "bunghole", "busty", "butt", "buttcheeks", "butthole", "cameltoe", "camgirl", "camslut", "camwhore", "carpetmuncher", "cialis", "circlejerk", "clit", "clitoris", "clusterfuck", "cock", "cocks", "coprolagnia", "coprophilia", "cornhole", "coon", "coons", "creampie", "cum", "cumming", "cumshot", "cumshots", "cunnilingus", "cunt", "darkie", "daterape", "deepthroat", "dendrophilia", "dick", "dildo", "dingleberry", "dingleberries", "dirtypillows", "doggiestyle", "doggystyle", "dogstyle", "dominatrix", "dommes", "dong", "doublepenetration", "dpaction", "eatmyass", "ecchi", "ejaculation", "erotic", "erotism", "eunuch", "fag", "faggot", "fecal", "felch", "fellatio", "feltch", "femalesquirting", "femdom", "figging", "fingerbang", "fingering", "fisting", "footfetish", "footjob", "frotting", "fuck", "fuckin", "fucking", "fucktards", "fudgepacker", "futanari", "gangbang", "gaysex", "genitals", "giantcock", "goatcx", "goatse", "gokkun", "goldenshower", "goodpoop", "goregasm", "grope", "groupsex", "handjob", "hentai", "homoerotic", "honkey", "hooker", "horny", "hotchick", "humping", "incest", "intercourse", "jackoff", "jailbait", "jerkoff", "jigaboo", "jiggaboo", "jiggerboo", "jizz", "juggs", "kinkster", "kinky", "knobbing", "livesex", "lolita", "lovemaking", "masturbate", "masturbating", "masturbation", "menage", "menageatrois", "milf", "motherfucker", "muffdiving", "nambla", "nawashi", "negro", "neonazi", "nigga", "nigger", "nignog", "nimphomania", "nipple", "nipples", "nsfw", "nude", "nudity", "nutten", "nympho", "nymphomania", "octopussy", "omorashi", "orgasm", "orgy", "paedophile", "panties", "panty", "pedobear", "pedophile", "pegging", "penis", "pieceofshit", "pisspig", "playboy", "ponyplay", "poopchute", "porn", "porno", "pornography", "pussy", "queaf", "queef", "raghead", "ragingboner", "rape", "raping", "rapist", "rectum", "reversecowgirl", "rimjob", "rimming", "rosypalm", "sadism", "santorum", "schlong", "scissoring", "semen", "sex", "sexcam", "sexo", "sexy", "sexual", "sexually", "sexuality", "shavedbeaver", "shavedpussy", "shemale", "shibari", "shit", "shitblimp", "shitty", "shota", "shrimping", "skeet", "slanteye", "slut", "smut", "snatch", "snowballing", "sodomize", "sodomy", "spastic", "splooge", "sploogemoose", "spooge", "spreadlegs", "strapon", "strappado", "stripclub", "sucks", "suicidegirls", "sultrywomen", "swastika", "swinger", "threesome", "throating", "thumbzilla", "tiedup", "tightwhite", "tits", "titties", "titty", "tongueina", "topless", "towelhead", "tranny", "tribadism", "tubgirl", "tubgirl", "tushy", "twat", "twink", "twinkie", "undressing", "upskirt", "urophilia", "vagina", "viagra", "vibrator", "vorarephilia", "voyeur", "voyeurweb", "voyuer", "vulva", "wank", "wetback", "wetdream", "whitepower", "whore", "worldsex", "yaoi", "yiffy", "zoophilia",] -------------------------------------------------------------------------------- /server/data/dataManager.ts: -------------------------------------------------------------------------------- 1 | export default class DataManager { 2 | private aesKey: CryptoKey | undefined 3 | private iv: Uint8Array 4 | private aesAlgorithm = "AES-CBC" 5 | 6 | constructor() { 7 | const aesKey = Deno.env.get('tinyaeskey') 8 | const key = aesKey ? aesKey : 'defaultaeskey123' 9 | const encodedKey = new TextEncoder().encode(key) 10 | 11 | this.iv = new TextEncoder().encode("tiny land online") 12 | 13 | crypto.subtle.importKey( 14 | "raw", 15 | encodedKey, 16 | this.aesAlgorithm, 17 | true, 18 | ["encrypt", "decrypt"], 19 | ).then((result: CryptoKey) => { 20 | this.aesKey = result 21 | } 22 | ) 23 | } 24 | 25 | public async encryptUserData(userData: string): Promise { 26 | const encryptedData = await crypto.subtle.encrypt( 27 | {name: this.aesAlgorithm, iv: this.iv}, 28 | this.aesKey!, 29 | new TextEncoder().encode(userData), 30 | ) 31 | return this.arrayBufferToHex(encryptedData) 32 | } 33 | 34 | public async decryptUserData(userData: string): Promise { 35 | const bytes = this.hexToUint8Array(userData) 36 | const decryptedData = await crypto.subtle.decrypt( 37 | {name: this.aesAlgorithm, iv: this.iv}, 38 | this.aesKey!, 39 | bytes, 40 | ) 41 | return new TextDecoder("utf-8").decode(decryptedData) 42 | } 43 | 44 | private hexToUint8Array(data: string): Uint8Array { 45 | const bytes = new Uint8Array(Math.ceil(data.length / 2)); 46 | for (let i = 0; i < bytes.length; i++) bytes[i] = parseInt(data.substr(i * 2, 2), 16); 47 | return bytes 48 | } 49 | 50 | private arrayBufferToHex(buffer: ArrayBuffer) { 51 | return [...new Uint8Array(buffer)] 52 | .map(x => x.toString(16).padStart(2, '0')) 53 | .join('') 54 | } 55 | } -------------------------------------------------------------------------------- /server/entities/items/adamantArmour.ts: -------------------------------------------------------------------------------- 1 | import { ItemsIds, ItemType, GearType } from "../../../shared/Enums.ts" 2 | import ItemBase from "./itemBase.ts" 3 | import { buyPrice, sellPrice } from "./itemPrices.ts"; 4 | 5 | export default class AdamantArmour extends ItemBase { 6 | 7 | constructor(dropChance: number, customBuyPrice: number = 0) { 8 | super(0, ItemsIds.AdamantArmour, ItemType.Weareable, GearType.Torso, 0, 0, 40, true, 0, 0, 0, dropChance, (customBuyPrice !== 0 ? customBuyPrice : buyPrice.AdamantArmour), sellPrice.AdamantArmour) 9 | } 10 | } -------------------------------------------------------------------------------- /server/entities/items/adamantDagger.ts: -------------------------------------------------------------------------------- 1 | import { ItemsIds, ItemType, GearType } from "../../../shared/Enums.ts" 2 | import ItemBase from "./itemBase.ts" 3 | import { buyPrice, sellPrice } from "./itemPrices.ts"; 4 | 5 | export default class AdamantDagger extends ItemBase { 6 | 7 | constructor(dropChance: number, customBuyPrice: number = 0) { 8 | super(0, ItemsIds.AdamantDagger, ItemType.Weareable, GearType.Weapon, 0, 0, 40, false, 4, 0, 0, dropChance, (customBuyPrice !== 0 ? customBuyPrice : buyPrice.AdamantDagger), sellPrice.AdamantDagger) 9 | } 10 | } -------------------------------------------------------------------------------- /server/entities/items/adamantHelm.ts: -------------------------------------------------------------------------------- 1 | import { ItemsIds, ItemType, GearType } from "../../../shared/Enums.ts" 2 | import ItemBase from "./itemBase.ts" 3 | import { buyPrice, sellPrice } from "./itemPrices.ts"; 4 | 5 | export default class AdamantHelm extends ItemBase { 6 | 7 | constructor(dropChance: number, customBuyPrice: number = 0) { 8 | super(0, ItemsIds.AdamantHelm, ItemType.Weareable, GearType.Head, 0, 0, 40, true, 0, 0, 0, dropChance, (customBuyPrice !== 0 ? customBuyPrice : buyPrice.AdamantHelm), sellPrice.AdamantHelm) 9 | } 10 | } -------------------------------------------------------------------------------- /server/entities/items/adamantLegs.ts: -------------------------------------------------------------------------------- 1 | import { ItemsIds, ItemType, GearType } from "../../../shared/Enums.ts" 2 | import ItemBase from "./itemBase.ts" 3 | import { buyPrice, sellPrice } from "./itemPrices.ts"; 4 | 5 | export default class AdamantLegs extends ItemBase { 6 | 7 | constructor(dropChance: number, customBuyPrice: number = 0) { 8 | super(0, ItemsIds.AdamantLegs, ItemType.Weareable, GearType.Legs, 0, 0, 40, true, 0, 0, 0, dropChance, (customBuyPrice !== 0 ? customBuyPrice : buyPrice.AdamantLegs), sellPrice.AdamantLegs) 9 | } 10 | } -------------------------------------------------------------------------------- /server/entities/items/adamantSword.ts: -------------------------------------------------------------------------------- 1 | import { ItemsIds, ItemType, GearType } from "../../../shared/Enums.ts" 2 | import ItemBase from "./itemBase.ts" 3 | import { buyPrice, sellPrice } from "./itemPrices.ts"; 4 | 5 | export default class AdamantSword extends ItemBase { 6 | 7 | constructor(dropChance: number, customBuyPrice: number = 0) { 8 | super(0, ItemsIds.AdamantSword, ItemType.Weareable, GearType.Weapon, 0, 0, 40, false, 0, 4, 0, dropChance, (customBuyPrice !== 0 ? customBuyPrice : buyPrice.AdamantSword), sellPrice.AdamantSword) 9 | } 10 | } -------------------------------------------------------------------------------- /server/entities/items/bank/bank.ts: -------------------------------------------------------------------------------- 1 | import { ItemsIds } from "../../../../shared/Enums.ts" 2 | import ItemBase from "../itemBase.ts" 3 | import { Player } from "../../player.ts" 4 | 5 | export default class Bank { 6 | public items: ItemBase[] = [] 7 | public size = 72 8 | private player: Player 9 | 10 | constructor(player: Player) { 11 | this.player = player 12 | } 13 | 14 | public retrieveItem(itemId: ItemsIds): boolean { 15 | const item = this.items.find(i => i.itemId == itemId) 16 | if (item) { 17 | const success = this.player.bag.addItem(item) 18 | if (success) { 19 | this.removeItem(item) 20 | return true 21 | } 22 | } 23 | return false 24 | } 25 | 26 | public storeItem(item: ItemBase): boolean { 27 | if (this.items.length < this.size) { 28 | this.items.push(item) 29 | return true 30 | } 31 | 32 | return false 33 | } 34 | 35 | private removeItem(item: ItemBase) { 36 | const index = this.items.indexOf(item) 37 | if (index > -1) { 38 | this.items.splice(index, 1) 39 | } 40 | } 41 | } -------------------------------------------------------------------------------- /server/entities/items/bluriteArmour.ts: -------------------------------------------------------------------------------- 1 | import { ItemsIds, ItemType, GearType } from "../../../shared/Enums.ts" 2 | import ItemBase from "./itemBase.ts" 3 | import { buyPrice, sellPrice } from "./itemPrices.ts"; 4 | 5 | export default class BluriteArmour extends ItemBase { 6 | 7 | constructor(dropChance: number, customBuyPrice: number = 0) { 8 | super(0, ItemsIds.BluriteArmour, ItemType.Weareable, GearType.Torso, 0, 0, 30, true, 0, 0, 0, dropChance, (customBuyPrice !== 0 ? customBuyPrice : buyPrice.BluriteArmour), sellPrice.BluriteArmour) 9 | } 10 | } -------------------------------------------------------------------------------- /server/entities/items/bluriteDagger.ts: -------------------------------------------------------------------------------- 1 | import { ItemsIds, ItemType, GearType } from "../../../shared/Enums.ts" 2 | import ItemBase from "./itemBase.ts" 3 | import { buyPrice, sellPrice } from "./itemPrices.ts"; 4 | 5 | export default class BluriteDagger extends ItemBase { 6 | 7 | constructor(dropChance: number, customBuyPrice: number = 0) { 8 | super(0, ItemsIds.BluriteDagger, ItemType.Weareable, GearType.Weapon, 0, 0, 30, false, 2, 0, 0, dropChance, (customBuyPrice !== 0 ? customBuyPrice : buyPrice.BluriteDagger), sellPrice.BluriteDagger) 9 | } 10 | } -------------------------------------------------------------------------------- /server/entities/items/bluriteHelm.ts: -------------------------------------------------------------------------------- 1 | import { ItemsIds, ItemType, GearType } from "../../../shared/Enums.ts" 2 | import ItemBase from "./itemBase.ts" 3 | import { buyPrice, sellPrice } from "./itemPrices.ts"; 4 | 5 | export default class BluriteHelm extends ItemBase { 6 | 7 | constructor(dropChance: number, customBuyPrice: number = 0) { 8 | super(0, ItemsIds.BluriteHelm, ItemType.Weareable, GearType.Head, 0, 0, 30, true, 0, 0, 0, dropChance, (customBuyPrice !== 0 ? customBuyPrice : buyPrice.BluriteHelm), sellPrice.BluriteHelm) 9 | } 10 | } -------------------------------------------------------------------------------- /server/entities/items/bluriteLegs.ts: -------------------------------------------------------------------------------- 1 | import { ItemsIds, ItemType, GearType } from "../../../shared/Enums.ts" 2 | import ItemBase from "./itemBase.ts" 3 | import { buyPrice, sellPrice } from "./itemPrices.ts"; 4 | 5 | export default class BluriteLegs extends ItemBase { 6 | 7 | constructor(dropChance: number, customBuyPrice: number = 0) { 8 | super(0, ItemsIds.BluriteLegs, ItemType.Weareable, GearType.Legs, 0, 0, 30, true, 0, 0, 0, dropChance, (customBuyPrice !== 0 ? customBuyPrice : buyPrice.BluriteLegs), sellPrice.BluriteLegs) 9 | } 10 | } -------------------------------------------------------------------------------- /server/entities/items/bluriteSword.ts: -------------------------------------------------------------------------------- 1 | import { ItemsIds, ItemType, GearType } from "../../../shared/Enums.ts" 2 | import ItemBase from "./itemBase.ts" 3 | import { buyPrice, sellPrice } from "./itemPrices.ts"; 4 | 5 | export default class BluriteSword extends ItemBase { 6 | 7 | constructor(dropChance: number, customBuyPrice: number = 0) { 8 | super(0, ItemsIds.BluriteSword, ItemType.Weareable, GearType.Weapon, 0, 0, 30, false, 0, 2, 0, dropChance, (customBuyPrice !== 0 ? customBuyPrice : buyPrice.BluriteSword), sellPrice.BluriteSword) 9 | } 10 | } -------------------------------------------------------------------------------- /server/entities/items/bronzeArmour.ts: -------------------------------------------------------------------------------- 1 | import { ItemsIds, ItemType, GearType } from "../../../shared/Enums.ts" 2 | import ItemBase from "./itemBase.ts" 3 | import { buyPrice, sellPrice } from "./itemPrices.ts"; 4 | 5 | export default class BronzeArmour extends ItemBase { 6 | 7 | constructor(dropChance: number, customBuyPrice: number = 0) { 8 | super(0, ItemsIds.BronzeArmour, ItemType.Weareable, GearType.Torso, 0, 0, 10, true, 0, 0, 0, dropChance, (customBuyPrice !== 0 ? customBuyPrice : buyPrice.BronzeArmour), sellPrice.BronzeArmour) 9 | } 10 | } -------------------------------------------------------------------------------- /server/entities/items/bronzeDagger.ts: -------------------------------------------------------------------------------- 1 | import { ItemsIds, ItemType, GearType } from "../../../shared/Enums.ts" 2 | import ItemBase from "./itemBase.ts" 3 | import { buyPrice, sellPrice } from "./itemPrices.ts"; 4 | 5 | export default class BronzeDagger extends ItemBase { 6 | 7 | constructor(dropChance: number, customBuyPrice: number = 0) { 8 | super(0, ItemsIds.BronzeDagger, ItemType.Weareable, GearType.Weapon, 0, 0, 10, false, 1, 0, 0, dropChance, (customBuyPrice !== 0 ? customBuyPrice : buyPrice.BronzeDagger), sellPrice.BronzeDagger) 9 | } 10 | } -------------------------------------------------------------------------------- /server/entities/items/bronzeHelm.ts: -------------------------------------------------------------------------------- 1 | import { ItemsIds, ItemType, GearType } from "../../../shared/Enums.ts" 2 | import ItemBase from "./itemBase.ts" 3 | import { buyPrice, sellPrice } from "./itemPrices.ts"; 4 | 5 | export default class BronzeHelm extends ItemBase { 6 | 7 | constructor(dropChance: number, customBuyPrice: number = 0) { 8 | super(0, ItemsIds.BronzeHelm, ItemType.Weareable, GearType.Head, 0, 0, 10, true, 0, 0, 0, dropChance, (customBuyPrice !== 0 ? customBuyPrice : buyPrice.BronzeHelm), sellPrice.BronzeHelm) 9 | } 10 | } -------------------------------------------------------------------------------- /server/entities/items/bronzeLegs.ts: -------------------------------------------------------------------------------- 1 | import { ItemsIds, ItemType, GearType } from "../../../shared/Enums.ts" 2 | import ItemBase from "./itemBase.ts" 3 | import { buyPrice, sellPrice } from "./itemPrices.ts"; 4 | 5 | export default class BronzeLegs extends ItemBase { 6 | 7 | constructor(dropChance: number, customBuyPrice: number = 0) { 8 | super(0, ItemsIds.BronzeLegs, ItemType.Weareable, GearType.Legs, 0, 0, 10, true, 0, 0, 0, dropChance, (customBuyPrice !== 0 ? customBuyPrice : buyPrice.BronzeLegs), sellPrice.BronzeLegs) 9 | } 10 | } -------------------------------------------------------------------------------- /server/entities/items/bronzeSword.ts: -------------------------------------------------------------------------------- 1 | import { ItemsIds, ItemType, GearType } from "../../../shared/Enums.ts" 2 | import ItemBase from "./itemBase.ts" 3 | import { buyPrice, sellPrice } from "./itemPrices.ts"; 4 | 5 | export default class BronzeSword extends ItemBase { 6 | 7 | constructor(dropChance: number, customBuyPrice: number = 0) { 8 | super(0, ItemsIds.BronzeSword, ItemType.Weareable, GearType.Weapon, 0, 0, 10, false, 0, 1, 0, dropChance, (customBuyPrice !== 0 ? customBuyPrice : buyPrice.BronzeSword), sellPrice.BronzeSword) 9 | } 10 | } -------------------------------------------------------------------------------- /server/entities/items/coins.ts: -------------------------------------------------------------------------------- 1 | import { ItemsIds, ItemType, GearType } from "../../../shared/Enums.ts" 2 | import ItemBase from "./itemBase.ts" 3 | 4 | export default class Coins extends ItemBase { 5 | 6 | constructor(dropChance: number, totalCoins: number) { 7 | super(0, ItemsIds.Coin, ItemType.Money, GearType.None, totalCoins, 0, 0, false, 0, 0, 5, dropChance, 1, 1) 8 | } 9 | } -------------------------------------------------------------------------------- /server/entities/items/consumable/bread.ts: -------------------------------------------------------------------------------- 1 | import { ItemsIds, ItemType, GearType } from "../../../../shared/Enums.ts" 2 | import ItemBase from "../itemBase.ts" 3 | import { buyPrice, sellPrice } from "../itemPrices.ts"; 4 | 5 | export default class Bread extends ItemBase { 6 | 7 | constructor(dropChance: number, customBuyPrice: number = 0) { 8 | super(0, ItemsIds.Bread, ItemType.Consumable, GearType.None, 0, 0, 0, false, 0, 0, 10, dropChance, (customBuyPrice !== 0 ? customBuyPrice : buyPrice.Bread), sellPrice.Bread) 9 | } 10 | } -------------------------------------------------------------------------------- /server/entities/items/consumable/cactusJuice.ts: -------------------------------------------------------------------------------- 1 | import { ItemsIds, ItemType, GearType } from "../../../../shared/Enums.ts" 2 | import ItemBase from "../itemBase.ts" 3 | 4 | export default class CactusJuice extends ItemBase { 5 | 6 | constructor(dropChance: number) { 7 | super(0, ItemsIds.CactusJuice, ItemType.QuestConsumable, GearType.None, 0, 0, 0, false, 0, 0, 0, dropChance, 0, 0) 8 | } 9 | } -------------------------------------------------------------------------------- /server/entities/items/consumable/coffee.ts: -------------------------------------------------------------------------------- 1 | import { ItemsIds, ItemType, GearType } from "../../../../shared/Enums.ts" 2 | import ItemBase from "../itemBase.ts" 3 | import { buyPrice, sellPrice } from "../itemPrices.ts"; 4 | 5 | export default class Coffee extends ItemBase { 6 | 7 | constructor(dropChance: number, customBuyPrice: number = 0) { 8 | super(0, ItemsIds.Coffee, ItemType.Consumable, GearType.None, 0, 0, 0, false, 0, 0, 5, dropChance, (customBuyPrice !== 0 ? customBuyPrice : buyPrice.Coffee), sellPrice.Coffee) 9 | } 10 | } -------------------------------------------------------------------------------- /server/entities/items/consumable/largeHp.ts: -------------------------------------------------------------------------------- 1 | import { ItemsIds, ItemType, GearType } from "../../../../shared/Enums.ts" 2 | import ItemBase from "../itemBase.ts" 3 | import { buyPrice, sellPrice } from "../itemPrices.ts"; 4 | 5 | export default class LargeHp extends ItemBase { 6 | 7 | constructor(dropChance: number, customBuyPrice: number = 0) { 8 | super(0, ItemsIds.LargeHp, ItemType.Consumable, GearType.None, 0, 0, 0, false, 0, 0, 30, dropChance, (customBuyPrice !== 0 ? customBuyPrice : buyPrice.LargeHp), sellPrice.LargeHp) 9 | } 10 | } -------------------------------------------------------------------------------- /server/entities/items/consumable/smallHp.ts: -------------------------------------------------------------------------------- 1 | import { ItemsIds, ItemType, GearType } from "../../../../shared/Enums.ts" 2 | import ItemBase from "../itemBase.ts" 3 | import { buyPrice, sellPrice } from "../itemPrices.ts"; 4 | 5 | export default class SmallHp extends ItemBase { 6 | 7 | constructor(dropChance: number, customBuyPrice: number = 0) { 8 | super(0, ItemsIds.SmallHp, ItemType.Consumable, GearType.None, 0, 0, 0, false, 0, 0, 15, dropChance, (customBuyPrice !== 0 ? customBuyPrice : buyPrice.SmallHp), sellPrice.SmallHp) 9 | } 10 | } -------------------------------------------------------------------------------- /server/entities/items/fireArmour.ts: -------------------------------------------------------------------------------- 1 | import { ItemsIds, ItemType, GearType } from "../../../shared/Enums.ts" 2 | import ItemBase from "./itemBase.ts" 3 | import { buyPrice, sellPrice } from "./itemPrices.ts"; 4 | 5 | export default class FireArmour extends ItemBase { 6 | 7 | constructor(dropChance: number, customBuyPrice: number = 0) { 8 | super(0, ItemsIds.FireArmour, ItemType.Weareable, GearType.Torso, 0, 0, 50, true, 0, 0, 0, dropChance, (customBuyPrice !== 0 ? customBuyPrice : buyPrice.FireArmour), sellPrice.FireArmour) 9 | } 10 | } -------------------------------------------------------------------------------- /server/entities/items/fireDagger.ts: -------------------------------------------------------------------------------- 1 | import { ItemsIds, ItemType, GearType } from "../../../shared/Enums.ts" 2 | import ItemBase from "./itemBase.ts" 3 | import { buyPrice, sellPrice } from "./itemPrices.ts"; 4 | 5 | export default class FireDagger extends ItemBase { 6 | 7 | constructor(dropChance: number, customBuyPrice: number = 0) { 8 | super(0, ItemsIds.FireDagger, ItemType.Weareable, GearType.Weapon, 0, 0, 50, false, 4, 0, 0, dropChance, (customBuyPrice !== 0 ? customBuyPrice : buyPrice.FireDagger), sellPrice.FireDagger) 9 | } 10 | } -------------------------------------------------------------------------------- /server/entities/items/fireHelm.ts: -------------------------------------------------------------------------------- 1 | import { ItemsIds, ItemType, GearType } from "../../../shared/Enums.ts" 2 | import ItemBase from "./itemBase.ts" 3 | import { buyPrice, sellPrice } from "./itemPrices.ts"; 4 | 5 | export default class FireHelm extends ItemBase { 6 | 7 | constructor(dropChance: number, customBuyPrice: number = 0) { 8 | super(0, ItemsIds.FireHelm, ItemType.Weareable, GearType.Head, 0, 0, 50, true, 0, 0, 0, dropChance, (customBuyPrice !== 0 ? customBuyPrice : buyPrice.FireHelm), sellPrice.FireHelm) 9 | } 10 | } -------------------------------------------------------------------------------- /server/entities/items/fireLegs.ts: -------------------------------------------------------------------------------- 1 | import { ItemsIds, ItemType, GearType } from "../../../shared/Enums.ts" 2 | import ItemBase from "./itemBase.ts" 3 | import { buyPrice, sellPrice } from "./itemPrices.ts"; 4 | 5 | export default class FireLegs extends ItemBase { 6 | 7 | constructor(dropChance: number, customBuyPrice: number = 0) { 8 | super(0, ItemsIds.FireLegs, ItemType.Weareable, GearType.Legs, 0, 0, 50, true, 0, 0, 0, dropChance, (customBuyPrice !== 0 ? customBuyPrice : buyPrice.FireLegs), sellPrice.FireLegs) 9 | } 10 | } -------------------------------------------------------------------------------- /server/entities/items/fireSword.ts: -------------------------------------------------------------------------------- 1 | import { ItemsIds, ItemType, GearType } from "../../../shared/Enums.ts" 2 | import ItemBase from "./itemBase.ts" 3 | import { buyPrice, sellPrice } from "./itemPrices.ts"; 4 | 5 | export default class FireSword extends ItemBase { 6 | 7 | constructor(dropChance: number, customBuyPrice: number = 0) { 8 | super(0, ItemsIds.FireSword, ItemType.Weareable, GearType.Weapon, 0, 0, 50, false, 0, 4, 0, dropChance, (customBuyPrice !== 0 ? customBuyPrice : buyPrice.FireSword), sellPrice.FireSword) 9 | } 10 | } -------------------------------------------------------------------------------- /server/entities/items/ironArmour.ts: -------------------------------------------------------------------------------- 1 | import { ItemsIds, ItemType, GearType } from "../../../shared/Enums.ts" 2 | import ItemBase from "./itemBase.ts" 3 | import { buyPrice, sellPrice } from "./itemPrices.ts"; 4 | 5 | export default class IronArmour extends ItemBase { 6 | 7 | constructor(dropChance: number, customBuyPrice: number = 0) { 8 | super(0, ItemsIds.IronArmour, ItemType.Weareable, GearType.Torso, 0, 0, 20, true, 0, 0, 0, dropChance, (customBuyPrice !== 0 ? customBuyPrice : buyPrice.IronArmour), sellPrice.IronArmour) 9 | } 10 | } -------------------------------------------------------------------------------- /server/entities/items/ironDagger.ts: -------------------------------------------------------------------------------- 1 | import { ItemsIds, ItemType, GearType } from "../../../shared/Enums.ts" 2 | import ItemBase from "./itemBase.ts" 3 | import { buyPrice, sellPrice } from "./itemPrices.ts"; 4 | 5 | export default class IronDagger extends ItemBase { 6 | 7 | constructor(dropChance: number, customBuyPrice: number = 0) { 8 | super(0, ItemsIds.IronDagger, ItemType.Weareable, GearType.Weapon, 0, 0, 20, false, 2, 0, 0, dropChance, (customBuyPrice !== 0 ? customBuyPrice : buyPrice.IronDagger), sellPrice.IronDagger) 9 | } 10 | } -------------------------------------------------------------------------------- /server/entities/items/ironHelm.ts: -------------------------------------------------------------------------------- 1 | import { ItemsIds, ItemType, GearType } from "../../../shared/Enums.ts" 2 | import ItemBase from "./itemBase.ts" 3 | import { buyPrice, sellPrice } from "./itemPrices.ts"; 4 | 5 | export default class IronHelm extends ItemBase { 6 | 7 | constructor(dropChance: number, customBuyPrice: number = 0) { 8 | super(0, ItemsIds.IronHelm, ItemType.Weareable, GearType.Head, 0, 0, 20, true, 0, 0, 0, dropChance, (customBuyPrice !== 0 ? customBuyPrice : buyPrice.IronHelm), sellPrice.IronHelm) 9 | } 10 | } -------------------------------------------------------------------------------- /server/entities/items/ironLegs.ts: -------------------------------------------------------------------------------- 1 | import { ItemsIds, ItemType, GearType } from "../../../shared/Enums.ts" 2 | import ItemBase from "./itemBase.ts" 3 | import { buyPrice, sellPrice } from "./itemPrices.ts"; 4 | 5 | export default class IronLegs extends ItemBase { 6 | 7 | constructor(dropChance: number, customBuyPrice: number = 0) { 8 | super(0, ItemsIds.IronLegs, ItemType.Weareable, GearType.Legs, 0, 0, 20, true, 0, 0, 0, dropChance, (customBuyPrice !== 0 ? customBuyPrice : buyPrice.IronLegs), sellPrice.IronLegs) 9 | } 10 | } -------------------------------------------------------------------------------- /server/entities/items/ironSword.ts: -------------------------------------------------------------------------------- 1 | import { ItemsIds, ItemType, GearType } from "../../../shared/Enums.ts" 2 | import ItemBase from "./itemBase.ts" 3 | import { buyPrice, sellPrice } from "./itemPrices.ts"; 4 | 5 | export default class IronSword extends ItemBase { 6 | 7 | constructor(dropChance: number, customBuyPrice: number = 0) { 8 | super(0, ItemsIds.IronSword, ItemType.Weareable, GearType.Weapon, 0, 0, 20, false, 0, 2, 0, dropChance, (customBuyPrice !== 0 ? customBuyPrice : buyPrice.IronSword), sellPrice.IronSword) 9 | } 10 | } -------------------------------------------------------------------------------- /server/entities/items/itemBase.ts: -------------------------------------------------------------------------------- 1 | import { ItemsIds, ItemType, GearType } from "../../../shared/Enums.ts" 2 | 3 | export default class ItemBase { 4 | public id: number 5 | public itemId: ItemsIds 6 | public type: ItemType 7 | public gearType: GearType 8 | public despawnTime: number 9 | public coins: number 10 | public level: number 11 | public bonusAttack: number 12 | public bonusDefense: number 13 | public healthRefuel: number 14 | public dropChance: number 15 | public isDefensive: boolean 16 | public storeSellPrice: number 17 | public playerSellPrice: number 18 | 19 | constructor(id: number, 20 | itemId: ItemsIds, 21 | type: ItemType, 22 | gearType: GearType, 23 | coins: number, 24 | despawnTime: number, 25 | level: number, 26 | isDefensive: boolean, 27 | bonusAttack: number, 28 | bonusDefense: number, 29 | healthRefuel: number, 30 | dropChance: number, 31 | storeSellPrice: number, 32 | playerSellPrice: number) { 33 | this.id = id 34 | this.itemId = itemId 35 | this.type = type 36 | this.gearType = gearType 37 | this.despawnTime = despawnTime == 0 ? 30000 : despawnTime 38 | this.coins = coins 39 | this.level = level 40 | this.isDefensive = isDefensive 41 | this.bonusAttack = !isDefensive ? Math.floor(level/2) + 2 + bonusAttack : bonusAttack 42 | this.bonusDefense = isDefensive ? Math.floor(level/2) + 1 + bonusDefense : bonusDefense 43 | this.healthRefuel = healthRefuel 44 | this.dropChance = dropChance 45 | this.storeSellPrice = storeSellPrice 46 | this.playerSellPrice = playerSellPrice 47 | } 48 | } -------------------------------------------------------------------------------- /server/entities/items/itemPrices.ts: -------------------------------------------------------------------------------- 1 | export const buyPrice = { 2 | Coffee: 5, 3 | Coin: 1, 4 | WoodenDagger: 1, 5 | WoodenSword: 5, 6 | BronzeDagger: 25, 7 | BronzeSword: 27, 8 | IronDagger: 150, 9 | IronSword: 155, 10 | BluriteDagger: 195, 11 | BluriteSword: 200, 12 | AdamantDagger: 250, 13 | AdamantSword: 260, 14 | FireDagger: 450, 15 | FireSword: 500, 16 | WoodenHelm: 15, 17 | BronzeHelm: 30, 18 | IronHelm: 145, 19 | BluriteHelm: 195, 20 | AdamantHelm: 230, 21 | FireHelm: 400, 22 | WoodenArmour: 20, 23 | BronzeArmour: 40, 24 | IronArmour: 165, 25 | BluriteArmour: 210, 26 | AdamantArmour: 280, 27 | FireArmour: 600, 28 | WoodenLegs: 20, 29 | BronzeLegs: 33, 30 | IronLegs: 150, 31 | BluriteLegs: 200, 32 | AdamantLegs: 250, 33 | FireLegs: 450, 34 | Bread: 15, 35 | SmallHp: 20, 36 | LargeHp: 30, 37 | JamulsMachete: 0, 38 | JamulsGuitar: 0, 39 | CactusJuice: 0, 40 | SacredStone: 0, 41 | SacredFireSword: 99999999, 42 | } 43 | 44 | export const sellPrice = { 45 | Coffee: 1, 46 | Coin: 1, 47 | WoodenDagger: 0, 48 | WoodenSword: 1, 49 | BronzeDagger: 5, 50 | BronzeSword: 5, 51 | IronDagger: 15, 52 | IronSword: 15, 53 | BluriteDagger: 20, 54 | BluriteSword: 20, 55 | AdamantDagger: 40, 56 | AdamantSword: 50, 57 | FireDagger: 100, 58 | FireSword: 120, 59 | WoodenHelm: 1, 60 | BronzeHelm: 4, 61 | IronHelm: 10, 62 | BluriteHelm: 15, 63 | AdamantHelm: 20, 64 | FireHelm: 75, 65 | WoodenArmour: 2, 66 | BronzeArmour: 10, 67 | IronArmour: 17, 68 | BluriteArmour: 25, 69 | AdamantArmour: 30, 70 | FireArmour: 100, 71 | WoodenLegs: 1, 72 | BronzeLegs: 3, 73 | IronLegs: 10, 74 | BluriteLegs: 15, 75 | AdamantLegs: 20, 76 | FireLegs: 50, 77 | Bread: 1, 78 | SmallHp: 5, 79 | LargeHp: 10, 80 | JamulsMachete: 0, 81 | JamulsGuitar: 0, 82 | CactusJuice: 0, 83 | SacredStone: 0, 84 | SacredFireSword: 700, 85 | } -------------------------------------------------------------------------------- /server/entities/items/jamulsGuitar.ts: -------------------------------------------------------------------------------- 1 | import { ItemsIds, ItemType, GearType } from "../../../shared/Enums.ts" 2 | import ItemBase from "./itemBase.ts" 3 | 4 | export default class JamulsGuitar extends ItemBase { 5 | 6 | constructor(dropChance: number) { 7 | super(0, ItemsIds.JamulsGuitar, ItemType.Weareable, GearType.Weapon, 0, 0, 1, true, 0, 0, 0, dropChance, 0, 0) 8 | } 9 | } -------------------------------------------------------------------------------- /server/entities/items/jamulsMachete.ts: -------------------------------------------------------------------------------- 1 | import { ItemsIds, ItemType, GearType } from "../../../shared/Enums.ts" 2 | import ItemBase from "./itemBase.ts" 3 | 4 | export default class JamulsMachete extends ItemBase { 5 | 6 | constructor(dropChance: number) { 7 | super(0, ItemsIds.JamulsMachete, ItemType.Quest, GearType.None, 0, 0, 0, false, 0, 0, 0, dropChance, 0, 0) 8 | } 9 | } -------------------------------------------------------------------------------- /server/entities/items/sacredFireSword.ts: -------------------------------------------------------------------------------- 1 | import { ItemsIds, ItemType, GearType } from "../../../shared/Enums.ts" 2 | import ItemBase from "./itemBase.ts" 3 | import { buyPrice, sellPrice } from "./itemPrices.ts"; 4 | 5 | export default class SacredFireSword extends ItemBase { 6 | 7 | constructor(dropChance: number, customBuyPrice: number = 0) { 8 | super(0, ItemsIds.SacredFireSword, ItemType.Weareable, GearType.Weapon, 0, 0, 50, false, 8, 8, 0, dropChance, (customBuyPrice !== 0 ? customBuyPrice : buyPrice.SacredFireSword), sellPrice.SacredFireSword) 9 | } 10 | } -------------------------------------------------------------------------------- /server/entities/items/sacredStone.ts: -------------------------------------------------------------------------------- 1 | import { ItemsIds, ItemType, GearType } from "../../../shared/Enums.ts" 2 | import ItemBase from "./itemBase.ts" 3 | 4 | export default class SacredStone extends ItemBase { 5 | 6 | constructor(dropChance: number) { 7 | super(0, ItemsIds.SacredStone, ItemType.Quest, GearType.None, 0, 0, 0, false, 0, 0, 0, dropChance, 0, 0) 8 | } 9 | } -------------------------------------------------------------------------------- /server/entities/items/woodenArmour.ts: -------------------------------------------------------------------------------- 1 | import { ItemsIds, ItemType, GearType } from "../../../shared/Enums.ts" 2 | import ItemBase from "./itemBase.ts" 3 | import { buyPrice, sellPrice } from "./itemPrices.ts"; 4 | 5 | export default class WoodenArmour extends ItemBase { 6 | 7 | constructor(dropChance: number, customBuyPrice: number = 0) { 8 | super(0, ItemsIds.WoodenArmour, ItemType.Weareable, GearType.Torso, 0, 0, 1, true, 0, 0, 0, dropChance, (customBuyPrice !== 0 ? customBuyPrice : buyPrice.WoodenArmour), sellPrice.WoodenArmour) 9 | } 10 | } -------------------------------------------------------------------------------- /server/entities/items/woodenDagger.ts: -------------------------------------------------------------------------------- 1 | import { ItemsIds, ItemType, GearType } from "../../../shared/Enums.ts" 2 | import ItemBase from "./itemBase.ts" 3 | import { buyPrice, sellPrice } from "./itemPrices.ts" 4 | 5 | export default class WoodenDagger extends ItemBase { 6 | 7 | constructor(dropChance: number, customBuyPrice: number = 0) { 8 | super(0, ItemsIds.WoodenDagger, ItemType.Weareable, GearType.Weapon, 0, 0, 1, false, 1, 0, 0, dropChance, (customBuyPrice !== 0 ? customBuyPrice : buyPrice.WoodenDagger), sellPrice.WoodenDagger) 9 | } 10 | } -------------------------------------------------------------------------------- /server/entities/items/woodenHelm.ts: -------------------------------------------------------------------------------- 1 | import { ItemsIds, ItemType, GearType } from "../../../shared/Enums.ts" 2 | import ItemBase from "./itemBase.ts" 3 | import { buyPrice, sellPrice } from "./itemPrices.ts"; 4 | 5 | export default class WoodenHelm extends ItemBase { 6 | 7 | constructor(dropChance: number, customBuyPrice: number = 0) { 8 | super(0, ItemsIds.WoodenHelm, ItemType.Weareable, GearType.Head, 0, 0, 1, true, 0, 0, 0, dropChance, (customBuyPrice !== 0 ? customBuyPrice : buyPrice.WoodenHelm), sellPrice.WoodenHelm) 9 | } 10 | } -------------------------------------------------------------------------------- /server/entities/items/woodenLegs.ts: -------------------------------------------------------------------------------- 1 | import { ItemsIds, ItemType, GearType } from "../../../shared/Enums.ts" 2 | import ItemBase from "./itemBase.ts" 3 | import { buyPrice, sellPrice } from "./itemPrices.ts"; 4 | 5 | export default class WoodenLegs extends ItemBase { 6 | 7 | constructor(dropChance: number, customBuyPrice: number = 0) { 8 | super(0, ItemsIds.WoodenLegs, ItemType.Weareable, GearType.Legs, 0, 0, 1, true, 0, 0, 0, dropChance, (customBuyPrice !== 0 ? customBuyPrice : buyPrice.WoodenLegs), sellPrice.WoodenLegs) 9 | } 10 | } -------------------------------------------------------------------------------- /server/entities/items/woodenSword.ts: -------------------------------------------------------------------------------- 1 | import { ItemsIds, ItemType, GearType } from "../../../shared/Enums.ts" 2 | import ItemBase from "./itemBase.ts" 3 | import { buyPrice, sellPrice } from "./itemPrices.ts"; 4 | 5 | export default class WoodenSword extends ItemBase { 6 | 7 | constructor(dropChance: number, customBuyPrice: number = 0) { 8 | super(0, ItemsIds.WoodenSword, ItemType.Weareable, GearType.Weapon, 0, 0, 1, false, 0, 1, 0, dropChance, (customBuyPrice !== 0 ? customBuyPrice : buyPrice.WoodenSword), sellPrice.WoodenSword) 9 | } 10 | } -------------------------------------------------------------------------------- /server/entities/npcs/adamantGhost.ts: -------------------------------------------------------------------------------- 1 | import { Npcs } from '../../../shared/Enums.ts' 2 | import NpcBase from './npcBase.ts' 3 | import AdamantHelm from '../items/adamantHelm.ts' 4 | import AdamantSword from '../items/adamantSword.ts' 5 | import LargeHp from '../items/consumable/largeHp.ts' 6 | 7 | export default class AdamantGhost extends NpcBase { 8 | constructor() { 9 | super(Npcs.AdamantGhost, true, 'adamantghost', 0, 0, 0, 40, 10000, 0.25, 6, 36, null, [new AdamantHelm(0.2), new AdamantSword(0.5), new LargeHp(0.5)], null) 10 | } 11 | } -------------------------------------------------------------------------------- /server/entities/npcs/bee.ts: -------------------------------------------------------------------------------- 1 | import { Npcs } from '../../../shared/Enums.ts' 2 | import NpcBase from './npcBase.ts' 3 | import Bread from '../items/consumable/bread.ts' 4 | import WoodenDagger from '../items/woodenDagger.ts' 5 | 6 | export default class Bee extends NpcBase { 7 | constructor() { 8 | super(Npcs.Bee, true, 'bee', 0, 0, 0, 2, 10000, 0.45, 8, 36, null, [new WoodenDagger(0.2),new Bread(0.4)], null) 9 | } 10 | } -------------------------------------------------------------------------------- /server/entities/npcs/butterflew.ts: -------------------------------------------------------------------------------- 1 | import { Npcs } from '../../../shared/Enums.ts' 2 | import NpcBase from './npcBase.ts' 3 | import SmallHp from '../items/consumable/smallHp.ts' 4 | import BronzeHelm from "../items/bronzeHelm.ts" 5 | 6 | export default class ButterFlew extends NpcBase { 7 | constructor() { 8 | super(Npcs.ButterFlew, true, 'butterflew', 0, 0, 0, 17, 10000, 0.25, 6, 36, null, [new BronzeHelm(0.8), new SmallHp(0.4)], null) 9 | } 10 | } -------------------------------------------------------------------------------- /server/entities/npcs/camel.ts: -------------------------------------------------------------------------------- 1 | import { Npcs } from '../../../shared/Enums.ts' 2 | import NpcBase from './npcBase.ts' 3 | 4 | export default class Camel extends NpcBase { 5 | constructor() { 6 | super(Npcs.Camel, false, 'camel', 0, 0, 0, 0, 1000, 0.25, 0, 36, null, [], null) 7 | } 8 | } -------------------------------------------------------------------------------- /server/entities/npcs/chicken.ts: -------------------------------------------------------------------------------- 1 | import { Npcs } from '../../../shared/Enums.ts' 2 | import NpcBase from './npcBase.ts' 3 | 4 | export default class Chicken extends NpcBase { 5 | constructor() { 6 | super(Npcs.Chicken, false, 'chicken', 0, 0, 0, 0, 1000, 0.25, 0, 36, null, [], null) 7 | } 8 | } -------------------------------------------------------------------------------- /server/entities/npcs/cow.ts: -------------------------------------------------------------------------------- 1 | import { Npcs } from '../../../shared/Enums.ts' 2 | import NpcBase from './npcBase.ts' 3 | 4 | export default class Cow extends NpcBase { 5 | constructor() { 6 | super(Npcs.Cow, false, 'cow', 0, 0, 0, 0, 1000, 0.25, 0, 36, null, [], null) 7 | } 8 | } -------------------------------------------------------------------------------- /server/entities/npcs/cursedCactus.ts: -------------------------------------------------------------------------------- 1 | import { Npcs } from '../../../shared/Enums.ts' 2 | import NpcBase from './npcBase.ts' 3 | import AdamantHelm from '../items/adamantHelm.ts' 4 | import CactusJuice from '../items/consumable/cactusJuice.ts' 5 | import SmallHp from "../items/consumable/smallHp.ts" 6 | 7 | export default class CursedCactus extends NpcBase { 8 | constructor() { 9 | super(Npcs.CursedCactus, true, 'cursedcactus', 0, 0, 0, 40, 10000, 0.25, 6, 36, null, [new CactusJuice(0.1), new AdamantHelm(0.15), new SmallHp(0.5)], null) 10 | } 11 | } -------------------------------------------------------------------------------- /server/entities/npcs/demon.ts: -------------------------------------------------------------------------------- 1 | import { Npcs } from '../../../shared/Enums.ts' 2 | import NpcBase from './npcBase.ts' 3 | import FireHelm from '../items/fireHelm.ts' 4 | import FireArmour from '../items/fireArmour.ts' 5 | import LargeHp from "../items/consumable/largeHp.ts" 6 | 7 | export default class Demon extends NpcBase { 8 | constructor() { 9 | super(Npcs.Demon, true, 'demon', 0, 5, 0, 75, 10000, 0.25, 8, 36, null, [new FireArmour(0.3), new FireHelm(0.4), new LargeHp(0.7)], null) 10 | } 11 | } -------------------------------------------------------------------------------- /server/entities/npcs/demon2.ts: -------------------------------------------------------------------------------- 1 | import { Npcs } from '../../../shared/Enums.ts' 2 | import NpcBase from './npcBase.ts' 3 | import FireLegs from '../items/fireLegs.ts' 4 | import FireDagger from '../items/fireDagger.ts' 5 | import FireSword from '../items/fireSword.ts' 6 | import LargeHp from "../items/consumable/largeHp.ts" 7 | 8 | export default class Demon2 extends NpcBase { 9 | constructor() { 10 | super(Npcs.Demon2, true, 'demon', 0, 5, 5, 75, 10000, 0.25, 8, 36, null, [new FireDagger(0.5), new FireLegs(0.6), new FireSword(0.5), new LargeHp(0.7)], null) 11 | } 12 | } -------------------------------------------------------------------------------- /server/entities/npcs/document.ts: -------------------------------------------------------------------------------- 1 | import { Npcs } from '../../../shared/Enums.ts' 2 | import NpcBase from './npcBase.ts' 3 | import Coffee from '../items/consumable/coffee.ts' 4 | 5 | export default class Document extends NpcBase { 6 | constructor() { 7 | super(Npcs.Document, true, 'document', 0, 0, 0, 20, 10000, 0.25, 6, 18, null, [new Coffee(0.1)], null) 8 | } 9 | } -------------------------------------------------------------------------------- /server/entities/npcs/dog.ts: -------------------------------------------------------------------------------- 1 | import { Npcs } from '../../../shared/Enums.ts' 2 | import NpcBase from './npcBase.ts' 3 | import UpdatesDogDialog from "./passive/dialogs/updatesDogDialog.ts"; 4 | 5 | export default class Dog extends NpcBase { 6 | constructor() { 7 | super(Npcs.Dog, false, 'dog', 0, 0, 0, 0, 1000, 0.25, 0, 36, new UpdatesDogDialog(), [], null) 8 | } 9 | } -------------------------------------------------------------------------------- /server/entities/npcs/evilEye.ts: -------------------------------------------------------------------------------- 1 | import { Npcs } from '../../../shared/Enums.ts' 2 | import NpcBase from './npcBase.ts' 3 | import IronSword from "../items/ironSword.ts" 4 | import BronzeSword from "../items/bronzeSword.ts" 5 | import SmallHp from "../items/consumable/smallHp.ts" 6 | 7 | export default class EvilEye extends NpcBase { 8 | constructor() { 9 | super(Npcs.EvilEye, true, 'evileye', 0, 0, 0, 25, 10000, 0.25, 6, 42, null, [new IronSword(0.8), new BronzeSword(0.9), new SmallHp(0.4)], null) 10 | } 11 | } -------------------------------------------------------------------------------- /server/entities/npcs/fireBlob.ts: -------------------------------------------------------------------------------- 1 | import { Npcs } from '../../../shared/Enums.ts' 2 | import NpcBase from './npcBase.ts' 3 | import FireDagger from '../items/fireDagger.ts' 4 | import FireHelm from '../items/fireHelm.ts' 5 | import AdamantSword from "../items/adamantSword.ts" 6 | import LargeHp from "../items/consumable/largeHp.ts" 7 | 8 | export default class FireBlob extends NpcBase { 9 | constructor() { 10 | super(Npcs.FireBlob, true, 'fireblob', 0, 0, 0, 50, 10000, 0.25, 6, 36, null, [new FireHelm(0.1), new FireDagger(0.1), new AdamantSword(0.9), new LargeHp(0.8)], null) 11 | } 12 | } -------------------------------------------------------------------------------- /server/entities/npcs/goblin.ts: -------------------------------------------------------------------------------- 1 | import { Npcs } from '../../../shared/Enums.ts' 2 | import NpcBase from './npcBase.ts' 3 | import Coffee from '../items/consumable/coffee.ts' 4 | import BronzeDagger from '../items/bronzeDagger.ts' 5 | import WoodenArmour from '../items/woodenArmour.ts' 6 | import SmallHp from "../items/consumable/smallHp.ts" 7 | 8 | export default class Goblin extends NpcBase { 9 | constructor() { 10 | super(Npcs.Goblin, true, 'goblin', 0, 0, 0, 10, 10000, 0.25, 6, 36, null, [new WoodenArmour(0.5),new BronzeDagger(0.2), new Coffee(0.6), new SmallHp(0.6)], null) 11 | } 12 | } -------------------------------------------------------------------------------- /server/entities/npcs/goblin2.ts: -------------------------------------------------------------------------------- 1 | import { Npcs } from '../../../shared/Enums.ts' 2 | import NpcBase from './npcBase.ts' 3 | import Coffee from '../items/consumable/coffee.ts' 4 | import BronzeHelm from '../items/bronzeHelm.ts' 5 | import WoodenSword from '../items/woodenSword.ts' 6 | import SmallHp from "../items/consumable/smallHp.ts" 7 | 8 | export default class Goblin2 extends NpcBase { 9 | constructor() { 10 | super(Npcs.Goblin2, true, 'goblin', 0, 0, 0, 10, 10000, 0.25, 6, 36, null, [new WoodenSword(0.5), new BronzeHelm(0.2),new Coffee(0.4), new SmallHp(0.3)], null) 11 | } 12 | } -------------------------------------------------------------------------------- /server/entities/npcs/goblin3.ts: -------------------------------------------------------------------------------- 1 | import { Npcs } from '../../../shared/Enums.ts' 2 | import NpcBase from './npcBase.ts' 3 | import BronzeDagger from '../items/bronzeDagger.ts' 4 | import BronzeArmour from "../items/bronzeArmour.ts" 5 | import SmallHp from "../items/consumable/smallHp.ts" 6 | 7 | export default class Goblin3 extends NpcBase { 8 | constructor() { 9 | super(Npcs.Goblin3, true, 'goblin', 0, 0, 0, 10, 10000, 0.25, 6, 36, null, [new BronzeArmour(0.2),new BronzeDagger(0.2),new SmallHp(0.4)], null) 10 | } 11 | } -------------------------------------------------------------------------------- /server/entities/npcs/grassSnake.ts: -------------------------------------------------------------------------------- 1 | import { Npcs } from '../../../shared/Enums.ts' 2 | import NpcBase from './npcBase.ts' 3 | import BronzeHelm from "../items/bronzeHelm.ts" 4 | import BronzeSword from "../items/bronzeSword.ts" 5 | import IronArmour from "../items/ironArmour.ts" 6 | import SmallHp from "../items/consumable/smallHp.ts" 7 | 8 | export default class GrassSnake extends NpcBase { 9 | constructor() { 10 | super(Npcs.GrassSnake, true, 'grasssnake', 0, 0, 0, 20, 10000, 0.25, 6, 36, null, [new IronArmour(0.4), new BronzeSword(0.8), new BronzeHelm(0.8), new SmallHp(0.4)], null) 11 | } 12 | } -------------------------------------------------------------------------------- /server/entities/npcs/horse.ts: -------------------------------------------------------------------------------- 1 | import { Npcs } from '../../../shared/Enums.ts' 2 | import NpcBase from './npcBase.ts' 3 | 4 | export default class Horse extends NpcBase { 5 | constructor() { 6 | super(Npcs.Horse, false, 'horse', 0, 0, 0, 0, 1000, 0, 0, 36, null, [], null) 7 | } 8 | } -------------------------------------------------------------------------------- /server/entities/npcs/horse2.ts: -------------------------------------------------------------------------------- 1 | import { Npcs } from '../../../shared/Enums.ts' 2 | import NpcBase from './npcBase.ts' 3 | 4 | export default class Horse2 extends NpcBase { 5 | constructor() { 6 | super(Npcs.Horse2, false, 'horse2', 0, 0, 0, 0, 1000, 0.05, 0, 36, null, [], null) 7 | } 8 | } -------------------------------------------------------------------------------- /server/entities/npcs/impArcher.ts: -------------------------------------------------------------------------------- 1 | import { Npcs } from '../../../shared/Enums.ts' 2 | import NpcBase from './npcBase.ts' 3 | import Coffee from '../items/consumable/coffee.ts' 4 | import WoodenHelm from '../items/woodenHelm.ts' 5 | import WoodenArmour from '../items/woodenArmour.ts' 6 | import Bread from "../items/consumable/bread.ts" 7 | 8 | export default class ImpArcher extends NpcBase { 9 | constructor() { 10 | super(Npcs.ImpArcher, true, 'imp archer', 1, 0, 0, 5, 10000, 0.15, 2, 42, null, [new WoodenHelm(0.3),new WoodenArmour(0.2), new Bread(0.3),new Coffee(0.4)], null) 11 | } 12 | } -------------------------------------------------------------------------------- /server/entities/npcs/impMage.ts: -------------------------------------------------------------------------------- 1 | import { Npcs } from '../../../shared/Enums.ts' 2 | import NpcBase from './npcBase.ts' 3 | import Coffee from '../items/consumable/coffee.ts' 4 | import WoodenLegs from '../items/woodenLegs.ts' 5 | 6 | export default class ImpMage extends NpcBase { 7 | constructor() { 8 | super(Npcs.ImpMage, true, 'imp mage', 0, 1, 0, 5, 10000, 0.25, 4, 36, null, [new WoodenLegs(0.2),new Coffee(0.4)], null) 9 | } 10 | } -------------------------------------------------------------------------------- /server/entities/npcs/impMeelee.ts: -------------------------------------------------------------------------------- 1 | import { Npcs } from '../../../shared/Enums.ts' 2 | import NpcBase from './npcBase.ts' 3 | import Coffee from '../items/consumable/coffee.ts' 4 | import WoodenDagger from '../items/woodenDagger.ts' 5 | import WoodenSword from '../items/woodenSword.ts' 6 | 7 | export default class ImpMeelee extends NpcBase { 8 | constructor() { 9 | super(Npcs.ImpMeelee, true, 'imp meelee', 0, 0, 0, 4, 10000, 0.35, 6, 24, null, [new WoodenDagger(0.3),new WoodenSword(0.2),new Coffee(0.4)], null) 10 | } 11 | } -------------------------------------------------------------------------------- /server/entities/npcs/ligneus.ts: -------------------------------------------------------------------------------- 1 | import { Npcs } from '../../../shared/Enums.ts' 2 | import NpcBase from './npcBase.ts' 3 | import WoodenDagger from '../items/woodenDagger.ts' 4 | import WoodenSword from '../items/woodenSword.ts' 5 | import WoodenArmour from '../items/woodenArmour.ts' 6 | import BronzeArmour from "../items/bronzeArmour.ts" 7 | import SmallHp from "../items/consumable/smallHp.ts" 8 | 9 | export default class Ligneus extends NpcBase { 10 | constructor() { 11 | super(Npcs.Ligneus, true, 'ligneus', 0, 0, 0, 15, 10000, 0.15, 8, 36, null, [new WoodenDagger(0.7),new WoodenSword(0.7),new WoodenArmour(0.7),new BronzeArmour(0.2),new SmallHp(0.5)], null) 12 | } 13 | } -------------------------------------------------------------------------------- /server/entities/npcs/npcBase.ts: -------------------------------------------------------------------------------- 1 | import { Npcs } from "../../../shared/Enums.ts" 2 | import ItemBase from "../items/itemBase.ts" 3 | import DialogBase from "./passive/dialogs/dialogBase.ts" 4 | import QuestBase from "./quests/questBase.ts" 5 | 6 | export default class NpcBase { 7 | public id: Npcs 8 | public agressive: boolean 9 | public name: string 10 | public hp: number 11 | public attack: number 12 | public defense: number 13 | public level: number 14 | public xpGiven: number 15 | public respawnTime: number 16 | public frequency: number 17 | public moveChance: number 18 | public anger: number 19 | public fieldOfView: number 20 | public isMerchant: boolean 21 | public sells: ItemBase[] 22 | public dialog: DialogBase | null 23 | public drops: ItemBase[] 24 | public quest: QuestBase | null 25 | 26 | constructor(id: number, 27 | agressive: boolean, 28 | name: string, 29 | hpBonus: number, 30 | attackBonus: number, 31 | defenseBonus: number, 32 | level: number, 33 | respawnTime: number, 34 | moveChance: number, 35 | anger: number, 36 | fieldOfView: number, 37 | dialog: DialogBase | null, 38 | drops: ItemBase[], 39 | quest: QuestBase | null, 40 | isMerchant: boolean = false, 41 | sells: ItemBase[] = []) { 42 | this.id = id 43 | this.agressive = agressive 44 | this.name = name 45 | this.level = level 46 | this.xpGiven = +((level**1.1)+5).toFixed(2) 47 | this.hp = (level + 9) + hpBonus 48 | this.attack = (level + 2) + attackBonus 49 | this.defense = (level + 2) + defenseBonus 50 | this.respawnTime = respawnTime 51 | this.frequency = 500 52 | this.moveChance = moveChance 53 | this.anger = anger 54 | this.fieldOfView = fieldOfView 55 | this.dialog = dialog 56 | this.drops = drops 57 | this.quest = quest 58 | this.isMerchant = isMerchant 59 | this.sells = sells 60 | } 61 | } -------------------------------------------------------------------------------- /server/entities/npcs/ogre.ts: -------------------------------------------------------------------------------- 1 | import { Npcs } from '../../../shared/Enums.ts' 2 | import NpcBase from './npcBase.ts' 3 | import BluriteDagger from '../items/bluriteDagger.ts' 4 | import BluriteSword from '../items/bluriteSword.ts' 5 | import IronArmour from "../items/ironArmour.ts" 6 | import IronLegs from "../items/ironLegs.ts" 7 | import SmallHp from "../items/consumable/smallHp.ts" 8 | 9 | export default class Ogre extends NpcBase { 10 | constructor() { 11 | super(Npcs.Ogre, true, 'ogre', 0, 0, 0, 30, 10000, 0.25, 6, 36, null, [new SmallHp(0.2), new BluriteDagger(0.2), new BluriteSword(0.5), new IronArmour(0.8), new IronLegs(0.8)], null) 12 | } 13 | } -------------------------------------------------------------------------------- /server/entities/npcs/passive/dialogs/abidDialog.ts: -------------------------------------------------------------------------------- 1 | import DialogBase from "./dialogBase.ts" 2 | 3 | export default class AbidDialog extends DialogBase { 4 | constructor() { 5 | super(['Welcome to Kharjid', 6 | 'I\'m Abid the salesman', 7 | 'what do you need?','']) 8 | } 9 | } -------------------------------------------------------------------------------- /server/entities/npcs/passive/dialogs/achmedDialog.ts: -------------------------------------------------------------------------------- 1 | import DialogBase from "./dialogBase.ts" 2 | 3 | export default class AchmedDialog extends DialogBase { 4 | constructor() { 5 | super(['Don\'t go east!', 6 | 'There are massive demons', 7 | 'Kharjid is your last chance to go back!','']) 8 | } 9 | } -------------------------------------------------------------------------------- /server/entities/npcs/passive/dialogs/beatriceDialog.ts: -------------------------------------------------------------------------------- 1 | import DialogBase from "./dialogBase.ts" 2 | 3 | export default class BeatriceDialog extends DialogBase { 4 | constructor() { 5 | super(['Hello! I\'m Beatrice', 6 | 'I can\'t talk much right now', 7 | 'I\'m training to become a doctor!', 8 | 'This place needs good doctors', 9 | 'and great warriors.', 10 | 'So we can heal the weak and fight the monsters','']) 11 | } 12 | } -------------------------------------------------------------------------------- /server/entities/npcs/passive/dialogs/borisDialog.ts: -------------------------------------------------------------------------------- 1 | import DialogBase from "./dialogBase.ts" 2 | 3 | export default class BorisDialog extends DialogBase { 4 | constructor() { 5 | super(['Hello, my name is Boris', 6 | 'I\'m a hunter, I also sell the food I hunt', 7 | 'but I\'m not selling anything yet','']) 8 | } 9 | } -------------------------------------------------------------------------------- /server/entities/npcs/passive/dialogs/castleGuardDialog.ts: -------------------------------------------------------------------------------- 1 | import DialogBase from "./dialogBase.ts" 2 | 3 | export default class CastleGuardDialog extends DialogBase { 4 | constructor() { 5 | super(['This is Subitnof\'s Castle', 6 | 'Don\'t break anything', 7 | 'and don\'t make loud noises', 8 | 'I\'ll be keeping an eye on you','']) 9 | } 10 | } -------------------------------------------------------------------------------- /server/entities/npcs/passive/dialogs/celineDialog.ts: -------------------------------------------------------------------------------- 1 | import DialogBase from "./dialogBase.ts" 2 | 3 | export default class CelineDialog extends DialogBase { 4 | constructor() { 5 | super(['Hi, my name is Celine', 6 | 'Once I was a very strong warrior', 7 | 'but those days are over for me', 8 | 'now I like to do needlework at home', 9 | 'since Subitnof has become', 10 | 'a very safe place for me','']) 11 | } 12 | } -------------------------------------------------------------------------------- /server/entities/npcs/passive/dialogs/cityGuardDialog.ts: -------------------------------------------------------------------------------- 1 | import DialogBase from "./dialogBase.ts" 2 | 3 | export default class CityGuardDialog extends DialogBase { 4 | constructor() { 5 | super(['Welcome to Subitnof', 6 | 'Here you\'ll find some merchants', 7 | 'maybe some people might trust you a quest', 8 | 'the castle is south west', 9 | 'long live Subitnof and the king!','']) 10 | } 11 | } -------------------------------------------------------------------------------- /server/entities/npcs/passive/dialogs/cooperDialog.ts: -------------------------------------------------------------------------------- 1 | import DialogBase from "./dialogBase.ts" 2 | 3 | export default class CooperDialog extends DialogBase { 4 | constructor() { 5 | super(['Hi, I\'m Cooper', 6 | 'I used to be a farmer', 7 | 'now I\'m a researcher', 8 | 'I study the history of Tiny Land', 9 | 'This world is 6000 years old', 10 | 'Something hapened around 3000 years ago', 11 | 'that brought weird evil creatures', 12 | 'like imps, giant snakes, rats, spirits', 13 | 'but the most terible are the demons', 14 | 'they say there are some actual demons', 15 | 'on the deserts', 16 | 'but i\'ve never seen them','']) 17 | } 18 | } -------------------------------------------------------------------------------- /server/entities/npcs/passive/dialogs/deriDialog.ts: -------------------------------------------------------------------------------- 1 | import DialogBase from "./dialogBase.ts" 2 | 3 | export default class DeriDialog extends DialogBase { 4 | constructor() { 5 | super(['My name is Deri', 'I owe my life to the Grand Tree','']) 6 | } 7 | } -------------------------------------------------------------------------------- /server/entities/npcs/passive/dialogs/dialogBase.ts: -------------------------------------------------------------------------------- 1 | 2 | 3 | export default class DialogBase { 4 | public dialogs: string[] 5 | public playerCurrentLine: {playerId:string,line:number,totalLines:number}[] = [] 6 | constructor(dialogs: string[]) { 7 | this.dialogs = dialogs 8 | } 9 | } -------------------------------------------------------------------------------- /server/entities/npcs/passive/dialogs/ediogDialog.ts: -------------------------------------------------------------------------------- 1 | import DialogBase from "./dialogBase.ts" 2 | 3 | export default class EdiogDialog extends DialogBase { 4 | constructor() { 5 | super(['Greetings traveler', 6 | 'I\'m Wizard Ediog', 7 | 'This is the Mages Tower', 8 | 'It\'s not yet accessible to visitors', 9 | 'but soon that door will be open.', 10 | 'Mages and Wizards gather here', 11 | 'to research and create spells', 12 | 'against evil beings of Tiny Land', 13 | 'specially demons.', 14 | 'As far as we know, there are lots of them', 15 | 'in south desert', 16 | 'We think there might have been', 17 | 'some sort of portal that brought them', 18 | 'to this land, about 3000 years ago', 19 | 'In fact, you look like you could help', 20 | 'with a great part of the research', 21 | 'we have come to conclusion that', 22 | 'some answers may be found with a -stone-', 23 | 'we call it \'The Sacred Stone\'', 24 | 'we have come to conclusion that', 25 | 'someone in Subitnof is in possession', 26 | 'of the stone. Can you help us find it?', 27 | '-quest: The Sacred Stone-','']) 28 | } 29 | } -------------------------------------------------------------------------------- /server/entities/npcs/passive/dialogs/edmondDialog.ts: -------------------------------------------------------------------------------- 1 | import DialogBase from "./dialogBase.ts" 2 | 3 | export default class EdmondDialog extends DialogBase { 4 | constructor() { 5 | super(['I\'m Edmond', 6 | 'Life here is pretty hard', 7 | 'we are surrounded by woods filled with monsters','']) 8 | } 9 | } -------------------------------------------------------------------------------- /server/entities/npcs/passive/dialogs/edwardDialog.ts: -------------------------------------------------------------------------------- 1 | import DialogBase from "./dialogBase.ts" 2 | 3 | export default class EdwardDialog extends DialogBase { 4 | constructor() { 5 | super(['Hello adventurer', 6 | 'I\'m Mage Edward', 7 | 'I study and practice old magic', 8 | 'I don\'t have any request for you', 9 | 'Some other day maybe','']) 10 | } 11 | } -------------------------------------------------------------------------------- /server/entities/npcs/passive/dialogs/elexiusDialog.ts: -------------------------------------------------------------------------------- 1 | import DialogBase from "./dialogBase.ts" 2 | 3 | export default class ElexiusDialog extends DialogBase { 4 | constructor() { 5 | super(['Hi there dear traveller', 6 | 'I\'m Wizard Elexius', 7 | 'I study the sacred stone', 8 | 'We\'re trying to uncover the history', 9 | 'Of this land', 10 | 'We must know our past to understand our present.', 11 | 'Never forget this.','']) 12 | } 13 | } -------------------------------------------------------------------------------- /server/entities/npcs/passive/dialogs/ephanDialog.ts: -------------------------------------------------------------------------------- 1 | import DialogBase from "./dialogBase.ts" 2 | 3 | export default class EphanDialog extends DialogBase { 4 | constructor() { 5 | super(['Hi there! I\'m Ephan!', 6 | 'Looking foward to become a warrior someday', 7 | 'for now I\'m stuck with farming...', 8 | 'can you help me become a warrior?', 9 | 'all I need to begin is', 10 | 'a full Wooden Set!', 11 | 'a wooden set is the simplest armour set', 12 | 'anyone from level 1 can wear it', 13 | 'it would be perfect!', 14 | 'I need a wooden dagger, armour, legs and helm', 15 | 'can you bring it to me?', 16 | '-quest: Warrior Someday-','']) 17 | } 18 | } -------------------------------------------------------------------------------- /server/entities/npcs/passive/dialogs/feemlunkDialog.ts: -------------------------------------------------------------------------------- 1 | import DialogBase from "./dialogBase.ts" 2 | 3 | export default class FeemlunkDialog extends DialogBase { 4 | constructor() { 5 | super(['Welcome the the Gnome Village', 6 | 'my name is Feemlunk, i\'m the ancient gnome', 7 | 'responsible for this village and this tree.', 8 | 'Our main source of life is the Grand Tree!', 9 | 'It provides us food, shelter and most importantly', 10 | 'the breath of life. Its an invisible force', 11 | 'that the tree emanates in us', 12 | 'in order to emanate this power it needs', 13 | 'not only strong roots, but also, the power', 14 | 'of the Magi Stone. A mystical rock located underground.','']) 15 | } 16 | } -------------------------------------------------------------------------------- /server/entities/npcs/passive/dialogs/francisDialog.ts: -------------------------------------------------------------------------------- 1 | import DialogBase from "./dialogBase.ts" 2 | 3 | export default class FrancisDialog extends DialogBase { 4 | constructor() { 5 | super(['...', 6 | 'excuse me','']) 7 | } 8 | } -------------------------------------------------------------------------------- /server/entities/npcs/passive/dialogs/horvynDialog.ts: -------------------------------------------------------------------------------- 1 | import DialogBase from "./dialogBase.ts" 2 | 3 | export default class HorvynDialog extends DialogBase { 4 | constructor() { 5 | super(['My name is Horvyn', 6 | 'Someday I\'ll marry Mytklash!', 7 | 'I just don\'t know how to impress her...', 8 | 'You think you can help me? That would be awesome!', 9 | '-quest: flower for Mytklash-','']) 10 | } 11 | } -------------------------------------------------------------------------------- /server/entities/npcs/passive/dialogs/jamesDialog.ts: -------------------------------------------------------------------------------- 1 | import DialogBase from "./dialogBase.ts" 2 | 3 | export default class JamesDialog extends DialogBase { 4 | constructor() { 5 | super(['I\'m James', 6 | 'I love this city', 7 | 'these walls protect us from', 8 | 'all the weird agressive creatures', 9 | 'i owe my safe life to the king of Subitnof','']) 10 | } 11 | } -------------------------------------------------------------------------------- /server/entities/npcs/passive/dialogs/jamulDialog.ts: -------------------------------------------------------------------------------- 1 | import DialogBase from "./dialogBase.ts" 2 | 3 | export default class JamulDialog extends DialogBase { 4 | constructor() { 5 | super(['Hi kid. I\'m Jamul', 6 | 'I have a coconut business', 7 | 'but i\'ve lost my machete', 8 | 'I believe some zombie stole it', 9 | 'do you think you can help me?', 10 | '-quest: Jamul\'s Machete-','']) 11 | } 12 | } -------------------------------------------------------------------------------- /server/entities/npcs/passive/dialogs/jasmineDialog.ts: -------------------------------------------------------------------------------- 1 | import DialogBase from "./dialogBase.ts" 2 | 3 | export default class JasmineDialog extends DialogBase { 4 | constructor() { 5 | super(['Hello, I\'m Jasmine', 6 | 'Welcome to Subitnof!','']) 7 | } 8 | } -------------------------------------------------------------------------------- /server/entities/npcs/passive/dialogs/kingZanderDialog.ts: -------------------------------------------------------------------------------- 1 | import DialogBase from "./dialogBase.ts" 2 | 3 | export default class KingZanderDialog extends DialogBase { 4 | constructor() { 5 | super(['Hello traveller!', 6 | 'I\'m king Zander, carer of Subitnof', 7 | 'I take very good care of my people', 8 | 'but recently I\'ve been having trouble', 9 | 'dealing with Ogres', 10 | 'could you help our city by getting rid of some?', 11 | '-quest: somebody once told me-','']) 12 | } 13 | } -------------------------------------------------------------------------------- /server/entities/npcs/passive/dialogs/kinleyDialog.ts: -------------------------------------------------------------------------------- 1 | import DialogBase from "./dialogBase.ts" 2 | 3 | export default class KinleyDialog extends DialogBase { 4 | constructor() { 5 | super(['Hello traveller.', 6 | 'My name is Kinley', 7 | 'my friend there is Peter', 8 | 'We have some of the best items', 9 | 'to sell around here','']) 10 | } 11 | } -------------------------------------------------------------------------------- /server/entities/npcs/passive/dialogs/lissyDialog.ts: -------------------------------------------------------------------------------- 1 | import DialogBase from "./dialogBase.ts" 2 | 3 | export default class LissyDialog extends DialogBase { 4 | constructor() { 5 | super(['My name is Lissy', 6 | 'I do most of the hunting here','']) 7 | } 8 | } -------------------------------------------------------------------------------- /server/entities/npcs/passive/dialogs/lugrusDialog.ts: -------------------------------------------------------------------------------- 1 | import DialogBase from "./dialogBase.ts" 2 | 3 | export default class LugrusDialog extends DialogBase { 4 | constructor() { 5 | super(['Hi man, I\'m Lugrus', 6 | 'some people call me Uui', 7 | 'I hate the giant rats around the city', 8 | 'Could you get rid of some?', 9 | '-quest: damn rats-','']) 10 | } 11 | } -------------------------------------------------------------------------------- /server/entities/npcs/passive/dialogs/marcusDialog.ts: -------------------------------------------------------------------------------- 1 | import DialogBase from "./dialogBase.ts" 2 | 3 | export default class MarcusDialog extends DialogBase { 4 | constructor() { 5 | super(['Hello young man! I\'m Marcus', 6 | 'Once I was young just like yourself', 7 | 'slayed many evil creatures with my sword', 8 | 'enjoy your youth my man!', 9 | 'and never lose your young spirit!','']) 10 | } 11 | } -------------------------------------------------------------------------------- /server/entities/npcs/passive/dialogs/martyDialog.ts: -------------------------------------------------------------------------------- 1 | import DialogBase from "./dialogBase.ts" 2 | 3 | export default class MartyDialog extends DialogBase { 4 | constructor() { 5 | super(['I\'m Marty', 6 | 'cool armour you got there!', 7 | 'Talk to you later, I\'m out of time', 8 | 'just remeber: if you put your mind to it', 9 | 'you can accomplish anything!','']) 10 | } 11 | } -------------------------------------------------------------------------------- /server/entities/npcs/passive/dialogs/mathuisDialog.ts: -------------------------------------------------------------------------------- 1 | import DialogBase from "./dialogBase.ts" 2 | 3 | export default class MathuisDialog extends DialogBase { 4 | constructor() { 5 | super(['I hate this place', 6 | 'I\'m Mathuis Alah', 7 | 'it\'s sand and zombies everywhere', 8 | 'wish I could go back to Subitnof', 9 | 'you look like someone who could help', 10 | 'could you kill 50 zombies for Kharjid?', 11 | '-quest: Zombie Killer-','']) 12 | } 13 | } -------------------------------------------------------------------------------- /server/entities/npcs/passive/dialogs/miahDialog.ts: -------------------------------------------------------------------------------- 1 | import DialogBase from "./dialogBase.ts" 2 | 3 | export default class MiahDialog extends DialogBase { 4 | constructor() { 5 | super(['Hi, my name is Miah', 6 | 'I\'m sick of all the monsters arround here', 7 | 'why the hell would someone build a village', 8 | 'in the middle of the woods?','']) 9 | } 10 | } -------------------------------------------------------------------------------- /server/entities/npcs/passive/dialogs/michaelDialog.ts: -------------------------------------------------------------------------------- 1 | import DialogBase from "./dialogBase.ts" 2 | 3 | export default class MichaelDialog extends DialogBase { 4 | constructor() { 5 | super(['Good day sir! I\'m Michael', 6 | 'I want to open a bread business someday','']) 7 | } 8 | } -------------------------------------------------------------------------------- /server/entities/npcs/passive/dialogs/mytklashDialog.ts: -------------------------------------------------------------------------------- 1 | import DialogBase from "./dialogBase.ts" 2 | 3 | export default class MytklashDialog extends DialogBase { 4 | constructor() { 5 | super(['Hi! I\'m Mytklash', 6 | 'I love our village and our tree', 7 | 'I also love colleting flowers!', 8 | 'There are some really pretty ones far south!','']) 9 | } 10 | } -------------------------------------------------------------------------------- /server/entities/npcs/passive/dialogs/mytklashsFlowerDialog.ts: -------------------------------------------------------------------------------- 1 | import DialogBase from "./dialogBase.ts" 2 | 3 | export default class MytklashsFlowerDialog extends DialogBase { 4 | constructor() { 5 | super(['You see a weird looking flower']) 6 | } 7 | } -------------------------------------------------------------------------------- /server/entities/npcs/passive/dialogs/nestorDialog.ts: -------------------------------------------------------------------------------- 1 | import DialogBase from "./dialogBase.ts" 2 | 3 | export default class NestorDialog extends DialogBase { 4 | constructor() { 5 | super(['Pleasure to meet you, i\'m Nestor', 6 | 'I would really appreciate if you didn\'t step on my lawn','']) 7 | } 8 | } -------------------------------------------------------------------------------- /server/entities/npcs/passive/dialogs/oswaldDialog.ts: -------------------------------------------------------------------------------- 1 | import DialogBase from "./dialogBase.ts" 2 | 3 | export default class OswaldDialog extends DialogBase { 4 | constructor() { 5 | super(['Hello traveller, I\'m Oswald', 6 | 'Looking for something to buy?','']) 7 | } 8 | } -------------------------------------------------------------------------------- /server/entities/npcs/passive/dialogs/peterDialog.ts: -------------------------------------------------------------------------------- 1 | import DialogBase from "./dialogBase.ts" 2 | 3 | export default class PeterDialog extends DialogBase { 4 | constructor() { 5 | super(['Hi adventurer!', 6 | 'Looking for some goods to buy?','']) 7 | } 8 | } -------------------------------------------------------------------------------- /server/entities/npcs/passive/dialogs/reevesDialog.ts: -------------------------------------------------------------------------------- 1 | import DialogBase from "./dialogBase.ts" 2 | 3 | export default class ReevesDialog extends DialogBase { 4 | constructor() { 5 | super(['Howdy mate! I\'m farmer Reeves', 6 | 'Francis Darci scares me','']) 7 | } 8 | } -------------------------------------------------------------------------------- /server/entities/npcs/passive/dialogs/rogerDialog.ts: -------------------------------------------------------------------------------- 1 | import DialogBase from "./dialogBase.ts" 2 | 3 | export default class RogerDialog extends DialogBase { 4 | constructor() { 5 | super(['My name is Roger', 6 | 'I love the farming life, tho these monsters', 7 | 'make it quite a challenge','']) 8 | } 9 | } -------------------------------------------------------------------------------- /server/entities/npcs/passive/dialogs/updatesDogDialog.ts: -------------------------------------------------------------------------------- 1 | import DialogBase from "./dialogBase.ts" 2 | 3 | export default class UpdatesDogDialog extends DialogBase { 4 | constructor() { 5 | super(['Hi, Im the woofdates dog', 6 | 'The most recent woofdate is...', 7 | 'Interiors! 2024-12-26', 8 | 'Merry Christmas! Also...', 9 | 'now you can enter the Castle', 10 | 'at Subtinof and the Wizards Tower too!', 11 | 'I heard the king needs help with something', 12 | '-woofdate read-']) 13 | } 14 | } -------------------------------------------------------------------------------- /server/entities/npcs/passive/dialogs/vardanDialog.ts: -------------------------------------------------------------------------------- 1 | import DialogBase from "./dialogBase.ts" 2 | 3 | export default class VardanDialog extends DialogBase { 4 | constructor() { 5 | super(['I\'m Vardan, The wise ancient', 6 | 'This is the Deep Lake Village', 7 | 'in here we try to live our lives and deal with', 8 | 'all the creatures around. There was a time', 9 | 'when this place was peaceful and calm', 10 | 'but two hundred years ago, many vicious creatures', 11 | 'started to appear, not only in these woods', 12 | 'but in the whole land', 13 | 'we don\'t know what made these beasts appear', 14 | 'but I wish someone would help us with them...', 15 | 'After that bridge are the vast plains', 16 | 'be very careful there!', 17 | 'By the way, we would appreciate if you could', 18 | 'take care of some monsters around here', 19 | '-quest: help the lake village-','']) 20 | } 21 | } -------------------------------------------------------------------------------- /server/entities/npcs/passive/dialogs/zeroDialog.ts: -------------------------------------------------------------------------------- 1 | import DialogBase from "./dialogBase.ts" 2 | 3 | export default class ZeroDialog extends DialogBase { 4 | constructor() { 5 | super(['Hi! My name is Zero', 'I know the secret to become One!','']) 6 | } 7 | } -------------------------------------------------------------------------------- /server/entities/npcs/passive/gnomes/deri.ts: -------------------------------------------------------------------------------- 1 | import { Npcs } from '../../../../../shared/Enums.ts' 2 | import NpcBase from '../../npcBase.ts' 3 | import DeriDialog from "../dialogs/deriDialog.ts" 4 | 5 | export default class Deri extends NpcBase { 6 | constructor() { 7 | super(Npcs.FemaleGnome, false, 'deri', 0, 0, 0, 0, 1000, 0.05, 0, 36, new DeriDialog(), [], null) 8 | } 9 | } -------------------------------------------------------------------------------- /server/entities/npcs/passive/gnomes/feemlunk.ts: -------------------------------------------------------------------------------- 1 | import { Npcs } from '../../../../../shared/Enums.ts' 2 | import NpcBase from '../../npcBase.ts' 3 | import FeemlunkDialog from "../dialogs/feemlunkDialog.ts" 4 | 5 | export default class Feemlunk extends NpcBase { 6 | constructor() { 7 | super(Npcs.AncientGnome, false, 'feemlunk', 0, 0, 0, 0, 1000, 0, 0, 36, new FeemlunkDialog(), [], null) 8 | } 9 | } -------------------------------------------------------------------------------- /server/entities/npcs/passive/gnomes/horvyn.ts: -------------------------------------------------------------------------------- 1 | import { Npcs } from '../../../../../shared/Enums.ts' 2 | import NpcBase from '../../npcBase.ts' 3 | import FlowerForMytklash from "../../quests/gnomes/flowerForMytklash.ts" 4 | import HorvynDialog from "../dialogs/horvynDialog.ts" 5 | 6 | export default class Horvyn extends NpcBase { 7 | constructor() { 8 | super(Npcs.MaleGnome, false, 'horvyn', 0, 0, 0, 0, 1000, 0.05, 0, 36, new HorvynDialog(), [], new FlowerForMytklash()) 9 | } 10 | } -------------------------------------------------------------------------------- /server/entities/npcs/passive/gnomes/mytklash.ts: -------------------------------------------------------------------------------- 1 | import { Npcs } from '../../../../../shared/Enums.ts' 2 | import NpcBase from '../../npcBase.ts' 3 | import MytklashDialog from "../dialogs/mytklashDialog.ts" 4 | 5 | export default class Mytklash extends NpcBase { 6 | constructor() { 7 | super(Npcs.FemaleGnome, false, 'mytklash', 0, 0, 0, 0, 1000, 0.05, 0, 36, new MytklashDialog(), [], null) 8 | } 9 | } -------------------------------------------------------------------------------- /server/entities/npcs/passive/gnomes/mytklashsFlower.ts: -------------------------------------------------------------------------------- 1 | import { Npcs } from '../../../../../shared/Enums.ts' 2 | import NpcBase from '../../npcBase.ts' 3 | import MytklashsFlowerDialog from "../dialogs/mytklashsFlowerDialog.ts" 4 | 5 | export default class MytklashsFlower extends NpcBase { 6 | constructor() { 7 | super(Npcs.MytklashsFlower, false, 'mytklashs flower', 0, 0, 0, 0, 1000, 0, 0, 36, new MytklashsFlowerDialog(), [], null) 8 | } 9 | } -------------------------------------------------------------------------------- /server/entities/npcs/passive/gnomes/nestor.ts: -------------------------------------------------------------------------------- 1 | import { Npcs } from '../../../../../shared/Enums.ts' 2 | import NpcBase from '../../npcBase.ts' 3 | import NestorDialog from "../dialogs/nestorDialog.ts" 4 | 5 | export default class Nestor extends NpcBase { 6 | constructor() { 7 | super(Npcs.MaleGnome, false, 'nestor', 0, 0, 0, 0, 1000, 0.05, 0, 36, new NestorDialog(), [], null) 8 | } 9 | } -------------------------------------------------------------------------------- /server/entities/npcs/passive/humans/deepLake/edmond.ts: -------------------------------------------------------------------------------- 1 | import { Npcs } from '../../../../../../shared/Enums.ts' 2 | import NpcBase from '../../../npcBase.ts' 3 | import EdmondDialog from "../../dialogs/edmondDialog.ts" 4 | 5 | export default class Edmond extends NpcBase { 6 | constructor() { 7 | super(Npcs.BlackMaleFarmer, false, 'edmond', 0, 0, 0, 0, 1000, 0.05, 0, 36, new EdmondDialog(), [], null) 8 | } 9 | } -------------------------------------------------------------------------------- /server/entities/npcs/passive/humans/deepLake/lissy.ts: -------------------------------------------------------------------------------- 1 | import { Npcs } from '../../../../../../shared/Enums.ts' 2 | import NpcBase from '../../../npcBase.ts' 3 | import LissyDialog from "../../dialogs/lissyDialog.ts" 4 | 5 | export default class Lissy extends NpcBase { 6 | constructor() { 7 | super(Npcs.WhiteFemaleFarmer, false, 'lissy', 0, 0, 0, 0, 1000, 0.05, 0, 36, new LissyDialog(), [], null) 8 | } 9 | } -------------------------------------------------------------------------------- /server/entities/npcs/passive/humans/deepLake/miah.ts: -------------------------------------------------------------------------------- 1 | import { Npcs } from '../../../../../../shared/Enums.ts' 2 | import NpcBase from '../../../npcBase.ts' 3 | import MiahDialog from "../../dialogs/miahDialog.ts" 4 | 5 | export default class Miah extends NpcBase { 6 | constructor() { 7 | super(Npcs.BlackFemaleFarmer, false, 'miah', 0, 0, 0, 0, 1000, 0.05, 0, 36, new MiahDialog(), [], null) 8 | } 9 | } -------------------------------------------------------------------------------- /server/entities/npcs/passive/humans/deepLake/roger.ts: -------------------------------------------------------------------------------- 1 | import { Npcs } from '../../../../../../shared/Enums.ts' 2 | import NpcBase from '../../../npcBase.ts' 3 | import RogerDialog from "../../dialogs/rogerDialog.ts" 4 | 5 | export default class Roger extends NpcBase { 6 | constructor() { 7 | super(Npcs.WhiteMaleFarmer, false, 'roger', 0, 0, 0, 0, 1000, 0.05, 0, 36, new RogerDialog(), [], null) 8 | } 9 | } -------------------------------------------------------------------------------- /server/entities/npcs/passive/humans/deepLake/vardan.ts: -------------------------------------------------------------------------------- 1 | import { Npcs } from '../../../../../../shared/Enums.ts' 2 | import NpcBase from '../../../npcBase.ts' 3 | import HelpTheLakeVillage from "../../../quests/humans/deepLake/helpTheLakeVillage.ts" 4 | import VardanDialog from "../../dialogs/vardanDialog.ts" 5 | 6 | export default class Vardan extends NpcBase { 7 | constructor() { 8 | super(Npcs.OldMan, false, 'vardan', 0, 0, 0, 0, 1000, 0, 0, 36, new VardanDialog(), [], new HelpTheLakeVillage()) 9 | } 10 | } -------------------------------------------------------------------------------- /server/entities/npcs/passive/humans/kharjid/abid.ts: -------------------------------------------------------------------------------- 1 | import { Npcs } from '../../../../../../shared/Enums.ts' 2 | import AdamantDagger from "../../../../items/adamantDagger.ts"; 3 | import AdamantSword from "../../../../items/adamantSword.ts"; 4 | import BluriteArmour from "../../../../items/bluriteArmour.ts"; 5 | import BluriteHelm from "../../../../items/bluriteHelm.ts"; 6 | import BluriteLegs from "../../../../items/bluriteLegs.ts"; 7 | import NpcBase from '../../../npcBase.ts' 8 | import AbidDialog from "../../dialogs/abidDialog.ts" 9 | 10 | export default class Abid extends NpcBase { 11 | constructor() { 12 | super(Npcs.DesertMale3, false, 'abid', 0, 0, 0, 0, 1000, 0.05, 0, 36, new AbidDialog(), [], null, 13 | true, [new BluriteArmour(1), new BluriteLegs(1), new BluriteHelm(1), new AdamantDagger(1), new AdamantSword(1)]) 14 | } 15 | } -------------------------------------------------------------------------------- /server/entities/npcs/passive/humans/kharjid/achmed.ts: -------------------------------------------------------------------------------- 1 | import { Npcs } from '../../../../../../shared/Enums.ts' 2 | import NpcBase from '../../../npcBase.ts' 3 | import AchmedDialog from "../../dialogs/achmedDialog.ts" 4 | 5 | export default class Achmed extends NpcBase { 6 | constructor() { 7 | super(Npcs.DesertMale2, false, 'achmed', 0, 0, 0, 0, 1000, 0.05, 0, 36, new AchmedDialog(), [], null) 8 | } 9 | } -------------------------------------------------------------------------------- /server/entities/npcs/passive/humans/kharjid/jamul.ts: -------------------------------------------------------------------------------- 1 | import { Npcs } from '../../../../../../shared/Enums.ts' 2 | import NpcBase from '../../../npcBase.ts' 3 | import JamulsMachete from "../../../quests/humans/kharjid/jamulsMachete.ts" 4 | import JamulDialog from "../../dialogs/jamulDialog.ts" 5 | 6 | export default class Jamul extends NpcBase { 7 | constructor() { 8 | super(Npcs.DesertMale1, false, 'jamul', 0, 0, 0, 0, 1000, 0.05, 0, 36, new JamulDialog(), [], new JamulsMachete()) 9 | } 10 | } -------------------------------------------------------------------------------- /server/entities/npcs/passive/humans/kharjid/mathuis.ts: -------------------------------------------------------------------------------- 1 | import { Npcs } from '../../../../../../shared/Enums.ts' 2 | import NpcBase from '../../../npcBase.ts' 3 | import ZombieKiller from "../../../quests/humans/kharjid/zombieKiller.ts" 4 | import MathuisDialog from "../../dialogs/mathuisDialog.ts" 5 | 6 | export default class Mathuis extends NpcBase { 7 | constructor() { 8 | super(Npcs.DesertMale4, false, 'mathuis', 0, 0, 0, 0, 1000, 0.05, 0, 36, new MathuisDialog(), [], new ZombieKiller()) 9 | } 10 | } -------------------------------------------------------------------------------- /server/entities/npcs/passive/humans/mages/ediog.ts: -------------------------------------------------------------------------------- 1 | import { Npcs } from '../../../../../../shared/Enums.ts' 2 | import NpcBase from '../../../npcBase.ts' 3 | import TheSacredStone from "../../../quests/humans/mages/theSacredStone.ts" 4 | import EdiogDialog from "../../dialogs/ediogDialog.ts" 5 | 6 | export default class Ediog extends NpcBase { 7 | constructor() { 8 | super(Npcs.Wizard3, false, 'ediog', 0, 0, 0, 0, 1000, 0.05, 0, 36, new EdiogDialog(), [], new TheSacredStone()) 9 | } 10 | } -------------------------------------------------------------------------------- /server/entities/npcs/passive/humans/mages/edward.ts: -------------------------------------------------------------------------------- 1 | import { Npcs } from '../../../../../../shared/Enums.ts' 2 | import NpcBase from '../../../npcBase.ts' 3 | import EdwardDialog from '../../dialogs/edwardDialog.ts' 4 | 5 | export default class MageEdward extends NpcBase { 6 | constructor() { 7 | super(Npcs.Wizard1, false, 'edward', 0, 0, 0, 0, 1000, 0.05, 0, 36, new EdwardDialog(), [], null) 8 | } 9 | } -------------------------------------------------------------------------------- /server/entities/npcs/passive/humans/mages/elexius.ts: -------------------------------------------------------------------------------- 1 | import { Npcs } from '../../../../../../shared/Enums.ts' 2 | import NpcBase from '../../../npcBase.ts' 3 | import ElexiusDialog from '../../dialogs/elexiusDialog.ts' 4 | 5 | export default class WizardElexius extends NpcBase { 6 | constructor() { 7 | super(Npcs.Wizard2, false, 'elexius', 0, 0, 0, 0, 1000, 0.05, 0, 36, new ElexiusDialog(), [], null) 8 | } 9 | } -------------------------------------------------------------------------------- /server/entities/npcs/passive/humans/merchants/kinley.ts: -------------------------------------------------------------------------------- 1 | import { Npcs } from '../../../../../../shared/Enums.ts' 2 | import IronArmour from "../../../../items/ironArmour.ts"; 3 | import IronHelm from "../../../../items/ironHelm.ts"; 4 | import IronLegs from "../../../../items/ironLegs.ts"; 5 | import IronSword from "../../../../items/ironSword.ts"; 6 | import NpcBase from '../../../npcBase.ts' 7 | import KinleyDialog from "../../dialogs/kinleyDialog.ts" 8 | 9 | export default class Kinley extends NpcBase { 10 | constructor() { 11 | super(Npcs.Merchant1, false, 'kinley', 0, 0, 0, 0, 1000, 0.05, 0, 36, new KinleyDialog(), [], null, 12 | true, [new IronSword(1), new IronLegs(1), new IronArmour(1), new IronHelm(1)]) 13 | } 14 | } -------------------------------------------------------------------------------- /server/entities/npcs/passive/humans/merchants/peter.ts: -------------------------------------------------------------------------------- 1 | import { Npcs } from '../../../../../../shared/Enums.ts' 2 | import LargeHp from "../../../../items/consumable/largeHp.ts"; 3 | import SmallHp from "../../../../items/consumable/smallHp.ts"; 4 | import NpcBase from '../../../npcBase.ts' 5 | import PeterDialog from "../../dialogs/peterDialog.ts" 6 | 7 | export default class Peter extends NpcBase { 8 | constructor() { 9 | super(Npcs.Merchant2, false, 'peter', 0, 0, 0, 0, 1000, 0.05, 0, 36, new PeterDialog(), [], null, 10 | true, [new LargeHp(1), new SmallHp(1)]) 11 | } 12 | } -------------------------------------------------------------------------------- /server/entities/npcs/passive/humans/subitnof/beatrice.ts: -------------------------------------------------------------------------------- 1 | import { Npcs } from '../../../../../../shared/Enums.ts' 2 | import NpcBase from '../../../npcBase.ts' 3 | import BeatriceDialog from "../../dialogs/beatriceDialog.ts" 4 | 5 | export default class Beatrice extends NpcBase { 6 | constructor() { 7 | super(Npcs.CityFemale2, false, 'beatrice', 0, 0, 0, 0, 1000, 0.05, 0, 36, new BeatriceDialog(), [], null) 8 | } 9 | } -------------------------------------------------------------------------------- /server/entities/npcs/passive/humans/subitnof/boris.ts: -------------------------------------------------------------------------------- 1 | import { Npcs } from '../../../../../../shared/Enums.ts' 2 | import NpcBase from '../../../npcBase.ts' 3 | import BorisDialog from "../../dialogs/borisDialog.ts" 4 | 5 | export default class Boris extends NpcBase { 6 | constructor() { 7 | super(Npcs.CityMale5, false, 'boris', 0, 0, 0, 0, 1000, 0.05, 0, 36, new BorisDialog(), [], null) 8 | } 9 | } -------------------------------------------------------------------------------- /server/entities/npcs/passive/humans/subitnof/castleGuard.ts: -------------------------------------------------------------------------------- 1 | import { Npcs } from '../../../../../../shared/Enums.ts' 2 | import NpcBase from '../../../npcBase.ts' 3 | import CastleGuardDialog from '../../dialogs/castleGuardDialog.ts' 4 | 5 | export default class CastleGuard extends NpcBase { 6 | constructor() { 7 | super(Npcs.CityGuard, false, 'subitnofguard', 0, 0, 0, 0, 1000, 0.05, 0, 36, new CastleGuardDialog(), [], null) 8 | } 9 | } -------------------------------------------------------------------------------- /server/entities/npcs/passive/humans/subitnof/celine.ts: -------------------------------------------------------------------------------- 1 | import { Npcs } from '../../../../../../shared/Enums.ts' 2 | import NpcBase from '../../../npcBase.ts' 3 | import CelineDialog from "../../dialogs/celineDialog.ts" 4 | 5 | export default class Celine extends NpcBase { 6 | constructor() { 7 | super(Npcs.CityFemale3, false, 'celine', 0, 0, 0, 0, 1000, 0.05, 0, 36, new CelineDialog(), [], null) 8 | } 9 | } -------------------------------------------------------------------------------- /server/entities/npcs/passive/humans/subitnof/cityGuard.ts: -------------------------------------------------------------------------------- 1 | import { Npcs } from '../../../../../../shared/Enums.ts' 2 | import NpcBase from '../../../npcBase.ts' 3 | import CityGuardDialog from "../../dialogs/cityGuardDialog.ts" 4 | 5 | export default class CityGuard extends NpcBase { 6 | constructor() { 7 | super(Npcs.CityGuard, false, 'subitnofguard', 0, 0, 0, 0, 1000, 0.05, 0, 36, new CityGuardDialog(), [], null) 8 | } 9 | } -------------------------------------------------------------------------------- /server/entities/npcs/passive/humans/subitnof/cooper.ts: -------------------------------------------------------------------------------- 1 | import { Npcs } from '../../../../../../shared/Enums.ts' 2 | import NpcBase from '../../../npcBase.ts' 3 | import CooperDialog from "../../dialogs/cooperDialog.ts" 4 | 5 | export default class Cooper extends NpcBase { 6 | constructor() { 7 | super(Npcs.CityMale9, false, 'cooper', 0, 0, 0, 0, 1000, 0.05, 0, 36, new CooperDialog(), [], null) 8 | } 9 | } -------------------------------------------------------------------------------- /server/entities/npcs/passive/humans/subitnof/ephan.ts: -------------------------------------------------------------------------------- 1 | import { Npcs } from '../../../../../../shared/Enums.ts' 2 | import NpcBase from '../../../npcBase.ts' 3 | import WarriorSomeday from "../../../quests/humans/subitnof/warriorSomeday.ts" 4 | import EphanDialog from "../../dialogs/ephanDialog.ts" 5 | 6 | export default class Ephan extends NpcBase { 7 | constructor() { 8 | super(Npcs.CityMale2, false, 'ephan', 0, 0, 0, 0, 1000, 0.05, 0, 36, new EphanDialog(), [], new WarriorSomeday()) 9 | } 10 | } -------------------------------------------------------------------------------- /server/entities/npcs/passive/humans/subitnof/francis.ts: -------------------------------------------------------------------------------- 1 | import { Npcs } from '../../../../../../shared/Enums.ts' 2 | import NpcBase from '../../../npcBase.ts' 3 | import FrancisDialog from "../../dialogs/francisDialog.ts" 4 | 5 | export default class Francis extends NpcBase { 6 | constructor() { 7 | super(Npcs.CityOldMale1, false, 'francis', 0, 0, 0, 0, 1000, 0.05, 0, 36, new FrancisDialog(), [], null) 8 | } 9 | } -------------------------------------------------------------------------------- /server/entities/npcs/passive/humans/subitnof/james.ts: -------------------------------------------------------------------------------- 1 | import { Npcs } from '../../../../../../shared/Enums.ts' 2 | import NpcBase from '../../../npcBase.ts' 3 | import JamesDialog from "../../dialogs/jamesDialog.ts" 4 | 5 | export default class James extends NpcBase { 6 | constructor() { 7 | super(Npcs.CityMale4, false, 'james', 0, 0, 0, 0, 1000, 0.05, 0, 36, new JamesDialog(), [], null) 8 | } 9 | } -------------------------------------------------------------------------------- /server/entities/npcs/passive/humans/subitnof/jasmine.ts: -------------------------------------------------------------------------------- 1 | import { Npcs } from '../../../../../../shared/Enums.ts' 2 | import NpcBase from '../../../npcBase.ts' 3 | import JasmineDialog from "../../dialogs/jasmineDialog.ts" 4 | 5 | export default class Jasmine extends NpcBase { 6 | constructor() { 7 | super(Npcs.CityFemale1, false, 'jasmine', 0, 0, 0, 0, 1000, 0.05, 0, 36, new JasmineDialog(), [], null) 8 | } 9 | } -------------------------------------------------------------------------------- /server/entities/npcs/passive/humans/subitnof/kingZander.ts: -------------------------------------------------------------------------------- 1 | import { Npcs } from '../../../../../../shared/Enums.ts' 2 | import NpcBase from '../../../npcBase.ts' 3 | import SomebodyOnceToldMe from '../../../quests/humans/subitnof/somebodyOnceToldMe.ts' 4 | import KingZanderDialog from "../../dialogs/kingZanderDialog.ts" 5 | 6 | export default class KingZander extends NpcBase { 7 | constructor() { 8 | super(Npcs.KingSubitnof, false, 'zander', 0, 0, 0, 0, 1000, 0.05, 0, 36, new KingZanderDialog(), [], new SomebodyOnceToldMe()) 9 | } 10 | } -------------------------------------------------------------------------------- /server/entities/npcs/passive/humans/subitnof/lugrus.ts: -------------------------------------------------------------------------------- 1 | import { Npcs } from '../../../../../../shared/Enums.ts' 2 | import NpcBase from '../../../npcBase.ts' 3 | import DamnRats from "../../../quests/humans/subitnof/damnRats.ts" 4 | import LugrusDialog from "../../dialogs/lugrusDialog.ts" 5 | 6 | export default class Lugrus extends NpcBase { 7 | constructor() { 8 | super(Npcs.CityMale8, false, 'lugrus', 0, 0, 0, 0, 1000, 0.05, 0, 36, new LugrusDialog(), [], new DamnRats()) 9 | } 10 | } -------------------------------------------------------------------------------- /server/entities/npcs/passive/humans/subitnof/marcus.ts: -------------------------------------------------------------------------------- 1 | import { Npcs } from '../../../../../../shared/Enums.ts' 2 | import NpcBase from '../../../npcBase.ts' 3 | import MarcusDialog from "../../dialogs/marcusDialog.ts" 4 | 5 | export default class Marcus extends NpcBase { 6 | constructor() { 7 | super(Npcs.CityOldMale2, false, 'marcus', 0, 0, 0, 0, 1000, 0.05, 0, 36, new MarcusDialog(), [], null) 8 | } 9 | } -------------------------------------------------------------------------------- /server/entities/npcs/passive/humans/subitnof/marty.ts: -------------------------------------------------------------------------------- 1 | import { Npcs } from '../../../../../../shared/Enums.ts' 2 | import NpcBase from '../../../npcBase.ts' 3 | import MartyDialog from "../../dialogs/martyDialog.ts" 4 | 5 | export default class Marty extends NpcBase { 6 | constructor() { 7 | super(Npcs.CityMale7, false, 'marty', 0, 0, 0, 0, 1000, 0.05, 0, 36, new MartyDialog(), [], null) 8 | } 9 | } -------------------------------------------------------------------------------- /server/entities/npcs/passive/humans/subitnof/michael.ts: -------------------------------------------------------------------------------- 1 | import { Npcs } from '../../../../../../shared/Enums.ts' 2 | import NpcBase from '../../../npcBase.ts' 3 | import MichaelDialog from "../../dialogs/michaelDialog.ts" 4 | 5 | export default class Michael extends NpcBase { 6 | constructor() { 7 | super(Npcs.CityMale6, false, 'michael', 0, 0, 0, 0, 1000, 0.05, 0, 36, new MichaelDialog(), [], null) 8 | } 9 | } -------------------------------------------------------------------------------- /server/entities/npcs/passive/humans/subitnof/oswald.ts: -------------------------------------------------------------------------------- 1 | import { Npcs } from '../../../../../../shared/Enums.ts' 2 | import BronzeSword from "../../../../items/bronzeSword.ts"; 3 | import Bread from "../../../../items/consumable/bread.ts"; 4 | import Coffee from "../../../../items/consumable/coffee.ts"; 5 | import SmallHp from "../../../../items/consumable/smallHp.ts"; 6 | import NpcBase from '../../../npcBase.ts' 7 | import OswaldDialog from "../../dialogs/oswaldDialog.ts" 8 | 9 | export default class Oswald extends NpcBase { 10 | constructor() { 11 | super(Npcs.CityMale1, false, 'oswald', 0, 0, 0, 0, 1000, 0.05, 0, 36, new OswaldDialog(), [], null, true, 12 | [new Bread(1), new Coffee(1), new SmallHp(1), new BronzeSword(1)]) 13 | } 14 | } -------------------------------------------------------------------------------- /server/entities/npcs/passive/humans/subitnof/reeves.ts: -------------------------------------------------------------------------------- 1 | import { Npcs } from '../../../../../../shared/Enums.ts' 2 | import NpcBase from '../../../npcBase.ts' 3 | import ReevesDialog from "../../dialogs/reevesDialog.ts" 4 | 5 | export default class Reeves extends NpcBase { 6 | constructor() { 7 | super(Npcs.CityMale3, false, 'reeves', 0, 0, 0, 0, 1000, 0.05, 0, 36, new ReevesDialog(), [], null) 8 | } 9 | } -------------------------------------------------------------------------------- /server/entities/npcs/passive/zero.ts: -------------------------------------------------------------------------------- 1 | 2 | import { Npcs } from '../../../../shared/Enums.ts' 3 | import NpcBase from '../npcBase.ts' 4 | import ZeroDialog from "./dialogs/zeroDialog.ts" 5 | 6 | export default class Zero extends NpcBase { 7 | constructor() { 8 | super(Npcs.Zero, false, 'zero', 0, 0, 0, 0, 1000, 0, 0, 36, new ZeroDialog(), [], null) 9 | } 10 | } -------------------------------------------------------------------------------- /server/entities/npcs/quests/gnomes/flowerForMytklash.ts: -------------------------------------------------------------------------------- 1 | import { Quests, RewardType, StepType } from "../../../../../shared/Enums.ts" 2 | import QuestBase from "../questBase.ts" 3 | import StepBase from "../stepBase.ts" 4 | 5 | export default class FlowerForMytklash extends QuestBase { 6 | constructor() { 7 | super(Quests.FlowerForMytklash, 8 | [ 9 | new StepBase(StepType.NpcToTalk,[],'mytklashs flower',['you found the flower Mytklash likes!', 'Go tell Horvyn!'],[],0), 10 | new StepBase(StepType.NpcToTalk,[],'horvyn',['Are you sure she will like it?', 'She loved it! Thank you so much', 'you received 30xp'],[],0), 11 | ], 12 | RewardType.Xp, 13 | null, 14 | 30, 15 | 'Hi hero! Thanks for the help with my love life!') 16 | } 17 | } -------------------------------------------------------------------------------- /server/entities/npcs/quests/humans/deepLake/helpTheLakeVillage.ts: -------------------------------------------------------------------------------- 1 | import { Npcs, Quests, RewardType, StepType } from "../../../../../../shared/Enums.ts" 2 | import QuestBase from "../../questBase.ts" 3 | import BluriteArmour from "../../../../items/bluriteArmour.ts" 4 | import StepBase from "../../stepBase.ts" 5 | import { MonstersToKillBase } from "../../monstersToKillBase.ts" 6 | 7 | export default class HelpTheLakeVillage extends QuestBase { 8 | constructor() { 9 | super(Quests.HelpTheVillage, 10 | [ 11 | new StepBase(StepType.MonstersToKill, 12 | [ 13 | new MonstersToKillBase(Npcs.ImpArcher, 10), 14 | new MonstersToKillBase(Npcs.ImpMeelee, 10), 15 | new MonstersToKillBase(Npcs.ImpMage, 10), 16 | ], 17 | 'vardan',[],[],0), 18 | new StepBase(StepType.NpcToTalk,[],'vardan',['You really killed all those imps!', 'Good job adventurer! We are far from having peace', 'but your help was precious. Take this armour as reward!', '-You received a Blurite Armour-'],[],0), 19 | ], 20 | RewardType.Item, 21 | new BluriteArmour(1), 22 | 0, 23 | 'Thank you for all your help!') 24 | } 25 | } -------------------------------------------------------------------------------- /server/entities/npcs/quests/humans/kharjid/jamulsMachete.ts: -------------------------------------------------------------------------------- 1 | import { ItemsIds, Quests, RewardType, StepType } from "../../../../../../shared/Enums.ts" 2 | import QuestBase from "../../questBase.ts" 3 | import StepBase from "../../stepBase.ts" 4 | import { ItemsToHaveBase } from "../../itemsToHaveBase.ts" 5 | import JamulsGuitar from "../../../../items/jamulsGuitar.ts" 6 | 7 | export default class JamulsMachete extends QuestBase { 8 | constructor() { 9 | super(Quests.JamulsMachete, 10 | [ 11 | new StepBase(StepType.ItemsToHave,[],'jamul', [], 12 | [ 13 | new ItemsToHaveBase(ItemsIds.JamulsMachete, 1) 14 | ],0), 15 | new StepBase(StepType.NpcToTalk,[],'jamul', 16 | [ 17 | 'oooh you got it son?!', 18 | 'thanks for finding my machete', 19 | 'the Jamul\'s Machete', 20 | 'I don\'t have much to give but', 21 | 'you can have my guitar', 22 | 'it doesn\'t do much', 23 | 'but I don\'t think many people have it', 24 | '-you received 500xp!-', 25 | '-you received Jamuls Guitar!-' 26 | ],[],0), 27 | ], 28 | RewardType.Both, 29 | new JamulsGuitar(0), 30 | 500, 31 | 'Hi son! You can call me Jamil') 32 | } 33 | } -------------------------------------------------------------------------------- /server/entities/npcs/quests/humans/kharjid/zombieKiller.ts: -------------------------------------------------------------------------------- 1 | import { Npcs, Quests, RewardType, StepType } from "../../../../../../shared/Enums.ts" 2 | import QuestBase from "../../questBase.ts" 3 | import StepBase from "../../stepBase.ts" 4 | import { MonstersToKillBase } from "../../monstersToKillBase.ts" 5 | 6 | export default class ZombieKiller extends QuestBase { 7 | constructor() { 8 | super(Quests.ZombieKiller, 9 | [ 10 | new StepBase(StepType.MonstersToKill, 11 | [ 12 | new MonstersToKillBase(Npcs.Zombie, 50), 13 | ], 14 | 'mathuis',[],[],0), 15 | new StepBase(StepType.NpcToTalk,[],'mathuis', 16 | [ 17 | 'Thanks for killing all those zombies', 18 | 'I still hate this place, but I feel', 19 | 'a tiny bit better now', 20 | '-you received 2500xp!-' 21 | ],[],0), 22 | ], 23 | RewardType.Xp, 24 | null, 25 | 2500, 26 | 'I hate the desert, thanks for killing some zombies tho...') 27 | } 28 | } -------------------------------------------------------------------------------- /server/entities/npcs/quests/humans/subitnof/damnRats.ts: -------------------------------------------------------------------------------- 1 | import { ItemsIds, Npcs, Quests, RewardType, StepType } from "../../../../../../shared/Enums.ts" 2 | import QuestBase from "../../questBase.ts" 3 | import StepBase from "../../stepBase.ts" 4 | import { MonstersToKillBase } from "../../monstersToKillBase.ts" 5 | import { ItemsToHaveBase } from "../../itemsToHaveBase.ts" 6 | 7 | export default class DamnRats extends QuestBase { 8 | constructor() { 9 | super(Quests.DamnRats, 10 | [ 11 | new StepBase(StepType.MonstersToKill, 12 | [ 13 | new MonstersToKillBase(Npcs.Rat, 25), 14 | ], 15 | 'lugrus',[],[],0), 16 | new StepBase(StepType.NpcToTalk,[],'lugrus', 17 | [ 18 | 'No way, you actually killed 25 rats!', 19 | 'Thats impressive', 20 | 'Since you\'re already into it', 21 | 'Could you bring me a cup of coffee?' 22 | ],[],0), 23 | new StepBase(StepType.ItemsToHave,[],'lugrus', [], 24 | [ 25 | new ItemsToHaveBase(ItemsIds.Coffee, 1) 26 | ],0), 27 | new StepBase(StepType.NpcToTalk,[],'lugrus', 28 | [ 29 | 'Thanks man, you deserve some xp', 30 | '-you received 500xp!-' 31 | ],[],0), 32 | ], 33 | RewardType.Xp, 34 | null, 35 | 500, 36 | 'Hey! Lugrus here.') 37 | } 38 | } -------------------------------------------------------------------------------- /server/entities/npcs/quests/humans/subitnof/somebodyOnceToldMe.ts: -------------------------------------------------------------------------------- 1 | import { ItemsIds, Npcs, Quests, RewardType, StepType } from "../../../../../../shared/Enums.ts" 2 | import QuestBase from "../../questBase.ts" 3 | import StepBase from "../../stepBase.ts" 4 | import { MonstersToKillBase } from "../../monstersToKillBase.ts" 5 | import { ItemsToHaveBase } from "../../itemsToHaveBase.ts" 6 | 7 | export default class SomebodyOnceToldMe extends QuestBase { 8 | constructor() { 9 | super(Quests.SomebodyOnceToldMe, 10 | [ 11 | new StepBase(StepType.MonstersToKill, 12 | [ 13 | new MonstersToKillBase(Npcs.Ogre, 20), 14 | ], 15 | 'zander',[],[],0), 16 | new StepBase(StepType.NpcToTalk,[],'zander', 17 | [ 18 | 'Thank you so much young man', 19 | 'I do have another request', 20 | 'If you\'re willing to help further', 21 | 'I need to be ready for battle', 22 | 'In case my man need me', 23 | 'I\'m not the kind of king', 24 | 'Who just sits and bosses around', 25 | 'But I need a full Blurite Set', 26 | 'To be of help', 27 | 'Armour, Helm, Legs and a Sword', 28 | 'Could you bring me?', 29 | ],[],0), 30 | new StepBase(StepType.ItemsToHave,[],'zander', [], 31 | [ 32 | new ItemsToHaveBase(ItemsIds.BluriteArmour, 1), 33 | new ItemsToHaveBase(ItemsIds.BluriteHelm, 1), 34 | new ItemsToHaveBase(ItemsIds.BluriteLegs, 1), 35 | new ItemsToHaveBase(ItemsIds.BluriteSword, 1) 36 | ],0), 37 | new StepBase(StepType.NpcToTalk,[],'zander', 38 | [ 39 | 'Thank you so much for your help', 40 | 'I won\'t forget what you\'ve done for us.', 41 | '-you received 3000xp!-' 42 | ],[],0), 43 | ], 44 | RewardType.Xp, 45 | null, 46 | 3000, 47 | 'Hi there young man! I\'m forever grateful for all your work.') 48 | } 49 | } -------------------------------------------------------------------------------- /server/entities/npcs/quests/humans/subitnof/warriorSomeday.ts: -------------------------------------------------------------------------------- 1 | import { ItemsIds, Quests, RewardType, StepType } from "../../../../../../shared/Enums.ts" 2 | import QuestBase from "../../questBase.ts" 3 | import StepBase from "../../stepBase.ts" 4 | import { ItemsToHaveBase } from "../../itemsToHaveBase.ts" 5 | 6 | export default class WarriorSomeday extends QuestBase { 7 | constructor() { 8 | super(Quests.WarriorSomeday, 9 | [ 10 | new StepBase(StepType.ItemsToHave,[],'ephan', [], 11 | [ 12 | new ItemsToHaveBase(ItemsIds.WoodenDagger, 1), 13 | new ItemsToHaveBase(ItemsIds.WoodenArmour, 1), 14 | new ItemsToHaveBase(ItemsIds.WoodenHelm, 1), 15 | new ItemsToHaveBase(ItemsIds.WoodenLegs, 1), 16 | ],0), 17 | new StepBase(StepType.NpcToTalk,[],'ephan', 18 | [ 19 | 'woooah you found a full set!', 20 | 'thank you so much!', 21 | 'now I can start training to become a warrior!', 22 | '-you received 250xp!-' 23 | ],[],0), 24 | ], 25 | RewardType.Xp, 26 | null, 27 | 250, 28 | 'Farming takes a lot of my time, but sometimes I train to be a warrior') 29 | } 30 | } -------------------------------------------------------------------------------- /server/entities/npcs/quests/itemsToHave.ts: -------------------------------------------------------------------------------- 1 | import { ItemsIds } from "../../../../shared/Enums.ts" 2 | import { ItemsToHaveBase } from "./itemsToHaveBase.ts" 3 | 4 | export class ItemsToHave { 5 | public item: ItemsIds 6 | public amount: number 7 | public amountTotal: number 8 | 9 | constructor(itemsBase: ItemsToHaveBase) { 10 | this.item = itemsBase.item 11 | this.amount = itemsBase.amount 12 | this.amountTotal = itemsBase.amount 13 | } 14 | } -------------------------------------------------------------------------------- /server/entities/npcs/quests/itemsToHaveBase.ts: -------------------------------------------------------------------------------- 1 | import { ItemsIds } from "../../../../shared/Enums.ts" 2 | 3 | export class ItemsToHaveBase { 4 | public item: ItemsIds 5 | public amount: number 6 | 7 | constructor(item: ItemsIds, 8 | amount: number) { 9 | this.item = item 10 | this.amount = amount 11 | } 12 | } -------------------------------------------------------------------------------- /server/entities/npcs/quests/monstersToKill.ts: -------------------------------------------------------------------------------- 1 | import { Npcs } from "../../../../shared/Enums.ts" 2 | import { MonstersToKillBase } from "./monstersToKillBase.ts" 3 | 4 | export class MonstersToKill { 5 | public monster: Npcs 6 | public amount: number 7 | 8 | constructor(monstersData: MonstersToKillBase) { 9 | this.monster = monstersData.monster 10 | this.amount = monstersData.amount 11 | } 12 | } -------------------------------------------------------------------------------- /server/entities/npcs/quests/monstersToKillBase.ts: -------------------------------------------------------------------------------- 1 | import { Npcs } from "../../../../shared/Enums.ts" 2 | 3 | export class MonstersToKillBase { 4 | public monster: Npcs 5 | public amount: number 6 | 7 | constructor(monster: Npcs, 8 | amount: number) { 9 | this.monster = monster 10 | this.amount = amount 11 | } 12 | } -------------------------------------------------------------------------------- /server/entities/npcs/quests/questBase.ts: -------------------------------------------------------------------------------- 1 | import { Quests, RewardType } from "../../../../shared/Enums.ts" 2 | import ItemBase from "../../items/itemBase.ts" 3 | import Step from "./step.ts" 4 | import StepBase from "./stepBase.ts" 5 | 6 | export default class QuestBase { 7 | public id: Quests 8 | public steps: StepBase[] 9 | public reward: RewardType 10 | public itemReward: ItemBase | null 11 | public xpReward: number 12 | public newDialogAfterComplete: string 13 | 14 | constructor(id: number, 15 | steps: StepBase[], 16 | reward: RewardType, 17 | itemReward: ItemBase | null, 18 | xpReward: number, 19 | newDialogAfterComplete: string) { 20 | this.id = id 21 | this.steps = steps 22 | this.reward = reward 23 | this.itemReward = itemReward 24 | this.xpReward = xpReward 25 | this.newDialogAfterComplete = newDialogAfterComplete 26 | } 27 | } -------------------------------------------------------------------------------- /server/entities/npcs/quests/step.ts: -------------------------------------------------------------------------------- 1 | import { ItemsIds, Npcs, StepType } from "../../../../shared/Enums.ts" 2 | import { MonstersToKill } from "./monstersToKill.ts" 3 | import { ItemsToHave } from "./itemsToHave.ts" 4 | import StepBase from "./stepBase.ts" 5 | import ItemBase from "../../items/itemBase.ts" 6 | 7 | export default class Step { 8 | public isCompleted: boolean = false 9 | public type: StepType 10 | public monstersToKill: MonstersToKill[] = [] 11 | public npcToTalk: string 12 | public npcLines: string[] 13 | public playerCurrentLine: number = 0 14 | public itemsToHave: ItemsToHave[] = [] 15 | public itemsToGive: ItemBase[] = [] 16 | public levelToReach: number 17 | 18 | constructor(stepData: StepBase) { 19 | this.type = stepData.type 20 | for (const monsterToKill of stepData.monstersToKill) { 21 | this.monstersToKill.push(new MonstersToKill(monsterToKill)) 22 | } 23 | this.npcToTalk = stepData.npcToTalk 24 | this.npcLines = stepData.npcLines 25 | for (const itemToHave of stepData.itemsToHave) { 26 | this.itemsToHave.push(new ItemsToHave(itemToHave)) 27 | } 28 | this.levelToReach = stepData.levelToReach 29 | if (stepData.itemsToGive != null) { 30 | for (const itemToGive of stepData.itemsToGive) { 31 | this.itemsToGive.push(new ItemBase(itemToGive.id, 32 | itemToGive.itemId, 33 | itemToGive.type, 34 | itemToGive.gearType, 35 | itemToGive.coins, 36 | itemToGive.despawnTime, 37 | itemToGive.level, 38 | itemToGive.isDefensive, 39 | itemToGive.bonusAttack, 40 | itemToGive.bonusDefense, 41 | itemToGive.healthRefuel, 42 | itemToGive.dropChance, 43 | itemToGive.storeSellPrice, 44 | itemToGive.playerSellPrice,)) 45 | } 46 | } 47 | 48 | } 49 | 50 | public checkItemToHave(item: ItemsIds) { 51 | if (this.type == StepType.ItemsToHave) { 52 | const itemToHave = this.itemsToHave.find(i => (i.item == item) && i.amount > 0) 53 | if (itemToHave) { 54 | itemToHave.amount -= 1 55 | return { validItem: true } 56 | } 57 | } 58 | return { validItem: false } 59 | } 60 | 61 | public resetAmountItemsToHave() { 62 | if (this.type == StepType.ItemsToHave) { 63 | for (let itemToHave of this.itemsToHave) { 64 | itemToHave.amount = itemToHave.amountTotal 65 | } 66 | } 67 | } 68 | 69 | public checkLevelToReach(level: number) { 70 | if (this.type == StepType.LevelToReach) { 71 | if (level >= this.levelToReach) { 72 | return true 73 | } 74 | } 75 | return false 76 | } 77 | 78 | public checkMonsterKill(monster: Npcs): { validMonster: boolean } { 79 | if (this.type == StepType.MonstersToKill) { 80 | const monsterToKill = this.monstersToKill.find(m => (m.monster == monster) && m.amount > 0) 81 | if (monsterToKill) { 82 | monsterToKill.amount -= 1 83 | return { validMonster: true } 84 | } 85 | } 86 | return { validMonster: false } 87 | } 88 | 89 | public checkNpcDialog(npc: string): {validNpc: boolean,line:string } { 90 | if (this.type == StepType.NpcToTalk) { 91 | if (npc == this.npcToTalk) { 92 | return { validNpc: true, line: this.npcLines[this.playerCurrentLine] } 93 | } 94 | } 95 | if (this.type == StepType.MonstersToKill) { 96 | if (npc == this.npcToTalk) { 97 | let monstersLog = '' 98 | for (const monster of this.monstersToKill) { 99 | monstersLog += `${Npcs[monster.monster]}: ${monster.amount} left; ` 100 | } 101 | return { validNpc: true, line: monstersLog } 102 | } 103 | } 104 | return { validNpc: false, line: '' } 105 | } 106 | } -------------------------------------------------------------------------------- /server/entities/npcs/quests/stepBase.ts: -------------------------------------------------------------------------------- 1 | import { StepType } from "../../../../shared/Enums.ts" 2 | import ItemBase from "../../items/itemBase.ts" 3 | import { ItemsToHaveBase } from "./itemsToHaveBase.ts" 4 | import { MonstersToKillBase } from "./monstersToKillBase.ts" 5 | 6 | export default class StepBase { 7 | public isCompleted: boolean = false 8 | public type: StepType 9 | public monstersToKill: MonstersToKillBase[] = [] 10 | public npcToTalk: string 11 | public npcLines: string[] 12 | public playerCurrentLine: number = 0 13 | public itemsToHave: ItemsToHaveBase[] = [] 14 | public itemsToGive: ItemBase[] | null = null 15 | public levelToReach: number 16 | 17 | constructor(type: StepType, 18 | monstersToKillBase: MonstersToKillBase[], 19 | npcToTalk: string, 20 | npcLines: string[], 21 | itemsToHaveBase: ItemsToHaveBase[], 22 | levelToReach: number, 23 | itemsToGive: ItemBase[] | null = null) { 24 | this.type = type 25 | this.monstersToKill = monstersToKillBase 26 | this.npcToTalk = npcToTalk 27 | this.npcLines = npcLines 28 | this.itemsToHave = itemsToHaveBase 29 | this.levelToReach = levelToReach 30 | this.itemsToGive = itemsToGive 31 | } 32 | } -------------------------------------------------------------------------------- /server/entities/npcs/rat.ts: -------------------------------------------------------------------------------- 1 | import { Npcs } from '../../../shared/Enums.ts' 2 | import NpcBase from './npcBase.ts' 3 | import BronzeSword from '../items/bronzeSword.ts' 4 | import Bread from "../items/consumable/bread.ts" 5 | 6 | export default class Rat extends NpcBase { 7 | constructor() { 8 | super(Npcs.Rat, true, 'rat', 0, 0, 0, 15, 10000, 0.25, 6, 36, null, [new Bread(0.4), new BronzeSword(0.4)], null) 9 | } 10 | } -------------------------------------------------------------------------------- /server/entities/npcs/sandCat.ts: -------------------------------------------------------------------------------- 1 | import { Npcs } from '../../../shared/Enums.ts' 2 | import NpcBase from './npcBase.ts' 3 | import BluriteHelm from '../items/bluriteHelm.ts' 4 | import IronHelm from "../items/ironHelm.ts" 5 | import IronLegs from "../items/ironLegs.ts" 6 | import SmallHp from "../items/consumable/smallHp.ts" 7 | 8 | export default class SandCat extends NpcBase { 9 | constructor() { 10 | super(Npcs.SandCat, true, 'sandcat', 0, 0, 0, 30, 10000, 0.25, 6, 36, null, [new BluriteHelm(0.2), new IronHelm(0.8), new IronLegs(0.8), new SmallHp(0.9)], null) 11 | } 12 | } -------------------------------------------------------------------------------- /server/entities/npcs/sandSnake.ts: -------------------------------------------------------------------------------- 1 | import { Npcs } from '../../../shared/Enums.ts' 2 | import NpcBase from './npcBase.ts' 3 | import BluriteHelm from '../items/bluriteHelm.ts' 4 | import BluriteDagger from "../items/bluriteDagger.ts" 5 | import BluriteArmour from "../items/bluriteArmour.ts" 6 | import AdamantLegs from "../items/adamantLegs.ts" 7 | import SmallHp from "../items/consumable/smallHp.ts" 8 | 9 | export default class SandSnake extends NpcBase { 10 | constructor() { 11 | super(Npcs.SandSnake, true, 'sandsnake', 0, 0, 0, 40, 10000, 0.25, 6, 36, null, [new SmallHp(0.1), new AdamantLegs(0.1), new BluriteArmour(0.3), new BluriteHelm(0.4), new BluriteDagger(0.8)], null) 12 | } 13 | } -------------------------------------------------------------------------------- /server/entities/npcs/sandSpirit.ts: -------------------------------------------------------------------------------- 1 | import { Npcs } from '../../../shared/Enums.ts' 2 | import NpcBase from './npcBase.ts' 3 | import AdamantArmour from '../items/adamantArmour.ts' 4 | import AdamantDagger from '../items/adamantDagger.ts' 5 | import AdamantSword from '../items/adamantSword.ts' 6 | import LargeHp from "../items/consumable/largeHp.ts" 7 | 8 | export default class SandSpirit extends NpcBase { 9 | constructor() { 10 | super(Npcs.SandSpirit, true, 'sandspirit', 0, 0, 0, 50, 10000, 0.25, 6, 36, null, [new LargeHp(0.4), new AdamantArmour(0.4), new AdamantDagger(0.4), new AdamantSword(0.4)], null) 11 | } 12 | } -------------------------------------------------------------------------------- /server/entities/npcs/sandTotem.ts: -------------------------------------------------------------------------------- 1 | import { Npcs } from '../../../shared/Enums.ts' 2 | import NpcBase from './npcBase.ts' 3 | import AdamantLegs from '../items/adamantLegs.ts' 4 | import AdamantHelm from '../items/adamantHelm.ts' 5 | import BluriteArmour from '../items/bluriteArmour.ts' 6 | import LargeHp from "../items/consumable/largeHp.ts" 7 | 8 | export default class SandTotem extends NpcBase { 9 | constructor() { 10 | super(Npcs.SandTotem, true, 'sandtotem', 0, 0, 0, 50, 10000, 0.25, 6, 36, null, [new LargeHp(0.4), new AdamantLegs(0.4), new AdamantHelm(0.4), new BluriteArmour(0.7)], null) 11 | } 12 | } -------------------------------------------------------------------------------- /server/entities/npcs/skeleton.ts: -------------------------------------------------------------------------------- 1 | import { Npcs } from '../../../shared/Enums.ts' 2 | import NpcBase from './npcBase.ts' 3 | import Coffee from '../items/consumable/coffee.ts' 4 | import BronzeDagger from '../items/bronzeDagger.ts' 5 | import BronzeSword from '../items/bronzeDagger.ts' 6 | import IronHelm from '../items/ironHelm.ts' 7 | import BronzeArmour from "../items/bronzeArmour.ts" 8 | import SmallHp from "../items/consumable/smallHp.ts" 9 | 10 | export default class Skeleton extends NpcBase { 11 | constructor() { 12 | super(Npcs.Skeleton, true, 'skeleton', 0, 0, 0, 20, 10000, 0.35, 6, 36, null, [new IronHelm(0.1),new BronzeDagger(0.6),new BronzeSword(0.6),new BronzeArmour(0.6),new SmallHp(0.4)], null) 13 | } 14 | } -------------------------------------------------------------------------------- /server/entities/npcs/skeletonKnight.ts: -------------------------------------------------------------------------------- 1 | import { Npcs } from '../../../shared/Enums.ts' 2 | import NpcBase from './npcBase.ts' 3 | import IronSword from '../items/ironSword.ts' 4 | import IronDagger from '../items/ironDagger.ts' 5 | import IronHelm from '../items/ironHelm.ts' 6 | import BronzeHelm from '../items/bronzeHelm.ts' 7 | import BronzeLegs from "../items/bronzeLegs.ts" 8 | import SmallHp from "../items/consumable/smallHp.ts" 9 | 10 | export default class SkeletonKnight extends NpcBase { 11 | constructor() { 12 | super(Npcs.SkeletonKnight, true, 'skeleton knight', 0, 0, 0, 25, 10000, 0.15, 6, 36, null, [new IronDagger(0.2),new IronSword(0.1),new IronHelm(0.3),new BronzeHelm(0.7),new BronzeLegs(0.7),new SmallHp(0.4)], null) 13 | } 14 | } -------------------------------------------------------------------------------- /server/entities/npcs/slime.ts: -------------------------------------------------------------------------------- 1 | import { Npcs } from '../../../shared/Enums.ts' 2 | import NpcBase from './npcBase.ts' 3 | import Coffee from '../items/consumable/coffee.ts' 4 | 5 | export default class Slime extends NpcBase { 6 | constructor() { 7 | super(Npcs.Slime, true, 'slime', 0, 0, 0, 1, 10000, 0.1, 3, 24, null, [new Coffee(0.4)], null) 8 | } 9 | } -------------------------------------------------------------------------------- /server/entities/npcs/spider.ts: -------------------------------------------------------------------------------- 1 | import { Npcs } from '../../../shared/Enums.ts' 2 | import NpcBase from './npcBase.ts' 3 | import Coffee from '../items/consumable/coffee.ts' 4 | import WoodenDagger from '../items/woodenDagger.ts' 5 | 6 | export default class Spider extends NpcBase { 7 | constructor() { 8 | super(Npcs.Spider, true, 'spider', 0, 0, 0, 1, 10000, 0.25, 6, 36, null, [new WoodenDagger(0.2),new Coffee(0.4)], null) 9 | } 10 | } -------------------------------------------------------------------------------- /server/entities/npcs/waterBlob.ts: -------------------------------------------------------------------------------- 1 | import { Npcs } from '../../../shared/Enums.ts' 2 | import NpcBase from './npcBase.ts' 3 | import IronSword from '../items/ironSword.ts' 4 | import BluriteDagger from "../items/bluriteDagger.ts" 5 | import BluriteSword from "../items/bluriteSword.ts" 6 | import LargeHp from "../items/consumable/largeHp.ts" 7 | 8 | export default class WaterBlob extends NpcBase { 9 | constructor() { 10 | super(Npcs.WaterBlob, true, 'waterblob', 0, 0, 0, 30, 10000, 0.25, 6, 36, null, [new BluriteSword(0.5), new BluriteDagger(0.4), new IronSword(0.7), new LargeHp(0.7)], null) 11 | } 12 | } -------------------------------------------------------------------------------- /server/entities/npcs/witch.ts: -------------------------------------------------------------------------------- 1 | import { Npcs } from '../../../shared/Enums.ts' 2 | import NpcBase from './npcBase.ts' 3 | import Coffee from '../items/consumable/coffee.ts' 4 | import WoodenDagger from '../items/woodenDagger.ts' 5 | import WoodenSword from '../items/woodenSword.ts' 6 | import WoodenHelm from '../items/woodenHelm.ts' 7 | import BronzeLegs from "../items/bronzeLegs.ts" 8 | 9 | export default class Witch extends NpcBase { 10 | constructor() { 11 | super(Npcs.Witch, true, 'witch', 0, 0, 0, 10, 10000, 0.25, 5, 36, null, [new BronzeLegs(0.1), new WoodenDagger(0.3),new WoodenSword(0.4),new WoodenHelm(0.5),new Coffee(0.4)], null) 12 | } 13 | } -------------------------------------------------------------------------------- /server/entities/npcs/zombie.ts: -------------------------------------------------------------------------------- 1 | import { Npcs } from '../../../shared/Enums.ts' 2 | import NpcBase from './npcBase.ts' 3 | import BluriteHelm from '../items/bluriteHelm.ts' 4 | import BluriteDagger from "../items/bluriteDagger.ts" 5 | import BluriteArmour from "../items/bluriteArmour.ts" 6 | import AdamantHelm from "../items/adamantHelm.ts" 7 | import JamulsMachete from "../items/jamulsMachete.ts" 8 | 9 | export default class Zombie extends NpcBase { 10 | constructor() { 11 | super(Npcs.Zombie, true, 'zombie', 0, 0, 0, 45, 10000, 0.25, 6, 36, null, [new JamulsMachete(0.1), new AdamantHelm(0.1), new BluriteArmour(0.3), new BluriteHelm(0.4), new BluriteDagger(0.8)], null) 12 | } 13 | } -------------------------------------------------------------------------------- /server/map/doorSpawns.ts: -------------------------------------------------------------------------------- 1 | import { ItemsIds, Quests, Rooms, RoomsInsides } from "../../shared/Enums.ts"; 2 | import { SolidLayersInsides } from "../../shared/solidLayers.ts"; 3 | import { NpcSpawnsInsides } from "./npcSpawns.ts"; 4 | import Door from "./rooms/door.ts"; 5 | import DoorConditions from "./rooms/doorConditions.ts"; 6 | import Exits from "./rooms/exits.ts"; 7 | 8 | export const DoorSpawns = { 9 | Gnomes1: [ 10 | new Door(12,7,RoomsInsides.GnomesCave1,new Exits(null,Rooms.Gnomes1,null,null,[],[11,7]),SolidLayersInsides.GnomesCave1,NpcSpawnsInsides.GnomesCave1,[8,15], new DoorConditions([ItemsIds.JamulsGuitar],[],[],0,0,0,'You need a magic instrument to get in')) 11 | ], 12 | Mages: [ 13 | new Door(8,11,RoomsInsides.MagesTower1,new Exits(null,Rooms.Mages,null,null,[],[8,12]),SolidLayersInsides.MagesTower1,NpcSpawnsInsides.MagesTower1,[8,15], null) 14 | ], 15 | Subitnof4: [ 16 | new Door(10,9,RoomsInsides.SubitnofCastle1,new Exits(null,Rooms.Subitnof4,null,null,[],[10,10]),SolidLayersInsides.SubitnofCastle1,NpcSpawnsInsides.SubitnofCastle1,[8,15], null) 17 | ] 18 | } -------------------------------------------------------------------------------- /server/map/map.ts: -------------------------------------------------------------------------------- 1 | import Room from './rooms/room.ts' 2 | import { ClientHandler } from '../clientHandler.ts' 3 | import { MapBuilder } from "./mapBuilder.ts" 4 | 5 | export default class Map { 6 | private mapBuilder: MapBuilder 7 | public rooms: Room[] 8 | 9 | constructor(clientHandler: ClientHandler) { 10 | this.mapBuilder = new MapBuilder(clientHandler) 11 | this.rooms = this.buildMap() 12 | } 13 | 14 | public getRoomById(roomId: number): Room { 15 | return this.rooms.find(room => { 16 | return room.id === roomId 17 | }) || this.rooms[roomId] 18 | } 19 | 20 | private buildMap(): any { 21 | return this.mapBuilder.buildMap() 22 | } 23 | } -------------------------------------------------------------------------------- /server/map/mapBuilder.ts: -------------------------------------------------------------------------------- 1 | import { SolidLayers } from "../../shared/solidLayers.ts" 2 | import { ClientHandler } from "../clientHandler.ts" 3 | import { Rooms } from "../../shared/Enums.ts" 4 | import { MapDimensionsHeightWidth, NpcSpawns } from "./npcSpawns.ts" 5 | import { DoorSpawns } from "./doorSpawns.ts" 6 | import Exits from "./rooms/exits.ts" 7 | import Room from "./rooms/room.ts" 8 | import Door from "./rooms/door.ts"; 9 | 10 | export class MapBuilder { 11 | private clientHandler: ClientHandler 12 | private mapDimensionsHeightWidth: number[] = MapDimensionsHeightWidth 13 | 14 | constructor(clientHandler: ClientHandler) { 15 | this.clientHandler = clientHandler 16 | } 17 | 18 | public buildMap() { 19 | const map: Room[] = [] 20 | const enumRoomsAny = Rooms as any 21 | const npcSpawnsAny = NpcSpawns as any 22 | const doorSpawnsAny = DoorSpawns as any 23 | const exits = this.generateExits() 24 | 25 | let count = 0 26 | for (const [key, value] of Object.entries(SolidLayers)) { 27 | const roomId = enumRoomsAny[key] 28 | const solidLayer = value 29 | let npcSpawns = npcSpawnsAny[key] 30 | let doorSpawns = doorSpawnsAny[key] 31 | 32 | if (!npcSpawns) { 33 | npcSpawns = this.generateEmptyNpcSpawns() 34 | } 35 | 36 | if (!doorSpawns) { 37 | doorSpawns = [] 38 | } 39 | 40 | for (const door of doorSpawns) { 41 | const doorTyped = door as Door 42 | const roomNotCreated = !map.some(x => x.id == doorTyped.toRoomId) 43 | if (doorTyped.toRoomId < 0 && roomNotCreated) { 44 | map.push(new Room(doorTyped.toRoomId, doorTyped.exits, this.clientHandler, doorTyped.solidLayer, doorTyped.npcSpawns, [])) 45 | } 46 | } 47 | 48 | map.push(new Room(roomId, exits[count], this.clientHandler, solidLayer, npcSpawns, doorSpawns)) 49 | count += 1 50 | } 51 | 52 | return map 53 | } 54 | 55 | private generateExits() { 56 | const exits = [] 57 | const mapWidth = this.mapDimensionsHeightWidth[1] 58 | const mapHeight = this.mapDimensionsHeightWidth[0] 59 | 60 | for (let height=0; height < mapHeight; height++) { 61 | for (let width=0; width < mapWidth; width++) { 62 | const n = (height - 1 >= 0) ? Rooms[width + ((height-1) * mapWidth)] ? width + ((height-1) * mapWidth) : null : null 63 | const s = (height + 1 < mapHeight) ? Rooms[width + ((height+1) * mapWidth)] ? width + ((height+1) * mapWidth) : null : null 64 | const w = (width - 1 >= 0) ? Rooms[(width-1) + (height * mapWidth)] ? (width-1) + (height * mapWidth) : null : null 65 | const e = (width + 1 < mapWidth) ? Rooms[(width+1) + (height * mapWidth)] ? (width+1) + (height * mapWidth) : null : null 66 | 67 | exits.push(new Exits(n, s, w, e)) 68 | } 69 | } 70 | 71 | return exits 72 | } 73 | 74 | private generateEmptyNpcSpawns() { 75 | return [[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], 76 | [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], 77 | [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], 78 | [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], 79 | [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], 80 | [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], 81 | [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], 82 | [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], 83 | [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], 84 | [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], 85 | [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], 86 | [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], 87 | [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], 88 | [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], 89 | [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], 90 | [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]] 91 | } 92 | } -------------------------------------------------------------------------------- /server/map/rooms/door.ts: -------------------------------------------------------------------------------- 1 | import NpcBase from "../../entities/npcs/npcBase.ts"; 2 | import { Player } from "../../entities/player.ts"; 3 | import DoorConditions from "./doorConditions.ts"; 4 | import Exits from "./exits.ts"; 5 | 6 | export default class Door { 7 | public x: number 8 | public y: number 9 | public toRoomId: number 10 | public exits: Exits 11 | public solidLayer: number[][] 12 | public npcSpawns: (number|NpcBase)[][] 13 | public playerSpawnXY: number[] 14 | public conditions: DoorConditions | null 15 | 16 | constructor(x: number, y: number, toRoomId: number, exits: Exits, solidLayer: number[][], npcSpawns: (number|NpcBase)[][], playerSpawnXY: number[], conditions: DoorConditions | null) { 17 | this.x = x 18 | this.y = y 19 | this.toRoomId = toRoomId 20 | this.exits = exits 21 | this.solidLayer = solidLayer 22 | this.npcSpawns = npcSpawns 23 | this.playerSpawnXY = playerSpawnXY 24 | this.conditions = conditions 25 | } 26 | 27 | public playerCanEnter(player: Player): {open: boolean,closedReason: string} { 28 | if (this.conditions != null) { 29 | return this.conditions.evaluate(player) 30 | } 31 | return { open: true, closedReason: '' } 32 | } 33 | } -------------------------------------------------------------------------------- /server/map/rooms/doorConditions.ts: -------------------------------------------------------------------------------- 1 | import { ItemsIds, Quests } from "../../../shared/Enums.ts"; 2 | import { Player } from "../../entities/player.ts"; 3 | 4 | export default class DoorConditions { 5 | public wearingItems: ItemsIds[] 6 | public bagItems: ItemsIds[] 7 | public questsCompleted: Quests[] 8 | public minLevel: number 9 | public minAttack: number 10 | public minDef: number 11 | public errorMessage: string 12 | 13 | constructor(wearingItems: ItemsIds[], bagItems: ItemsIds[], questsCompleted: Quests[], minLevel: number, minAttack: number, minDef: number, errorMessage: string) { 14 | this.wearingItems = wearingItems 15 | this.bagItems = bagItems 16 | this.questsCompleted = questsCompleted 17 | this.minLevel = minLevel 18 | this.minAttack = minAttack 19 | this.minDef = minDef 20 | this.errorMessage = errorMessage 21 | } 22 | 23 | public evaluate(player: Player): {open: boolean,closedReason: string} { 24 | const hasItemsInBag = player.bag.hasAllItems(this.bagItems) 25 | const isWearingItems = player.gear.wearingAllItems(this.wearingItems) 26 | const questsCompleted = player.quests.filter(x => this.questsCompleted.some(y => y == x.id) && x.isCompleted) 27 | const hasCompletedQuests = questsCompleted.length == this.questsCompleted.length 28 | 29 | return { 30 | open: (player.level >= this.minLevel && 31 | player.totalDefense() >= this.minDef && 32 | player.totalAttack() >= this.minAttack && 33 | hasItemsInBag && 34 | isWearingItems && 35 | hasCompletedQuests), 36 | closedReason: this.errorMessage 37 | } 38 | } 39 | } -------------------------------------------------------------------------------- /server/map/rooms/exits.ts: -------------------------------------------------------------------------------- 1 | export default class Exits { 2 | public n: number | null 3 | public s: number | null 4 | public w: number | null 5 | public e: number | null 6 | public customXYN: number[] 7 | public customXYS: number[] 8 | public customXYW: number[] 9 | public customXYE: number[] 10 | 11 | constructor(n: number | null, s: number | null, w: number | null, e: number | null, 12 | customXYN: number[] = [], 13 | customXYS: number[] = [], 14 | customXYW: number[] = [], 15 | customXYE: number[] = [], 16 | ) { 17 | this.n = n 18 | this.s = s 19 | this.w = w 20 | this.e = e 21 | this.customXYN = customXYN 22 | this.customXYS = customXYS 23 | this.customXYW = customXYW 24 | this.customXYE = customXYE 25 | } 26 | 27 | public hasNorth(): boolean { 28 | return this.n !== null 29 | } 30 | 31 | public hasSouth(): boolean { 32 | return this.s !== null 33 | } 34 | 35 | public hasWest(): boolean { 36 | return this.w !== null 37 | } 38 | 39 | public hasEast(): boolean { 40 | return this.e !== null 41 | } 42 | } -------------------------------------------------------------------------------- /server/pve/pveData.ts: -------------------------------------------------------------------------------- 1 | import { Player } from "../entities/player.ts"; 2 | import { Npc } from "../entities/npc.ts"; 3 | import Room from "../map/rooms/room.ts"; 4 | import { PveAttacker } from "../../shared/Enums.ts"; 5 | 6 | export class PveData { 7 | public room: Room 8 | public player: Player 9 | public npc: Npc 10 | public attacker: PveAttacker 11 | public damageCaused: number 12 | public damageDefended: number 13 | public fightingNpcId: number 14 | 15 | constructor(room: Room, 16 | player: Player, 17 | npc: Npc, 18 | attacker: PveAttacker) { 19 | this.room = room 20 | this.player = player 21 | this.npc = npc 22 | this.attacker = attacker 23 | this.damageCaused = 0 24 | this.damageDefended = 0 25 | this.fightingNpcId = player.fightingNpcId == null ? 0 : player.fightingNpcId 26 | } 27 | } --------------------------------------------------------------------------------