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 |
spinners = 4 #How many spinners on the slotmachine? |
27 |
|
28 |
Slots=CFGamble.SlotMachine(slotname,slotlist,minpot,maxpot) |
29 |
|
30 |
object = activator.CheckInventory(cointype) |
31 |
if (object): |
32 |
pay = CFItemBroker.Item(object).subtract(cost) |
33 |
if (pay): |
34 |
Slots.placebet(cost) |
35 |
results = Slots.spin(spinners) |
36 |
pay = 0 |
37 |
pot = Slots.checkslot() |
38 |
activator.Write('%s' %results, 7) |
39 |
for item in results: |
40 |
#match all but one - pays out by coin e.g 3 to 1 or 4 to 1 |
41 |
if results.count(item) == spinners-1: |
42 |
if item == "Silver": |
43 |
pay = 1 |
44 |
elif item == "Gold": |
45 |
pay = 2 |
46 |
elif item == "Platinum": |
47 |
pay = 3 |
48 |
elif item == "Sapphire": |
49 |
pay = 4 |
50 |
elif item == "Emerald": |
51 |
pay = 5 |
52 |
elif item == "Ruby": |
53 |
pay = 6 |
54 |
elif item == "Diamond": |
55 |
pay = 10 |
56 |
elif item == "Jackpot": |
57 |
pay = 15 |
58 |
else: |
59 |
break |
60 |
activator.Write("%d %ss, a minor win!" %(spinners-1,item)) |
61 |
payoff = cost*pay |
62 |
Slots.payoff(payoff) |
63 |
id = activator.Map.CreateObject(cointype, x, y) |
64 |
CFItemBroker.Item(id).add(payoff) |
65 |
if payoff == 1: |
66 |
message = "you win %d %s!" %(payoff,cointype) |
67 |
else: |
68 |
message = "You win %d %ss!!" %(payoff,cointype) |
69 |
break |
70 |
elif results.count(item) == spinners: |
71 |
#all match - pays out as percent of pot |
72 |
activator.Write('%d %ss, a Major win!' %(spinners,item)) |
73 |
if item == "Silver": |
74 |
pay = .1 |
75 |
elif item == "Gold": |
76 |
pay = .15 |
77 |
elif item == "Platinum": |
78 |
pay = .25 |
79 |
elif item == "Sapphire": |
80 |
pay = .3 |
81 |
elif item == "Emerald": |
82 |
pay = .4 |
83 |
elif item == "Ruby": |
84 |
pay = .5 |
85 |
elif item == "Diamond": |
86 |
pay = .6 |
87 |
elif item == "JackPot": |
88 |
pay = 1 |
89 |
payoff = pot*pay |
90 |
Slots.payoff(payoff) |
91 |
id = activator.Map.CreateObject(cointype, x, y) |
92 |
CFItemBroker.Item(id).add(payoff) |
93 |
if payoff == 1: |
94 |
message = "you win %d %s!" %(payoff,cointype) |
95 |
else: |
96 |
message = "You win %d %ss!!" %(payoff,cointype) |
97 |
break |
98 |
else: |
99 |
message = "Better luck next time!" |
100 |
activator.Write(message) |
101 |
activator.Write("%d in the Jackpot, Play again?" %Slots.checkslot()) |
102 |
else: |
103 |
activator.Write("Sorry, you do not have enough %ss" %(cointype)) |
104 |
else: |
105 |
activator.Write("Sorry, you do not have any %ss" %(cointype)) |