@@ -1,26 +0,0 @@ | |||||
module.exports = { | |||||
init: function (event) { | |||||
const { config, rewards, eventManager } = event; | |||||
event.participators.forEach(p => { | |||||
const rList = [{ | |||||
nameLike: 'Ancient Carp', | |||||
removeAll: true | |||||
}]; | |||||
const pRewards = rewards[p.name]; | |||||
if (pRewards && pRewards.length) | |||||
rList.push(...pRewards); | |||||
if (rList.length > 1) | |||||
rList[1].msg = `${config.name} reward:`; | |||||
eventManager.instance.mail.sendMail(p.name, rList); | |||||
}); | |||||
if (config.events && config.events.afterGiveRewards) | |||||
config.events.afterGiveRewards(event); | |||||
this.end = true; | |||||
} | |||||
}; |
@@ -15,10 +15,5 @@ module.exports = { | |||||
subType: '', | subType: '', | ||||
quantity: [3, 7], | quantity: [3, 7], | ||||
dropChance: 0.5 | dropChance: 0.5 | ||||
}, { | |||||
name: 'Green Fingers', | |||||
type: 'gatherResource', | |||||
subType: 'herb', | |||||
quantity: [5, 10] | |||||
}] | }] | ||||
}; | }; |
@@ -33,7 +33,7 @@ module.exports = { | |||||
zoneTemplate = globalQuests; | zoneTemplate = globalQuests; | ||||
let config = extend({}, zoneTemplate); | let config = extend({}, zoneTemplate); | ||||
this.instance.eventEmitter.emit('onBeforeGetQuests', config); | |||||
this.instance.eventEmitter.emit('onBeforeGetQuests', config, zoneName); | |||||
if (config.infini.length === 0) | if (config.infini.length === 0) | ||||
return; | return; | ||||
@@ -48,7 +48,14 @@ module.exports = { | |||||
if (!pickQuest) | if (!pickQuest) | ||||
pickQuest = config.infini[~~(Math.random() * config.infini.length)]; | pickQuest = config.infini[~~(Math.random() * config.infini.length)]; | ||||
let pickType = pickQuest.type[0].toUpperCase() + pickQuest.type.substr(1); | let pickType = pickQuest.type[0].toUpperCase() + pickQuest.type.substr(1); | ||||
let questClass = require(`../../config/quests/templates/quest${pickType}`); | |||||
const questMsg = { | |||||
type: pickType, | |||||
path: pickQuest.path || `../../config/quests/templates/quest${pickType}` | |||||
}; | |||||
this.instance.eventEmitter.emit('onBeforeBuildQuest', questMsg); | |||||
let questClass = require(questMsg.path); | |||||
let quest = extend({}, pickQuest, questTemplate, questClass, template); | let quest = extend({}, pickQuest, questTemplate, questClass, template); | ||||
@@ -1,80 +0,0 @@ | |||||
module.exports = { | |||||
type: 'gatherResource', | |||||
need: null, | |||||
gatherType: null, | |||||
requiredQuality: 0, | |||||
have: 0, | |||||
build: function () { | |||||
if (!this.need) { | |||||
this.need = 2 + ~~(Math.random() * 3); | |||||
this.gatherType = ['herb', 'fish'][~~(Math.random() * 2)]; | |||||
if (this.gatherType === 'fish') { | |||||
this.name = 'Lure of the Sea'; | |||||
let isQualityQ = (Math.random() < 0.3); | |||||
if (isQualityQ) { | |||||
this.requiredQuality = 1 + ~~(Math.random() * 2); | |||||
this.need = 1; | |||||
} | |||||
} | |||||
} | |||||
if (['herb', 'fish'].indexOf(this.gatherType) === -1) | |||||
this.gatherType = 'herb'; | |||||
this.typeName = (this.gatherType === 'herb') ? 'herbs' : 'fish'; | |||||
this.updateDescription(); | |||||
return true; | |||||
}, | |||||
getXpMultiplier: function () { | |||||
if (this.requiredQuality === 2) | |||||
return 8; | |||||
else if (this.requiredQuality === 1) | |||||
return 6; | |||||
return this.need; | |||||
}, | |||||
updateDescription: function () { | |||||
let typeName = this.typeName; | |||||
if (this.requiredQuality > 0) | |||||
typeName = ['big', 'giant'][this.requiredQuality - 1] + ' ' + typeName; | |||||
let action = ({ | |||||
herb: 'Gather', | |||||
fish: 'Catch' | |||||
})[this.gatherType]; | |||||
this.description = `${action} ${this.have}/${this.need} ${typeName}`; | |||||
}, | |||||
events: { | |||||
afterGatherResource: function (gatherResult) { | |||||
if (gatherResult.nodeType !== this.gatherType) | |||||
return; | |||||
else if ((this.requiredQuality) && (gatherResult.items[0].quality < this.requiredQuality)) | |||||
return; | |||||
else if (gatherResult.items[0].name.toLowerCase() === 'cerulean pearl') { | |||||
//This is a hack but we have no other way to tell fish from pearls at the moment | |||||
return; | |||||
} | |||||
if ((this.obj.zoneName !== this.zoneName) || (this.have >= this.need)) | |||||
return; | |||||
this.have++; | |||||
this.updateDescription(); | |||||
this.obj.syncer.setArray(true, 'quests', 'updateQuests', this.simplify(true)); | |||||
if (this.have >= this.need) | |||||
this.ready(); | |||||
} | |||||
} | |||||
}; |
@@ -1,4 +1,4 @@ | |||||
let phaseTemplate = require('../config/eventPhases/phaseTemplate'); | |||||
let phaseTemplate = require('./phases/phaseTemplate'); | |||||
let fs = require('fs'); | let fs = require('fs'); | ||||
let mapList = require('../config/maps/mapList'); | let mapList = require('../config/maps/mapList'); | ||||
@@ -386,7 +386,7 @@ module.exports = { | |||||
let phase = event.phases[i]; | let phase = event.phases[i]; | ||||
if (!phase) { | if (!phase) { | ||||
let phaseFile = 'phase' + p.type[0].toUpperCase() + p.type.substr(1); | let phaseFile = 'phase' + p.type[0].toUpperCase() + p.type.substr(1); | ||||
let typeTemplate = require('../config/eventPhases/' + phaseFile); | |||||
let typeTemplate = require('./phases/' + phaseFile); | |||||
phase = extend({ | phase = extend({ | ||||
instance: this.instance, | instance: this.instance, | ||||
event: event | event: event | ||||
@@ -0,0 +1,21 @@ | |||||
module.exports = { | |||||
init: function (event) { | |||||
const { config, rewards, eventManager } = event; | |||||
Object.entries(rewards).forEach(e => { | |||||
const { name, rList } = e; | |||||
if (!rList.length) | |||||
return; | |||||
rList[0].msg = `${config.name} reward:`; | |||||
this.instance.mail.sendMail(name, rList); | |||||
}); | |||||
if ((config.events) && (config.events.afterGiveRewards)) | |||||
config.events.afterGiveRewards(eventManager, config); | |||||
this.end = true; | |||||
} | |||||
}; |