Esempio n. 1
0
def cmd_withdraw(argv):
    """Withdraw money from the player's account."""
    if len(argv) >= 3:
        coinName = getCoinNameFromArgs(argv[2:])
        exchange_rate = getExchangeRate(coinName)
        amount = int(argv[1])
        if exchange_rate is None:
            whoami.Say("Hmm... I've never seen that kind of money.")
            return
        if amount <= 0:
            whoami.Say("Sorry, you can't withdraw that amount.")
            return

        # Make sure the player has sufficient funds.
        with CFBank.open() as bank:
            if bank.withdraw(activator.Name, amount * exchange_rate):
                message = "%d %s withdrawn from your account. %s" \
                        % (amount, coinName, random.choice(thanks_message))

                # Drop the money and have the player pick it up.
                withdrawal = activator.Map.CreateObject(
                    ArchType.get(coinName.upper()), x, y)
                CFItemBroker.Item(withdrawal).add(amount)
                activator.Take(withdrawal)
            else:
                message = "I'm sorry, you don't have enough money."
    else:
        message = "How much money would you like to withdraw?"
        Crossfire.AddReply("withdraw <amount> <coin name>", "This much!")

    whoami.Say(message)
Esempio n. 2
0
    def do_withdraw(self, text):
        if (not activator.DungeonMaster == 1
                and not CheckClearance([self.guildname, "Master"], activator)):
            whoami.Say(
                "Only guild masters, masters, and DMs can withdraw funds from the guild."
            )
            return

        try:
            Amount = int(text[1])
        except:
            whoami.Say("Usage: withdraw <quantity> {cointype=silver}")
            return

        bank = CFBank.CFBank(bankdatabase)
        balance = bank.getbalance(self.accountname)

        if len(text) > 2:
            Type = ' '.join(text[2:])
        else:
            Type = "silver"

        if not Type.upper() in CoinTypes.keys():
            whoami.Say("Sorry, I have no clue what %s are" % Type)
            return

        Value = CoinTypes.get(Type.upper())

        if Amount * Value <= balance:
            message = (str(Amount))
            message += " " + Type + " withdrawn.\nYour new present balance is "

            id = activator.CreateObject(ArchType.get(Type.upper()))
            CFItemBroker.Item(id).add(Amount)
            bank.withdraw(self.accountname, Amount * Value)
            message += formatted_amount(bank.getbalance(
                self.accountname)) + "."
            whoami.Say(message)
        else:
            message = "You only have " + formatted_amount(
                bank.getbalance(self.accountname)) + " on your account."
            whoami.Say(message)
Esempio n. 3
0
    "Dread", "Dragon", "Knight", "Wizard", "Titan", "Septre", "Emperor",
    "JackPot"
]

#Pay for minor and major wins.
#Major as percent of pot. Minor as how many times cost
slotminor = [1, 2, 3, 4, 5, 6, 10, 20]
slotmajor = [.1, .15, .20, .25, .30, .40, .50, 1]

spinners = 4  #How many spinners on the slotmachine?

Slots = CFGamble.SlotMachine(slotname, slotlist, minpot, maxpot)

object = activator.CheckInventory(cointype)
if (object) and not object.Unpaid:
    pay = CFItemBroker.Item(object).subtract(cost)
    if (pay):
        Slots.placebet(cost)
        results = Slots.spin(spinners)
        pay = 0
        pot = Slots.checkslot()
        activator.Write('%s' % results, 7)
        for item in results:
            #match all but one - pays out by coin e.g 3 to 1 or 4 to 1
            if results.count(item) == spinners - 1:
                if item in slotlist:
                    pay = slotminor[slotlist.index(item)]
                else:
                    break
                activator.Write("%d %ss, a minor win!" % (spinners - 1, item))
                payoff = cost * pay
Esempio n. 4
0
cointype = "recatokn" #What type of coin is this slotmachine using?
coinname = "Red Casino Token"
minpot = 200 #Minimum slot jackpot size
maxpot = 10000 #Maxiumum slot jackpot size
cost = 1 #Price of usage

#Change the items on the slot spinner or the number of items.
slotlist = ["Dread", "Dragon", "Knight", "Wizard", "Titan", "Septre", "BlueToken", "RedToken"]

spinners = 4 #How many spinners on the slotmachine?

Slots=CFGamble.SlotMachine(slotname,slotlist,minpot,maxpot)

object = activator.CheckInventory(cointype)
if (object):
    pay = CFItemBroker.Item(object).subtract(cost)
    if (pay):
       Slots.placebet(cost)
       results = Slots.spin(spinners)
       pay = 0
       pot = Slots.checkslot()
       activator.Write('%s' %results, 7)
       for item in results:
          #match all but one - pays out by coin e.g 3 to 1 or 4 to 1
          if results.count(item) == spinners-1:
             if item == "Dread":
                pay = 1
             elif item == "Dragon":
                pay = 2
             elif item == "Knight":
                pay = 3
Esempio n. 5
0
                (amount * (exchange_rate / 10)) * fees)
    else:
        message = 'Usage "deposit <amount in Imperial Stock Certificates>"'

elif text[0] == 'withdraw':
    if len(text) == 2:
        amount = int(text[1])
        if amount <= 0:
            message = 'Usage "withdraw <amount in Imperial Stock Certificates>"'
        elif amount > 10000:
            message = 'Sorry, we do not accept more than 10000 Imperial Stock Certificates for one withdraw.'
        elif bank.withdraw(activatorname, amount):
            message = '%d Imperial Stock Certificates withdrawn from broker account. %s' \
            %(amount, random.choice(thanks_message))
            id = activator.Map.CreateObject('istock', x, y)
            CFItemBroker.Item(id).add(amount)
            activator.Take(id)
        else:
            message = 'Not enough Imperial Stock Certificates on your account'
    else:
        message = 'Usage "withdraw <amount in Imperial Stock Certificates>"'

elif text[0] == 'exchange':
    if len(text) == 2:
        amount = int(text[1])
        if amount <= 0:
            message = 'Usage "exchange <amount>" (Imperial Stock Certificates to platinum coins)'
        elif amount > 10000:
            message = 'Sorry, we do not exchange more than 10000 Imperial Stock Certificates all at once.'
        else:
            inv = activator.CheckInventory('istock')
Esempio n. 6
0
         pay = 2
     elif item == "Star":
         pay = 4
     elif item == "Light":
         pay = 5
     elif item == "SilveR":
         pay = 15
     elif item == "SiLvErStAr!":
         pay = 30
     else:
         break
     activator.Write("%d %ss, a minor win!" % (spinners - 1, item))
     payoff = cost * pay
     Slots.payoff(payoff)
     id = activator.Map.CreateObject(cointype, x, y)
     CFItemBroker.Item(id).add(payoff)
     if payoff == 1:
         message = "you win %d %s!" % (payoff, cointype)
     else:
         message = "You win %d %ss!!" % (payoff, cointype)
     break
 elif results.count(item) == spinners:
     #all match - pays out as percent of pot
     activator.Write('%d %ss, a Major win!' % (spinners, item))
     if item == "moon":
         pay = .10
     elif item == "sun":
         pay = .15
     elif item == "Star":
         pay = .20
     elif item == "Light":