1 |
root |
1.1 |
import Crossfire |
2 |
|
|
import random |
3 |
|
|
#import CFLog |
4 |
|
|
|
5 |
|
|
Crossfire.SetReturnValue( 1 ) |
6 |
|
|
|
7 |
|
|
whoami=Crossfire.WhoAmI() |
8 |
|
|
|
9 |
|
|
def do_help(): |
10 |
|
|
whoami.Say('Usage: say <test name>\nAvailable tests:') |
11 |
|
|
whoami.Say(' - arch: archetypes-related tests') |
12 |
|
|
whoami.Say(' - maps: maps-related tests') |
13 |
|
|
whoami.Say(' - party: party-related tests') |
14 |
|
|
whoami.Say(' - region: party-related tests') |
15 |
|
|
whoami.Say(' - ref: some checks on objects references') |
16 |
|
|
whoami.Say(' - mark: marked item') |
17 |
|
|
whoami.Say(' - memory: storage-related tests') |
18 |
|
|
|
19 |
|
|
def do_arch(): |
20 |
|
|
archs = Crossfire.GetArchetypes() |
21 |
|
|
whoami.Say('%d archetypes'%len(archs)) |
22 |
|
|
which = random.randint(0,len(archs)) |
23 |
|
|
arch = archs[which] |
24 |
|
|
whoami.Say('random = %s'%arch.Name) |
25 |
|
|
|
26 |
elmex |
1.1.1.2 |
arch = Crossfire.WhoIsActivator().Archetype |
27 |
root |
1.1 |
whoami.Say('your archetype is %s'%arch.Name) |
28 |
|
|
|
29 |
|
|
def do_maps(): |
30 |
|
|
maps = Crossfire.GetMaps() |
31 |
|
|
whoami.Say('%d maps loaded'%len(maps)) |
32 |
|
|
for map in maps: |
33 |
|
|
whoami.Say('%s -> %d players'%(map.Name,map.Players)) |
34 |
|
|
#activator=Crossfire.WhoIsActivator() |
35 |
|
|
|
36 |
|
|
def do_party(): |
37 |
|
|
parties = Crossfire.GetParties() |
38 |
|
|
whoami.Say('%d parties'%len(parties)) |
39 |
|
|
for party in parties: |
40 |
|
|
whoami.Say('%s'%(party.Name)) |
41 |
|
|
players = party.GetPlayers() |
42 |
|
|
for player in players: |
43 |
|
|
whoami.Say(' %s'%player.Name) |
44 |
|
|
if len(parties) >= 2: |
45 |
|
|
Crossfire.WhoIsActivator().Party = parties[1] |
46 |
|
|
whoami.Say('changed your party!') |
47 |
|
|
|
48 |
|
|
def do_region(): |
49 |
|
|
whoami.Say('Known regions, region for current map is signaled by ***') |
50 |
|
|
cur = whoami.Map.Region |
51 |
|
|
whoami.Say('This map\'s region is %s'%(cur.Name)) |
52 |
|
|
regions = Crossfire.GetRegions() |
53 |
|
|
whoami.Say('%d regions'%len(regions)) |
54 |
|
|
for region in regions: |
55 |
|
|
if cur == region: |
56 |
|
|
whoami.Say('*** %s - %s'%(region.Name,region.Longname)) |
57 |
|
|
else: |
58 |
|
|
whoami.Say('%s - %s'%(region.Name,region.Longname)) |
59 |
|
|
parent = cur.GetParent() |
60 |
|
|
if parent: |
61 |
|
|
whoami.Say('Parent is %s'%parent.Name) |
62 |
|
|
else: |
63 |
|
|
whoami.Say('Region without parent') |
64 |
|
|
|
65 |
|
|
def do_activator(): |
66 |
|
|
who = Crossfire.WhoIsActivator() |
67 |
|
|
who2 = Crossfire.WhoIsOther() |
68 |
|
|
who3 = Crossfire.WhoAmI() |
69 |
|
|
who = 0 |
70 |
|
|
who2 = 0 |
71 |
|
|
who3 = 0 |
72 |
|
|
whoami.Say('let\'s hope no reference crash!') |
73 |
|
|
|
74 |
|
|
def do_marker(): |
75 |
|
|
who = Crossfire.WhoIsActivator() |
76 |
|
|
obj = who.MarkedItem |
77 |
|
|
if obj: |
78 |
|
|
whoami.Say(' your marked item is: %s'%obj.Name) |
79 |
|
|
mark = obj.Below |
80 |
|
|
else: |
81 |
|
|
whoami.Say(' no marked item') |
82 |
|
|
mark = who.Inventory |
83 |
|
|
while (mark) and (mark.Invisible): |
84 |
|
|
mark = mark.Below |
85 |
|
|
who.MarkedItem = mark |
86 |
|
|
whoami.Say('Changed marked item!') |
87 |
|
|
|
88 |
|
|
def do_memory(): |
89 |
|
|
whoami.Say('Value save test') |
90 |
|
|
dict = Crossfire.GetPrivateDictionary() |
91 |
|
|
if dict.has_key('s'): |
92 |
|
|
x = dict['s'] |
93 |
|
|
whoami.Say(' x was %d'%x) |
94 |
|
|
x = x + 1 |
95 |
|
|
else: |
96 |
|
|
x = 0 |
97 |
|
|
whoami.Say(' new x') |
98 |
|
|
|
99 |
|
|
dict['s'] = x |
100 |
|
|
|
101 |
elmex |
1.1.1.2 |
|
102 |
|
|
def do_resist(): |
103 |
|
|
whoami.Say('Resistance test') |
104 |
|
|
who = Crossfire.WhoIsActivator() |
105 |
|
|
for r in range(25): |
106 |
|
|
whoami.Say(' %d -> %d'%(r,who.GetResist(r))) |
107 |
|
|
|
108 |
|
|
def do_basics(): |
109 |
|
|
whoami.Say('Basic test') |
110 |
|
|
who = Crossfire.WhoIsActivator() |
111 |
|
|
whoami.Say('type = %d'%who.Type) |
112 |
|
|
|
113 |
root |
1.1 |
whoami.Say( 'plugin test' ) |
114 |
|
|
|
115 |
|
|
topic = Crossfire.WhatIsMessage().split() |
116 |
|
|
#whoami.Say('topic = %s'%topic) |
117 |
|
|
#whoami.Say('topic[0] = %s'%topic[0]) |
118 |
|
|
if topic[0] == 'arch': |
119 |
|
|
do_arch() |
120 |
|
|
elif topic[0] == 'maps': |
121 |
|
|
do_maps() |
122 |
|
|
elif topic[0] == 'party': |
123 |
|
|
do_party() |
124 |
|
|
elif topic[0] == 'region': |
125 |
|
|
do_region() |
126 |
|
|
elif topic[0] == 'mark': |
127 |
|
|
do_marker() |
128 |
|
|
elif topic[0] == 'ref': |
129 |
|
|
do_activator() |
130 |
|
|
elif topic[0] == 'memory': |
131 |
|
|
do_memory() |
132 |
elmex |
1.1.1.2 |
elif topic[0] == 'resist': |
133 |
|
|
do_resist() |
134 |
|
|
elif topic[0] == 'basics': |
135 |
|
|
do_basics() |
136 |
root |
1.1 |
else: |
137 |
|
|
do_help() |