Esempio n. 1
0
 def make_textbox(self):
     rect = (self.screen_rect.centerx - 200, self.screen_rect.top + 600,
             400, 200)
     self.textbox = TextBox(rect,
                            outline_color=pg.Color("white"),
                            color=pg.Color("blue2"),
                            font=pg.font.Font(self.font, 36),
                            font_color=pg.Color("white"))
     self.textbox.accepted = string.digits
     self.dollar_sign = Label(self.font, 36, "$", "white",
                              {"midright": (rect[0] - 5, rect[1] + 100)})
     self.textbox.update()
Esempio n. 2
0
 def setup_debug_entry(self):
     self.debug_lbl = Label(self.font, self.font_size, '6 6', "gold3",
                            {"center": (750, 950)})
     settings = {
         "command": self.debug_roll,
         "inactive_on_enter": False,
         'active': False
     }
     self.widgets.append(TextBox((700, 1000, 150, 30), **settings))
Esempio n. 3
0
 def make_textbox(self):
     rect = (self.screen_rect.centerx - 200, self.screen_rect.top + 600, 400, 200)
     self.textbox = TextBox(
         rect,
         outline_color=pg.Color("white"),
         color=pg.Color("blue2"),
         font=pg.font.Font(self.font, 36),
         font_color=pg.Color("white"),
     )
     self.textbox.accepted = string.digits
     self.dollar_sign = Label(self.font, 36, "$", "white", {"midright": (rect[0] - 5, rect[1] + 100)})
     self.textbox.update()
Esempio n. 4
0
class AdvanceScreen(ATMState):
    def __init__(self):
        super(AdvanceScreen, self).__init__()
        self.make_textbox()
        self.title = Label(
            self.font,
            36,
            "Enter Cash Advance Amount",
            "white",
            {"midtop": (self.screen_rect.centerx, self.screen_rect.top + 300)},
        )
        self.make_enter_button()

    def make_dynamic_labels(self, player):
        text = "The maximum advance is ${:.2f}".format(player.account.max_advance)
        dyna1 = Label(self.font, 36, text, "white", {"midtop": (self.screen_rect.centerx, self.screen_rect.top + 80)})
        fee_text = "A {}% fee will be added to the advance amount".format(player.account.lending_rate * 100)
        dyna2 = Label(self.font, 36, fee_text, "white", {"midtop": (self.screen_rect.centerx, dyna1.rect.bottom + 10)})
        self.dynamic_labels = [dyna1, dyna2]

    def make_enter_button(self):
        self.button_labels = []
        self.buttons = ButtonGroup()
        Button(((1278, 840), (88, 65)), self.buttons, bindings=[pg.K_RETURN])
        rect_pos = {"midright": (1251, 872)}
        label = Label(self.font, 36, "Enter", "white", rect_pos, bg="blue2")
        self.button_labels.append(label)

    def make_textbox(self):
        rect = (self.screen_rect.centerx - 200, self.screen_rect.top + 600, 400, 200)
        self.textbox = TextBox(
            rect,
            outline_color=pg.Color("white"),
            color=pg.Color("blue2"),
            font=pg.font.Font(self.font, 36),
            font_color=pg.Color("white"),
        )
        self.textbox.accepted = string.digits
        self.dollar_sign = Label(self.font, 36, "$", "white", {"midright": (rect[0] - 5, rect[1] + 100)})
        self.textbox.update()

    def leave_message(self, msg):
        self.make_textbox()
        self.beep()
        self.persist["message"] = msg
        self.next = "MESSAGESCREEN"
        self.done = True

    def back_to_menu(self):
        self.beep()
        self.next = "MAINMENU"
        self.done = True

    def get_event(self, event, scale):
        self.textbox.get_event(event, tools.scaled_mouse_pos(scale))
        self.buttons.get_event(event)
        if event.type == pg.QUIT:
            self.back_to_menu()
        elif event.type == pg.KEYUP:
            if event.key == pg.K_ESCAPE:
                self.back_to_menu()

    def update(self, surface, keys, current, dt, scale, player):
        self.textbox.update()
        if not self.textbox.active:
            self.beep()
            try:
                amount = int(self.textbox.final)
            except ValueError:
                amount = 0
            if amount > player.account.max_advance:
                amount = 0
                self.leave_message("You are not authorized for this amount")
            else:
                player.account.cash_advance(amount)
                player.cash += amount
                msg = "${:.2f} Dispensed".format(amount)
                self.leave_message(msg)
        self.buttons.update(tools.scaled_mouse_pos(scale))
        self.make_dynamic_labels(player)
        self.draw(surface)

    def draw(self, surface):
        surface.fill(pg.Color("blue2"))
        self.title.draw(surface)
        self.dollar_sign.draw(surface)
        self.textbox.draw(surface)
        for label in self.dynamic_labels:
            label.draw(surface)
        for b_label in self.button_labels:
            b_label.draw(surface)
Esempio n. 5
0
class WithdrawalScreen(ATMState):
    def __init__(self):
        super(WithdrawalScreen, self).__init__()
        self.title = Label(
            self.font,
            36,
            "Enter Withdrawal Amount",
            "white",
            {"midtop": (self.screen_rect.centerx, self.screen_rect.top + 300)},
        )

        self.make_textbox()
        self.make_enter_button()

    def make_enter_button(self):
        self.buttons = ButtonGroup()
        self.labels = []
        Button(((1278, 840), (88, 65)), self.buttons, bindings=[pg.K_RETURN])
        rect_pos = {"midright": (1251, 872)}
        label = Label(self.font, 36, "Enter", "white", rect_pos, bg="blue2")
        self.labels.append(label)

    def make_textbox(self):
        rect = (self.screen_rect.centerx - 200, self.screen_rect.top + 600, 400, 200)
        self.textbox = TextBox(
            rect,
            outline_color=pg.Color("white"),
            color=pg.Color("blue2"),
            font=pg.font.Font(self.font, 36),
            font_color=pg.Color("white"),
        )
        self.textbox.accepted = string.digits
        self.dollar_sign = Label(self.font, 36, "$", "white", {"midright": (rect[0] - 5, rect[1] + 100)})
        # update needed to set textbox.render_area
        self.textbox.update()

    def leave_message(self, msg):
        self.make_textbox()
        self.persist["message"] = msg
        self.next = "MESSAGESCREEN"
        self.done = True

    def back_to_menu(self):
        self.beep()
        self.next = "MAINMENU"
        self.done = True

    def get_event(self, event, scale):
        self.textbox.get_event(event, tools.scaled_mouse_pos(scale))
        self.buttons.get_event(event)
        if event.type == pg.QUIT:
            self.back_to_menu()
        elif event.type == pg.KEYUP:
            if event.key == pg.K_ESCAPE:
                self.back_to_menu()

    def update(self, surface, keys, current, dt, scale, player):
        self.textbox.update()
        if not self.textbox.active:
            self.beep()
            try:
                amount = int(self.textbox.final)
            except ValueError:
                amount = 0
            if player.account.balance >= amount:
                player.account.withdrawal(amount)
                player.cash += amount
                self.leave_message("${:.2f} Withdrawn".format(amount))
            else:
                msg = "Insufficient Funds for Withdrawal"
                self.leave_message(msg)
        self.buttons.update(tools.scaled_mouse_pos(scale))
        text = "You have ${:.2f} available for withdrawal".format(player.account.balance)
        self.dyna_label = Label(
            self.font, 36, text, "white", {"midtop": (self.screen_rect.centerx, self.screen_rect.top + 80)}
        )
        self.draw(surface)

    def draw(self, surface):
        surface.fill(pg.Color("blue2"))
        self.title.draw(surface)
        self.dollar_sign.draw(surface)
        self.textbox.draw(surface)
        for label in self.labels:
            label.draw(surface)
        self.dyna_label.draw(surface)
Esempio n. 6
0
class AdvanceScreen(ATMState):
    def __init__(self):
        super(AdvanceScreen, self).__init__()
        self.make_textbox()
        self.title = Label(
            self.font, 36, "Enter Cash Advance Amount", "white",
            {"midtop": (self.screen_rect.centerx, self.screen_rect.top + 300)})
        self.make_enter_button()

    def make_dynamic_labels(self, player):
        text = "The maximum advance is ${:.2f}".format(
            player.account.max_advance)
        dyna1 = Label(
            self.font, 36, text, "white",
            {"midtop": (self.screen_rect.centerx, self.screen_rect.top + 80)})
        fee_text = "A {}% fee will be added to the advance amount".format(
            player.account.lending_rate * 100)
        dyna2 = Label(
            self.font, 36, fee_text, "white",
            {"midtop": (self.screen_rect.centerx, dyna1.rect.bottom + 10)})
        self.dynamic_labels = [dyna1, dyna2]

    def make_enter_button(self):
        self.button_labels = []
        self.buttons = ButtonGroup()
        Button(((1278, 840), (88, 65)), self.buttons, bindings=[pg.K_RETURN])
        rect_pos = {"midright": (1251, 872)}
        label = Label(self.font, 36, "Enter", "white", rect_pos, bg="blue2")
        self.button_labels.append(label)

    def make_textbox(self):
        rect = (self.screen_rect.centerx - 200, self.screen_rect.top + 600,
                400, 200)
        self.textbox = TextBox(rect,
                               outline_color=pg.Color("white"),
                               color=pg.Color("blue2"),
                               font=pg.font.Font(self.font, 36),
                               font_color=pg.Color("white"))
        self.textbox.accepted = string.digits
        self.dollar_sign = Label(self.font, 36, "$", "white",
                                 {"midright": (rect[0] - 5, rect[1] + 100)})
        self.textbox.update()

    def leave_message(self, msg):
        self.make_textbox()
        self.beep()
        self.persist["message"] = msg
        self.next = "MESSAGESCREEN"
        self.done = True

    def back_to_menu(self):
        self.beep()
        self.next = "MAINMENU"
        self.done = True

    def get_event(self, event, scale):
        self.textbox.get_event(event, tools.scaled_mouse_pos(scale))
        self.buttons.get_event(event)
        if event.type == pg.QUIT:
            self.back_to_menu()
        elif event.type == pg.KEYUP:
            if event.key == pg.K_ESCAPE:
                self.back_to_menu()

    def update(self, surface, keys, current, dt, scale, player):
        self.textbox.update()
        if not self.textbox.active:
            self.beep()
            try:
                amount = int(self.textbox.final)
            except ValueError:
                amount = 0
            if amount > player.account.max_advance:
                amount = 0
                self.leave_message("You are not authorized for this amount")
            else:
                player.account.cash_advance(amount)
                player.cash += amount
                msg = "${:.2f} Dispensed".format(amount)
                self.leave_message(msg)
        self.buttons.update(tools.scaled_mouse_pos(scale))
        self.make_dynamic_labels(player)
        self.draw(surface)

    def draw(self, surface):
        surface.fill(pg.Color("blue2"))
        self.title.draw(surface)
        self.dollar_sign.draw(surface)
        self.textbox.draw(surface)
        for label in self.dynamic_labels:
            label.draw(surface)
        for b_label in self.button_labels:
            b_label.draw(surface)
Esempio n. 7
0
class WithdrawalScreen(ATMState):
    def __init__(self):
        super(WithdrawalScreen, self).__init__()
        self.title = Label(
            self.font, 36, "Enter Withdrawal Amount", "white",
            {"midtop": (self.screen_rect.centerx, self.screen_rect.top + 300)})

        self.make_textbox()
        self.make_enter_button()

    def make_enter_button(self):
        self.buttons = ButtonGroup()
        self.labels = []
        Button(((1278, 840), (88, 65)), self.buttons, bindings=[pg.K_RETURN])
        rect_pos = {"midright": (1251, 872)}
        label = Label(self.font, 36, "Enter", "white", rect_pos, bg="blue2")
        self.labels.append(label)

    def make_textbox(self):
        rect = (self.screen_rect.centerx - 200, self.screen_rect.top + 600,
                400, 200)
        self.textbox = TextBox(rect,
                               outline_color=pg.Color("white"),
                               color=pg.Color("blue2"),
                               font=pg.font.Font(self.font, 36),
                               font_color=pg.Color("white"))
        self.textbox.accepted = string.digits
        self.dollar_sign = Label(self.font, 36, "$", "white",
                                 {"midright": (rect[0] - 5, rect[1] + 100)})
        #update needed to set textbox.render_area
        self.textbox.update()

    def leave_message(self, msg):
        self.make_textbox()
        self.persist["message"] = msg
        self.next = "MESSAGESCREEN"
        self.done = True

    def back_to_menu(self):
        self.beep()
        self.next = "MAINMENU"
        self.done = True

    def get_event(self, event, scale):
        self.textbox.get_event(event, tools.scaled_mouse_pos(scale))
        self.buttons.get_event(event)
        if event.type == pg.QUIT:
            self.back_to_menu()
        elif event.type == pg.KEYUP:
            if event.key == pg.K_ESCAPE:
                self.back_to_menu()

    def update(self, surface, keys, current, dt, scale, player):
        self.textbox.update()
        if not self.textbox.active:
            self.beep()
            try:
                amount = int(self.textbox.final)
            except ValueError:
                amount = 0
            if player.account.balance >= amount:
                player.account.withdrawal(amount)
                player.cash += amount
                self.leave_message("${:.2f} Withdrawn".format(amount))
            else:
                msg = "Insufficient Funds for Withdrawal"
                self.leave_message(msg)
        self.buttons.update(tools.scaled_mouse_pos(scale))
        text = "You have ${:.2f} available for withdrawal".format(
            player.account.balance)
        self.dyna_label = Label(
            self.font, 36, text, "white",
            {"midtop": (self.screen_rect.centerx, self.screen_rect.top + 80)})
        self.draw(surface)

    def draw(self, surface):
        surface.fill(pg.Color("blue2"))
        self.title.draw(surface)
        self.dollar_sign.draw(surface)
        self.textbox.draw(surface)
        for label in self.labels:
            label.draw(surface)
        self.dyna_label.draw(surface)