def __init__(self, rectangle): window.Window.__init__(self, rectangle) self.is_visible = False self.menu = 0 #if job change includes character in bar self.page = 0 self.top = rectangle.top self.left = rectangle.left self.right = rectangle.right self.centerx = rectangle.centerx self.menu_font = pygame.font.Font("ipag.ttf", 20) self.job_change_confirm = system_notify.Confirm_window( Rect(180, 80, 360, 110), 20) #find all characters that could change job self.possible_characters = []
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 set_coordinate(self, game_self, coordinate): self.coordinate = coordinate #set message if self.coordinate == [10, 3, 1]: self.message = [u"部屋の中には、龍の彫像がある。", u"彫像はブロンズで、台座はオニキスで出来ている。"] self.search_window = system_notify.Confirm_window( Rect(190, 200, 200, 110), system_notify.Confirm_window.SEARCH) self.search_window.is_visible = True self.key_press = True if self.coordinate == [5, 4, 2]: self.message = [u"部屋の中には、水溜りがある。", u"あまり綺麗とは言えないが不快ではない。"] self.search_window = system_notify.Confirm_window( Rect(190, 200, 200, 110), system_notify.Confirm_window.SEARCH) self.search_window.is_visible = True self.key_press = True if self.coordinate == [7, 0, 2]: self.message = [u"部屋の中には、泉がある。"] self.swim_window = system_notify.Confirm_window( Rect(190, 200, 200, 110), system_notify.Confirm_window.SWIM) self.swim_window.is_visible = True self.key_press = True if self.coordinate == [15, 14, 2]: self.message = [u"目の前にスイッチがある"] if self.key_press == True: self.press_window = system_notify.Confirm_window( Rect(190, 200, 200, 110), system_notify.Confirm_window.PRESS) self.press_window.is_visible = True if self.coordinate == [13, 14, 4]: self.message = [ u"フードを被った人間型の大きな彫像が見える。", u"フードの穴の中からはキン色の光が漏れていて、", u"彫像にはさまざまなかたちの宝石が散りばめられている。", u"彫像の前には祭壇があり、新しい香が焚かれている。" ] self.key_press = True if self.coordinate == [5, 9, 5]: self.message = [u"勇気無き者は南の扉を開け、逃げ戻るが良い。", u"勇気有る者は北の扉を開けるが良い。"] self.key_press = True if self.coordinate == [6, 6, 5 ] and game_self.dungeon.object[6][6] == 16: self.message = [ u"冒険者達が扉を開けると荘厳な、", u"まるで王宮の一室の如き部屋に出た。", u"", u"しかし、床も壁も全て酷く血に汚れ、", u"先ほどまで生きていた冒険者の死体や、", u"何ヶ月も放置された腐敗した死体等、", u"無数の屍がむせ返る血の臭いがした。", "change", u"そしてその奥からのっそりと竜が這い出てきた。", u"その体は無数の冒険者の血を浴び、", u"赤黒く見るもおぞましい姿であった。", u"", u"竜は冒険者達を見つけると", u"口から炎を混じらせた恐ろしい叫び声を上げつつ、", u"冒険者達に襲い掛かった!" ] self.key_press = True if self.coordinate == [6, 2, 5 ] and game_self.dungeon.object[2][6] == 4: self.message = [ u"冒険者達は新たな部屋に入ると", u"そこは大きな祭壇のある部屋であった。", u"", u"祭壇の上に立つと", u"七色に輝く羅針盤が手の中に現れた。", u"", u"そして、冒険者達の心に直接呼びかける声が聞こえた。", u"change", u"ようこそ、我が塔へ。", u"勇気と強さ、そして何よりも意思強き者達よ。", u"", u"我が名はエルダードラゴン、", u"始まりの龍にしてこの塔の支配者なり。", u"change", u"諸君、私はこの塔を諸君等の為に作った。", u"この大地に生きる生き物は欲深く、", u"時に罪を重ねる。", u"", u"飽くなき戦いを繰り返し", u"その欲望を成就させようとしている、", u"それは良い。", u"それが生きる者、生物の業であると私は思う。", u"change", u"しかし、それだけで良いはずが無い…", u"私は過去の世界を見た、この世界で無い別の世界も見た。", u"それにより、私は知ったのだ。", u"", u"世界を動かし、変革してゆくのは常に強く、", u"そして確固たる己を持ち、", u"そして勇気と知恵を持って進むものであると。", u"change", u"私は大いなる力を持つ、", u"諸君らが神と呼ぶものに近い力を持つ。", u"しかし私はこの世界を如何に変えるか、その目的を持たぬ。", u"", u"何故ならば、私が諸君らが、", u"この大地の生命が如何様な運命を", u"辿ろうとも私には何の支障も生まれぬからだ", u"だから、私は一つの事を決めた。", u"change", u"それは生命に試練を与えその試練を乗り越えし者に", u"世界を変えるチャンスを与えようと。", u"", u"諸君、私はこの塔の頂上にて諸君らを待つ。", u"change", u"試練を乗り越え、", u"運命や世界を変えるに相応しい者であると証明すれば", u"私は諸君等の如何なる願いでも叶えるであろう。", u"change", u"塔を進むも自由、戻るも自由、去るも自由。", u"", u"諸君等の道は諸君等が決めるが良い。", u"私は何の手も貸さず、慈悲も与えぬ。", u"", u"己の運命を切り開く者のみに私はこの力を使おう…", u"塔の最上階にて私は諸君等を待つ…", u"change", u"語りかける声が消えると同時に羅針盤は", u"その輝きを弱め、小さく七色の光を湛えている…", u"", u"冒険者達は「天龍の羅針盤」を手に入れた!" ] self.key_press = True if self.message != None and self.key_press == True: self.is_visible = True
def __init__(self, rectangle, instruction, game_self): window.Window.__init__(self, rectangle) self.is_visible = False self.top = rectangle.top self.left = rectangle.left self.right = rectangle.right self.centerx = rectangle.centerx self.instruction = instruction self.message = None self.menu_font = pygame.font.Font("ipag.ttf", 20) self.buy_window = None self.key_press = False self.message_number = 0 self.more_message = False self.get_item = None self.price = 0 self.relation = game_self.dungeon.party_encounter_window.relation #to get item if self.instruction == self.ITEM: self.get_item = dungeon.party_encount_item( True, game_self.party.member[0].coordinate[2]) self.price = self.get_item[1] self.get_item = item.Item(game_self.item_data[self.get_item[0]]) elif self.instruction == self.BUY: self.get_item = dungeon.party_encount_item( False, game_self.party.member[0].coordinate[2]) self.price = self.get_item[1] self.get_item = item.Item(game_self.item_data[self.get_item[0]]) #if point is higher: #gives better info #at least 3 points needed on item given, then if point difference is > 3 that is point needed #price down on buy #higher probability of premitive attack, and less prob of enemy first if self.instruction == self.INFO: #select information to give self.message = [u"まだ情報はありません"] pass elif self.instruction == self.ITEM: self.ok = False if self.relation == self.GOOD: if game_self.dungeon.party_encounter_window.use_points < 4: good_probability = int( 100 * game_self.dungeon.party_encounter_window.use_points / 4) probability = random.randint(1, 100) if probability < good_probability: self.ok = True else: self.ok = True elif self.relation == self.NEUTRAL: if game_self.dungeon.party_encounter_window.use_points < 8: good_probability = int( 100 * game_self.dungeon.party_encounter_window.use_points / 8) probability = random.randint(1, 100) if probability < good_probability: self.ok = True else: self.ok = True elif self.relation == self.EVIL: if game_self.dungeon.party_encounter_window.use_points < 16: good_probability = int( 100 * game_self.dungeon.party_encounter_window.use_points / 16) probability = random.randint(1, 100) if probability < good_probability: self.ok = True else: self.ok = True #select receiving item if self.ok == True: self.message = [ u"目の前の冒険者達は荷物からアイテムを取り出すと、", u"冒険者達に差し出してきた。", "", u"冒険者達は" + self.get_item.name + u"を手に入れた!" ] else: self.message = [u"目の前の冒険者達は静かに首を横に振った。", "", u"アイテムを貰えなかった。"] elif self.instruction == self.BUY: if self.relation == self.GOOD: self.price = self.price - int( self.price * game_self.dungeon.party_encounter_window.use_points * 5 / 100) elif self.relation == self.NEUTRAL: self.price *= 2 self.price = self.price - int( self.price * game_self.dungeon.party_encounter_window.use_points * 3.5 / 100) elif self.relation == self.EVIL: self.price *= 4 self.price = self.price - int( self.price * game_self.dungeon.party_encounter_window.use_points * 1.5 / 100) #select buying item self.message = [ u"目の前の冒険者達はアイテムを取り出すと", u"冒険者達に値段を告げた。", "", u"アイテムを" + str(self.price) + u"TGで購入しますか?" ] self.buy_window = system_notify.Confirm_window( Rect(160, 150, 380, 110), system_notify.Confirm_window.BUY_ITEM) self.buy_window.is_visible = True pass elif self.instruction == self.HEAL: self.heal_percent = 0 self.price = 0 if self.relation == self.GOOD: self.heal_percent = game_self.dungeon.party_encounter_window.use_points * 25 elif self.relation == self.NEUTRAL: self.heal_percent = game_self.dungeon.party_encounter_window.use_points * 10 elif self.relation == self.EVIL: self.heal_percent = game_self.dungeon.party_encounter_window.use_points * 5 for chara in game_self.party.member: if chara.status[5] == 1 or chara.status[ 6] == 1 or chara.status[7] == 1: continue chara.hp += random.randint( 0, int(math.ceil((self.heal_percent / 100.0) * chara.max_hp))) if chara.hp > chara.max_hp: chara.hp = chara.max_hp self.message = [u"冒険者達は傷を治してもらった!"]
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