Debian Codegraph @

python/casino/diamondslots.py

raw
1 #SlotMachine configuration file
2 #to make a new kind of slot machine, copy this file, change the settings and point the slotmachine to the new file.
3 #Standard type Diamond Slots
4 #FYI - This one uses an object for cointype and not the money code :)
5
6 import Crossfire
7 import CFGamble
8 import CFItemBroker
9
10 activator=Crossfire.WhoIsActivator()
11 activatorname=activator.Name
12 whoami=Crossfire.WhoAmI()
13 #gets slot name and adds map name for unique jackpot
14 slotname= '%s#%s' %(whoami.Name,whoami.Map.Path)
15 x=activator.X
16 y=activator.Y
17
18 cointype = "gem" #What type of coin is this slotmachine using?
19 minpot = 200 #Minimum slot jackpot size
20 maxpot = 10000 #Maxiumum slot jackpot size
21 cost = 1 #Price of usage
22
23 #Change the items on the slot spinner or the number of items.
24 slotlist = ["Silver", "Gold", "Platinum", "Sapphire", "Emerald", "Ruby", "Diamond", "JackPot"]
25
26 #Major as percent of pot. Minor as how many times cost
27 slotminor = [1, 2, 3, 4, 5, 6, 10, 15]
28 slotmajor = [.1, .15, .25, .30, .40, .50, .60, 1]
29
30 spinners = 4 #How many spinners on the slotmachine?
31
32 Slots=CFGamble.SlotMachine(slotname,slotlist,minpot,maxpot)
33
34 object = activator.CheckInventory(cointype)
35 if (object) and not object.Unpaid:
36 pay = CFItemBroker.Item(object).subtract(cost)
37 if (pay):
38 Slots.placebet(cost)
39 results = Slots.spin(spinners)
40 pay = 0
41 pot = Slots.checkslot()
42 activator.Write('%s' %results, 7)
43 for item in results:
44 #match all but one - pays out by coin e.g 3 to 1 or 4 to 1
45 if results.count(item) == spinners-1:
46 if item in slotlist:
47 pay = slotminor[slotlist.index(item)]
48 else:
49 break
50 activator.Write("%d %ss, a minor win!" %(spinners-1,item))
51 payoff = cost*pay
52 Slots.payoff(payoff)
53 id = Crossfire.CreateObjectByName(cointype)
54 id.Quantity = payoff
55 id.InsertInto(activator)
56 if payoff == 1:
57 message = "you win %d %s!" %(payoff,cointype)
58 else:
59 message = "You win %d %ss!!" %(payoff,cointype)
60 break
61 elif results.count(item) == spinners:
62 #all match - pays out as percent of pot
63 activator.Write('%d %ss, a Major win!' %(spinners,item))
64 if item in slotlist:
65 pay = slotmajor[slotlist.index(item)]
66 else:
67 break
68 payoff = int(pot*pay)
69 Slots.payoff(payoff)
70 id = Crossfire.CreateObjectByName(cointype)
71 id.Quantity = payoff
72 id.InsertInto(activator)
73 if payoff == 1:
74 message = "you win %d %s!" %(payoff,cointype)
75 else:
76 message = "You win %d %ss!!" %(payoff,cointype)
77 break
78 else:
79 message = "Better luck next time!"
80 activator.Write(message)
81 activator.Write("%d in the Jackpot, Play again?" %Slots.checkslot())
82 else:
83 activator.Write("Sorry, you do not have enough %ss" %(cointype))
84 else:
85 activator.Write("Sorry, you do not have any %ss" %(cointype))