Debian Codegraph @

python/casino/silverslots.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
4 import Crossfire
5 import CFGamble
6 import CFItemBroker
7
8 activator=Crossfire.WhoIsActivator()
9 activatorname=activator.Name
10 whoami=Crossfire.WhoAmI()
11 #gets slot name and adds map name for unique jackpot
12 slotname= '%s#%s' %(whoami.Name,whoami.Map.Path)
13 x=activator.X
14 y=activator.Y
15
16 cointype = "silvercoin" #What type of coin is this slotmachine using?
17 minpot = 100 #Minimum slot jackpot size
18 maxpot = 50000 #Maxiumum slot jackpot size
19 cost = 1 #Price of usage
20
21 #Change the items on the slot spinner or the number of items.
22 slotlist = ["Merchant", "Coin", "Diamond", "Imp", "Devil", "JackPot"]
23
24 #Pay for minor and major wins.
25 #Major as percent of pot. Minor as how many times cost.
26 slotminor = [1, 2, 4, 5, 10, 20]
27 slotmajor = [.10, .15, .20, .30, .5, 1]
28
29 spinners = 4 #How many spinners on the slotmachine?
30
31
32 Slots=CFGamble.SlotMachine(slotname,slotlist,minpot,maxpot)
33
34 if (activator.PayAmount(cost)):#silvercoin
35 Slots.placebet(cost)
36 results = Slots.spin(spinners)
37 pay = 0
38 pot = Slots.checkslot()
39 activator.Write('%s' %results, 7)
40 for item in results:
41 #match all but one - pays out by coin e.g 3 to 1 or 4 to 1
42 if results.count(item) == spinners-1:
43 if item in slotlist:
44 pay = slotminor[slotlist.index(item)]
45 else:
46 break
47 activator.Write("%d %ss, a minor win!" %(spinners-1,item))
48 payoff = cost*pay
49 Slots.payoff(payoff)
50 id = Crossfire.CreateObjectByName(cointype)
51 id.Quantity = payoff
52 id.InsertInto(activator)
53 if payoff == 1:
54 message = "you win %d %s!" %(payoff,cointype)
55 else:
56 message = "You win %d %ss!!" %(payoff,cointype)
57 break
58 elif results.count(item) == spinners:
59 #all match - pays out as percent of pot
60 activator.Write('%d %ss, a Major win!' %(spinners,item))
61 if item in slotlist:
62 pay = slotmajor[slotlist.index(item)]
63 else:
64 break
65 payoff = int(pot*pay)
66 Slots.payoff(payoff)
67 id = Crossfire.CreateObjectByName(cointype)
68 id.Quantity = payoff
69 id.InsertInto(activator)
70 if payoff == 1:
71 message = "you win %d %s!" %(payoff,cointype)
72 else:
73 message = "You win %d %ss!!" %(payoff,cointype)
74 break
75 else:
76 message = "Better luck next time!"
77 activator.Write(message)
78 activator.Write("%d in the Jackpot, Play again?" %Slots.checkslot())
79 else:
80 activator.Write("Sorry, you do not have enough money")