From 5b90804e69de92b1e673a57209bcc0da594d1467 Mon Sep 17 00:00:00 2001 From: ryo_saeba Date: Sun, 18 Mar 2007 00:08:45 +0000 Subject: [PATCH] More Python tests. git-svn-id: svn://svn.code.sf.net/p/crossfire/code/maps/trunk@5819 282e977c-c81d-0410-88c4-b93c2d0d6712 --- test/python | 16 ++++++++++++++++ test/python.py | 31 +++++++++++++++++++++++++++++++ test/python_exit.py | 8 ++++++++ 3 files changed, 55 insertions(+) create mode 100644 test/python_exit.py diff --git a/test/python b/test/python index 0f3cae3d6..9fe329520 100644 --- a/test/python +++ b/test/python @@ -41,6 +41,14 @@ arch cobblestones2 x 1 y 4 end +arch exit +x 1 +y 4 +arch event_apply +title Python +slaying /test/python_exit.py +end +end arch cobblestones2 x 2 end @@ -72,6 +80,14 @@ arch cobblestones2 x 2 y 4 end +arch oakdoor +x 2 +y 4 +arch event_apply +title Python +slaying /test/python_exit.py +end +end arch cobblestones2 x 3 end diff --git a/test/python.py b/test/python.py index 605229b0d..88ab28628 100644 --- a/test/python.py +++ b/test/python.py @@ -27,6 +27,9 @@ def do_help(): whoami.Say(' - readkey') whoami.Say(' - writekey') whoami.Say(' - speed') + whoami.Say(' - owner') + whoami.Say(' - friendlylist') + whoami.Say(' - create') def do_arch(): archs = Crossfire.GetArchetypes() @@ -233,6 +236,28 @@ def do_speed(): who.SpeedLeft = -50 whoami.Say('Changed your speed, now %f and %f'%(who.Speed, who.SpeedLeft)) +def do_owner(): + whoami.Say('Not implemented.'); + +def do_friendlylist(): + friends = Crossfire.GetFriendlyList() + for ob in friends: + if (ob.Owner): + n = ob.Owner.Name + else: + n = '' + whoami.Say(' - %s (%s)'%(ob.Name, n)) + +def do_create(): + first = Crossfire.CreateObjectByName('gem') + if (first): + whoami.Say('created gem: %s'%first.Name) + first.Teleport(whoami.Map, 2, 2) + second = Crossfire.CreateObjectByName('diamond') + if (second): + whoami.Say('created diamond: %s'%second.Name) + second.Teleport(whoami.Map, 2, 2) + topic = Crossfire.WhatIsMessage().split() #whoami.Say('topic = %s'%topic) #whoami.Say('topic[0] = %s'%topic[0]) @@ -278,5 +303,11 @@ elif topic[0] == 'writekey': do_writekey() elif topic[0] == 'speed': do_speed() +elif topic[0] == 'owner': + do_owner() +elif topic[0] == 'friendlylist': + do_friendlylist() +elif topic[0] == 'create': + do_create() else: do_help() diff --git a/test/python_exit.py b/test/python_exit.py new file mode 100644 index 000000000..b449fff95 --- /dev/null +++ b/test/python_exit.py @@ -0,0 +1,8 @@ +import Crossfire + +#Crossfire.SetReturnValue( 1 ) + +whoami = Crossfire.WhoAmI() +who = Crossfire.WhoIsActivator() + +whoami.Say("exit applied by %s"%who.Name)