ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cf.schmorp.de/maps/python/casino/silverslots.py
Revision: 1.1.1.1 (vendor branch)
Committed: Sun Feb 5 00:02:09 2006 UTC (18 years, 10 months ago) by root
Content type: text/x-python
Branch: UPSTREAM, MAIN
CVS Tags: post_fixaltar, last_stable, post_fixaltar2, rel-2_82, rel-2_81, rel-2_80, pre_coinconvert, UPSTREAM_2006_03_15, rel-3_0, rel-2_6, rel-2_7, rel-2_4, rel-2_5, rel-2_2, rel-2_0, rel-2_1, rel-2_72, rel-2_73, rel-2_71, rel-2_76, rel-2_77, rel-2_74, rel-2_75, rel-2_54, rel-2_55, rel-2_56, rel-2_79, UPSTREAM_2006_02_01, rel-2_53, pre_material_cfarch_normalize_run, rel-2_32, pre_fixconverter, post_coinconvert, pre_fixaltar2, pre_map_rename, UPSTREAM_2006_02_22, rel-2_90, rel-2_92, rel-2_93, rel-2_78, post_fixconverter, pre_fixaltar, rel-2_61, rel-2_43, rel-2_42, rel-2_41, HEAD
Changes since 1.1: +0 -0 lines
Log Message:
Initial Import

File Contents

# Content
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")