Debian Codegraph @

python/commands/dip.py

raw
1 import Crossfire
2
3 def find_fountain(pl):
4 below = pl.Below
5 while below is not None:
6 if below.ArchName == "fountain":
7 return below
8 below = below.Below
9 return None
10
11 def dip(pl):
12 f = find_fountain(pl)
13 if f is None:
14 pl.Message("You must be at a fountain to dip an object into one.")
15 return False
16
17 ob = pl.MarkedItem
18 if ob is None:
19 pl.Message("Mark the item that you would like to dip.")
20 return False
21
22 name_before = ob.Name
23 def something(s):
24 pl.Message("You dip the %s into the %s. %s" % (name_before, f.Name, s))
25
26 def nothing():
27 something("Nothing happens.")
28
29 if ob.ArchName == "wbottle_empty":
30 ob.Quantity -= 1
31 w = Crossfire.CreateObjectByName("water")
32 w.Identified = 1
33 w.InsertInto(pl)
34 pl.Message("You fill the %s with water from the %s." % (name_before, f.Name))
35 elif ob.ArchName == "scroll_new":
36 ob.Quantity -= 1
37 w = Crossfire.CreateObjectByName("scroll")
38 w.Identified = 0
39 w.InsertInto(pl)
40 something("The magic runes fade away.")
41 elif ob.Type == Crossfire.Type.BOOK:
42 if ob.Message != None and len(ob.Message) != 0:
43 ob.Message = ""
44 something("The writing fades away.")
45 else:
46 something("It gets wet.")
47 else:
48 nothing()
49
50 dip(Crossfire.WhoAmI())