| 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 |
|
|
arch = Crossfire.WhoIsActivator().Archetype() |
| 27 |
|
|
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 |
|
|
whoami.Say( 'plugin test' ) |
| 102 |
|
|
|
| 103 |
|
|
topic = Crossfire.WhatIsMessage().split() |
| 104 |
|
|
#whoami.Say('topic = %s'%topic) |
| 105 |
|
|
#whoami.Say('topic[0] = %s'%topic[0]) |
| 106 |
|
|
if topic[0] == 'arch': |
| 107 |
|
|
do_arch() |
| 108 |
|
|
elif topic[0] == 'maps': |
| 109 |
|
|
do_maps() |
| 110 |
|
|
elif topic[0] == 'party': |
| 111 |
|
|
do_party() |
| 112 |
|
|
elif topic[0] == 'region': |
| 113 |
|
|
do_region() |
| 114 |
|
|
elif topic[0] == 'mark': |
| 115 |
|
|
do_marker() |
| 116 |
|
|
elif topic[0] == 'ref': |
| 117 |
|
|
do_activator() |
| 118 |
|
|
elif topic[0] == 'memory': |
| 119 |
|
|
do_memory() |
| 120 |
|
|
else: |
| 121 |
|
|
do_help() |