def temple_handler(self, event): """event handler of temple""" if self.temple.donate_money != None and self.temple.donate_money.is_visible: self.temple.donate_money.system_notify_window_handler( event, self, self.party.member) return elif self.temple.temple_cure_window != None and self.temple.temple_cure_window.is_visible: self.temple.temple_cure_window.temple_window_handler(event, self) return if event.type == KEYDOWN and event.key == K_UP: #moves the cursor up self.cursor_se.play() self.temple.menu -= 1 if self.temple.menu < 0: self.temple.menu = MENU_MAX elif event.type == KEYDOWN and event.key == K_DOWN: self.cursor_se.play() self.temple.menu += 1 if self.temple.menu > MENU_MAX: self.temple.menu = 0 if event.type == KEYDOWN and (event.key == K_SPACE or event.key == K_z or event.key == K_RETURN): if self.temple.menu == Temple.CURE: self.temple.temple_cure_window = temple_window.Temple_window( Rect(60, 50, 520, 360)) self.temple.temple_cure_window.is_visible = True elif self.temple.menu == Temple.DONATE: self.temple.donate_money = system_notify.System_notify_window( Rect(200, 120, 240, 240), system_notify.System_notify_window.DONATE) self.temple.donate_money.is_visible = True elif self.temple.menu == Temple.BACK: self.game_state = CITY self.temple.menu = Temple.CURE self.temple.music = 0 self.temple = None self.city = city.City() self.city.menu = 4 self.select_se.play() if event.type == KEYDOWN and (event.key == K_x): self.game_state = CITY self.temple.menu = Temple.CURE self.temple.music = 0 self.temple = None self.city = city.City() self.city.menu = 4 self.cancel_se.play()
def temple_window_handler(self, event, game_self): if self.cure_pay_window != None and self.cure_pay_window.is_visible == True: self.cure_pay_window.system_notify_window_handler( event, game_self, game_self.party.member) return if event.type == KEYDOWN and event.key == K_x: self.menu = 0 self.page = 0 self.is_visible = False self.to_cure = [] if event.type == KEYDOWN and event.key == K_UP: #moves the cursor up self.menu -= 1 if self.menu < 0: self.menu = 0 elif event.type == KEYDOWN and event.key == K_DOWN: if len(self.to_cure) > self.menu+self.page*10+1: self.menu += 1 if self.menu > self.MENU_MAX: self.menu = self.MENU_MAX elif event.type == KEYDOWN and event.key == K_RIGHT: if len(self.to_cure) > (self.page+1)*10: self.page += 1 self.menu = 0 elif event.type == KEYDOWN and event.key == K_LEFT: if self.page > 0: self.page -= 1 self.menu = 0 elif event.type == KEYDOWN and (event.key == K_SPACE or event.key == K_z or event.key == K_RETURN): if len(self.to_cure) == 0: return if self.to_cure[self.menu+self.page*10].status == [0,0,0,0,0,0,0,0,0]: bad_status = random.randint(1,100) if bad_status < 25: self.to_cure[self.menu+self.page*10].status[4] = 1 elif bad_status < 50: self.to_cure[self.menu+self.page*10].status[5] = 1 elif bad_status < 75: self.to_cure[self.menu+self.page*10].status[6] = 1 else: self.to_cure[self.menu+self.page*10].status[7] = 1 else: self.cure_pay_window = system_notify.System_notify_window(Rect(200,120,340, 240),system_notify.System_notify_window.TEMPLE_PAY) self.cure_pay_window.is_visible = True
def inn_window_handler(self, event, game_self, character): if self.who_rest != None and self.who_rest.is_visible == True: self.who_rest.system_notify_window_handler( event, game_self, character) return if event.type == KEYDOWN and (event.key == K_SPACE or event.key == K_z or event.key == K_RETURN): self.who_rest = system_notify.System_notify_window(Rect(240, 80 ,240, 240), system_notify.System_notify_window.REST) self.who_rest.is_visible = True if event.type == KEYDOWN and event.key == K_x: self.menu = 0 self.is_visible = False if event.type == KEYDOWN and event.key == K_UP: self.menu -= 1 if self.menu < 0: self.menu = self.MENU_MAX if event.type == KEYDOWN and event.key == K_DOWN: self.menu += 1 if self.menu > self.MENU_MAX: self.menu = 0
def bar_handler(self, event): """event handler of bar""" if self.bar.status_view != None and self.bar.status_view.is_visible: self.bar.status_view.status_view_window_handler( self, event, self.party.member) return elif self.bar.party_add != None and self.bar.party_add.is_visible: self.bar.party_add.character_view_handler(self, event, self.characters) return elif self.bar.party_remove != None and self.bar.party_remove.is_visible: self.bar.party_remove.character_view_handler(self, event, self.party.member) return elif self.bar.character_check != None and self.bar.character_check.is_visible: self.bar.character_check.character_view_handler( self, event, self.party.member) return elif self.bar.share_money != None and self.bar.share_money.is_visible: self.bar.share_money.system_notify_window_handler(event, self, None) return elif self.bar.donate_money != None and self.bar.donate_money.is_visible: self.bar.donate_money.system_notify_window_handler( event, self, self.party.member) return elif self.bar.collect_money != None and self.bar.collect_money.is_visible: self.bar.collect_money.system_notify_window_handler( event, self, self.party.member) return if event.type == KEYDOWN and event.key == K_UP: #moves the cursor up self.cursor_se.play() self.bar.menu -= 1 if self.bar.menu < 0: self.bar.menu = MENU_MAX elif event.type == KEYDOWN and event.key == K_DOWN: self.cursor_se.play() self.bar.menu += 1 if self.bar.menu > MENU_MAX: self.bar.menu = 0 if event.type == KEYDOWN and (event.key == K_SPACE or event.key == K_z or event.key == K_RETURN): if self.bar.menu == Bar.ADD: if len(self.characters) > 0: self.bar.party_add = character_view.Character_view( Rect(80, 60, 480, 360), character_view.Character_view.ADD) self.bar.party_add.is_visible = True elif self.bar.menu == Bar.REMOVE: if len(self.party.member) > 0: self.bar.party_remove = character_view.Character_view( Rect(80, 60, 480, 360), character_view.Character_view.REMOVE) self.bar.party_remove.is_visible = True elif self.bar.menu == Bar.CHECK: if len(self.party.member) > 0: self.bar.character_check = character_view.Character_view( Rect(80, 60, 480, 360), character_view.Character_view.CHECK) self.bar.character_check.is_visible = True elif self.bar.menu == Bar.SHARE: if len(self.party.member) > 0: self.bar.share_money = system_notify.System_notify_window( Rect(220, 140, 220, 50), system_notify.System_notify_window.SHARE) self.bar.share_money.is_visible = True elif self.bar.menu == Bar.DONATE: if len(self.party.member) > 0: self.bar.donate_money = system_notify.System_notify_window( Rect(200, 120, 240, 240), system_notify.System_notify_window.DONATE) self.bar.donate_money.is_visible = True elif self.bar.menu == Bar.COLLECT: if len(self.party.member) > 0: self.bar.collect_money = system_notify.System_notify_window( Rect(200, 120, 240, 240), system_notify.System_notify_window.COLLECT) self.bar.collect_money.is_visible = True elif self.bar.menu == Bar.BACK: self.game_state = CITY self.bar.menu = Bar.ADD self.bar.music = 0 self.city = city.City() self.city.menu = 0 self.bar = None self.select_se.play() if event.type == KEYDOWN and (event.key == K_x): self.game_state = CITY self.bar.menu = Bar.ADD self.cancel_se.play() self.bar.music = 0 self.city = city.City() self.city.menu = 0 self.bar = None
def castle_handler(self, event): """event handler of castle""" if self.castle.delete_confirm != None and self.castle.delete_confirm.is_visible: self.castle.delete_confirm.delete_confirm_window_handler( self, event, self.characters) return elif self.castle.character_rename != None and self.castle.character_rename.is_visible: self.castle.character_rename.character_view_handler( self, event, self.characters) return elif self.castle.character_delete != None and self.castle.character_delete.is_visible: self.castle.character_delete.character_view_handler( self, event, self.characters) return elif self.castle.donate_money != None and self.castle.donate_money.is_visible: self.castle.donate_money.system_notify_window_handler( event, self, self.party.member) return elif self.castle.change_job_window != None and self.castle.change_job_window.is_visible: self.castle.change_job_window.change_job_window_handler(self, event) return if event.type == KEYDOWN and event.key == K_UP: #moves the cursor up self.cursor_se.play() self.castle.menu -= 1 if self.castle.menu < 0: self.castle.menu = MENU_MAX elif event.type == KEYDOWN and event.key == K_DOWN: self.cursor_se.play() self.castle.menu += 1 if self.castle.menu > MENU_MAX: self.castle.menu = 0 if event.type == KEYDOWN and (event.key == K_SPACE or event.key == K_z or event.key == K_RETURN): if self.castle.menu == Castle.NEW: self.game_state = CHARACTER_MAKE elif self.castle.menu == Castle.DELETE: if len(self.characters) > 0: self.castle.character_delete = character_view.Character_view( Rect(80, 60, 480, 360), character_view.Character_view.DELETE) self.castle.character_delete.is_visible = True elif self.castle.menu == Castle.NAME_CHANGE: if len(self.characters) > 0: self.castle.character_rename = character_view.Character_view( Rect(80, 60, 480, 360), character_view.Character_view.RENAME) self.castle.character_rename.is_visible = True elif self.castle.menu == Castle.JOB_CHANGE: if len(self.party.member) > 0: self.castle.change_job_window = Change_job_window( Rect(80, 60, 480, 360)) self.castle.change_job_window.is_visible = True elif self.castle.menu == Castle.DONATE: if len(self.party.member) > 0: self.castle.donate_money = system_notify.System_notify_window( Rect(200, 120, 240, 240), system_notify.System_notify_window.DONATE) self.castle.donate_money.is_visible = True elif self.castle.menu == Castle.BACK: self.game_state = CITY self.castle.menu = Castle.NEW self.castle.music = 0 self.castle = None self.city = city.City() self.city.menu = 5 self.select_se.play() if event.type == KEYDOWN and (event.key == K_x): self.game_state = CITY self.castle.menu = Castle.NEW self.castle.music = 0 self.castle = None self.city = city.City() self.city.menu = 5 self.cancel_se.play()
def inn_handler(self, event): """event handler of inn""" if self.inn.inn_window != None and self.inn.inn_window.is_visible: self.inn.inn_window.inn_window_handler(event, self, self.party.member) return elif self.inn.save_confirm != None and self.inn.save_confirm.is_visible: self.inn.save_confirm.confirm_window_handler(self, event, None) return elif self.inn.load_confirm != None and self.inn.load_confirm.is_visible: self.inn.load_confirm.confirm_window_handler(self, event, None) return elif self.inn.item_out_window != None and self.inn.item_out_window.is_visible: self.inn.item_out_window.system_notify_window_handler( event, self, self.party.member) return elif self.inn.item_in_window != None and self.inn.item_in_window.is_visible: self.inn.item_in_window.system_notify_window_handler( event, self, self.party.member) return #moves the cursor up if event.type == KEYDOWN and event.key == K_UP: self.cursor_se.play() self.inn.menu -= 1 if self.inn.menu < 0: self.inn.menu = MENU_MAX #moves the cursor down elif event.type == KEYDOWN and event.key == K_DOWN: self.cursor_se.play self.inn.menu += 1 if self.inn.menu > MENU_MAX: self.inn.menu = 0 if event.type == KEYDOWN and (event.key == K_SPACE or event.key == K_z or event.key == K_RETURN): if self.inn.menu == Inn.REST: if len(self.party.member) > 0: self.inn.inn_window = inn_window.Inn_window( Rect(80, 100, 340, 200)) self.inn.inn_window.is_visible = True elif self.inn.menu == Inn.ITEM_OUT: if len(self.party.member) > 0: self.inn.item_out_window = system_notify.System_notify_window( Rect(200, 120, 340, 240), system_notify.System_notify_window.ITEM_OUT) self.inn.item_out_window.is_visible = True elif self.inn.menu == Inn.ITEM_IN: if len(self.party.member) > 0: self.inn.item_in_window = system_notify.System_notify_window( Rect(200, 120, 340, 240), system_notify.System_notify_window.ITEM_IN) self.inn.item_in_window.is_visible = True elif self.inn.menu == Inn.SAVE: self.inn.save_confirm = system_notify.Confirm_window( Rect(150, 150, 200, 110), system_notify.Confirm_window.SAVE) self.inn.save_confirm.is_visible = True elif self.inn.menu == Inn.LOAD: self.inn.load_confirm = system_notify.Confirm_window( Rect(150, 150, 200, 110), system_notify.Confirm_window.LOAD) self.inn.load_confirm.is_visible = True elif self.inn.menu == Inn.BACK: self.game_state = CITY self.inn.menu = Inn.REST self.inn.music = 0 self.inn = None self.city = city.City() self.city.menu = 1 self.select_se.play() if event.type == KEYDOWN and (event.key == K_x): self.cancel_se.play() self.game_state = CITY self.inn.menu = Inn.REST self.inn.music = 0 self.inn = None self.city = city.City() self.city.menu = 1
def shop_handler(self, event): """event handler of shop""" if self.shop.donate_money != None and self.shop.donate_money.is_visible: self.shop.donate_money.system_notify_window_handler( event, self, self.party.member) return elif self.shop.remove_curse != None and self.shop.remove_curse.is_visible: self.shop.remove_curse.system_notify_window_handler( event, self, self.party.member) return elif self.shop.buy_house != None and self.shop.buy_house.is_visible: self.shop.buy_house.confirm_window_handler(self, event, self.party.member) return elif self.shop.shop_window != None and self.shop.shop_window.is_visible: self.shop.shop_window.shop_window_handler(event, self) return elif self.shop.sell_window != None and self.shop.sell_window.is_visible: self.shop.sell_window.system_notify_window_handler( event, self, self.party.member) return #moves the cursor up if event.type == KEYDOWN and event.key == K_UP: self.cursor_se.play() self.shop.menu -= 1 if self.shop.menu < 0: self.shop.menu = MENU_MAX if self.shop.menu == 4 and self.party.house > 0: self.shop.menu -= 1 #moves the cursor down elif event.type == KEYDOWN and event.key == K_DOWN: self.cursor_se.play() self.shop.menu += 1 if self.shop.menu > MENU_MAX: self.shop.menu = 0 if self.shop.menu == 4 and self.party.house > 0: self.shop.menu += 1 #select the menu items if event.type == KEYDOWN and (event.key == K_SPACE or event.key == K_z or event.key == K_RETURN): if self.shop.menu == Shop.BUY: self.shop.shop_window = shop_window.Shop_window( Rect(200, 50, 240, 380)) self.shop.shop_window.is_visible = True elif self.shop.menu == Shop.SELL: self.shop.sell_window = system_notify.System_notify_window( Rect(200, 120, 340, 240), system_notify.System_notify_window.SELL) self.shop.sell_window.is_visible = True elif self.shop.menu == Shop.CURSE: self.shop.remove_curse = system_notify.System_notify_window( Rect(150, 120, 340, 240), system_notify.System_notify_window.CURSE) self.shop.remove_curse.is_visible = True elif self.shop.menu == Shop.DONATE: self.shop.donate_money = system_notify.System_notify_window( Rect(200, 120, 240, 240), system_notify.System_notify_window.DONATE) self.shop.donate_money.is_visible = True elif self.shop.menu == Shop.BUY_HOUSE: self.shop.buy_house = system_notify.Confirm_window( Rect(100, 160, 300, 120), system_notify.Confirm_window.HOUSE) self.shop.buy_house.is_visible = True elif self.shop.menu == Shop.BACK: self.game_state = CITY self.shop.menu = Shop.BUY self.shop.music = 0 #save temp shop data save.save_shop_item(self, "Save/shop_item_temp.dat") self.shop = None self.city = city.City() self.city.menu = 3 self.select_se.play() if event.type == KEYDOWN and (event.key == K_x): self.game_state = CITY self.shop.menu = Shop.BUY self.shop.music = 0 for item_list in self.shop.stock: item_list.sort(cmp=lambda x, y: cmp(x.id, y.id), reverse=False) save.save_shop_item(self, "Save/shop_item_temp.dat") self.shop = None self.city = city.City() self.city.menu = 3 self.cancel_se.play()
def menu_handler(self, event, game_self): if self.item_window != None and self.item_window.is_visible == True: self.item_window.system_notify_window_handler( event, game_self, game_self.party.member) return elif self.magic_window != None and self.magic_window.is_visible == True: self.magic_window.system_notify_window_handler( event, game_self, game_self.party.member) return elif self.status_window != None and self.status_window.is_visible == True: self.status_window.system_notify_window_handler( event, game_self, game_self.party.member) return elif self.change_window != None and self.change_window.is_visible == True: self.change_window.system_notify_window_handler( event, game_self, self.temp_party1) return #moves the cursor up if event.type == KEYDOWN and event.key == K_UP: game_self.cursor_se.play() self.menu -= 1 if self.menu < 0: self.menu = self.MENU_MAX #moves the cursor up if event.type == KEYDOWN and event.key == K_DOWN: game_self.cursor_se.play() self.menu += 1 if self.menu > self.MENU_MAX: self.menu = 0 if event.type == KEYDOWN and (event.key == K_z or event.key == K_SPACE or event.key == K_RETURN): game_self.select_se.play() if self.menu == self.ITEM: if len(game_self.party.member) > 0: self.item_window = system_notify.System_notify_window( Rect(200, 120, 340, 240), system_notify.System_notify_window.USE_ITEM) self.item_window.is_visible = True if self.menu == self.MAGIC: if len(game_self.party.member) > 0: self.magic_window = system_notify.System_notify_window( Rect(200, 120, 340, 240), system_notify.System_notify_window.USE_MAGIC) self.magic_window.is_visible = True if self.menu == self.STATUS: if len(game_self.party.member) > 0: self.status_window = system_notify.System_notify_window( Rect(200, 120, 340, 240), system_notify.System_notify_window.VIEW_STATUS) self.status_window.is_visible = True if self.menu == self.CHANGE: if len(game_self.party.member) > 0: for character in game_self.party.member: self.temp_party1.append(character) self.change_window = system_notify.System_notify_window( Rect(200, 120, 340, 240), system_notify.System_notify_window.CHANGE_PARTY) self.change_window.is_visible = True if self.menu == self.SETTINGS: character_name_message = u"パーティ名を入力してください" message_title = u"パーティ名入力" fieldnames = [u"パーティ名"] fieldvalues = [] fieldvalues = easygui.multenterbox(character_name_message, message_title, fieldnames) if (fieldvalues != None): #if empty string, then re-enter if len(fieldvalues[0]) == 0: return #if it includes spaces at front, then also re-enter if fieldvalues[0][0] == " ": return if fieldvalues == None: return game_self.party.party_name = u"" + fieldvalues[0] if self.menu == self.BACK: self.menu = self.ITEM if game_self.party.member == []: game_self.game_state = CITY game_self.city = city.City() game_self.menu = None return if game_self.party.member[0].coordinate != [-1, -1, -1]: game_self.game_state = DUNGEON game_self.menu = None game_self.dungeon = dungeon.Dungeon( game_self.party.member[0].coordinate[2]) game_self.dungeon.vertical_wall = game_self.vertical_wall_temp game_self.dungeon.horizontal_wall = game_self.horizontal_wall_temp game_self.dungeon.ground = game_self.ground_temp game_self.dungeon.space = game_self.space_temp game_self.dungeon.object = game_self.object_temp #dungeon load???? else: game_self.game_state = CITY game_self.city = city.City() game_self.menu = None if event.type == KEYDOWN and (event.key == K_x): game_self.cancel_se.play() self.menu = self.ITEM if game_self.party.member == []: game_self.game_state = CITY game_self.city = city.City() game_self.menu = None return if game_self.party.member[0].coordinate != [-1, -1, -1]: game_self.game_state = DUNGEON game_self.menu = None game_self.dungeon = dungeon.Dungeon( game_self.party.member[0].coordinate[2]) game_self.dungeon.vertical_wall = game_self.vertical_wall_temp game_self.dungeon.horizontal_wall = game_self.horizontal_wall_temp game_self.dungeon.ground = game_self.ground_temp game_self.dungeon.space = game_self.space_temp game_self.dungeon.object = game_self.object_temp #dungeon load????? else: game_self.game_state = CITY game_self.city = city.City() game_self.menu = None
def house_handler(self, game_self, event): """event handler for house""" if self.who_rest != None and self.who_rest.is_visible: self.who_rest.system_notify_window_handler(event, game_self, game_self.party.member) return elif self.house_change != None and self.house_change.is_visible: self.house_change.confirm_window_handler(game_self, event, game_self.party.member) return elif self.save_confirm != None and self.save_confirm.is_visible: self.save_confirm.confirm_window_handler(game_self, event, None) return elif self.load_confirm != None and self.load_confirm.is_visible: self.load_confirm.confirm_window_handler(game_self, event, None) return elif self.item_out_window != None and self.item_out_window.is_visible: self.item_out_window.system_notify_window_handler( event, game_self, game_self.party.member) return elif self.item_in_window != None and self.item_in_window.is_visible: self.item_in_window.system_notify_window_handler( event, game_self, game_self.party.member) return #moves the cursor up if event.type == KEYDOWN and event.key == K_UP: game_self.cursor_se.play() self.menu -= 1 if self.menu < 0: self.menu = self.MENU_MAX if game_self.party.house == 5 and self.menu == 5: self.menu -= 1 #moves the cursor down elif event.type == KEYDOWN and event.key == K_DOWN: game_self.cursor_se.play() self.menu += 1 if self.menu > self.MENU_MAX: self.menu = 0 if game_self.party.house == 5 and self.menu == 5: self.menu += 1 if event.type == KEYDOWN and (event.key == K_SPACE or event.key == K_z or event.key == K_RETURN): game_self.select_se.play() if self.menu == self.REST: if len(game_self.party.member) > 0: self.who_rest = system_notify.System_notify_window( Rect(240, 80, 240, 240), system_notify.System_notify_window.REST) self.who_rest.is_visible = True elif self.menu == self.ITEM_OUT: if len(game_self.party.member) > 0: self.item_out_window = system_notify.System_notify_window( Rect(200, 120, 340, 240), system_notify.System_notify_window.ITEM_OUT) self.item_out_window.is_visible = True elif self.menu == self.ITEM_IN: if len(game_self.party.member) > 0: self.item_in_window = system_notify.System_notify_window( Rect(200, 120, 340, 240), system_notify.System_notify_window.ITEM_IN) self.item_in_window.is_visible = True elif self.menu == self.SAVE: self.save_confirm = system_notify.Confirm_window( Rect(150, 150, 200, 110), system_notify.Confirm_window.SAVE) self.save_confirm.is_visible = True elif self.menu == self.LOAD: self.load_confirm = system_notify.Confirm_window( Rect(150, 150, 200, 110), system_notify.Confirm_window.LOAD) self.load_confirm.is_visible = True elif self.menu == self.REFORM: if len(game_self.party.member) > 0: self.house_change = system_notify.Confirm_window( Rect(180, 80, 360, 110), system_notify.Confirm_window.HOUSE_CHANGE) self.house_change.is_visible = True elif self.menu == self.BACK: game_self.game_state = CITY self.menu = self.REST game_self.city = city.City() game_self.city.menu = 2 game_self.house = None if event.type == KEYDOWN and (event.key == K_x): game_self.game_state = CITY self.menu = self.REST game_self.city = city.City() game_self.city.menu = 2 game_self.house = None