예제 #1
0
파일: Member.py 프로젝트: Geunuk/RHBS
    def bet(self,bet_point,pw,game_id,horse_name,dialog):
        print("베팅")
        if (self.isvalid_point(bet_point,"exchange")) and (self.isvalid_pw(pw)):
            self.point = self.point - int(bet_point)
            dialog.close()

            member_table = table.Table("member_info")
            popped_member = member_table.pop_row((self.id,))

            popped_member.point = self.__point
            member_table.append(popped_member)
            member_table.save_file()
            info = betting_info.Betting_Info(self.__id,game_id,horse_name,bet_point)
            for game in self.__gm.game_list:
                if game_id == game.id:
                    game.betting_info.append(info)
                    game.calc_dividend_rate()

            betting_info_table = table.Table("betting_info")
            bet_info = betting_info.Betting_Info(self.__id,game_id,horse_name,bet_point)

            betting_info_table.append(bet_info)
            betting_info_table.save_file()

        elif ((self.isvalid_point(bet_point, "exchange")) == False):
            msg = "포인트 입력이 잘못 되었습니다."
            self.show_error_box(dialog,msg)

        else:
            msg = "pw 입력이 잘못 되었습니다."
            self.show_error_box(dialog, msg)
예제 #2
0
파일: Game_Manager.py 프로젝트: Geunuk/RHBS
 def init_game(self):
     game_list = table.Table("game_info")
     betting_list = table.Table("betting_info")
     for game in game_list:
         bet_info = []
         for info in betting_list:
             if(info.game_id == game.game_id):
                 bet_info.append(info)
         game1 = Game.Game(game.game_id,game.proceeding,game.result,game.horses,game.start_time,bet_info,game.dividend_rate)
         self.__game_list.append(game1)
예제 #3
0
    def signup(self, input_member_info):
        print("회원 가입")

        valid_result = self.isvalid_signup(input_member_info)
        if valid_result == 0:
            self.__signup_Dialog.close()
            member_table = table.Table("member_info")
            member = member_info.Member_Info(
                input_member_info[0], input_member_info[1],
                input_member_info[3], input_member_info[4],
                input_member_info[5], input_member_info[6],
                input_member_info[7])

            member_table.append(member)
            member_table.save_file()

        elif valid_result == 1:
            self.__signup_Dialog.setEnabled(False)
            self.show_error_box(self.__signup_Dialog, "빈 항목이 있습니다")

        elif valid_result == 2:
            self.__signup_Dialog.setEnabled(False)
            self.show_error_box(self.__signup_Dialog, "동일한 ID가 이미 존재합니다")

        elif valid_result == 3:
            self.__signup_Dialog.setEnabled(False)
            self.show_error_box(self.__signup_Dialog, "패스워드가 일치하지 않습니다")

        else:
            self.__signup_Dialog.setEnabled(False)
            self.show_error_box(self.__signup_Dialog, "주민번호가 이미 존재합니다")
예제 #4
0
    def isvalid_signup(self, input_member_info):
        """
        :return: 0 => success
                  1 => empty input
                  2 => duplicate id
                  3 => password not agree
                  4 => duplicate ssn
        """
        id_ = input_member_info[0]
        pw = input_member_info[1]
        pw_repeat = input_member_info[2]
        ssn = input_member_info[4]

        member_table = table.Table("member_info")
        member_table.load_file()
        id_list = [x[0] for x in member_table.select_all_row(('member_id', ))]
        ssn_list = [x[0] for x in member_table.select_all_row(('ssn', ))]

        if "" in input_member_info:
            return 1
        elif id_ in id_list:
            return 2
        elif pw != pw_repeat:
            return 3
        elif ssn in ssn_list:
            return 4
        else:
            return 0
예제 #5
0
    def change_member_info(self, pw1, pw2, anum, email, pnum):
        print("회원 정보 변경")
        valid_result = self.isvalid_change(pw1, pw2, anum, email, pnum)
        if valid_result == 0:
            logged_in_member = self.__login_account
            logged_in_member.password = pw1
            logged_in_member.account_number = anum
            logged_in_member.email = email
            logged_in_member.phone_number = pnum

            member_table = table.Table("member_info")
            popped_member = member_table.pop_row((logged_in_member.id, ))

            popped_member.password = pw1
            popped_member.account_number = anum
            popped_member.email = email
            popped_member.phone_number = pnum

            member_table.append(popped_member)
            member_table.save_file()

            return True

        elif valid_result == 1:
            self.__login_Dialog.setEnabled(False)
            self.show_error_box(self.__member_info_Dialog, "빈 항목이 있습니다")
            return False

        else:
            self.__member_info_ui.modify_flag = True
            self.__login_Dialog.setEnabled(False)
            self.show_error_box(self.__member_info_Dialog, "패스워드가 일치하지 않습니다")
            return False
예제 #6
0
파일: Game_Manager.py 프로젝트: Geunuk/RHBS
 def save_game_file(self):
     game_list = []
     for g in self.__game_list:
         game = game_info.Game_Info(g.id,g.start_time,g.result,g.horses,g.dividend_rate,g.proceeding)
         game_list.append(game)
     game_table = table.Table("game_info")
     game_table.clear()
     game_table.extend(game_list)
     game_table.save_file()
예제 #7
0
 def set_input_horse_combo_box(self):
     combos = [
         self.input_horse1, self.input_horse2, self.input_horse3,
         self.input_horse4, self.input_horse5
     ]
     horse_table = table.Table("horse_info")
     horses = [ls[0] for ls in horse_table.select_all_row(("name", ))]
     for combo in combos:
         combo.addItems(horses)
예제 #8
0
파일: Game.py 프로젝트: Geunuk/RHBS
 def calc_dividend(self):
     member_table = table.Table("member_info")
     idx = self.__result[0]
     for info in self.__betting_info:
         if(info.horse_name == self.__horses[idx].name):
             popped_member = member_table.pop_row((info.member_id,))
             popped_member.point += int(int(info.bet_money) * self.__dividend_rate[idx])
             member_table.append(popped_member)
             member_table.save_file()
             if(type(self.__login_account == 'Member.Member')):
                 self.__login_account.point += int(int(info.bet_money) * self.__dividend_rate[idx])
예제 #9
0
파일: Member.py 프로젝트: Geunuk/RHBS
    def exchange_point(self, exchanged_point):
        print("포인트 환전")
        if self.isvalid_point(exchanged_point, "exchange"):
            self.__point = self.__point - int(exchanged_point)
            self.__point_exchange_Dialog.close()

            member_table = table.Table("member_info")
            popped_member = member_table.pop_row((self.id,))

            popped_member.point = self.__point
            member_table.append(popped_member)
            member_table.save_file()

        else:
            self.__point_exchange_Dialog.setEnabled(False)
            self.show_error_box(self.__point_exchange_Dialog, "유효하지 않은 입력입니다")
예제 #10
0
    def login(self, id, pw):
        valid_result = self.isvalid_login(id, pw)
        if valid_result == 0:
            self.__login_Dialog.close()
            self.__init_ui.login_msg.setText(id + "님 환영합니다!")
            self.__init_ui.init_login_btn.setText("로그아웃")
            self.__init_ui.init_signup_btn.setText("회원정보확인")

            member_table = table.Table("member_info")
            member_info = member_table.select_row(
                (id, ), ('member_id', 'password', 'name', 'ssn',
                         'account_number', 'email', 'phone_number', 'point'))

            if self.is_admin(id):
                self.__init_ui.init_game_manage_btn.setEnabled(True)
                self.__init_ui.init_signup_btn.setEnabled(False)
                self.__login_account = Admin.Admin(self.__gm, self.__init_ui,
                                                   self.__init_window)

            else:
                self.__init_ui.init_bet_btn.setEnabled(True)
                self.__init_ui.init_bet_result_btn.setEnabled(True)
                self.__init_ui.init_game_status_btn.setEnabled(True)
                self.__init_ui.init_charge_point_btn.setEnabled(True)
                self.__init_ui.init_exchange_point_btn.setEnabled(True)

                self.__login_account = Member.Member(
                    member_info[0], member_info[1], member_info[2],
                    member_info[3],
                    member_info[4], member_info[5], member_info[6],
                    int(member_info[7]), self.__init_ui, self.__init_window,
                    self.__gm)
                self.__gm.login_account = self.__login_account

        elif valid_result == 1:
            self.__login_Dialog.setEnabled(False)
            self.show_error_box(self.__login_Dialog, "빈 항목이 있습니다")

        elif valid_result == 2:
            self.__login_Dialog.setEnabled(False)
            self.show_error_box(self.__login_Dialog, "존재하지 않는 ID 입니다")

        else:
            self.__login_Dialog.setEnabled(False)
            self.show_error_box(self.__login_Dialog, "틀린 패스워드입니다")
예제 #11
0
    def isvalid_login(self, id, pw):
        """
        :return: 0 => Success
                  1 => empty input
                  2 => id not exist
                  3 => id, password not agree
        """
        member_table = table.Table("member_info")
        member_table.load_file()
        id_pw_list = member_table.select_row((id, ), ('member_id', 'password'))

        if id == "" or pw == "":
            return 1
        if not id_pw_list:
            return 2
        elif (id_pw_list[0] != id) or (id_pw_list[1] != pw):
            return 3
        else:
            return 0
예제 #12
0
파일: Admin.py 프로젝트: Geunuk/RHBS
    def register_game(self, game_id, start_time, horse_name_list):
        print("경기 추가")

        today = datetime.date.today()
        start_time = datetime.datetime.strptime(start_time, "%p %I:%M")
        start_time = start_time.replace(year=today.year,
                                        month=today.month,
                                        day=today.day)

        valid_result = self.isvalid_register(game_id, start_time,
                                             horse_name_list)
        if valid_result == 0:
            self.__manage_game_add_Dialog.close()
            horse_table = table.Table("horse_info")
            horse_info_list = []
            for horse_name in horse_name_list:
                horse_info_list.append(horse_table.get_row((horse_name, )))
            new_game = Game.Game(game_id, False, [], horse_info_list,
                                 start_time, [], [1, 1, 1, 1, 1])
            self.__game_manager.game_list.append(new_game)
            self.__game_manage_ui.set_game_table()

        elif valid_result == 1:
            self.__manage_game_add_Dialog.setEnabled(False)
            self.show_error_box(self.__manage_game_add_Dialog, "빈 항목이 있습니다")

        elif valid_result == 2:
            self.__manage_game_add_Dialog.setEnabled(False)
            self.show_error_box(self.__manage_game_add_Dialog,
                                "동일한 경기 이름이 존재합니다")

        elif valid_result == 3:
            self.__manage_game_add_Dialog.setEnabled(False)
            self.show_error_box(self.__manage_game_add_Dialog, "말이 중복됩니다")

        else:
            self.__manage_game_add_Dialog.setEnabled(False)
            self.show_error_box(self.__manage_game_add_Dialog,
                                "경기 시간은 현재 시간보다 나중이어야 합니다")