Reddo il y a 5 ans
Parent
commit
be79b814b2
2 fichiers modifiés avec 6 ajouts et 5 suppressions
  1. 5 4
      app/World/Classes/AI.ts
  2. 1 1
      app/World/Classes/Things/Person.ts

+ 5 - 4
app/World/Classes/AI.ts

@@ -4,12 +4,14 @@
 /// <reference path="../../Functions.ts" />
 
 interface AIOptions {
+    actor : Thing,
     wanderer? : boolean,
     wandersOn? : Region,
     picksShinies? : boolean
 }
 
 class AI {
+    public actor : Thing;
     public wanderer = true;
     public wandersOn : Region;
     public wanderChance = 50;
@@ -25,16 +27,15 @@ class AI {
      * Executing an AI returns an Action. DOESN'T execute the action, just finds it!
      * @returns {Promise<Action>}
      */
-    public async execute (actor : Thing) : Promise<Action> {
+    public async execute () : Promise<Action> {
         let promise : Promise<Action>;
-        // TODO: if actor.isInCombat();
         if (promise != undefined) {
             promise = AI.combatRules.execute({
-                noun : actor
+                noun : this.actor
             }, ...this.extraCombatRules);
         } else {
             promise = AI.rules.execute({
-                noun : actor
+                noun : this.actor
             }, ...this.extraRules);
         }
 

+ 1 - 1
app/World/Classes/Things/Person.ts

@@ -11,7 +11,7 @@
  * Fuck your standards.
  */
 class Person extends Thing implements AttributeBearer, SkillBearer {
-    public AI = new AI({});
+    public AI = new AI({actor: this});
     public animated = true;
 
     public soreness = 0;