File: actions.py

package info (click to toggle)
0ad 0.0.26-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 130,460 kB
  • sloc: cpp: 261,824; ansic: 198,392; javascript: 19,067; python: 14,557; sh: 7,629; perl: 4,072; xml: 849; makefile: 741; java: 533; ruby: 229; php: 190; pascal: 30; sql: 21; tcl: 4
file content (63 lines) | stat: -rw-r--r-- 1,519 bytes parent folder | download
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
def construct(units, template, x, z, angle=0, autorepair=True, autocontinue=True, queued=False):
    unit_ids = [ unit.id() for unit in units ]
    return {
        'type': 'construct',
        'entities': unit_ids,
        'template': template,
        'x': x,
        'z': z,
        'angle': angle,
        'autorepair': autorepair,
        'autocontinue': autocontinue,
        'queued': queued,
    }

def gather(units, target, queued=False):
    unit_ids = [ unit.id() for unit in units ]
    return {
        'type': 'gather',
        'entities': unit_ids,
        'target': target.id(),
        'queued': queued,
    }

def train(entities, unit_type, count=1):
    entity_ids = [ unit.id() for unit in entities ]
    return {
        'type': 'train',
        'entities': entity_ids,
        'template': unit_type,
        'count': count,
    }

def chat(message):
    return {
        'type': 'aichat',
        'message': message
    }

def reveal_map():
    return {
        'type': 'reveal-map',
        'enable': True
    }

def walk(units, x, z, queued=False):
    ids = [ unit.id() for unit in units ]
    return {
        'type': 'walk',
        'entities': ids,
        'x': x,
        'z': z,
        'queued': queued
    }

def attack(units, target, queued=False, allow_capture=True):
    unit_ids = [ unit.id() for unit in units ]
    return {
        'type': 'attack',
        'entities': unit_ids,
        'target': target.id(),
        'allowCapture': allow_capture,
        'queued': queued
    }