File: fire.py

package info (click to toggle)
cyphesis-cpp 0.5.16-1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 5,084 kB
  • ctags: 3,627
  • sloc: cpp: 30,418; python: 4,812; xml: 4,674; sh: 4,118; makefile: 902; ansic: 617
file content (29 lines) | stat: -rw-r--r-- 1,211 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#This file is distributed under the terms of the GNU General Public license.
#Copyright (C) 1999 Aloril (See the file COPYING for details).

from mind.goals.common.common import *
from mind.goals.common.move import move_me
from mind.goals.dynamic.add_unique_goal import add_unique_goal_by_perception

class extinguish_fire(Goal):
    def __init__(self, what):
        Goal.__init__(self,"extinguish fire",
                      self.fire_extinguished,
                      [move_me(what.location),self.extinguish])
        self.what=what
        self.vars=["what"]
    def fire_extinguished(self, me):
        fire=me.map.get(self.what.id)
        if not fire:
            self.irrelevant=1 #remove this goal
            return 1
        return 0
    def extinguish(self, me):
        return Operation("extinguish",Entity(self.what.id),to=self.what)

class add_extinguish_fire(add_unique_goal_by_perception):
    def __init__(self, desc="add extinguish fire goal"):
        add_unique_goal_by_perception.__init__(self,
                                               extinguish_fire,
                                               trigger="sight_burn",
                                               desc=desc)