File: events.py

package info (click to toggle)
snowballz 0.9.5.1-2
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 10,888 kB
  • ctags: 1,242
  • sloc: python: 7,511; makefile: 53; sh: 2
file content (29 lines) | stat: -rw-r--r-- 663 bytes parent folder | download | duplicates (4)
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
PENGUIN_MOVE = 1
PENGUIN_RELOAD = 2
PENGUIN_HIT = 3
PENGUIN_DIRECT_HIT = 4
PENGUIN_FROZEN = 5
PENGUIN_GATHERED = 6
PENGUIN_UNLOADED = 7

# When this event is fired, the first param is the region in question and the
# second param is the player that it used to belong to.
REGION_TAKEOVER = 8

connects = {}

def connect(event, callback):
    if not connects.has_key(event):
        connects[event] = []
    connects[event].append(callback)

def disconnect(event, callback):
    connects[event].remove(callback)

def fire(event, *params):
    if not connects.has_key(event):
        connects[event] = []

    cs = connects[event]
    for c in cs:
        c(*params)