vue-shovel/src/types.d.ts
Norman Köhring be68f73721 fix types
2025-03-16 00:10:04 +01:00

84 lines
2.1 KiB
TypeScript

export type ItemQuality = 'wood' | 'iron' | 'diamond'
export type ItemType = 'tool' | 'block' | 'ore'
export type DropItem =
| 'Wooden Shovel' | 'Iron Shovel' | 'Diamond Shovel'
| 'Wooden Pick Axe' | 'Iron Pick Axe' | 'Diamond Pick Axe'
| 'Wooden Sword' | 'Iron Sword' | 'Diamond Sword'
| 'leaves' | 'dirt' | 'wood' | 'stone' | 'gravel'
| 'coal' | 'iron' | 'silver' | 'gold' | 'ruby' | 'diamond' | 'emerald'
export interface Item {
name: DropItem
type: ItemType
icon: string
quality?: ItemQuality
builds?: BlockType
}
export interface ToolItem extends Item {
type: 'tool'
quality: ItemQuality
}
export interface BlockItem extends Item {
type: 'block'
builds: BlockType
}
export type BlockType =
| 'air' | 'grass'
| 'treeCrown' | 'treeLeaves' | 'treeTrunk' | 'treeRoot' | 'treeRootRight' | 'treeRootMiddle' | 'treeRootLeft'
| 'soil' | 'soilGravel' | 'stone' | 'stoneGravel'
| 'bedrock' | 'cave'
| 'brickWall'
export type Block = {
type: BlockType, // what is it?
hp: number, // how long do I need to hit it?
walkable: boolean, // can I walk through it?
climbable?: boolean, // can I climb it?
transparent?: boolean, // can I see through it?
illuminated?: boolean, // is it glowing?
drops?: DropItem, // what do I get, when loot it?
}
// describes a changed block, eg digged or placed by the player
type DamagedBlock = {
change: 'damage'
x: number
y: number
damage: number
}
type ChangedBlock = {
change: 'exchange'
x: number
y: number
newType: BlockType
}
type Change = DamagedBlock | ChangedBlock
export interface InventoryItem extends Item {
amount: number
quality: ItemQuality | null
}
export interface Moveable {
x: number // position on x-axis (fixed for the player)
y: number // position on y-axis (fixed for the player)
lastDir: number // store last face direction
vx: number // velocity on the x-axis
vy: number // velocity on the y-axis
}
export interface Npc extends Moveable {
hostile: boolean
inventory: InventoryItem[]
}
export interface Player extends Moveable {
inventory: InventoryItem[]
}
export type Direction = 'at' | 'left' | 'right' | 'up' | 'down'