Char creation process finalized
This commit is contained in:
@@ -23,6 +23,10 @@ export class PegasusActorCreate {
|
||||
this.perks = perksPack.map(i => i.toObject())
|
||||
const specPack = await PegasusUtility.loadCompendium("fvtt-pegasus-rpg.specialisations")
|
||||
this.specs = specPack.map(i => i.toObject())
|
||||
const virtuePack = await PegasusUtility.loadCompendium("fvtt-pegasus-rpg.virtues")
|
||||
this.virtues = virtuePack.map(i => i.toObject())
|
||||
const vicePack = await PegasusUtility.loadCompendium("fvtt-pegasus-rpg.vices")
|
||||
this.vices = vicePack.map(i => i.toObject())
|
||||
|
||||
this.showRaces()
|
||||
}
|
||||
@@ -64,7 +68,7 @@ export class PegasusActorCreate {
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
processChatEvent(event) {
|
||||
async processChatEvent(event) {
|
||||
const step = $(event.currentTarget).data("step-name");
|
||||
const itemId = $(event.currentTarget).data("item-id");
|
||||
|
||||
@@ -199,7 +203,11 @@ export class PegasusActorCreate {
|
||||
this.nbPerks--;
|
||||
if (this.nbPerks == 0 || this.rolePerks.length == 0) {
|
||||
this.nbGlobalSpec = 5
|
||||
this.showGlobalSpec()
|
||||
if (this.forceVirtue) {
|
||||
this.showVirtue()
|
||||
} else {
|
||||
this.showGlobalSpec()
|
||||
}
|
||||
} else {
|
||||
this.showRolePerks()
|
||||
}
|
||||
@@ -212,8 +220,11 @@ export class PegasusActorCreate {
|
||||
this.nbGlobalSpec--;
|
||||
if (this.nbGlobalSpec == 0) {
|
||||
this.nbGlobalStat = 5
|
||||
this.showGlobalStat()
|
||||
//this.showCharacterEnd()
|
||||
if (this.forceVirtue) {
|
||||
this.showVirtue()
|
||||
} else {
|
||||
this.showGlobalStat()
|
||||
}
|
||||
} else {
|
||||
this.showGlobalSpec()
|
||||
}
|
||||
@@ -226,8 +237,11 @@ export class PegasusActorCreate {
|
||||
this.nbGlobalStat--
|
||||
if (this.nbGlobalStat == 0) {
|
||||
this.nbGlobalPerk = 1
|
||||
this.showGlobalPerk()
|
||||
//this.showCharacterEnd()
|
||||
if (this.forceVirtue) {
|
||||
this.showVirtue()
|
||||
} else {
|
||||
this.showGlobalPerk()
|
||||
}
|
||||
} else {
|
||||
this.showGlobalStat()
|
||||
}
|
||||
@@ -240,8 +254,11 @@ export class PegasusActorCreate {
|
||||
this.nbGlobalPerk--;
|
||||
if (this.nbGlobalPerk == 0) {
|
||||
this.nbGlobalStatus = 1
|
||||
this.showGlobalStatus()
|
||||
//this.showCharacterEnd()
|
||||
if (this.forceVirtue) {
|
||||
this.showVirtue()
|
||||
} else {
|
||||
this.showGlobalStatus()
|
||||
}
|
||||
} else {
|
||||
this.showGlobalPerk()
|
||||
}
|
||||
@@ -253,13 +270,102 @@ export class PegasusActorCreate {
|
||||
this.actor.addStatusBonus(statusKey, 1)
|
||||
this.nbGlobalStatus--;
|
||||
if (this.nbGlobalStatus == 0) {
|
||||
this.showCharacterEnd()
|
||||
this.nbBonusSelection = 1
|
||||
if (this.forceVirtue) {
|
||||
this.showVirtue()
|
||||
} else {
|
||||
this.showBonusSelection()
|
||||
}
|
||||
} else {
|
||||
this.showGlobalStatus()
|
||||
}
|
||||
}
|
||||
|
||||
if (step == 'select-bonus-selection') {
|
||||
PegasusUtility.removeChatMessageId(PegasusUtility.findChatMessageId(event.currentTarget))
|
||||
let nextStep = $(event.currentTarget).data("bonus-key")
|
||||
this.forceVirtue = true
|
||||
if (nextStep == "bonus-statistic") {
|
||||
this.nbGlobalStat = 2
|
||||
this.showGlobalStat()
|
||||
}
|
||||
if (nextStep == "bonus-specialisation") {
|
||||
this.nbGlobalSpec = 4
|
||||
this.showGlobalSpec()
|
||||
}
|
||||
if (nextStep == "bonus-perk") {
|
||||
this.nbGlobalPerk = 2
|
||||
this.showGlobalPerk()
|
||||
}
|
||||
if (nextStep == "bonus-status") {
|
||||
this.nbGlobalStatus = 5
|
||||
this.showGlobalStatus()
|
||||
}
|
||||
if (nextStep == "bonus-roleability") {
|
||||
this.actor.increaseRoleAbility()
|
||||
}
|
||||
if (nextStep == "bonus-ppp5") {
|
||||
this.actor.addPPP(5)
|
||||
}
|
||||
if (nextStep == "bonus-wealthy") {
|
||||
ChatMessage.create({ content: "NOT AUTOMATED! Your character starts with x2 Starting Funds" })
|
||||
this.showVirtue()
|
||||
}
|
||||
if (nextStep == "bonus-heirloom") {
|
||||
ChatMessage.create({ content: "NOT AUTOMATED! Your character starts with an item of choice (GM Must approve). This item provides a Level 1 Bonus Dice to a Stat of choice" })
|
||||
this.showVirtue()
|
||||
}
|
||||
if (nextStep == "bonus-vehicle") {
|
||||
ChatMessage.create({ content: "NOT AUTOMATED! Your character starts with a Vehicle of Choice (GM Must approve)." })
|
||||
this.showVirtue()
|
||||
}
|
||||
if (nextStep == "bonus-mount") {
|
||||
ChatMessage.create({ content: "NOT AUTOMATED! Your character starts with a Mount of Choice (GM Must approve)." })
|
||||
this.showVirtue()
|
||||
}
|
||||
if (nextStep == "bonus-sidekick") {
|
||||
ChatMessage.create({ content: "NOT AUTOMATED! Your character starts with a Sidekick of Choice (GM Must approve)." })
|
||||
this.showVirtue()
|
||||
}
|
||||
if (nextStep == "bonus-ambidextrious") {
|
||||
this.actor.setHandInformation("Ambidextrious")
|
||||
this.showVirtue()
|
||||
}
|
||||
}
|
||||
|
||||
if (step == 'select-global-virtue') {
|
||||
PegasusUtility.removeChatMessageId(PegasusUtility.findChatMessageId(event.currentTarget));
|
||||
let virtue = this.virtues.find(item => item._id == itemId);
|
||||
await this.actor.createEmbeddedDocuments('Item', [virtue])
|
||||
this.showVice()
|
||||
}
|
||||
|
||||
if (step == 'select-global-vice') {
|
||||
PegasusUtility.removeChatMessageId(PegasusUtility.findChatMessageId(event.currentTarget));
|
||||
let vice = this.vices.find(item => item._id == itemId);
|
||||
await this.actor.createEmbeddedDocuments('Item', [vice]);
|
||||
if(this.forceEnd) {
|
||||
this.showCharacterEnd()
|
||||
} else {
|
||||
this.showViceQuestion()
|
||||
}
|
||||
}
|
||||
|
||||
if (step == "select-vice-question") {
|
||||
PegasusUtility.removeChatMessageId(PegasusUtility.findChatMessageId(event.currentTarget))
|
||||
let nextStep = $(event.currentTarget).data("question-key")
|
||||
this.forceEnd = true
|
||||
if (nextStep == "vice-next-step") {
|
||||
this.showCharacterEnd()
|
||||
}
|
||||
if (nextStep == "vice-5-cdp") {
|
||||
this.actor.addCDP(5)
|
||||
this.showVice()
|
||||
}
|
||||
if (nextStep == "vice-vertue") {
|
||||
this.showVirtue()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
@@ -515,6 +621,85 @@ export class PegasusActorCreate {
|
||||
this.renderChatMessage(formData)
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async showBonusSelection() {
|
||||
let formData = this.createFormData("select-bonus-selection")
|
||||
formData.bonuses = {
|
||||
"bonus-statistic": { name: "Increase 2 Stats" },
|
||||
"bonus-specialisation": { name: "Increase 4 Specialisations" },
|
||||
"bonus-perk": { name: "Choose/Upgrade 2 Perks" },
|
||||
"bonus-status": { name: "Upgrade 5 status" },
|
||||
"bonus-roleability": { name: "Role Ability +1" },
|
||||
"bonus-ppp5": { name: "Gain +5 PPP" },
|
||||
"bonus-wealthy": { name: "Wealthy (money x 2)" },
|
||||
"bonus-heirloom": { name: "Family Heirloom (Special Item)" },
|
||||
"bonus-vehicle": { name: "Starting Vehicle" },
|
||||
"bonus-sidekick": { name: "Starting Sidekick" },
|
||||
"bonus-ambidextrious": { name: "Ambidextrious" }
|
||||
}
|
||||
this.renderChatMessage(formData)
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async showVirtue() {
|
||||
let formData = this.createFormData("select-global-virtue")
|
||||
let virtues = this.actor.items.filter(it => it.type == "virtue")
|
||||
formData.virtues = []
|
||||
for ( let virtue1 of this.virtues) { // Filter existing virtues
|
||||
let isOK = true
|
||||
for(let virtue2 of virtues) {
|
||||
if (virtue1.name == virtue2.name) {
|
||||
isOK = false
|
||||
break
|
||||
}
|
||||
}
|
||||
if (isOK) {
|
||||
formData.virtues.push(virtue1)
|
||||
}
|
||||
}
|
||||
formData.virtues.sort(function compare(a, b) { if (a.name < b.name) { return -1 } else { return 1 } })
|
||||
this.renderChatMessage(formData)
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
async showVice() {
|
||||
let formData = this.createFormData("select-global-vice")
|
||||
let virtues = this.actor.items.filter(it => it.type == "virtue")
|
||||
let vices = this.actor.items.filter(it => it.type == "vice")
|
||||
formData.vices = []
|
||||
for (let vice of this.vices) {
|
||||
let isOK = true
|
||||
for ( let virtue of virtues) {
|
||||
for (let nonVice of virtue.system.unavailablevice) {
|
||||
if(nonVice.name == vice.name) {
|
||||
isOK = false
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
for ( let vice2 of vices) {
|
||||
if(vice2.name == vice.name) {
|
||||
isOK = false
|
||||
break
|
||||
}
|
||||
}
|
||||
if (isOK) {
|
||||
formData.vices.push( vice)
|
||||
}
|
||||
}
|
||||
formData.vices.sort(function compare(a, b) { if (a.name < b.name) { return -1 } else { return 1 } })
|
||||
this.renderChatMessage(formData)
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
showViceQuestion() {
|
||||
let formData = this.createFormData("select-vice-question")
|
||||
formData.questions = {
|
||||
"vice-next-step": { name: "Go to next step" },
|
||||
"vice-5-cdp": { name: "Gain +5 CDP and choose a Vice" },
|
||||
"vice-vertue": { name: "Choose a Virtue and a Vice" }
|
||||
}
|
||||
this.renderChatMessage(formData)
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async showCharacterEnd() {
|
||||
|
Reference in New Issue
Block a user