First v10 release
This commit is contained in:
@@ -28,7 +28,7 @@ export class Imperium5Actor extends Actor {
|
||||
return super.create(data, options);
|
||||
}
|
||||
// If the created actor has items (only applicable to duplicated actors) bypass the new actor creation logic
|
||||
if (data.items) {
|
||||
if (items) {
|
||||
let actor = super.create(data, options);
|
||||
return actor;
|
||||
}
|
||||
@@ -53,7 +53,7 @@ export class Imperium5Actor extends Actor {
|
||||
prepareDerivedData() {
|
||||
|
||||
if (this.type == 'character') {
|
||||
//this.data.data.encCapacity = this.getEncumbranceCapacity()
|
||||
//this.system.encCapacity = this.getEncumbranceCapacity()
|
||||
//this.buildContainerTree()
|
||||
}
|
||||
console.log("Acteur : ", this)
|
||||
@@ -68,49 +68,61 @@ export class Imperium5Actor extends Actor {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
getArchetype() {
|
||||
let item = duplicate( this.data.items.find( it => it.type == "archetype") || [])
|
||||
let item = duplicate( this.items.find( it => it.type == "archetype") || [])
|
||||
return item
|
||||
}
|
||||
getSpecialites() {
|
||||
let item = duplicate(this.data.items.filter( it => it.type == "specialite") || [] )
|
||||
let item = duplicate(this.items.filter( it => it.type == "specialite") || [] )
|
||||
return item
|
||||
}
|
||||
getFamiliarites() {
|
||||
let item = duplicate(this.data.items.filter( it => it.type == "familiarite") || [] )
|
||||
let item = duplicate(this.items.filter( it => it.type == "familiarite") || [] )
|
||||
return item
|
||||
}
|
||||
getNatureProfonde() {
|
||||
let item = duplicate( this.data.items.find( it => it.type == "nature") || [])
|
||||
let item = duplicate( this.items.find( it => it.type == "nature") || [])
|
||||
return item
|
||||
}
|
||||
getTraits() {
|
||||
let item = duplicate(this.data.items.filter( it => it.type == "trait") || [] )
|
||||
let item = duplicate(this.items.filter( it => it.type == "trait") || [] )
|
||||
return item
|
||||
}
|
||||
getSymbioses() {
|
||||
let item = duplicate(this.data.items.filter( it => it.type == "symbiose") || [] )
|
||||
let item = duplicate(this.items.filter( it => it.type == "symbiose") || [] )
|
||||
return item
|
||||
}
|
||||
getEquipements() {
|
||||
let item = duplicate(this.data.items.filter( it => it.type == "equipement") || [] )
|
||||
let item = duplicate(this.items.filter( it => it.type == "equipement") || [] )
|
||||
return item
|
||||
}
|
||||
getCapacites() {
|
||||
let item = duplicate(this.data.items.filter( it => it.type == "capacite") || [] )
|
||||
let item = duplicate(this.items.filter( it => it.type == "capacite") || [] )
|
||||
return item
|
||||
}
|
||||
getUnusedCapacites(){
|
||||
let item = this.items.filter( it => it.type == "capacite") || []
|
||||
return item
|
||||
}
|
||||
getSingularites(){
|
||||
let item = duplicate(this.data.items.filter( it => it.type == "singularite") || [] )
|
||||
let item = duplicate(this.items.filter( it => it.type == "singularite") || [] )
|
||||
return item
|
||||
}
|
||||
getContacts(){
|
||||
let item = duplicate(this.data.items.filter( it => it.type == "contact") || [] )
|
||||
let item = duplicate(this.items.filter( it => it.type == "contact") || [] )
|
||||
return item
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
incDecKarma( value ) {
|
||||
let karma = duplicate(this.system.karma)
|
||||
karma.value += value
|
||||
karma.value = Math.max(karma.value, 0)
|
||||
this.update( { 'system.karma': karma})
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
getItemById(id) {
|
||||
let item = this.data.items.find(item => item.id == id)
|
||||
let item = this.items.find(item => item.id == id)
|
||||
if (item) {
|
||||
item = duplicate(item)
|
||||
}
|
||||
@@ -135,7 +147,7 @@ export class Imperium5Actor extends Actor {
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
getEffectByLabel(label) {
|
||||
return this.getActiveEffects().find(it => it.data.label == label);
|
||||
return this.getActiveEffects().find(it => it.label == label);
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
getEffectById(id) {
|
||||
@@ -154,21 +166,21 @@ export class Imperium5Actor extends Actor {
|
||||
/* -------------------------------------------- */
|
||||
getSubActors() {
|
||||
let subActors = [];
|
||||
for (let id of this.data.data.subactors) {
|
||||
for (let id of this.system.subactors) {
|
||||
subActors.push(duplicate(game.actors.get(id)))
|
||||
}
|
||||
return subActors;
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
async addSubActor(subActorId) {
|
||||
let subActors = duplicate(this.data.data.subactors);
|
||||
let subActors = duplicate(this.system.subactors);
|
||||
subActors.push(subActorId);
|
||||
await this.update({ 'data.subactors': subActors });
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
async delSubActor(subActorId) {
|
||||
let newArray = [];
|
||||
for (let id of this.data.data.subactors) {
|
||||
for (let id of this.system.subactors) {
|
||||
if (id != subActorId) {
|
||||
newArray.push(id);
|
||||
}
|
||||
@@ -176,25 +188,16 @@ export class Imperium5Actor extends Actor {
|
||||
await this.update({ 'data.subactors': newArray });
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
syncRoll(rollData) {
|
||||
let linkedRollId = Imperium5Utility.getDefenseState(this.id);
|
||||
if (linkedRollId) {
|
||||
rollData.linkedRollId = linkedRollId;
|
||||
}
|
||||
this.lastRollId = rollData.rollId;
|
||||
Imperium5Utility.saveRollData(rollData);
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async deleteAllItemsByType(itemType) {
|
||||
let items = this.data.items.filter(item => item.type == itemType);
|
||||
let items = this.items.filter(item => item.type == itemType);
|
||||
await this.deleteEmbeddedDocuments('Item', items);
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async addItemWithoutDuplicate(newItem) {
|
||||
let item = this.data.items.find(item => item.type == newItem.type && item.name.toLowerCase() == newItem.name.toLowerCase())
|
||||
let item = this.items.find(item => item.type == newItem.type && item.name.toLowerCase() == newItem.name.toLowerCase())
|
||||
if (!item) {
|
||||
await this.createEmbeddedDocuments('Item', [newItem]);
|
||||
}
|
||||
@@ -202,9 +205,9 @@ export class Imperium5Actor extends Actor {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async incDecQuantity(objetId, incDec = 0) {
|
||||
let objetQ = this.data.items.get(objetId)
|
||||
let objetQ = this.items.get(objetId)
|
||||
if (objetQ) {
|
||||
let newQ = objetQ.data.data.quantity + incDec
|
||||
let newQ = objetQ.system.quantity + incDec
|
||||
if (newQ >= 0) {
|
||||
const updated = await this.updateEmbeddedDocuments('Item', [{ _id: objetQ.id, 'data.quantity': newQ }]) // pdates one EmbeddedEntity
|
||||
}
|
||||
@@ -217,34 +220,43 @@ export class Imperium5Actor extends Actor {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
addEffects(rollData) {
|
||||
let effects = this.data.items.filter(item => item.type == 'effect')
|
||||
let effects = this.items.filter(item => item.type == 'effect')
|
||||
for (let effect of effects) {
|
||||
effect = duplicate(effect)
|
||||
if (!effect.data.hindrance
|
||||
&& (effect.data.stataffected != "notapplicable" || effect.data.specaffected.length > 0)
|
||||
&& effect.data.stataffected != "special") {
|
||||
if (effect.data.effectstatlevel) {
|
||||
effect.data.effectlevel = this.data.data.statistics[effect.data.effectstat].value
|
||||
if (!effect.system.hindrance
|
||||
&& (effect.system.stataffected != "notapplicable" || effect.system.specaffected.length > 0)
|
||||
&& effect.system.stataffected != "special") {
|
||||
if (effect.system.effectstatlevel) {
|
||||
effect.system.effectlevel = this.system.statistics[effect.system.effectstat].value
|
||||
}
|
||||
rollData.effectsList.push({ label: effect.name, type: "effect", applied: false, effect: effect, value: effect.data.effectlevel })
|
||||
rollData.effectsList.push({ label: effect.name, type: "effect", applied: false, effect: effect, value: effect.system.effectlevel })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
getCommonRollData(statKey = undefined, useShield = false) {
|
||||
rollAme( ameKey) {
|
||||
let rollData = this.getCommonRollData()
|
||||
rollData.ame = duplicate(this.system.ames[ameKey])
|
||||
rollData.ameMalus = this.system.amestype[rollData.ame.type].malus
|
||||
this.startRoll(rollData)
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
getCommonRollData() {
|
||||
let rollData = Imperium5Utility.getBasicRollData()
|
||||
rollData.alias = this.name
|
||||
rollData.actorImg = this.img
|
||||
rollData.actorId = this.id
|
||||
rollData.img = this.img
|
||||
rollData.capacites = this.getUnusedCapacites()
|
||||
rollData.karma = this.system.karma.value
|
||||
|
||||
return rollData
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async startRoll(rollData) {
|
||||
this.syncRoll(rollData)
|
||||
let rollDialog = await Imperium5RollDialog.create(this, rollData)
|
||||
console.log(rollDialog)
|
||||
rollDialog.render(true)
|
||||
|
||||
Reference in New Issue
Block a user