我目前正在使用 Node 来制作我的第一个机器人,但我对如何将其变为现实感到有些困惑。问题是,我应该为这类东西使用的最佳模式和模式名称是什么?
基本上,一个人可以听一个主题和说话者。
var test = person("ask_name","hallo person you are special");
console.log(test); // should return thanks!
var test = person("ask_name","hallo person you are dumb as the bird");
console.log(test); // should return i hate you!
function person(ability, body) {
console.log(ability,body);
var ability_name = "ability_" + ability;
console.log(ability_name,typeof ability_name); // ignore all of this, trying something
if (typeof ability_name) {};
// ability list array
var ability = [];
// Search for ability
// not done
var say_bad = function() {
this.listen_subject = 'ask_name';
this.listen_body = 'you are dumb';
return "i hate you!"
}
var say_good = function() {
this.listen_subject = 'ask_name';
this.listen_body = 'you are special';
return "thanks!"
}
}
对不起,没有完成代码,但这是我能走的最远的地方。