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