From 43041fec06f5c6cd7d6c58da7fd5f2094df38779 Mon Sep 17 00:00:00 2001 From: ryo_saeba Date: Thu, 9 Jun 2011 18:57:10 +0000 Subject: [PATCH] Add 'disinfect' command for DMs, removing diseases on the current map. git-svn-id: svn://svn.code.sf.net/p/crossfire/code/maps/trunk@14525 282e977c-c81d-0410-88c4-b93c2d0d6712 --- python/commands/disinfect.py | 22 ++++++++++++++++++++++ python/events/init/disinfect_command.py | 2 ++ 2 files changed, 24 insertions(+) create mode 100644 python/commands/disinfect.py create mode 100644 python/events/init/disinfect_command.py diff --git a/python/commands/disinfect.py b/python/commands/disinfect.py new file mode 100644 index 000000000..628188f43 --- /dev/null +++ b/python/commands/disinfect.py @@ -0,0 +1,22 @@ +import Crossfire + +whoami = Crossfire.WhoAmI() +map = whoami.Map + +if map != None and whoami.DungeonMaster: + count = 0 + map.Print('%s disinfecting %s'%(whoami.Name, map.Path)) + for x in range(0, map.Width): + for y in range(0, map.Height): + o = map.ObjectAt(x, y) + while o != None: + a = o.Above + if o.Type == Crossfire.Type.DISEASE: + whoami.Message(' removing %s at %d,%d'%(o.Name, x, y)) + count = count + 1 + o.Remove() + o = a + if count == 0: + map.Print(' => nothing removed') + else: + map.Print(' => %d diseases removed'%count) \ No newline at end of file diff --git a/python/events/init/disinfect_command.py b/python/events/init/disinfect_command.py new file mode 100644 index 000000000..e38ad4634 --- /dev/null +++ b/python/events/init/disinfect_command.py @@ -0,0 +1,2 @@ +import Crossfire +Crossfire.RegisterCommand("disinfect", "/python/commands/disinfect", 0)