- fixed issue with slotmachines where items created reset number of
existing items in the same space. (using itemborker to set number of items add or remove as a safer way to manage this.) - touched up bank dialogue (and incorporated itembroker code) git-svn-id: svn://svn.code.sf.net/p/crossfire/code/trunk/maps@2413 282e977c-c81d-0410-88c4-b93c2d0d6712master
parent
616a6f3c72
commit
55d9353f1c
|
|
@ -1,22 +1,25 @@
|
||||||
#CFItemBroker.py
|
#CFItemBroker.py
|
||||||
#An often used bit of code to add or remove a number of objects
|
#An often used bit of code to add or remove a number of objects
|
||||||
#Mostly useful for removing items (like in payment or as part of
|
#Useful for removing items (like in payment or as part of
|
||||||
#an inventory check)
|
#an inventory check) This is also useful for setting the number
|
||||||
#This will not check for the existance of an item as that would better
|
#of a newly created item(s) as it will check for existing item(s) and add
|
||||||
|
#the appropriate number of new items avoiding such sillyness as the
|
||||||
|
#number of the existing items being reset.
|
||||||
|
#This will not check for the existence of an item as that would better
|
||||||
#be done in the calling script so you can be flexable.
|
#be done in the calling script so you can be flexable.
|
||||||
#
|
#
|
||||||
#ToddMitchell
|
#ToddMitchell
|
||||||
|
|
||||||
import CFPython
|
import CFPython
|
||||||
|
|
||||||
class ItemBroker:
|
class Item:
|
||||||
|
|
||||||
def __init__(self, object):
|
def __init__(self, object):
|
||||||
self.object = object
|
self.object = object
|
||||||
self.numberof = CFPython.GetQuantity(self.object)
|
self.numberof = CFPython.GetQuantity(self.object)
|
||||||
|
|
||||||
def add(self, number):
|
def add(self, number):
|
||||||
tmp = self.numberof + number
|
tmp = (self.numberof + number)-1
|
||||||
CFPython.SetQuantity(self.object, tmp)
|
CFPython.SetQuantity(self.object, tmp)
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -52,7 +52,7 @@ thanks_message = ['Thank you for banking the Imperial Way.', 'Thank you, please
|
||||||
again.', 'Thank you, please come again.','Thank you for banking the Imperial Way.', \
|
again.', 'Thank you, please come again.','Thank you for banking the Imperial Way.', \
|
||||||
'Thank you for your patronage.', 'Thank you, have a nice day.', 'Thank you. "Service" \
|
'Thank you for your patronage.', 'Thank you, have a nice day.', 'Thank you. "Service" \
|
||||||
is our middle name.', 'Thank you. "Service" is our middle name.', 'Thank you for your \
|
is our middle name.', 'Thank you. "Service" is our middle name.', 'Thank you for your \
|
||||||
patronage.', 'Thank you, have a nice day.', 'Thank you. Hows about a big slobbery \ kiss?']
|
patronage.', 'Thank you, have a nice day.', 'Thank you. Hows about a big slobbery kiss?']
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -66,8 +66,8 @@ elif text[0] == 'deposit':
|
||||||
if len(text)==2:
|
if len(text)==2:
|
||||||
if (CFPython.PayAmount(activator, (int(text[1])*exchange_rate)*fees)):
|
if (CFPython.PayAmount(activator, (int(text[1])*exchange_rate)*fees)):
|
||||||
bank.deposit(activatorname, int(text[1]))
|
bank.deposit(activatorname, int(text[1]))
|
||||||
message = '%d imperials deposited to bank account. %s' \
|
message = '%d recieved, %d imperials deposited to bank account. %s' \
|
||||||
%(int(text[1]),random.choice(thanks_message))
|
%((int(text[1])*(exchange_rate/50))*fees,int(text[1]),random.choice(thanks_message))
|
||||||
else:
|
else:
|
||||||
message = 'You would need %d gold'%((int(text[1])*(exchange_rate/10))*fees)
|
message = 'You would need %d gold'%((int(text[1])*(exchange_rate/10))*fees)
|
||||||
else:
|
else:
|
||||||
|
|
@ -79,7 +79,7 @@ elif text[0] == 'withdraw':
|
||||||
message = '%d imperials withdrawn from bank account. %s' \
|
message = '%d imperials withdrawn from bank account. %s' \
|
||||||
%(int(text[1]),random.choice(thanks_message))
|
%(int(text[1]),random.choice(thanks_message))
|
||||||
id = CFPython.CreateObject('imperial', (x, y))
|
id = CFPython.CreateObject('imperial', (x, y))
|
||||||
CFPython.SetQuantity(id, int(text[1]))
|
CFItemBroker.Item(id).add(int(text[1]))
|
||||||
else:
|
else:
|
||||||
message = 'Not enough imperials on your account'
|
message = 'Not enough imperials on your account'
|
||||||
else:
|
else:
|
||||||
|
|
@ -89,10 +89,10 @@ elif text[0] == 'exchange':
|
||||||
if len(text)==2:
|
if len(text)==2:
|
||||||
inv=CFPython.CheckInventory(activator,'imperial')
|
inv=CFPython.CheckInventory(activator,'imperial')
|
||||||
if inv:
|
if inv:
|
||||||
pay = CFItemBroker.ItemBroker(inv).subtract(int(text[1]))
|
pay = CFItemBroker.Item(inv).subtract(int(text[1]))
|
||||||
if pay:
|
if pay:
|
||||||
id = CFPython.CreateObject('platinum coin', (x, y))
|
id = CFPython.CreateObject('platinum coin', (x, y))
|
||||||
CFPython.SetQuantity(id, int(text[1])*(exchange_rate/50))
|
CFItemBroker.Item(id).add(int(text[1])*(exchange_rate/50))
|
||||||
message = random.choice(thanks_message)
|
message = random.choice(thanks_message)
|
||||||
else:
|
else:
|
||||||
message = 'Sorry, you do not have %d imperials' %int(text[1])
|
message = 'Sorry, you do not have %d imperials' %int(text[1])
|
||||||
|
|
@ -103,8 +103,12 @@ elif text[0] == 'exchange':
|
||||||
|
|
||||||
elif text[0] == 'balance':
|
elif text[0] == 'balance':
|
||||||
balance = bank.getbalance(activatorname)
|
balance = bank.getbalance(activatorname)
|
||||||
message = 'Amount in bank: %d Ip'%(balance)
|
if balance == 1:
|
||||||
|
message = 'Amount in bank: 1 imperial note'
|
||||||
|
elif balance:
|
||||||
|
message = 'Amount in bank: %d imperial notes'%(balance)
|
||||||
|
else:
|
||||||
|
message = 'Sorry, you have no balance.'
|
||||||
else:
|
else:
|
||||||
message = 'Do you need help?'
|
message = 'Do you need help?'
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ Slots=CFGamble.SlotMachine(slotname,slotlist,minpot,maxpot)
|
||||||
|
|
||||||
object = CFPython.CheckInventory(activator,cointype)
|
object = CFPython.CheckInventory(activator,cointype)
|
||||||
if (object):
|
if (object):
|
||||||
pay = CFItemBroker.ItemBroker(object).subtract(cost)
|
pay = CFItemBroker.Item(object).subtract(cost)
|
||||||
if (pay):
|
if (pay):
|
||||||
Slots.placebet(cost)
|
Slots.placebet(cost)
|
||||||
results = Slots.spin(spinners)
|
results = Slots.spin(spinners)
|
||||||
|
|
@ -63,7 +63,7 @@ if (object):
|
||||||
payoff = cost*pay
|
payoff = cost*pay
|
||||||
Slots.payoff(payoff)
|
Slots.payoff(payoff)
|
||||||
id = CFPython.CreateObject(cointype, (x, y))
|
id = CFPython.CreateObject(cointype, (x, y))
|
||||||
CFPython.SetQuantity(id, payoff)
|
CFItemBroker.Item(id).add(payoff)
|
||||||
if payoff == 1:
|
if payoff == 1:
|
||||||
message = "you win %d %s!" %(payoff,cointype)
|
message = "you win %d %s!" %(payoff,cointype)
|
||||||
else:
|
else:
|
||||||
|
|
@ -91,7 +91,7 @@ if (object):
|
||||||
payoff = pot*pay
|
payoff = pot*pay
|
||||||
Slots.payoff(payoff)
|
Slots.payoff(payoff)
|
||||||
id = CFPython.CreateObject(cointype, (x, y))
|
id = CFPython.CreateObject(cointype, (x, y))
|
||||||
CFPython.SetQuantity(id, payoff)
|
CFItemBroker.Item(id).add(payoff)
|
||||||
if payoff == 1:
|
if payoff == 1:
|
||||||
message = "you win %d %s!" %(payoff,cointype)
|
message = "you win %d %s!" %(payoff,cointype)
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ import CFPython
|
||||||
import sys
|
import sys
|
||||||
sys.path.append('%s/%s/python' %(CFPython.GetDataDirectory(),CFPython.GetMapDirectory()))
|
sys.path.append('%s/%s/python' %(CFPython.GetDataDirectory(),CFPython.GetMapDirectory()))
|
||||||
import CFGamble
|
import CFGamble
|
||||||
|
import CFItemBroker
|
||||||
|
|
||||||
activator=CFPython.WhoIsActivator()
|
activator=CFPython.WhoIsActivator()
|
||||||
activatorname=CFPython.GetName(activator)
|
activatorname=CFPython.GetName(activator)
|
||||||
|
|
@ -57,7 +58,7 @@ if (CFPython.PayAmount(activator, cost*10)):#goldcoin
|
||||||
payoff = cost*pay
|
payoff = cost*pay
|
||||||
Slots.payoff(payoff)
|
Slots.payoff(payoff)
|
||||||
id = CFPython.CreateObject(cointype, (x, y))
|
id = CFPython.CreateObject(cointype, (x, y))
|
||||||
CFPython.SetQuantity(id, payoff)
|
CFItemBroker.Item(id).add(payoff)
|
||||||
if payoff == 1:
|
if payoff == 1:
|
||||||
message = "you win %d %s!" %(payoff,cointype)
|
message = "you win %d %s!" %(payoff,cointype)
|
||||||
else:
|
else:
|
||||||
|
|
@ -83,7 +84,7 @@ if (CFPython.PayAmount(activator, cost*10)):#goldcoin
|
||||||
payoff = pot*pay
|
payoff = pot*pay
|
||||||
Slots.payoff(payoff)
|
Slots.payoff(payoff)
|
||||||
id = CFPython.CreateObject(cointype, (x, y))
|
id = CFPython.CreateObject(cointype, (x, y))
|
||||||
CFPython.SetQuantity(id, payoff)
|
CFItemBroker.Item(id).add(payoff)
|
||||||
if payoff == 1:
|
if payoff == 1:
|
||||||
message == "you win %d %s!" %(payoff,cointype)
|
message == "you win %d %s!" %(payoff,cointype)
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ Slots=CFGamble.SlotMachine(slotname,slotlist,minpot,maxpot)
|
||||||
|
|
||||||
object = CFPython.CheckInventory(activator,cointype)
|
object = CFPython.CheckInventory(activator,cointype)
|
||||||
if (object):
|
if (object):
|
||||||
pay = CFItemBroker.ItemBroker(object).subtract(cost)
|
pay = CFItemBroker.Item(object).subtract(cost)
|
||||||
if (pay):
|
if (pay):
|
||||||
Slots.placebet(cost)
|
Slots.placebet(cost)
|
||||||
results = Slots.spin(spinners)
|
results = Slots.spin(spinners)
|
||||||
|
|
@ -63,7 +63,7 @@ if (object):
|
||||||
payoff = cost*pay
|
payoff = cost*pay
|
||||||
Slots.payoff(payoff)
|
Slots.payoff(payoff)
|
||||||
id = CFPython.CreateObject(cointype, (x, y))
|
id = CFPython.CreateObject(cointype, (x, y))
|
||||||
CFPython.SetQuantity(id, payoff)
|
CFItemBroker.Item(id).add(payoff)
|
||||||
if payoff == 1:
|
if payoff == 1:
|
||||||
message = "you win %d %s!" %(payoff,cointype)
|
message = "you win %d %s!" %(payoff,cointype)
|
||||||
else:
|
else:
|
||||||
|
|
@ -91,7 +91,7 @@ if (object):
|
||||||
payoff = pot*pay
|
payoff = pot*pay
|
||||||
Slots.payoff(payoff)
|
Slots.payoff(payoff)
|
||||||
id = CFPython.CreateObject(cointype, (x, y))
|
id = CFPython.CreateObject(cointype, (x, y))
|
||||||
CFPython.SetQuantity(id, payoff)
|
CFItemBroker.Item(id).add(payoff)
|
||||||
if payoff == 1:
|
if payoff == 1:
|
||||||
message = "you win %d %s!" %(payoff,cointype)
|
message = "you win %d %s!" %(payoff,cointype)
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ import CFPython
|
||||||
import sys
|
import sys
|
||||||
sys.path.append('%s/%s/python' %(CFPython.GetDataDirectory(),CFPython.GetMapDirectory()))
|
sys.path.append('%s/%s/python' %(CFPython.GetDataDirectory(),CFPython.GetMapDirectory()))
|
||||||
import CFGamble
|
import CFGamble
|
||||||
|
import CFItemBroker
|
||||||
|
|
||||||
activator=CFPython.WhoIsActivator()
|
activator=CFPython.WhoIsActivator()
|
||||||
activatorname=CFPython.GetName(activator)
|
activatorname=CFPython.GetName(activator)
|
||||||
|
|
@ -59,7 +60,7 @@ if (CFPython.PayAmount(activator, cost*50)):#platinumcoin
|
||||||
payoff = cost*pay
|
payoff = cost*pay
|
||||||
Slots.payoff(payoff)
|
Slots.payoff(payoff)
|
||||||
id = CFPython.CreateObject(cointype, (x, y))
|
id = CFPython.CreateObject(cointype, (x, y))
|
||||||
CFPython.SetQuantity(id, payoff)
|
CFItemBroker.Item(id).add(payoff)
|
||||||
if payoff == 1:
|
if payoff == 1:
|
||||||
message = "you win %d %s!" %(payoff,cointype)
|
message = "you win %d %s!" %(payoff,cointype)
|
||||||
else:
|
else:
|
||||||
|
|
@ -87,7 +88,7 @@ if (CFPython.PayAmount(activator, cost*50)):#platinumcoin
|
||||||
payoff = pot*pay
|
payoff = pot*pay
|
||||||
Slots.payoff(payoff)
|
Slots.payoff(payoff)
|
||||||
id = CFPython.CreateObject(cointype, (x, y))
|
id = CFPython.CreateObject(cointype, (x, y))
|
||||||
CFPython.SetQuantity(id, payoff)
|
CFItemBroker.Item(id).add(payoff)
|
||||||
if payoff == 1:
|
if payoff == 1:
|
||||||
message = "you win %d %s!" %(payoff,cointype)
|
message = "you win %d %s!" %(payoff,cointype)
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ import CFPython
|
||||||
import sys
|
import sys
|
||||||
sys.path.append('%s/%s/python' %(CFPython.GetDataDirectory(),CFPython.GetMapDirectory()))
|
sys.path.append('%s/%s/python' %(CFPython.GetDataDirectory(),CFPython.GetMapDirectory()))
|
||||||
import CFGamble
|
import CFGamble
|
||||||
|
import CFItemBroker
|
||||||
|
|
||||||
activator=CFPython.WhoIsActivator()
|
activator=CFPython.WhoIsActivator()
|
||||||
activatorname=CFPython.GetName(activator)
|
activatorname=CFPython.GetName(activator)
|
||||||
|
|
@ -54,7 +55,7 @@ if (CFPython.PayAmount(activator, cost)):#silvercoin
|
||||||
payoff = cost*pay
|
payoff = cost*pay
|
||||||
Slots.payoff(payoff)
|
Slots.payoff(payoff)
|
||||||
id = CFPython.CreateObject(cointype, (x, y))
|
id = CFPython.CreateObject(cointype, (x, y))
|
||||||
CFPython.SetQuantity(id, payoff)
|
CFItemBroker.Item(id).add(payoff)
|
||||||
if payoff == 1:
|
if payoff == 1:
|
||||||
message = "you win %d %s!" %(payoff,cointype)
|
message = "you win %d %s!" %(payoff,cointype)
|
||||||
else:
|
else:
|
||||||
|
|
@ -78,7 +79,7 @@ if (CFPython.PayAmount(activator, cost)):#silvercoin
|
||||||
payoff = pot*pay
|
payoff = pot*pay
|
||||||
Slots.payoff(payoff)
|
Slots.payoff(payoff)
|
||||||
id = CFPython.CreateObject(cointype, (x, y))
|
id = CFPython.CreateObject(cointype, (x, y))
|
||||||
CFPython.SetQuantity(id, payoff)
|
CFItemBroker.Item(id).add(payoff)
|
||||||
if payoff == 1:
|
if payoff == 1:
|
||||||
message = "you win %d %s!" %(payoff,cointype)
|
message = "you win %d %s!" %(payoff,cointype)
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue