diff --git a/python/CFItemBroker.py b/python/CFItemBroker.py new file mode 100644 index 000000000..3379d3411 --- /dev/null +++ b/python/CFItemBroker.py @@ -0,0 +1,32 @@ +#CFItemBroker.py +#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 +#an inventory check) +#This will not check for the existance of an item as that would better +#be done in the calling script so you can be flexable. +# +#ToddMitchell + +import CFPython + +class ItemBroker: + + def __init__(self, object): + self.object = object + self.numberof = CFPython.GetQuantity(self.object) + + def add(self, number): + tmp = self.numberof + number + CFPython.SetQuantity(self.object, tmp) + return 1 + + def subtract(self, number): + remainder = self.numberof - number + if remainder >= number: + CFPython.SetQuantity(self.object, remainder) + return 1 + elif remainder == 0: + CFPython.RemoveObject(self.object) + return 1 + else: + return 0 diff --git a/python/IPO/banksay.py b/python/IPO/banksay.py index 2f2838640..2dcd9a759 100644 --- a/python/IPO/banksay.py +++ b/python/IPO/banksay.py @@ -18,7 +18,8 @@ # # The author can be reached via e-mail at jbontje@suespammers.org # -#Updated to use new path functions in CFPython and broken and modified a bit by -Todd Mitchell +# Updated to use new path functions in CFPython and broken and +# modified a bit by -Todd Mitchell import CFPython @@ -29,6 +30,7 @@ sys.path.append('%s/%s/python' %(CFPython.GetDataDirectory(),CFPython.GetMapDire import string import random import CFBank +import CFItemBroker activator=CFPython.WhoIsActivator() activatorname=CFPython.GetName(activator) @@ -46,22 +48,26 @@ fees=(service_charge/100)+1 bank = CFBank.CFBank(bankdatabase) text = string.split(CFPython.WhatIsMessage()) -thanks_message = ['Thank you for banking the Imperial Way.', 'Thank you, please come again.',\ -'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?'] +thanks_message = ['Thank you for banking the Imperial Way.', 'Thank you, please come \ +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" \ +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?'] if text[0] == 'help' or text[0] == 'yes': message ='You can:\n-deposit,-withdraw,-balance,-exchange \ \nAll transactions are in imperial notes\n(1 : 1000 gold coins). \ - \nA service charge of %d percent will be placed on all deposits' %(service_charge) + \nA service charge of %d percent will be placed on all deposits' \ + %(service_charge) elif text[0] == 'deposit': if len(text)==2: if (CFPython.PayAmount(activator, (int(text[1])*exchange_rate)*fees)): bank.deposit(activatorname, int(text[1])) - message = '%d imperials deposited to bank account. %s' %(int(text[1]),random.choice(thanks_message)) + message = '%d imperials deposited to bank account. %s' \ + %(int(text[1]),random.choice(thanks_message)) else: message = 'You would need %d gold'%((int(text[1])*(exchange_rate/10))*fees) else: @@ -70,7 +76,8 @@ elif text[0] == 'deposit': elif text[0] == 'withdraw': if len(text)==2: if (bank.withdraw(activatorname, int(text[1]))): - message = '%d imperials withdrawn from bank account. %s' %(int(text[1]),random.choice(thanks_message)) + message = '%d imperials withdrawn from bank account. %s' \ + %(int(text[1]),random.choice(thanks_message)) id = CFPython.CreateObject('imperial', (x, y)) CFPython.SetQuantity(id, int(text[1])) else: @@ -81,23 +88,16 @@ elif text[0] == 'withdraw': elif text[0] == 'exchange': if len(text)==2: inv=CFPython.CheckInventory(activator,'imperial') - if(inv): - available = CFPython.GetQuantity(inv) - remainder = available - int(text[1]) - if remainder > int(text[1]): - CFPython.SetQuantity(inv, (available - int(text[1]))) - id = CFPython.CreateObject('platinum coin', (x, y)) - CFPython.SetQuantity(id, int(text[1])*(exchange_rate/50)) - message = random.choice(thanks_message) - elif remainder == 0: - CFPython.RemoveObject(inv) + if inv: + pay = CFItemBroker.ItemBroker(inv).subtract(int(text[1])) + if pay: id = CFPython.CreateObject('platinum coin', (x, y)) CFPython.SetQuantity(id, int(text[1])*(exchange_rate/50)) message = random.choice(thanks_message) else: message = 'Sorry, you do not have %d imperials' %int(text[1]) else: - message = 'Sorry, you do not have %d imperials' %int(text[1]) + message = 'Sorry, you do not have any imperials' else: message = 'Usage "exchange " (imperials to platimum coins)' diff --git a/python/IPO/board.py b/python/IPO/board.py index 3cd672c97..db60efbdb 100755 --- a/python/IPO/board.py +++ b/python/IPO/board.py @@ -36,6 +36,7 @@ activatorname=CFPython.GetName(activator) whoami=CFPython.WhoAmI() boardname=CFPython.GetEventOptions(whoami,6) # 6 is say event +print "Activated %s" %boardname if (boardname): diff --git a/python/casino/diamondslots.py b/python/casino/diamondslots.py new file mode 100644 index 000000000..e753a4583 --- /dev/null +++ b/python/casino/diamondslots.py @@ -0,0 +1,107 @@ +#SlotMachine configuration file +#to make a new kind of slot machine, copy this file, change the settings and point the slotmachine to the new file. +#Standard type Diamond Slots +#FYI - This one uses an object for cointype and not the money code :) + +import CFPython +import sys +sys.path.append('%s/%s/python' %(CFPython.GetDataDirectory(),CFPython.GetMapDirectory())) +import CFGamble +import CFItemBroker + +activator=CFPython.WhoIsActivator() +activatorname=CFPython.GetName(activator) +whoami=CFPython.WhoAmI() +#gets slot name and adds map name for unique jackpot +slotname= '%s#%s' %(CFPython.GetName(whoami),CFPython.GetMapPath(CFPython.GetMap(whoami))) +x=CFPython.GetXPosition(activator) +y=CFPython.GetYPosition(activator) + +cointype = "gem" #What type of coin is this slotmachine using? +minpot = 200 #Minimum slot jackpot size +maxpot = 10000 #Maxiumum slot jackpot size +cost = 1 #Price of usage + +#Change the items on the slot spinner or the number of items. +slotlist = ["Silver", "Gold", "Platinum", "Sapphire", "Emerald", "Ruby", "Diamond", "JackPot"] + +spinners = 4 #How many spinners on the slotmachine? + +Slots=CFGamble.SlotMachine(slotname,slotlist,minpot,maxpot) + +object = CFPython.CheckInventory(activator,cointype) +if (object): + pay = CFItemBroker.ItemBroker(object).subtract(cost) + if (pay): + Slots.placebet(cost) + results = Slots.spin(spinners) + pay = 0 + pot = Slots.checkslot() + CFPython.Write('%s' %results, activator, 7) + for item in results: + #match all but one - pays out by coin e.g 3 to 1 or 4 to 1 + if results.count(item) == spinners-1: + if item == "Silver": + pay = 1 + elif item == "Gold": + pay = 2 + elif item == "Platinum": + pay = 3 + elif item == "Sapphire": + pay = 4 + elif item == "Emerald": + pay = 5 + elif item == "Ruby": + pay = 6 + elif item == "Diamond": + pay = 10 + elif item == "Jackpot": + pay = 15 + else: + break + CFPython.Write("%d %ss, a minor win!" %(spinners-1,item),activator) + payoff = cost*pay + Slots.payoff(payoff) + id = CFPython.CreateObject(cointype, (x, y)) + CFPython.SetQuantity(id, payoff) + if payoff == 1: + message = "you win %d %s!" %(payoff,cointype) + else: + message = "You win %d %ss!!" %(payoff,cointype) + break + elif results.count(item) == spinners: + #all match - pays out as percent of pot + CFPython.Write('%d %ss, a Major win!' %(spinners,item),activator) + if item == "Silver": + pay = .1 + elif item == "Gold": + pay = .15 + elif item == "Platinum": + pay = .25 + elif item == "Sapphire": + pay = .3 + elif item == "Emerald": + pay = .4 + elif item == "Ruby": + pay = .5 + elif item == "Diamond": + pay = .6 + elif item == "JackPot": + pay = 1 + payoff = pot*pay + Slots.payoff(payoff) + id = CFPython.CreateObject(cointype, (x, y)) + CFPython.SetQuantity(id, payoff) + if payoff == 1: + message = "you win %d %s!" %(payoff,cointype) + else: + message = "You win %d %ss!!" %(payoff,cointype) + break + else: + message = "Better luck next time!" + CFPython.Write(message,activator) + CFPython.Write("%d in the Jackpot, Play again?" %Slots.checkslot(),activator) + else: + CFPython.Write("Sorry, you do not have enough %ss" %(cointype),activator) +else: + CFPython.Write("Sorry, you do not have any %ss" %(cointype),activator) diff --git a/python/casino/goldslots.py b/python/casino/goldslots.py index c5f292377..5b2942c9d 100644 --- a/python/casino/goldslots.py +++ b/python/casino/goldslots.py @@ -71,7 +71,7 @@ if (CFPython.PayAmount(activator, cost*10)):#goldcoin elif item == "Staff": pay = .15 elif item == "Shield": - pay = .25 + pay = .20 elif item == "Sword": pay = .25 elif item == "Wand": diff --git a/python/casino/imperialslots.py b/python/casino/imperialslots.py new file mode 100644 index 000000000..d32f9070d --- /dev/null +++ b/python/casino/imperialslots.py @@ -0,0 +1,107 @@ +#SlotMachine configuration file +#to make a new kind of slot machine, copy this file, change the settings and point the slotmachine to the new file. +#Standard type Imperial Slots +#FYI - This one uses an object for cointype and not the money code :) + +import CFPython +import sys +sys.path.append('%s/%s/python' %(CFPython.GetDataDirectory(),CFPython.GetMapDirectory())) +import CFGamble +import CFItemBroker + +activator=CFPython.WhoIsActivator() +activatorname=CFPython.GetName(activator) +whoami=CFPython.WhoAmI() +#gets slot name and adds map name for unique jackpot +slotname= '%s#%s' %(CFPython.GetName(whoami),CFPython.GetMapPath(CFPython.GetMap(whoami))) +x=CFPython.GetXPosition(activator) +y=CFPython.GetYPosition(activator) + +cointype = "imperial" #What type of coin is this slotmachine using? +minpot = 200 #Minimum slot jackpot size +maxpot = 10000 #Maxiumum slot jackpot size +cost = 1 #Price of usage + +#Change the items on the slot spinner or the number of items. +slotlist = ["Dread", "Dragon", "Knight", "Wizard", "Titan", "Septre", "Emperor", "JackPot"] + +spinners = 4 #How many spinners on the slotmachine? + +Slots=CFGamble.SlotMachine(slotname,slotlist,minpot,maxpot) + +object = CFPython.CheckInventory(activator,cointype) +if (object): + pay = CFItemBroker.ItemBroker(object).subtract(cost) + if (pay): + Slots.placebet(cost) + results = Slots.spin(spinners) + pay = 0 + pot = Slots.checkslot() + CFPython.Write('%s' %results, activator, 7) + for item in results: + #match all but one - pays out by coin e.g 3 to 1 or 4 to 1 + if results.count(item) == spinners-1: + if item == "Dread": + pay = 1 + elif item == "Dragon": + pay = 2 + elif item == "Knight": + pay = 3 + elif item == "Wizard": + pay = 4 + elif item == "Titan": + pay = 5 + elif item == "Septre": + pay = 6 + elif item == "Emperor": + pay = 10 + elif item == "Jackpot": + pay = 20 + else: + break + CFPython.Write("%d %ss, a minor win!" %(spinners-1,item),activator) + payoff = cost*pay + Slots.payoff(payoff) + id = CFPython.CreateObject(cointype, (x, y)) + CFPython.SetQuantity(id, payoff) + if payoff == 1: + message = "you win %d %s!" %(payoff,cointype) + else: + message = "You win %d %ss!!" %(payoff,cointype) + break + elif results.count(item) == spinners: + #all match - pays out as percent of pot + CFPython.Write('%d %ss, a Major win!' %(spinners,item),activator) + if item == "Dread": + pay = .1 + elif item == "Dragon": + pay = .15 + elif item == "Knight": + pay = .20 + elif item == "Wizard": + pay = .25 + elif item == "Titan": + pay = .30 + elif item == "Septre": + pay = .40 + elif item == "Emperor": + pay = .50 + elif item == "JackPot": + pay = 1 + payoff = pot*pay + Slots.payoff(payoff) + id = CFPython.CreateObject(cointype, (x, y)) + CFPython.SetQuantity(id, payoff) + if payoff == 1: + message = "you win %d %s!" %(payoff,cointype) + else: + message = "You win %d %ss!!" %(payoff,cointype) + break + else: + message = "Better luck next time!" + CFPython.Write(message,activator) + CFPython.Write("%d in the Jackpot, Play again?" %Slots.checkslot(),activator) + else: + CFPython.Write("Sorry, you do not have enough %ss" %(cointype),activator) +else: + CFPython.Write("Sorry, you do not have any %ss" %(cointype),activator) diff --git a/python/casino/platinumslots.py b/python/casino/platinumslots.py index 8bdf44eb4..3cc291966 100644 --- a/python/casino/platinumslots.py +++ b/python/casino/platinumslots.py @@ -16,7 +16,7 @@ x=CFPython.GetXPosition(activator) y=CFPython.GetYPosition(activator) cointype = "platinacoin" #What type of coin is this slotmachine using? -minpot = 300 #Minimum slot jackpot size +minpot = 200 #Minimum slot jackpot size maxpot = 100000 #Maxiumum slot jackpot size cost = 1 #Price of usage diff --git a/python/casino/silverslots.py b/python/casino/silverslots.py index 63ec8023b..690e26908 100644 --- a/python/casino/silverslots.py +++ b/python/casino/silverslots.py @@ -20,7 +20,7 @@ maxpot = 50000 #Maxiumum slot jackpot size cost = 1 #Price of usage #Change the items on the slot spinner or the number of items. -slotlist = ["Maid", "Merchant", "Coin", "Diamond", "Imp", "Devil", "JackPot"] +slotlist = ["Merchant", "Coin", "Diamond", "Imp", "Devil", "JackPot"] spinners = 4 #How many spinners on the slotmachine? @@ -36,12 +36,10 @@ if (CFPython.PayAmount(activator, cost)):#silvercoin for item in results: #match all but one - pays out by coin e.g 3 to 1 or 4 to 1 if results.count(item) == spinners-1: - if item == "Maid": + if item == "Merchant": pay = 1 - elif item == "Merchant": - pay = 2 elif item == "Coin": - pay = 3 + pay = 2 elif item == "Diamond": pay = 4 elif item == "Imp": @@ -65,16 +63,14 @@ if (CFPython.PayAmount(activator, cost)):#silvercoin elif results.count(item) == spinners: #all match - pays out as percent of pot CFPython.Write('%d %ss, a Major win!' %(spinners,item),activator) - if item == "Maid": + if item == "Merchant": pay = .10 - elif item == "Merchant": - pay = .15 elif item == "Coin": - pay = .25 + pay = .15 elif item == "Diamond": - pay = .25 + pay = .20 elif item == "Imp": - pay = .35 + pay = .30 elif item == "Devil": pay = .50 elif item == "JackPot": diff --git a/python/misc/CFInsulter.py b/python/misc/CFInsulter.py new file mode 100644 index 000000000..404300aac --- /dev/null +++ b/python/misc/CFInsulter.py @@ -0,0 +1,64 @@ +# CFInsulter.py (formerly shakeinsult.py) +# This is an adaptation of Nick Hodges' Shakspearean Insult Generator in python. +# +# "This is available under a BSD style license. Once I said I would never +# write any non-GPL stuff for fun. Oh well. Just let me know if you use it." +# http://www.zope.org/Members/tfarrell/shakeinsult +# +# +# Adapted for use in Crossfire by Todd Mitchell +# +# Please help by adding new styles of insults to this fine script. + +import CFPython +import sys +sys.path.append('%s/%s/python' %(CFPython.GetDataDirectory(),CFPython.GetMapDirectory())) +from random import choice + +def Insult(style): + +##SHAKESPEAR STYLE + + if style == "shakespear": + adj1 = ['artless', 'bawdy', 'beslubbering', 'bootless', 'churlish', 'cockered', 'clouted', 'craven', 'currish', 'dankish', 'dissembling', 'droning', 'errant', 'fawning', 'fobbing', 'froward', 'frothy', 'gleeking', 'goatish', 'gorbellied', 'impertinent', 'infectious', 'jarring', 'loggerheaded', 'lumpish', 'mammering', 'mangled', 'mewling', 'paunchy', 'pribbling', 'puking', 'puny', 'qualling', 'rank', 'reeky', 'roguish', 'ruttish', 'saucy', 'spleeny', 'spongy', 'surly', 'tottering', 'unmuzzled', 'vain', 'venomed', 'villainous', 'warped', 'wayward', 'weedy', 'yeasty', 'vomiting', 'vulturous', 'contemptuous', 'groping', 'miniscule', 'quivering', 'shivering', 'trembling', 'miserable', 'licentious', 'cowering', 'sulking', 'gloating', 'murmuring', 'audacious', 'befouling', 'insolent', 'murky', 'pitiable', 'wretched', 'dolorous', 'lamentable', 'inadequate', 'contemptible', 'paltry', 'measly', 'meager', 'paltry', 'inadequate', 'insignificant', 'empty', 'inferior', 'pathetic', 'atrocious', 'execrable', 'damnable', 'repugnant', 'repulsive', 'revolting', 'repellent', 'offensive', 'disgusting', 'horrid', 'horrible', 'obscene', 'beastly', 'vile', 'abominable', 'pitiful', 'wrangled', 'whoring'] + adj2 = ['base-court', 'bat-fowling', 'beef-witted', 'beetle-headed', 'boil-brained', 'clapper-clawed','clay-brained', 'common-kissing', 'crook-pated', 'dismal-dreaming', 'dizzy-eyed', 'doghearted', 'dread-bolted', 'earth-vexing', 'elf-skinned', 'fat-kidneyed', 'fen-sucked', 'flap-mouthed', 'fly-bitten', 'folly-fallen', 'fool-born', 'full-gorged', 'guts-griping', 'half-faced', 'hasty-witted', 'hedge-born', 'hell-hated', 'idle-headed', 'ill-breeding', 'ill-nurtured', 'knotty-pated', 'milk-livered', 'motley-minded', 'onion-eyed', 'plume-plucked', 'pottle-deep', 'pox-marked', 'reeling-ripe', 'rough-hewn', 'rude-growing', 'rump-fed', 'shard-borne', 'sheep-biting', 'spur-galled', 'swag-bellied', 'tardy-gaited', 'tickle-brained', 'toad-spotted', 'unchin-snouted', 'weather-bitten', 'weather-beaten', 'mutton-eating', 'coffee-nosed', 'malodorous'] + noun = ['apple-john', 'baggage', 'barnacle', 'bladder', 'boar-pig', 'bugbear', 'bum-bailey', 'canker-blossom', 'clack-dish', 'clotpole', 'coxcomb', 'codpiece', 'death-token', 'dewberry', 'flap-dragon', 'flax-wench', 'flirt-gill', 'foot-licker', 'fustilarian', 'giglet', 'gudgeon', 'haggard', 'harpy', 'hedge-pig', 'horn-beast', 'hugger-mugger', 'joithead', 'lewdster', 'lout', 'maggot-pie', 'malt-worm', 'mammet', 'measle', 'minnow', 'miscreant', 'moldwarp', 'mumble-news', 'nut-hook', 'pigeon-egg', 'pignut', 'puttock', 'pumpion', 'ratsbane', 'scut', 'skainsmate', 'strumpet', 'varlet', 'vassal', 'whey-face', 'wagtail', 'phlegm-barrel', 'numb-skull', 'lip-infection', 'blood-clot', 'boar-tick', 'pervert'] + prefixA = ['Thou art a','Thy Mother is a', 'Thou'] + prefixAn = ['Thou art an', 'Thy Mother is an', 'Thou'] + +##TEXAS STYLE + + elif style == "texas": + adj1 = ['stewpid', 'uglee', 'pea brained', 'dung-headed', 'hatless', 'witless', 'dumb'] + adj2 = ['horse-knappin', 'hog-licking', 'knock-kneed', 'brown-nosed', 'lilly-livered' ] + noun = ['dipshit', 'city-slicker', 'root-head', 'cow-pie', 'greenhorn', 'idgit'] + prefixA = ['Yer a','Yer Mama\'s a', 'Yew'] + prefixAn = ['Yer a', 'Yer Mama\'s a', 'Yew'] + +##NO STYLE + else: + return "No such style stupid." + + vowels = ['a', 'e', 'i', 'o', 'u'] + isvowel = 0 + + rnoun = choice(noun) + radj1 = choice(adj1) + radj2 = choice(adj2) + + for letter in vowels: + if (radj1[0] == letter): + rprefix = choice(prefixAn) + isvowel = 1 + if (isvowel == 0): + rprefix = choice(prefixA) + insult = "%s %s %s %s!" % (rprefix, radj1, radj2, rnoun) + return insult + + +activator=CFPython.WhoIsActivator() +whoami=CFPython.WhoAmI() +#style of insult desired to hurl in event options +style = CFPython.GetEventOptions(whoami,1) # 1 is apply event + +CFPython.Write(Insult(style),activator) \ No newline at end of file