49 lines
1.3 KiB
TypeScript
49 lines
1.3 KiB
TypeScript
import { enemyDamageInfo } from "./enemyDamageInfo.js";
|
|
import { characterDataInventory, characterDataStart, characterDataUpdate } from "./Outgoing/characterDataPartial.js";
|
|
import { physicsObject } from "./physicsObject.js";
|
|
import { playerInventory } from "./playerInventory.js";
|
|
import { questBook } from "./questBook.js";
|
|
|
|
export class characterData{
|
|
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<characterData>) {
|
|
Object.assign(this, init);
|
|
this.questBook = new questBook(this.questBook)
|
|
this.inventory = new playerInventory(this.inventory)
|
|
}
|
|
|
|
copyStart(){
|
|
return new characterDataStart(this)
|
|
}
|
|
|
|
copyUpdate(){
|
|
return new characterDataUpdate(this)
|
|
}
|
|
|
|
copyInventory(){
|
|
return new characterDataInventory(this)
|
|
}
|
|
|
|
getItemById(id : number){
|
|
let item = this.inventory.items.find(i=>i.id == id)
|
|
return item
|
|
}
|
|
|
|
resetDamageInfo(){
|
|
this.damageInfo = []
|
|
}
|
|
|
|
validateEquipment(){
|
|
if(this.inventory.equipment.length < 3){
|
|
this.inventory.equipment = [-1, -1, -1]
|
|
}
|
|
}
|
|
} |