added dir to /python for handling the private shops

git-svn-id: svn://svn.code.sf.net/p/crossfire/code/maps/trunk@12871 282e977c-c81d-0410-88c4-b93c2d0d6712
master
alestan 2010-04-07 22:18:35 +00:00
parent 05cb47d794
commit de8ebe64df
6 changed files with 1280 additions and 0 deletions

View File

@ -0,0 +1,69 @@
import Crossfire,sys
sys.stderr=open('/tmp/output.log','w')
Params=Crossfire.ScriptParameters()
whoami=Crossfire.WhoAmI()
Arch=None
if whoami.Name=="Magic Lever":
Arch=whoami.Map.ObjectAt(49,2)
elif whoami.Name=="Buildable Lever":
Arch=whoami.Map.ObjectAt(49,3)
StartXY=Params.split(":")[0].split(',')
StopXY=Params.split(":")[1].split(',')
Width=int(StopXY[0])-int(StartXY[0])
Height=int(StopXY[1])-int(StartXY[1])
Area=Width*Height
XRange=range(int(StartXY[0]),int(StopXY[0]))
YRange=range(int(StartXY[1]),int(StopXY[1]))
def GetObjectByName(Map,X,Y,Name):
Object=Map.ObjectAt(X,Y)
while Object!=None:
if Object.Name==Name:
return Object
else:
Object=Object.Above
return Object
if Arch!=None:
whoami.Value=int(whoami.Value==1)
Arch.Quantity=Area+1
#def MoveToBottom(object):
#object.Say('s')
#Dict={}
#Counter=0
#Item=object.Below
#object.Say(str(Item))
#while Item!=None:
#Dict.update({str(Counter):Item})
#Item=Item.Below
#for i in list(Dict.values()):
#i.Teleport(object.Map,object.X,object.Y)
for i in XRange:
for a in YRange:
if whoami.Value==1:
TmpArch=Arch.Split(1)
TmpArch.Teleport(whoami.Map,i,a)
#MoveToBottom(TmpArch)
else:
TmpArch=GetObjectByName(whoami.Map,i,a,Arch.Name)
if TmpArch!=None:
TmpArch.Remove()
else:
whoami.Say("Arch not found at "+str(i)+","+str(a))
else:
for i in XRange:
for a in YRange:
t=whoami.Map.ObjectAt(i,a)
while t!=None:
if t.Floor==1:
t.Name="Shop Floor"
t=t.Above

382
python/pshop/Ice.py 100755
View File

@ -0,0 +1,382 @@
import Crossfire,random,math
import CFDataBase
CFDB=CFDataBase.CFDataBase("PShop")
Params=Crossfire.ScriptParameters()
def GetObjectByName(object, Name):
while object.Name!=Name:
object=object.Above
if not object:
return 0
return object
def FindFridge(object):
TRUE=False
while object!=None:
if object.Name=="Shop Floor":
TRUE=True
object=None
else:
object=object.Below
return TRUE
def FindPuddle(object):
a=object
while object!=None:
if object.Name.find("Puddle")>-1:
return object
else:
object=object.Above
object=a
while object!=None:
if object.Name.find("Puddle")>-1:
return object
else:
object=object.Below
return None
if Params=="Destroy":
whoami=Crossfire.WhoAmI()
a=whoami.Inventory
while a !=None:
a.Remove()
a=whoami.Inventory
b=whoami.CreateObject("icecube")
b.Weight=0
z=b.CreateObject("event_time")
b.Speed=0.0010000000475*4
if whoami.Map.Path.find("/world_")>-1:
b.Speed=b.Speed*10
z.Title="Python"
z.Name="Puddle"
z.Slaying="/python/pshop/Ice.py"
z=b.CreateObject("event_destroy")
z.Title="Python"
z.Name="PuddleDeath"
z.Slaying="/python/pshop/Ice.py"
b.NamePl=str(1)
b.Teleport(whoami.Map,whoami.X,whoami.Y)
g=FindPuddle(b)
if g!=None:
b.Remove()
b=g
b.Weight+=whoami.Weight
b.Name="Puddle"
if b.Weight<2000:
b.Face="rain1.111"
elif b.Weight<20000:
b.Face="rain2.111"
elif b.Weight<200000:
b.Face="rain3.111"
elif b.Weight<2000000:
b.Face="rain4.111"
else:
b.Face="rain5.111"
b.Pickable=0
elif Params=="FogDeath":
whoami=Crossfire.WhoAmI()
a=whoami.Inventory
while a !=None:
a.Remove()
a=whoami.Inventory
elif Params=="Fog":
whoami=Crossfire.WhoAmI()
Rand=random.randint(0,8)
if Rand!=0:
whoami.Move(Rand)
whoami.Weight-=1
if whoami.Weight>=0:
Crossfire.SetReturnValue(1)
elif Params=="Get":
whoami=Crossfire.WhoAmI()
activator=Crossfire.WhoIsActivator()
Dict=CFDB.get("pshop")
WL=str(whoami.WeightLimit)
Me=Dict.get(WL)
a=(Me[0],"PickedUp",Me[2])
#Me=str(Me[0],(activator.X,activator.Y),Me[1])
Dict.update({str(whoami.WeightLimit):(a[0],a[1],a[2])})
CFDB.store("pshop",Dict)
elif Params=="Player":
whoami=Crossfire.WhoAmI()
elif Params=="PuddleDeath":
whoami=Crossfire.WhoAmI()
Fogs=int(whoami.Weight/1000)
a=whoami.Inventory
while a !=None:
a.Remove()
a=whoami.Inventory
FogsTmp=Fogs
if whoami.Name=="fog":
FogsTmp=whoami.Value
if Fogs > 50:
z=whoami.CreateObject("temp_fog")
Z=z.CreateObject("event_destroy")
Z.Name="PuddleDeath"
Z.Title="Python"
Z.Slaying="/python/pshop/Ice.py"
z.Weight=(Fogs-50)*1000
Fogs=50
z.Speed*=2
z.Value=FogsTmp
for i in range(Fogs):
z=whoami.CreateObject("temp_fog")
z.Weight=(3+random.randint(1,10+int(math.sqrt(FogsTmp))))
Rand=random.randint(1,2+int(FogsTmp/10))
z.Speed*=Rand
z.Weight*=int(Rand/10)+1
y=z.CreateObject("event_time")
y.Name="Fog"
y.Title="Python"
y.Slaying="/python/pshop/Ice.py"
#y=z.CreateObject("event_destroy")
#y.Name="FogDeath"
#y.Title="Python"
#y.Slaying="/python/pshop/Ice.py"
elif Params=="Puddle":
whoami=Crossfire.WhoAmI()
whoami.Value+=1
#whoami.Speed+=(0.00010000000475/2)
Mass=int(math.sqrt(whoami.Weight))
IntMass=int(Mass/1000)
for i in range(IntMass):
z=whoami.CreateObject("temp_fog")
y=z.CreateObject("event_time")
y.Name="Fog"
y.Title="Python"
y.Slaying="/python/pshop/Ice.py"
#y=z.CreateObject("event_destroy")
#y.Name="FogDeath"
#y.Title="Python"
#y.Slaying="/python/pshop/Ice.py"
z.Weight=(3+random.randint(1,int(IntMass)+10))
z.Speed=5*z.Speed
whoami.Drop(z)
whoami.Weight-=Mass
if whoami.Weight<=0:
whoami.Remove()
else:
if whoami.Weight>20000:
a=whoami.CreateObject('icecube')
Mass=random.randint(1,int(whoami.Weight/2))
whoami.Weight-=Mass
a.Weight=Mass
Direction=random.randint(1,8)
whoami.Drop(a)
tmp=0
CTRL=0
if whoami.Map.Path.find("/world/world_")>-1:
tmp=0
CTRL=0
XY=(whoami.X,whoami.Y)
while tmp==0:
tmp=whoami.Move(Direction)
Direction+=1
if Direction==9:
Direction=1
CTRL+=1
if CTRL==8:
tmp=2
a.Teleport(whoami.Map, whoami.X,whoami.Y)
whoami.Teleport(whoami.Map,XY[0],XY[1])
else:
while tmp==0:
tmp=a.Move(Direction)
Direction+=1
if Direction==9:
Direction=1
CTRL+=1
if CTRL==8:
tmp=1
b=a.Map.ObjectAt(a.X,a.Y)
b=FindPuddle(b)
if b!=None:
b.Weight+=a.Weight
a.Remove()
a=b
else:
a.Name=whoami.Name
if a.Weight < 1600:
a.Face="rain1.111"
elif a.Weight < 3200:
a.Face="rain2.111"
elif a.Weight<6400:
a.Face="rain3.111"
elif a.Weight<12800:
a.Face="rain4.111"
else:
a.Face="rain5.111"
Z=False
y=a.Inventory
while y!=None:
if y.Name.find("Puddle")>-1:
Z=True
y=None
else:
y=y.Below
if Z==False:
z=a.CreateObject("event_time")
a.Speed=0.0010000000475*4
z.Title="Python"
z.Name="Puddle"
z.Slaying="/python/pshop/Ice.py"
z=a.CreateObject("event_destroy")
z.Title="Python"
z.Name="PuddleDeath"
z.Slaying="/python/pshop/Ice.py"
#a.CreateTimer(500,2)
a.NamePl=str(1)
a.Pickable=0
a.Speed=(0.0010000000475*4)
if whoami.Weight < 1600:
whoami.Face="rain1.111"
elif whoami.Weight < 3200:
whoami.Face="rain2.111"
elif whoami.Weight<6400:
whoami.Face="rain3.111"
elif whoami.Weight<12800:
whoami.Face="rain4.111"
else:
whoami.Face="rain5.111"
whoami.Speed=(0.0010000000475*4)+0.0010000000475*whoami.Value/(whoami.Weight/1000)
#whoami.Speed=max(whoami.Speed,0.0010000000475*4)
elif Params=="Timer":
whoami=Crossfire.WhoAmI()
b=FindPuddle(whoami.Map.ObjectAt(whoami.X,whoami.Y))
if b==None:
b=whoami.CreateObject("icecube")
b.Weight=0
z=b.CreateObject("event_time")
b.Speed=0.0010000000475*4
if whoami.Map.Path.find("/world_")>-1:
b.Speed=10*b.Speed
z.Title="Python"
z.Name="Puddle"
z.Slaying="/python/pshop/Ice.py"
z=b.CreateObject("event_destroy")
z.Title="Python"
z.Name="PuddleDeath"
z.Slaying="/python/pshop/Ice.py"
#b.CreateTimer(500,2)
b.NamePl=str(1)
whoami.Drop(b)
#b.Speed+=.00001
b.Name="Puddle"
Mass=int(100+math.sqrt(whoami.Weight))
b.Weight+=max(Mass,50)
whoami.Weight-=max(Mass,50)
b.Pickable=0
if b.Weight<2000:
b.Face="rain1.111"
elif b.Weight<4000:
b.Face="rain2.111"
elif b.Weight<8000:
b.Face="rain3.111"
elif b.Weight<16000:
b.Face="rain4.111"
else:
b.Face="rain5.111"
if whoami.Weight<=0:
whoami.Quantity=0
whoami.Speed+=0.00010000000475
else:
whoami=Crossfire.WhoAmI()
activator=Crossfire.WhoIsActivator()
mymap=activator.Map
t=mymap.ObjectAt(activator.X, activator.Y)
if (FindFridge(t)):
whoami.Speed=0
Dict=CFDB.get("pshop")
WL=str(whoami.WeightLimit)
Me=Dict.get(WL)
a=(Me[0],(activator.X,activator.Y),Me[2])
#Me=str(Me[0],(activator.X,activator.Y),Me[1])
Dict.update({str(whoami.WeightLimit):(a[0],a[1],a[2])})
CFDB.store("pshop",Dict)
Crossfire.SetReturnValue(0)
else:
whoami.Speed=0.0010000000475*4
if activator.Map.Path.find("/world_")>-1:
#whoami.CreateTimer(1,2)
whoami.Speed=whoami.Speed*10
Crossfire.SetReturnValue(0)

View File

@ -0,0 +1,6 @@
Make buildable switch <Done>
Add event_destroy method to duplicate the icecube and mail a note to the owner.
Add event_timer to players on pickup to make the icecubes melt <Aborted>
Reduce description of the items to only non 0 values. <Done>
Split script Params so that multiple shops can be run. <Done>
Add tag to items for shop <path> and shop name. <Done>

View File

@ -0,0 +1,141 @@
import Crossfire,datetime,CFDataBase
CFDB=CFDataBase.CFDataBase("PShop")
def GetObjectByWeightLimit(object, WeightLimit):
while object.WeightLimit!=WeightLimit:
object=object.Above
if not object:
return 0
return object
def GetObjectByName(object, Name):
while object.Name!=Name:
object=object.Above
if not object:
return 0
return object
def find_player(object):
while (object.Type != 1) : #1 is type 'Player'
object = object.Above
if not object:
return 0
return object
def GetObjectAt(Map,X,Y,Name):
Object=Map.ObjectAt(X,Y)
while Object!=None:
if Object.Name==Name:
return Object
else:
Object=Object.Above
return Object
def Expire():
global Owner
Inventory=mymap.ObjectAt(43,2)
MailMap=Crossfire.ReadyMap("/planes/IPO_storage")
while Inventory!=None:
if Inventory.Name!="Vault":
package=whoami.CreateObject("package")
package.Name="IPO-package F: Your-Private-Shop T: "+Owner
Inventory.InsertInto(package)
package.Teleport(MailMap,2,2)
Inventory=Inventory.Above
Inventory=mymap.ObjectAt(43,2)
while Inventory!=None:
if Inventory.Name!="Vault":
package=whoami.CreateObject("package")
package.Name="IPO-package F: Your-Private-Shop T: "+Owner
Inventory.InsertInto(package)
package.Teleport(MailMap,2,2)
Inventory=Inventory.Below
Dict=CFDB.get("pshop")
for i in Dict:
whoami.Say(i)
This=Dict.get(i)
whoami.Say(str(This))
if This[1]!="PickedUp":
That=mymap.ObjectAt(This[1][0],This[1][1])
whoami.Say(str(That))
if That!=None:
That=GetObjectByWeightLimit(That,int(i))
whoami.Say(str(That))
if That!=0:
That.Teleport(whoami.Map,37,0)
CFDB.store('pshop',{})
Owner="Unowned"
Chest=mymap.ObjectAt(30,8)
Chest=GetObjectByName(Chest, "Rent Box")
if Chest!=0:
Chest.Teleport(mymap, 15,10)
for i in range(0,34):
for a in range(0,35):
b=GetObjectAt(whoami.Map,i,a,'NoBuild')
b.Remove
b=GetObjectAt(whoami.Map,i,a,'NoSpell')
b.Remove()
GetObjectAt(whoami.Map,30,5,"Brazier material").Remove()
GetObjectAt(whoami.Map,30,6,"Firepot material").Remove()
GetObjectAt(whoami.Map,30,7,"Bright Firepot Material").Remove()
GetObjectAt(whoami.Map,29,8,"Red CWall material").Remove()
whoami.Map.ObjectAt(49,5).Teleport(whoami.Map,30,5)
whoami.Map.ObjectAt(49,4).Teleport(whoami.Map,30,6)
whoami.Map.ObjectAt(49,6).Teleport(whoami.Map,30,7)
whoami.Map.ObjectAt(49,7).Teleport(whoami.Map,29,8)
whoami=Crossfire.WhoAmI()
activator=Crossfire.WhoIsActivator()
activatorname=activator.Name
mymap=activator.Map
Variables=GetObjectByName(mymap.ObjectAt(49,0),"Variables")
VariableList= Variables.Message.split('\n')
Owner=VariableList[0]
Date=VariableList[1]
Days=VariableList[2]
Owner=Owner.split(": ")[1]
Date=Date.split(": ")[1]
Days=int(Days.split(": ")[1])
Year, Month, Day=Date.split("-")
LastDate=datetime.datetime(int(Year),int(Month),int(Day))
Today=datetime.date(1,2,3).today()
Today=datetime.datetime(Today.year, Today.month, Today.day)
DaysPast=(Today-LastDate).days
Days-=DaysPast
if Days<=0:
global Owner
Expire()
Variables.Message="Owner: "+Owner+"\nDate: "+str(Today.year)+"-"+str(Today.month)+"-"+str(Today.day)+"\nDays: "+str(Days)
if activatorname==Owner:
message=Crossfire.WhatIsMessage()
if (message.upper().find("ENTER")>-1) or (message.upper().find("YES")>-1):
X=activator.X
Y=activator.Y
activator.Teleport(mymap, 37,3)
activator.Teleport(mymap, X, Y)
whoami.Say("Greetings sire, you have "+str(Days)+" days left.")
else:
whoami.Say("Greetings sire, would you like entry?")
else:
if Owner!="Unowned":
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.")
else:
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.")

View File

@ -0,0 +1,682 @@
import Crossfire,sys,datetime
whoami=Crossfire.WhoAmI()
import CFDataBase,CFBank
sys.stderr=open("/tmp/output.log",'w')
sys.stdout=open("/tmp/output.log1",'w')
#for i in dir(CFDataBase):
#print i
#print CFDataBase.__file__
CFDB=CFDataBase.CFDataBase("PShop")
bank=CFBank.CFBank("ImperialBank_DB")
pshop=whoami.Map.Path.replace("/","_")
print CFDB.get(pshop)
print pshop
sys.stdout.flush()
activator=Crossfire.WhoIsActivator()
def Expire():
global Owner
Inventory=mymap.ObjectAt(43,2)
MailMap=Crossfire.ReadyMap("/planes/IPO_storage")
while Inventory!=None:
if Inventory.Name!="Vault":
package=whoami.CreateObject("package")
package.Name="IPO-package F: Your-Private-Shop T: "+Owner
Inventory.InsertInto(package)
package.Teleport(MailMap,2,2)
Inventory=Inventory.Above
Inventory=mymap.ObjectAt(43,2)
while Inventory!=None:
if Inventory.Name!="Vault":
package=whoami.CreateObject("package")
package.Name="IPO-package F: Your-Private-Shop T: "+Owner
Inventory.InsertInto(package)
package.Teleport(MailMap,2,2)
Inventory=Inventory.Below
Dict=CFDB.get(pshop)
for i in Dict:
whoami.Say(i)
This=Dict.get(i)
whoami.Say(str(This))
if This[1]!="PickedUp":
That=mymap.ObjectAt(This[1][0],This[1][1])
whoami.Say(str(That))
if That!=None:
That=GetObjectByWeightLimit(That,int(i))
whoami.Say(str(That))
if That!=0:
That.Teleport(whoami.Map,37,0)
CFDB.store(pshop,{})
Owner="Unowned"
Chest=mymap.ObjectAt(30,8)
Chest=GetObjectByName(Chest, "Rent Box")
if Chest!=0:
Chest.Teleport(mymap, 15,10)
for i in range(0,34):
for a in range(0,35):
b=GetObjectAt(whoami.Map,i,a,'NoBuild')
b.Remove
b=GetObjectAt(whoami.Map,i,a,'NoSpell')
b.Remove()
GetObjectAt(whoami.Map,30,5,"Brazier material").Remove()
GetObjectAt(whoami.Map,30,6,"Firepot material").Remove()
GetObjectAt(whoami.Map,30,7,"Bright Firepot Material").Remove()
GetObjectAt(whoami.Map,29,8,"Red CWall material").Remove()
whoami.Map.ObjectAt(49,5).Teleport(whoami.Map,30,5)
whoami.Map.ObjectAt(49,4).Teleport(whoami.Map,30,6)
whoami.Map.ObjectAt(49,6).Teleport(whoami.Map,30,7)
whoami.Map.ObjectAt(49,7).Teleport(whoami.Map,29,8)
def GetObjectByName(object, Name):
while object.Name!=Name:
object=object.Above
if not object:
return 0
return object
def GetObjectByWeightLimit(object, WeightLimit):
while object.WeightLimit!=WeightLimit:
object=object.Above
if not object:
return 0
return object
def GetObjectByUID(object, UID):
while object.Name.split()[0]!=UID:
object=object.Above
if not object:
return 0
return object
def GetInvCount(object):
Inv=object.Inventory
Counter=-1
while Inv!=None:
Counter+=1
Inv=Inv.Below
return Counter
mymap=activator.Map
CoinTypes={"SILVER":1,"GOLD":10,"PLATINUM":50,"JADE":5000,"AMBER":500000,"IMPERIAL":10000}
Params=Crossfire.ScriptParameters()
whoami.Say(str(whoami.Name))
if whoami.Name.find("Store")>-1:
InvCount=GetInvCount(whoami)
if InvCount==0:
whoami.Say("Useage: Put an item in me and name a price. For details, ask for 'help'.")
else:
Message=Crossfire.WhatIsMessage()
Message=Message.split()
Value=0
for i in range(len(Message)):
CoinType=CoinTypes.get(Message[i].upper())
if CoinType!=None:
Quantity=int(Message[i-1])
Value+=Quantity*CoinType
Package=whoami.CreateObject("dust_generic")
Package.Face="package.111"
Package.Teleport(whoami.Map,43,2)
for i in range(InvCount):
Item=whoami.Inventory
Item.InsertInto(Package)
Package.Name=str(whoami.Value)+" "+str(Value)
Package.Speed=whoami.Value
Package.WeightLimit=0
z=Package.CreateObject("event_pickup")
z.Name="Pickup"
z.Title="Python"
z.Slaying="/python/pshop/pshop.py"
#STRING=STRING.split("Items: ")[1]
if Item.Name==Crossfire.ScriptParameters():
Item=Item.Below
GlassReplica=whoami.CreateObject("icecube")
GlassReplica.WeightLimit=whoami.Value
GlassReplica.Weight=max(Item.Weight*Item.Quantity,1)
GlassReplica.Quantity=1
t=GlassReplica.CreateObject("event_drop")
t.Name="Drop"
t.Value=whoami.Value
t.Title="Python"
t.Slaying="/python/pshop/Ice.py"
t=GlassReplica.CreateObject("event_pickup")
t.Name="Get"
t.Title="Python"
t.Slaying="/python/pshop/Ice.py"
t=GlassReplica.CreateObject("event_destroy")
t.Name="Destroy"
t.Title="Python"
t.Slaying="/python/pshop/Ice.py"
t=GlassReplica.CreateObject("event_time")
t.Name="Timer"
t.Title="Python"
t.Slaying="/python/pshop/Ice.py"
GlassReplica.Speed=0.0010000000475
GlassReplica.Face=str(Item.Face)
#GlassReplica.Material=(96,'ice')
GlassReplica.Name=str(Item.Quantity)+" "+Item.Name+" Price: "+str(Value)
GlassReplica.NamePl="0"
Message="Name: "+str(Item.Name)
Message+="\nTitle: "+str(Item.Title)
Message+="\nMaterial: "+str(Item.Material.get("MaterialName"))
Message+="\nQuantity: "+str(Item.Quantity)
if Item.Cursed==1:
Message+="\nCursed: True"
Message+="\nWeight: "+str(Item.Weight)
if Item.Dam!=0:
Message+="\nDam: "+str(Item.Dam)
if Item.AC!=0:
Message+="\nAC: "+str(Item.AC)
if Item.WC!=0:
Message+="\nWC: "+str(Item.WC)
if Item.Wis!=0:
Message+="\nWis: "+str(Item.Wis)
if Item.Str!=0:
Message+="\nStr: "+str(Item.Str)
if Item.Pow!=0:
Message+="\nPow: "+str(Item.Pow)
if Item.Int!=0:
Message+="\nInt: "+str(Item.Int)
if Item.Dex!=0:
Message+="\nDex: "+str(Item.Dex)
if Item.Con!=0:
Message+="\nCon: "+str(Item.Con)
if Item.Cha!=0:
Message+="\nCha: "+str(Item.Cha)
if Item.Value!=0:
Message+="\nValue: "+str(Item.Value)
GlassReplica.Message=Message
Dict=CFDB.get(pshop)
if Dict==0:
Dict={}
if Dict==None:
Dict={}
Dict.update({str(whoami.Value):(Value,"PickedUp",Message)})
CFDB.store(pshop,Dict)
whoami.Value+=1
elif whoami.Name.find("Rent Box")>-1:
whoami.Say('g')
Value=0
Inventory=whoami.Inventory
while Inventory!=None:
if Inventory.ArchName=="event_close":
Inventory=Inventory.Above
else:
Value+=Inventory.Value*Inventory.Quantity
Inventory.Teleport(whoami.Map,37,5)
Inventory=whoami.Inventory
Variables=whoami.Map.ObjectAt(49,0)
Variables=GetObjectByName(Variables,"Variables")
VariableList= Variables.Message.split('\n')
Owner=VariableList[0].split(": ")[1]
Date=VariableList[1].split(": ")[1]
Days=int(VariableList[2].split(": ")[1])
Year, Month, Day=Date.split("-")
LastDate=datetime.datetime(int(Year),int(Month),int(Day))
Today=datetime.date(1,2,3).today()
Today=datetime.datetime(Today.year, Today.month, Today.day)
DaysPast=(Today-LastDate).days
Days-=DaysPast
MaxDays=int(Params)
if Owner!="Unowned":
if Days<30:
DT30=30-Days
if DT30<=Value/50:
Value-=DT30*50
Days=30
else:
Days+=int(Value/50)
Value-=int(Value/50)*50
if Value>=100:
if Days<60:
DT60=60-Days
if DT60<=Value/100:
Value-=DT60*100
Days=60
else:
Days+=int(Value/100)
Value-=int(Value/100)*100
if Value>=200:
if Days<90:
DT90=90-Days
if DT90<=Value/200:
Value-=DT90*200
Days=90
else:
Days+=int(Value/200)
Value-=int(Value/200)*200
if Value>=400:
if Days<120:
DT120=120-Days
if DT120<=Value/400:
Value-=DT120*400
Days=120
else:
Days+=int(Value/400)
Value-=int(Value/400)*400
if Value>=800:
if Days<150:
DT150=150-Days
if DT150<=Value/800:
Value-=DT150*800
Days=150
else:
Days+=int(Value/800)
Value-=int(Value/800)*800
if Value>=1600:
if Days<180:
DT180=180-Days
if DT90<=Value/1600:
Value-=DT180*1600
Days=180
else:
Days+=int(Value/1600)
Value-=int(Value/1600)*1600
if Value>=3200:
if Days<210:
DT210=210-Days
if DT210<=Value/3200:
Value-=DT210*3200
Days=210
else:
Days+=int(Value/3200)
Value-=int(Value/3200)*3200
if Value>=6400:
if Days<240:
DT240=240-Days
if DT240<=Value/6400:
Value-=DT240*6400
Days=240
else:
Days+=int(Value/6400)
Value-=int(Value/6400)*6400
if Value>=12800:
if Days<270:
DT270=270-Days
if DT270<=Value/12800:
Value-=DT270*12800
Days=270
else:
Days+=int(Value/12800)
Value-=int(Value/12800)*12800
if Value>=25600:
if Days<300:
DT300=300-Days
if DT300<=Value/25600:
Value-=DT300*25600
Days=300
else:
Days+=int(Value/25600)
Value-=int(Value/25600)*25600
if Value>=51200:
if Days<330:
DT330=330-Days
if DT330<=Value/51200:
Value-=DT330*51200
Days=330
else:
Days+=int(Value/51200)
Value-=int(Value/51200)*51200
if Value>=102400:
if Days<366:
DT366=366-Days
if DT366<=Value/102400:
Value-=DT366*102400
Days=366
else:
Days+=int(Value/102400)
Value-=int(Value/102400)*102400
tmp=whoami.CreateObject("silvercoin")
tmp.Quantity=Value
Days=min(Days,MaxDays)
else:
DT30=30
Owner=activator.Name
if DT30<=Value/50:
Value-=DT30*50
Days=30
else:
Days+=int(Value/50)
Value-=int(Value/50)
if Value>0:
tmp=whoami.CreateObject("silvercoin")
tmp.Quantity=Value
if Days>=1:
whoami.Teleport(whoami.Map,30,8)
else:
whoami.Teleport(whoami.Map,15,10)
Variables.Message="Owner: "+Owner+"\nDate: "+str(Today.year)+"-"+str(Today.month)+"-"+str(Today.day)+"\nDays: "+str(Days)
elif Params=="Trade":
Message=Crossfire.WhatIsMessage().split()
if Message[0].upper()=='TRADE':
Name=''
Title=''
Quantity=0
for i in range(len(Message)):
if Message[i].upper()=="NAME":
Name=Message[i+1]
elif Message[i].upper()=='TITLE':
Title=Message[i+1]
elif Message[i].upper()=='QUANTITY':
Quantity=int(Message[i+1])
elif Params=="Exchange":
pass
elif Params=="InventorySay":
Message=Crossfire.WhatIsMessage().split()
if Message[0]=="Remove":
CFDB.store(pshop,None)
if Message[0].upper().find("DETAIL")>-1:
Item=' '.join(Message[1:])
Dict=CFDB.get(pshop)
if Dict==0:
Dict={}
Ctrl=1
for i in Dict:
Str=Dict.get(str(i))
Name=Str[2].split('\n')[0].split("Name: ")[1]
if Item==Name:
Message="\n"+str(Dict.get(i)[2])
Message+=("\nAsking Price: "+str(Dict.get(i)[0])+"\nLocation: ")
if Dict.get(i)[1]=="PickedUp":
Message+="Not on store floor"
elif Dict.get(i)[1][1]<=9:
Message+="In employee only area."
else:
Message+=str(Dict.get(i)[1])
Message+="\n(You are at ("+str(whoami.X)+","+str(whoami.Y)+")."
whoami.Say(Message)
Ctrl=0
if Ctrl==1:
Item=int(Message[1])
Item=list(Dict)[Item-1]
Item=Dict.get(str(Item))[2].split('\n')[0].split('Name: ')[1]
for i in Dict:
Str=Dict.get(str(i))
Name=Str[2].split('\n')[0].split("Name: ")[1]
if Item==Name:
Message="\n"+str(Dict.get(i)[2])
Message+=("\nAsking Price: "+str(Dict.get(i)[0])+"\nLocation: ")
if Dict.get(i)[1]=="PickedUp":
Message+="Not on store floor"
elif Dict.get(i)[1][1]<=9:
Message+="In employee only area."
else:
Message+=str(Dict.get(i)[1])
Message+="\n(You are at ("+str(whoami.X)+","+str(whoami.Y)+")."
whoami.Say(Message)
Ctrl=0
elif Params=="AutoCheckout":
Dict=CFDB.get(pshop)
Inv=activator.Inventory
Items=[]
RealItems=[]
MissingItems=[]
Price=0
while Inv!=None:
if (Inv.Name.find("Price: ")>-1) and (Inv.Message.find("Value: ")>-1):
Items=Items.__add__([Inv])
Inv=Inv.Below
for i in Items:
Item=(activator.Map.ObjectAt(43,2))
Item=GetObjectByUID(Item,str(i.WeightLimit))
if Item!=0:
Price+=int(Item.Name.split()[1])
RealItems=RealItems.__add__([Item])
else:
whoami.Say("Item "+i.Name+" missing.")
MissingItems=MissingItems.__add__([i])
if activator.PayAmount(Price):
for i in RealItems:
i.InsertInto(activator)
tmp=Dict.pop((str(i.Name.split()[0])))
for i in Items:
i.Teleport(activator.Map, 37,0)
i.Speed+=(0.00010000000475*2)
for i in MissingItems:
i.Teleport(activator.Map,37,0)
i.Speed+=(0.00010000000475*2)
tmp=Dict.pop((str(i.WeightLimit)))
CFDB.store(pshop,Dict)
Variables=GetObjectByName(mymap.ObjectAt(49,0),"Variables")
VariableList= Variables.Message.split('\n')
Owner=VariableList[0]
Date=VariableList[1]
Days=VariableList[2]
Owner=Owner.split(": ")[1]
Date=Date.split(": ")[1]
Days=int(Days.split(": ")[1])
Year, Month, Day=Date.split("-")
LastDate=datetime.datetime(int(Year),int(Month),int(Day))
Today=datetime.date(1,2,3).today()
Today=datetime.datetime(Today.year, Today.month, Today.day)
DaysPast=(Today-LastDate).days
Days-=DaysPast
if Days<30:
DT30=30-Days
if DT30<=Price/50:
Price-=DT30*50
Days=30
else:
Days+=int(Price/50)
Price-=int(Price/50)
if Days<=0:
global Owner
Expire()
Variables.Message="Owner: "+Owner+"\nDate: "+str(Today.year)+"-"+str(Today.month)+"-"+str(Today.day)+"\nDays: "+str(Days)
bank.deposit(Owner, int(Price/1.01))
else:
whoami.Say("You do not have enough cash, "+str(Price)+" silver needed.")
elif Params=="BankCheckout":
Dict=CFDB.get(pshop)
Inv=activator.Inventory
Items=[]
RealItems=[]
MissingItems=[]
Price=0
while Inv!=None:
if (Inv.Name.find("Price: ")>-1) and (Inv.Message.find("Value: ")>-1):
Items=Items.__add__([Inv])
Inv=Inv.Below
for i in Items:
Item=(activator.Map.ObjectAt(43,2))
Item=GetObjectByUID(Item,str(i.WeightLimit))
if Item!=0:
Price+=int(Item.Name.split()[1])
RealItems=RealItems.__add__([Item])
else:
whoami.Say("Item "+i.Name+" missing.")
MissingItems=MissingItems.__add__([i])
if bank.getbalance(activator.Name)>=Price:
bank.withdraw(activator.Name, Price)
for i in RealItems:
i.InsertInto(activator)
tmp=Dict.pop((str(i.Name.split()[0])))
for i in Items:
i.Teleport(activator.Map, 37,0)
i.Speed+=(0.00010000000475*2)
for i in MissingItems:
i.Teleport(activator.Map,37,0)
i.Speed+=(0.00010000000475*2)
tmp=Dict.pop((str(i.WeightLimit)))
CFDB.store(pshop,Dict)
Variables=GetObjectByName(mymap.ObjectAt(49,0),"Variables")
VariableList= Variables.Message.split('\n')
Owner=VariableList[0]
Date=VariableList[1]
Days=VariableList[2]
Owner=Owner.split(": ")[1]
Date=Date.split(": ")[1]
Days=int(Days.split(": ")[1])
Year, Month, Day=Date.split("-")
LastDate=datetime.datetime(int(Year),int(Month),int(Day))
Today=datetime.date(1,2,3).today()
Today=datetime.datetime(Today.year, Today.month, Today.day)
DaysPast=(Today-LastDate).days
Days-=DaysPast
if Days<30:
DT30=30-Days
if DT30<=Price/50:
Price-=DT30*50
Days=30
else:
Days+=int(Price/50)
Price-=int(Price/50)
if Days<=0:
global Owner
Expire()
Variables.Message="Owner: "+Owner+"\nDate: "+str(Today.year)+"-"+str(Today.month)+"-"+str(Today.day)+"\nDays: "+str(Days)
bank.deposit(Owner, int(Price/1.01))
else:
whoami.Say("You do not have enough funds in the bank. "+str(Price)+" needed.")
elif Params=="TrashOpen":
Trash=whoami.Map.ObjectAt(37,0)
while Trash!=None:
Trash1=Trash.Above
Trash.InsertInto(whoami)
Trash=Trash1
elif Params=="TrashClose":
Trash=whoami.Inventory
while Trash!=None:
if (Trash.Name=="TrashClose") or (Trash.Name=="TrashOpen"):
Trash=Trash.Above
else:
Trash.Teleport(whoami.Map,37,0)
if Trash.ArchName=="icecube":
Trash.Speed+=(0.00010000000475*2)
Trash=whoami.Inventory
else:
whoami.Message="xyzzy"
Dict=CFDB.get(pshop)
if Dict==0:
Dict={}
whoami.Message=''
for i in Dict:
Str=Dict.get(i)[2].split('\n')[0]
whoami.Message+=str(Str)

View File