Crossfire Server, Trunk
entry.py
Go to the documentation of this file.
1 import Crossfire,datetime,CFDataBase
2 CFDB=CFDataBase.CFDataBase("PShop")
3 def GetObjectByWeightLimit(object, WeightLimit):
4  while object.WeightLimit!=WeightLimit:
5  object=object.Above
6  if not object:
7  return 0
8  return object
9 def GetObjectByName(object, Name):
10  while object.Name!=Name:
11  object=object.Above
12  if not object:
13  return 0
14  return object
15 
16 def find_player(object):
17  while (object.Type != 1) : #1 is type 'Player'
18  object = object.Above
19  if not object:
20  return 0
21  return object
22 def GetObjectAt(Map,X,Y,Name):
23  Object=Map.ObjectAt(X,Y)
24  while Object!=None:
25  if Object.Name==Name:
26  return Object
27  else:
28  Object=Object.Above
29  return Object
30 def Expire():
31  global Owner
32 
33  Inventory=mymap.ObjectAt(43,2)
34  MailMap=Crossfire.ReadyMap("/planes/IPO_storage")
35  while Inventory!=None:
36  if Inventory.Name!="Vault":
37  package=whoami.CreateObject("package")
38  package.Name="IPO-package F: Your-Private-Shop T: "+Owner
39  Inventory.InsertInto(package)
40  package.Teleport(MailMap,2,2)
41 
42  Inventory=Inventory.Above
43  Inventory=mymap.ObjectAt(43,2)
44  while Inventory!=None:
45  if Inventory.Name!="Vault":
46  package=whoami.CreateObject("package")
47  package.Name="IPO-package F: Your-Private-Shop T: "+Owner
48  Inventory.InsertInto(package)
49  package.Teleport(MailMap,2,2)
50 
51  Inventory=Inventory.Below
52 
53  Dict=CFDB.get("pshop")
54 
55  for i in Dict:
56  whoami.Say(i)
57  This=Dict.get(i)
58  whoami.Say(str(This))
59  if This[1]!="PickedUp":
60  That=mymap.ObjectAt(This[1][0],This[1][1])
61  whoami.Say(str(That))
62  if That!=None:
63  That=GetObjectByWeightLimit(That,int(i))
64  whoami.Say(str(That))
65  if That!=0:
66  That.Teleport(whoami.Map,37,0)
67 
68  CFDB.store('pshop',{})
69  Owner="Unowned"
70  Chest=mymap.ObjectAt(30,8)
71  Chest=GetObjectByName(Chest, "Rent Box")
72  if Chest!=0:
73  Chest.Teleport(mymap, 15,10)
74  for i in range(0,34):
75  for a in range(0,35):
76  b=GetObjectAt(whoami.Map,i,a,'NoBuild')
77  b.Remove
78  b=GetObjectAt(whoami.Map,i,a,'NoSpell')
79  b.Remove()
80 
81  GetObjectAt(whoami.Map,30,5,"Brazier material").Remove()
82  GetObjectAt(whoami.Map,30,6,"Firepot material").Remove()
83  GetObjectAt(whoami.Map,30,7,"Bright Firepot Material").Remove()
84  GetObjectAt(whoami.Map,29,8,"Red CWall material").Remove()
85  whoami.Map.ObjectAt(49,5).Teleport(whoami.Map,30,5)
86  whoami.Map.ObjectAt(49,4).Teleport(whoami.Map,30,6)
87  whoami.Map.ObjectAt(49,6).Teleport(whoami.Map,30,7)
88  whoami.Map.ObjectAt(49,7).Teleport(whoami.Map,29,8)
89 whoami=Crossfire.WhoAmI()
90 
91 
92 
93 activator=Crossfire.WhoIsActivator()
94 activatorname=activator.Name
95 mymap=activator.Map
96 
97 Variables=GetObjectByName(mymap.ObjectAt(49,0),"Variables")
98 
99 
100 VariableList= Variables.Message.split('\n')
101 Owner=VariableList[0]
102 Date=VariableList[1]
103 Days=VariableList[2]
104 
105 Owner=Owner.split(": ")[1]
106 Date=Date.split(": ")[1]
107 
108 Days=int(Days.split(": ")[1])
109 
110 Year, Month, Day=Date.split("-")
111 LastDate=datetime.datetime(int(Year),int(Month),int(Day))
112 Today=datetime.date(1,2,3).today()
113 Today=datetime.datetime(Today.year, Today.month, Today.day)
114 DaysPast=(Today-LastDate).days
115 Days-=DaysPast
116 
117 if Days<=0:
118  global Owner
119 
120 
121  Expire()
122 
123 Variables.Message="Owner: "+Owner+"\nDate: "+str(Today.year)+"-"+str(Today.month)+"-"+str(Today.day)+"\nDays: "+str(Days)
124 
125 
126 if activatorname==Owner:
127  message=Crossfire.WhatIsMessage()
128  if (message.upper().find("ENTER")>-1) or (message.upper().find("YES")>-1):
129  X=activator.X
130  Y=activator.Y
131  activator.Teleport(mymap, 37,3)
132  activator.Teleport(mymap, X, Y)
133  whoami.Say("Greetings sire, you have "+str(Days)+" days left.")
134  else:
135  whoami.Say("Greetings sire, would you like entry?")
136 else:
137 
138  if Owner!="Unowned":
139  whoami.Say("You are not alowed beyond this point. The rent will by up in "+str(Days)+" and you may rent it yourself then. If the current owner doesn't pay, that is.")
140  else:
141  whoami.Say("You are currently not alowed beyond this point. The rent is past due. If you wish to proceed, place a platinum coin in the deposit box.")
entry.Expire
def Expire()
Definition: entry.py:30
make_face_from_files.str
str
Definition: make_face_from_files.py:24
entry.GetObjectAt
def GetObjectAt(Map, X, Y, Name)
Definition: entry.py:22
entry.GetObjectByName
def GetObjectByName(object, Name)
Definition: entry.py:9
make_face_from_files.int
int
Definition: make_face_from_files.py:26
CFDataBase.CFDataBase
Definition: CFDataBase.py:29
entry.GetObjectByWeightLimit
def GetObjectByWeightLimit(object, WeightLimit)
Definition: entry.py:3
entry.find_player
def find_player(object)
Definition: entry.py:16