Python test map/script

git-svn-id: svn://svn.code.sf.net/p/crossfire/code/trunk/maps@4303 282e977c-c81d-0410-88c4-b93c2d0d6712
master
ryo_saeba 2006-01-07 17:25:13 +00:00
parent 5ea3def4c1
commit 395831dbc8
3 changed files with 247 additions and 16 deletions

108
test/python 100644
View File

@ -0,0 +1,108 @@
arch map
region scorn
name python
msg
Creator: CF Java Map Editor
Date: 7/15/2005
endmsg
width 5
height 5
end
arch cobblestones2
end
arch cobblestones2
y 1
end
arch cobblestones2
y 2
end
arch cobblestones2
y 3
end
arch cobblestones2
y 4
end
arch cobblestones2
x 1
end
arch cobblestones2
x 1
y 1
end
arch cobblestones2
x 1
y 2
end
arch cobblestones2
x 1
y 3
end
arch cobblestones2
x 1
y 4
end
arch cobblestones2
x 2
end
arch cobblestones2
x 2
y 1
end
arch cobblestones2
x 2
y 2
end
arch sage
x 2
y 2
arch event_say
slaying /test/python.py
title Python
end
end
arch cobblestones2
x 2
y 3
end
arch cobblestones2
x 2
y 4
end
arch cobblestones2
x 3
end
arch cobblestones2
x 3
y 1
end
arch cobblestones2
x 3
y 2
end
arch cobblestones2
x 3
y 3
end
arch cobblestones2
x 3
y 4
end
arch cobblestones2
x 4
end
arch cobblestones2
x 4
y 1
end
arch cobblestones2
x 4
y 2
end
arch cobblestones2
x 4
y 3
end
arch cobblestones2
x 4
y 4
end

121
test/python.py 100644
View File

@ -0,0 +1,121 @@
import Crossfire
import random
#import CFLog
Crossfire.SetReturnValue( 1 )
whoami=Crossfire.WhoAmI()
def do_help():
whoami.Say('Usage: say <test name>\nAvailable tests:')
whoami.Say(' - arch: archetypes-related tests')
whoami.Say(' - maps: maps-related tests')
whoami.Say(' - party: party-related tests')
whoami.Say(' - region: party-related tests')
whoami.Say(' - ref: some checks on objects references')
whoami.Say(' - mark: marked item')
whoami.Say(' - memory: storage-related tests')
def do_arch():
archs = Crossfire.GetArchetypes()
whoami.Say('%d archetypes'%len(archs))
which = random.randint(0,len(archs))
arch = archs[which]
whoami.Say('random = %s'%arch.Name)
arch = Crossfire.WhoIsActivator().Archetype()
whoami.Say('your archetype is %s'%arch.Name)
def do_maps():
maps = Crossfire.GetMaps()
whoami.Say('%d maps loaded'%len(maps))
for map in maps:
whoami.Say('%s -> %d players'%(map.Name,map.Players))
#activator=Crossfire.WhoIsActivator()
def do_party():
parties = Crossfire.GetParties()
whoami.Say('%d parties'%len(parties))
for party in parties:
whoami.Say('%s'%(party.Name))
players = party.GetPlayers()
for player in players:
whoami.Say(' %s'%player.Name)
if len(parties) >= 2:
Crossfire.WhoIsActivator().Party = parties[1]
whoami.Say('changed your party!')
def do_region():
whoami.Say('Known regions, region for current map is signaled by ***')
cur = whoami.Map.Region
whoami.Say('This map\'s region is %s'%(cur.Name))
regions = Crossfire.GetRegions()
whoami.Say('%d regions'%len(regions))
for region in regions:
if cur == region:
whoami.Say('*** %s - %s'%(region.Name,region.Longname))
else:
whoami.Say('%s - %s'%(region.Name,region.Longname))
parent = cur.GetParent()
if parent:
whoami.Say('Parent is %s'%parent.Name)
else:
whoami.Say('Region without parent')
def do_activator():
who = Crossfire.WhoIsActivator()
who2 = Crossfire.WhoIsOther()
who3 = Crossfire.WhoAmI()
who = 0
who2 = 0
who3 = 0
whoami.Say('let\'s hope no reference crash!')
def do_marker():
who = Crossfire.WhoIsActivator()
obj = who.MarkedItem
if obj:
whoami.Say(' your marked item is: %s'%obj.Name)
mark = obj.Below
else:
whoami.Say(' no marked item')
mark = who.Inventory
while (mark) and (mark.Invisible):
mark = mark.Below
who.MarkedItem = mark
whoami.Say('Changed marked item!')
def do_memory():
whoami.Say('Value save test')
dict = Crossfire.GetPrivateDictionary()
if dict.has_key('s'):
x = dict['s']
whoami.Say(' x was %d'%x)
x = x + 1
else:
x = 0
whoami.Say(' new x')
dict['s'] = x
whoami.Say( 'plugin test' )
topic = Crossfire.WhatIsMessage().split()
#whoami.Say('topic = %s'%topic)
#whoami.Say('topic[0] = %s'%topic[0])
if topic[0] == 'arch':
do_arch()
elif topic[0] == 'maps':
do_maps()
elif topic[0] == 'party':
do_party()
elif topic[0] == 'region':
do_region()
elif topic[0] == 'mark':
do_marker()
elif topic[0] == 'ref':
do_activator()
elif topic[0] == 'memory':
do_memory()
else:
do_help()

View File

@ -11,6 +11,24 @@ enter_y 2
end
arch cobblestones2
end
arch guildmaster
name dwarf
face dwarf_p.111
hp 100
maxhp 100
pick_up 0
randomitems standard
arch quest_override
msg
@match 1
First sentence
@match 2
Second sentence
endmsg
name_pl dummy
hp 7
end
end
arch cobblestones2
y 1
end
@ -106,14 +124,6 @@ endlore
name_pl dummy
end
end
arch quest_override
msg
@match quest
You completed the quest already.
endmsg
hp 8
name_pl dummy
end
end
arch cobblestones2
x 2
@ -190,14 +200,6 @@ arch cobblestones2
x 5
y 1
end
arch marker
msg
Random event.
endmsg
slaying quest Test random
x 5
y 1
end
arch cobblestones
x 5
y 1