I am working on developing a game that utilizes an AI. This AI's API consists of 3 methods implemented in an Angular Service
Here is a simplified version of the code:
app.service('AI', [function(){
return {
offer: angular.noop,
accept: angular.noop,
reject: angular.noop
}
}])
The challenge lies in the fact that the implementation of these methods (and subsequently, how the AI responds) can vary based on multiple factors such as nationality, age, etc.
I have been considering using Angular Decorators, but I would need to choose from several decorators. One approach could be to create individual files for each implementation:
- less-than-10.decorator.js
- less-than-20.decorator.js
- and so on...
But then I face the question:
"If I have an 18-year-old player... should I load less-than-20.decorator.js and apply the decorator?"
OR
"I have an 18-year-old player... should I use this decorator instead of that one?"
In summary: I wish to implement a conditional loading of decorators.
After some research, I came across a method where instead of returning $delegate, I could return the original service, but I feel like it may not be the most elegant solution...
Do you have any suggestions for a better approach?