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 |
spinners = 4 #How many spinners on the slotmachine? |
25 |
|
26 |
|
27 |
Slots=CFGamble.SlotMachine(slotname,slotlist,minpot,maxpot) |
28 |
|
29 |
if (activator.PayAmount(cost)):#silvercoin |
30 |
Slots.placebet(cost) |
31 |
results = Slots.spin(spinners) |
32 |
pay = 0 |
33 |
pot = Slots.checkslot() |
34 |
activator.Write('%s' %results, 7) |
35 |
for item in results: |
36 |
#match all but one - pays out by coin e.g 3 to 1 or 4 to 1 |
37 |
if results.count(item) == spinners-1: |
38 |
if item == "Merchant": |
39 |
pay = 1 |
40 |
elif item == "Coin": |
41 |
pay = 2 |
42 |
elif item == "Diamond": |
43 |
pay = 4 |
44 |
elif item == "Imp": |
45 |
pay = 5 |
46 |
elif item == "Devil": |
47 |
pay = 10 |
48 |
elif item == "JackPot": |
49 |
pay = 20 |
50 |
else: |
51 |
break |
52 |
activator.Write("%d %ss, a minor win!" %(spinners-1,item)) |
53 |
payoff = cost*pay |
54 |
Slots.payoff(payoff) |
55 |
id = activator.Map.CreateObject(cointype, x, y) |
56 |
CFItemBroker.Item(id).add(payoff) |
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 == "Merchant": |
66 |
pay = .10 |
67 |
elif item == "Coin": |
68 |
pay = .15 |
69 |
elif item == "Diamond": |
70 |
pay = .20 |
71 |
elif item == "Imp": |
72 |
pay = .30 |
73 |
elif item == "Devil": |
74 |
pay = .50 |
75 |
elif item == "JackPot": |
76 |
pay = 1 |
77 |
payoff = pot*pay |
78 |
Slots.payoff(payoff) |
79 |
id = activator.Map.CreateObject(cointype, x, y) |
80 |
CFItemBroker.Item(id).add(payoff) |
81 |
if payoff == 1: |
82 |
message = "you win %d %s!" %(payoff,cointype) |
83 |
else: |
84 |
message = "You win %d %ss!!" %(payoff,cointype) |
85 |
break |
86 |
else: |
87 |
message = "Better luck next time!" |
88 |
activator.Write(message) |
89 |
activator.Write("%d in the Jackpot, Play again?" %Slots.checkslot()) |
90 |
else: |
91 |
activator.Write("Sorry, you do not have enough money") |