Debian Codegraph @

python/casino/imperialslots.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 Imperial 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 = "imperial" #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 = ["Dread", "Dragon", "Knight", "Wizard", "Titan", "Septre", "Emperor", "JackPot"]
25
26 #Pay for minor and major wins.
27 #Major as percent of pot. Minor as how many times cost
28 slotminor = [1, 2, 3, 4, 5, 6, 10, 20]
29 slotmajor = [.1, .15, .20, .25, .30, .40, .50, 1]
30
31 spinners = 4 #How many spinners on the slotmachine?
32
33 Slots=CFGamble.SlotMachine(slotname,slotlist,minpot,maxpot)
34
35 object = activator.CheckInventory(cointype)
36 if (object) and not object.Unpaid:
37 pay = CFItemBroker.Item(object).subtract(cost)
38 if (pay):
39 Slots.placebet(cost)
40 results = Slots.spin(spinners)
41 pay = 0
42 pot = Slots.checkslot()
43 activator.Write('%s' %results, 7)
44 for item in results:
45 #match all but one - pays out by coin e.g 3 to 1 or 4 to 1
46 if results.count(item) == spinners-1:
47 if item in slotlist:
48 pay = slotminor[slotlist.index(item)]
49 else:
50 break
51 activator.Write("%d %ss, a minor win!" %(spinners-1,item))
52 payoff = cost*pay
53 Slots.payoff(payoff)
54 id = Crossfire.CreateObjectByName(cointype)
55 id.Quantity = payoff
56 id.InsertInto(activator)
57 if payoff == 1:
58 message = "you win %d %s!" %(payoff,cointype)
59 else:
60 message = "You win %d %ss!!" %(payoff,cointype)
61 break
62 elif results.count(item) == spinners:
63 #all match - pays out as percent of pot
64 activator.Write('%d %ss, a Major win!' %(spinners,item))
65 if item in slotlist:
66 pay = slotmajor[slotlist.index(item)]
67 else:
68 break
69 payoff = int(pot*pay)
70 Slots.payoff(payoff)
71 id = Crossfire.CreateObjectByName(cointype)
72 id.Quantity = payoff
73 id.InsertInto(activator)
74 if payoff == 1:
75 message = "you win %d %s!" %(payoff,cointype)
76 else:
77 message = "You win %d %ss!!" %(payoff,cointype)
78 break
79 else:
80 message = "Better luck next time!"
81 activator.Write(message)
82 activator.Write("%d in the Jackpot, Play again?" %Slots.checkslot())
83 else:
84 activator.Write("Sorry, you do not have enough %ss" %(cointype))
85 else:
86 activator.Write("Sorry, you do not have any %ss" %(cointype))