|
|
@@ -13,7 +13,7 @@ var handlers = { |
|
|
|
|
|
|
|
'RequestIntent': function () { |
|
|
|
var given = [] |
|
|
|
var category = this.event.request.intent.slots.Role |
|
|
|
var category = this.event.request.intent.slots.Role.value.toString() |
|
|
|
given.push(category) |
|
|
|
|
|
|
|
randomHero(given, (name) => { |
|
|
@@ -23,8 +23,8 @@ var handlers = { |
|
|
|
|
|
|
|
'RequestTwoIntent': function () { |
|
|
|
var given = [] |
|
|
|
var category1 = this.event.request.intent.slots.RoleOne |
|
|
|
var category2 = this.event.request.intent.slots.RoleTwo |
|
|
|
var category1 = this.event.request.intent.slots.RoleOne.value.toString() |
|
|
|
var category2 = this.event.request.intent.slots.RoleTwo.value.toString() |
|
|
|
given.push(category1) |
|
|
|
given.push(category2) |
|
|
|
|
|
|
@@ -35,9 +35,9 @@ var handlers = { |
|
|
|
|
|
|
|
'RequestThreeIntent': function () { |
|
|
|
var given = [] |
|
|
|
var category1 = this.event.request.intent.slots.RoleOne |
|
|
|
var category2 = this.event.request.intent.slots.RoleTwo |
|
|
|
var category3 = this.event.request.intent.slots.RoleThree |
|
|
|
var category1 = this.event.request.intent.slots.RoleOne.value.toString() |
|
|
|
var category2 = this.event.request.intent.slots.RoleTwo.value.toString() |
|
|
|
var category3 = this.event.request.intent.slots.RoleThree.value.toString() |
|
|
|
given.push(category1) |
|
|
|
given.push(category2) |
|
|
|
given.push(category3) |
|
|
@@ -56,7 +56,7 @@ var handlers = { |
|
|
|
}, |
|
|
|
|
|
|
|
'AMAZON.HelpIntent': function () { |
|
|
|
this.emit(':ask', 'You can try saying random any hero, random melee carry or random ranged support for more specific randoming.') |
|
|
|
this.emit(':ask', 'You can try saying random any hero, random melee carry or random ranged support.') |
|
|
|
}, |
|
|
|
|
|
|
|
'Stop': function () { |
|
|
@@ -71,11 +71,13 @@ function randomHero (categories, callback) { |
|
|
|
|
|
|
|
httpsGet((heroes) => { |
|
|
|
var possible = false |
|
|
|
var i = 0 |
|
|
|
|
|
|
|
for (var i = 0; i < heroes.length; i++) { |
|
|
|
while (possible === false && i < heroes.length) { |
|
|
|
if (checkCategory(categories, heroes[i])) { |
|
|
|
possible = true |
|
|
|
} |
|
|
|
i++ |
|
|
|
} |
|
|
|
|
|
|
|
if (!possible) { |
|
|
@@ -122,9 +124,14 @@ function checkCategory (categories, hero) { |
|
|
|
var hits = false |
|
|
|
|
|
|
|
for (var i = 0; i < categories.length; i++) { |
|
|
|
for (var j = 0; j < hero.roles.length; j++) { |
|
|
|
if (categories[i].localeCompare(hero.roles[j]) === 0) { |
|
|
|
hits = true |
|
|
|
if (categories[i].toLowerCase().localeCompare(hero.attack_type.toLowerCase()) === 0 || categories[i].toLowerCase().substring(0, 3).localeCompare(hero.primary_attr) === 0) { |
|
|
|
hits = true |
|
|
|
} else { |
|
|
|
for (var j = 0; j < hero.roles.length; j++) { |
|
|
|
if (categories[i].toLowerCase().localeCompare(hero.roles[j].toLowerCase()) === 0) { |
|
|
|
hits = true |
|
|
|
break |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|