57 lines
1.6 KiB
TypeScript
57 lines
1.6 KiB
TypeScript
import { enemyDamageInfo } from "./enemyDamageInfo";
|
|
import { physicsObject } from "./physicsObject";
|
|
import { playerInventory } from "./playerInventory";
|
|
import { questBook } from "./questBook";
|
|
|
|
export class playerData{
|
|
id : number
|
|
level : number = 1
|
|
room : string = "0_0"
|
|
characterId : number
|
|
inventory : playerInventory = new playerInventory()
|
|
rigidbody : physicsObject = new physicsObject()
|
|
questBook : questBook = new questBook()
|
|
damageInfo : enemyDamageInfo[] = []
|
|
|
|
constructor(init?: Partial<playerData>) {
|
|
Object.assign(this, init);
|
|
this.questBook = new questBook(this.questBook)
|
|
}
|
|
|
|
copyStart(){
|
|
let player : any = {}
|
|
player.id = this.id
|
|
player.characterId = this.characterId
|
|
player.rigidbody = physicsObject.characterOnly(this.rigidbody)
|
|
return player
|
|
}
|
|
|
|
copyUpdate(){
|
|
let player : any = {}
|
|
player.id = this.id
|
|
if(this.rigidbody == null){
|
|
console.log(this)
|
|
}
|
|
player.rigidbody = physicsObject.characterOnly(this.rigidbody)
|
|
if(this.damageInfo.length > 0) player.damageInfo = this.damageInfo
|
|
return player
|
|
}
|
|
|
|
copyInventory(){
|
|
let player : any = {}
|
|
player.id = this.id
|
|
player.inventory = this.inventory
|
|
return player
|
|
}
|
|
|
|
getItemById(id : number){
|
|
let item = this.inventory.items.find(i=>i.id == id)
|
|
return item
|
|
}
|
|
|
|
validateEquipment(){
|
|
if(this.inventory.equipment.length < 3){
|
|
this.inventory.equipment = [-1, -1, -1]
|
|
}
|
|
}
|
|
} |