@@ -53,6 +53,8 @@ define([ | |||
}, | |||
onJoinChannel: function (channel) { | |||
this.find('[filter="' + channel.trim() + '"]').remove(); | |||
var container = this.find('.filters'); | |||
var newFilter = $(tplTab) | |||
.appendTo(container) | |||
@@ -1,13 +1,13 @@ | |||
define([ | |||
], function( | |||
], function ( | |||
) { | |||
return { | |||
type: 'quests', | |||
quests: [], | |||
init: function(blueprint) { | |||
init: function (blueprint) { | |||
var quests = blueprint.quests || []; | |||
var qLen = quests.length; | |||
for (var i = 0; i < qLen; i++) { | |||
@@ -20,25 +20,26 @@ define([ | |||
this.blueprint = blueprint; | |||
}, | |||
transfer: function() { | |||
var blueprint = { quests: this.quests }; | |||
transfer: function () { | |||
var blueprint = { | |||
quests: this.quests | |||
}; | |||
this.quests = []; | |||
this.init(blueprint); | |||
}, | |||
obtain: function(quest, hideMessage) { | |||
obtain: function (quest, hideMessage) { | |||
quest.active = (this.obj.zoneName == quest.zoneName); | |||
this.quests.push(quest); | |||
if (!quest.init(hideMessage)) { | |||
this.quests.spliceWhere(q => (q == quest)); | |||
return false; | |||
} | |||
else | |||
} else | |||
return true; | |||
}, | |||
complete: function(id) { | |||
complete: function (id) { | |||
var quest = this.quests.find(q => q.id == id); | |||
if ((!quest) || (!quest.isReady)) | |||
return; | |||
@@ -50,26 +51,7 @@ define([ | |||
this.obj.instance.questBuilder.obtain(this.obj); | |||
}, | |||
/*update: function() { | |||
var quests = this.quests; | |||
var qLen = quests.length; | |||
var completed = false; | |||
for (var i = 0; i < qLen; i++) { | |||
var q = quests[i]; | |||
if (q.isCompleted) { | |||
quests.splice(i, 1); | |||
q.ready(); | |||
completed = true; | |||
qLen--; | |||
i--; | |||
} | |||
} | |||
if (completed) | |||
questBuilder.obtain(this.obj); | |||
},*/ | |||
fireEvent: function(event, args) { | |||
fireEvent: function (event, args) { | |||
var quests = this.quests; | |||
var qLen = quests.length; | |||
for (var i = 0; i < qLen; i++) { | |||
@@ -77,8 +59,7 @@ define([ | |||
if (!q) { | |||
qLen--; | |||
continue; | |||
} | |||
else if (q.completed) | |||
} else if (q.completed) | |||
continue; | |||
var events = q.events; | |||
@@ -93,7 +74,7 @@ define([ | |||
} | |||
}, | |||
simplify: function(self) { | |||
simplify: function (self) { | |||
if (!self) | |||
return; | |||
@@ -111,4 +92,4 @@ define([ | |||
return result; | |||
} | |||
}; | |||
}); | |||
}); |
@@ -2,29 +2,28 @@ define([ | |||
'config/quests/templates/questTemplate', | |||
'config/questsBase', | |||
'misc/events' | |||
], function( | |||
], function ( | |||
questTemplate, | |||
globalQuests, | |||
events | |||
) { | |||
return { | |||
instance: null, | |||
init: function(instance) { | |||
init: function (instance) { | |||
this.instance = instance; | |||
}, | |||
obtain: function(obj, template) { | |||
obtain: function (obj, template) { | |||
var zoneName = template ? template.zoneName : obj.zoneName; | |||
var oQuests = obj.quests; | |||
if (oQuests.quests.filter(q => q.zoneName == zoneName).length > 0) | |||
return; | |||
return; | |||
var zoneTemplate = null; | |||
try { | |||
zoneTemplate = require('config/maps/' + zoneName + '/quests.js'); | |||
} | |||
catch (e) { | |||
} catch (e) { | |||
zoneTemplate = globalQuests; | |||
} | |||
@@ -39,7 +38,7 @@ define([ | |||
var pickQuest = null; | |||
if ((template) && (template.type)) | |||
pickQuest = config.infini.find(c => c.type == template.type); | |||
if (!pickQuest) | |||
pickQuest = config.infini[~~(Math.random() * config.infini.length)]; | |||
var pickType = pickQuest.type[0].toUpperCase() + pickQuest.type.substr(1); | |||
@@ -68,4 +67,4 @@ define([ | |||
this.obtain(obj, template); | |||
} | |||
}; | |||
}); | |||
}); |
@@ -7,7 +7,7 @@ define([ | |||
type: 'gatherResource', | |||
need: null, | |||
type: null, | |||
gatherType: null, | |||
requiredQuality: 0, | |||
have: 0, | |||
@@ -15,9 +15,9 @@ define([ | |||
if (!this.need) { | |||
this.need = 2 + ~~(Math.random() * 3); | |||
this.type = ['herb', 'fish'][~~(Math.random() * 2)]; | |||
this.gatherType = ['herb', 'fish'][~~(Math.random() * 2)]; | |||
if (this.type == 'fish') { | |||
if (this.gatherType == 'fish') { | |||
this.name = 'Lure of the Sea'; | |||
var isQualityQ = (Math.random() < 0.3); | |||
@@ -28,10 +28,10 @@ define([ | |||
} | |||
} | |||
if (['herb', 'fish'].indexOf(this.type) == -1) | |||
this.type = 'herb'; | |||
if (['herb', 'fish'].indexOf(this.gatherType) == -1) | |||
this.gatherType = 'herb'; | |||
this.typeName = (this.type == 'herb') ? 'herbs' : 'fish'; | |||
this.typeName = (this.gatherType == 'herb') ? 'herbs' : 'fish'; | |||
this.updateDescription(); | |||
@@ -46,14 +46,14 @@ define([ | |||
var action = ({ | |||
herb: 'Gather', | |||
fish: 'Catch' | |||
})[this.type]; | |||
})[this.gatherType]; | |||
this.description = `${action} ${this.have}/${this.need} ${typeName}`; | |||
}, | |||
events: { | |||
afterGatherResource: function (gatherResult) { | |||
if (gatherResult.nodeType != this.type) | |||
if (gatherResult.nodeType != this.gatherType) | |||
return; | |||
else if ((this.requiredQuality) && (gatherResult.items[0].quality != this.requiredQuality)) | |||
return; | |||
@@ -37,7 +37,8 @@ define([ | |||
'hands', | |||
'waist', | |||
'legs', | |||
'feet' | |||
'feet', | |||
'offHand' | |||
], | |||
[ | |||
'trinket', | |||