Sfoglia il codice sorgente

String compare issues

pull/1/head
BinHong Lee 7 anni fa
parent
commit
951191eadb
5 ha cambiato i file con 87 aggiunte e 39 eliminazioni
  1. +0
    -4
      speechAssets/CustomSlot.txt
  2. +25
    -8
      speechAssets/IntentSchema.json
  3. +10
    -0
      speechAssets/ROLE_TYPES.txt
  4. +18
    -12
      speechAssets/Utterances.txt
  5. +34
    -15
      src/index.js

+ 0
- 4
speechAssets/CustomSlot.txt Vedi File

@@ -1,4 +0,0 @@
melee
ranged
carry
support

+ 25
- 8
speechAssets/IntentSchema.json Vedi File

@@ -2,23 +2,40 @@
"intents": [
{
"intent": "RequestIntent",
"slot": [
"slots": [
{
"name": "Category",
"type": "CustomSlot"
"name": "Role",
"type": "ROLE_TYPES"
}
]
},
{
"intent": "RequestTwoIntent",
"slot": [
"slots": [
{
"name": "Category1",
"type": "CustomSlot"
"name": "RoleOne",
"type": "ROLE_TYPES"
},
{
"name": "Category2",
"type": "CustomSlot"
"name": "RoleTwo",
"type": "ROLE_TYPES"
}
]
},
{
"intent": "RequestThreeIntent",
"slots": [
{
"name": "RoleOne",
"type": "ROLE_TYPES"
},
{
"name": "RoleTwo",
"type": "ROLE_TYPES"
},
{
"name": "RoleThree",
"type": "ROLE_TYPES"
}
]
},


+ 10
- 0
speechAssets/ROLE_TYPES.txt Vedi File

@@ -0,0 +1,10 @@
melee
ranged
carry
support
strength
intelligence
agility
nuker
initiator
escape

+ 18
- 12
speechAssets/Utterances.txt Vedi File

@@ -1,15 +1,21 @@
RequestIntent random {Category}
RequestIntent random {Category} hero
RequestIntent random any {Category}
RequestIntent random any {Category} hero
RequestIntent random another {Category}
RequestIntent random another {Category} hero
RequestTwoIntent random {Category1} {Category2}
RequestIntent random {Category1} {Category2} hero
RequestIntent random any {Category1} {Category2}
RequestIntent random any {Category1} {Category2} hero
RequestIntent random another {Category1} {Category2}
RequestIntent random another {Category1} {Category2} hero
RequestIntent random {Role}
RequestIntent random {Role} hero
RequestIntent random any {Role}
RequestIntent random any {Role} hero
RequestIntent random another {Role}
RequestIntent random another {Role} hero
RequestTwoIntent random {RoleOne} {RoleTwo}
RequestTwoIntent random {RoleOne} {RoleTwo} hero
RequestTwoIntent random any {RoleOne} {RoleTwo}
RequestTwoIntent random any {RoleOne} {RoleTwo} hero
RequestTwoIntent random another {RoleOne} {RoleTwo}
RequestTwoIntent random another {RoleOne} {RoleTwo} hero
RequestThreeIntent random {RoleOne} {RoleTwo} {RoleThree}
RequestThreeIntent random {RoleOne} {RoleTwo} {RoleThree} hero
RequestThreeIntent random any {RoleOne} {RoleTwo} {RoleThree}
RequestThreeIntent random any {RoleOne} {RoleTwo} {RoleThree} hero
RequestThreeIntent random another {RoleOne} {RoleTwo} {RoleThree}
RequestThreeIntent random another {RoleOne} {RoleTwo} {RoleThree} hero
AnyRequest random any hero
AnyRequest random any other hero
Stop stop

+ 34
- 15
src/index.js Vedi File

@@ -13,7 +13,7 @@ var handlers = {

'RequestIntent': function () {
var given = []
var category = this.event.request.intent.slots.Category
var category = this.event.request.intent.slots.Role
given.push(category)

randomHero(given, (name) => {
@@ -23,8 +23,8 @@ var handlers = {

'RequestTwoIntent': function () {
var given = []
var category1 = this.event.request.intent.slots.Category1
var category2 = this.event.request.intent.slots.Category2
var category1 = this.event.request.intent.slots.RoleOne
var category2 = this.event.request.intent.slots.RoleTwo
given.push(category1)
given.push(category2)

@@ -33,6 +33,20 @@ 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
given.push(category1)
given.push(category2)
given.push(category3)

randomHero(given, (name) => {
this.emit(':tell', name)
})
},

'AnyRequest': function () {
var given = []
randomHero(given, (name) => {
@@ -56,6 +70,19 @@ function randomHero (categories, callback) {
var location

httpsGet((heroes) => {
var possible = false

for (var i = 0; i < heroes.length; i++) {
if (checkCategory(categories, heroes[i])) {
possible = true
}
}

if (!possible) {
callback('Random failed')
return
}

do {
location = random(heroes.length)
} while (!checkCategory(categories, heroes[location]))
@@ -92,24 +119,16 @@ function random (size) {
}

function checkCategory (categories, hero) {
var i = 0

var hits = false

while (i < categories.length) {
if (categories[i] === hero.primary_attr || categories[i] === hero.attack_type) {
hits = true
} else {
for (var j = 0; j < hero.roles.length; j++) {
if (categories[i] === hero.roles[j]) {
hits = true
break
}
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 (hits) {
i++
hits = false
} else {
return false


Caricamento…
Annulla
Salva