def handle_read_only(self): if config.HANDLED_READ_ONLY: return # check that Display Message when Modifying Read-Only Parts is not set # (Customer Defaults > Assemblies > Miscellaneous > Display Message when Modifying Read-Only Parts) read_only_warn_mod = self.session.OptionsManager.GetIntValue( "Assemblies_DisplayReadOnly") logging.getLogger(__name__).debug( "Assemblies Warn Read-Only state: {}".format(read_only_warn_mod)) if read_only_warn_mod == 1: msg = [ "Display of modification warning for Read-Only parts is turned on.", "", "This means that for every Read-Only part being processed, ", "\tyou will get a warning that the part was modified during processing.", "", "To suppress this, you need to turn the following option off and restart NX for the change to take affect.", "File > Utilities > Customer Defaults > Assemblies > Miscellaneous > Display Message when Modifying Read-Only Parts", "", "Do you want to continue processing parts read-only parts?", ] res = dialog.question( msg, "Read-Only modifications will display warning") if res == 2: # user chose to abort. make sure nothing else processes self.parts_to_process.clear() res = dialog.question("Do you want these warnings turned off?", "Turn off warnings") # turn off warning for user if res == 1: change_opt = self.session.OptionsManager.NewOptionsChangeList( NXOpen.Options.LevelType.User, NXOpen.Options.LevelLockedByDefault.FalseValue) change_opt.SetValue("Assemblies_DisplayReadOnly", 0) change_opt.Save() change_opt.Dispose() dialog.info( "Modification warnings turned off. Please restart NX.") # will tell part processing to abort return True # keep this dialog from showing again config.HANDLED_READ_ONLY = True
def activate(self): action = dialog.question(self.intro, ('I have an item to sell', 'I would like to make a purchase', 'Never mind')) if action == 0: self.do_sell() elif action == 1: choice = dialog.question('Select the item your heart desires:', self.item_names) if choice >= len(self.item_names)-1: dialog.message("Come back when you are ready to order!") return item = self.item_list[choice] hero = core.game.save_data.hero if item.value <= hero.get_gold(): hero.add_gold( -item.get_value() ) self.purchased(item) else: dialog.message('Come back when you have accumulated enough gold!')
def walk_in_front_of_dude(self): choice = dialog.question( "I am the wise dude. What is it you would like to know?", [ "What am I supposed to do here?", "How does fighting work?", "Any hints on getting started?", "This seems too simple, is that it?" ]) if choice == 0: dialog.message("You're job is to destroy the evil Minotaur. " + "He lives in a cave north of town. You'll find " + "him on the 20th level. Yeah, its a big cave. " + "Should be pretty easy to find him though, the " + "levels are mostly just stops between stairs. " + "No one knows why he'd want to keep digging like " + "that, seems like it would be a pain to go up " + "and down the stairs all the time to mess with us.") elif choice == 1: dialog.message("Its pretty simple really, you can hack, slash, " + "or stab. Each method has a different chance of " + "hitting and does a different amount of damage. " + "Hack is the basic attack. It is the easiest to " + "hit with, but does the least damage. Slash is " + "a little harder to hit with, but does more " + "damage. Stab is the hardest to use, but does " + "the most damage. Now get out there and fight") elif choice == 2: dialog.message("Starting out is always the hardest part. You " + "have nothing but a little money. At least its " + "not zilch. There are two basic strategies for " + "you. Either save the money for the hospital, " + "or go get yourself armor or a weapon and get " + "fighting. If you buy armor, you have a better " + "chance of not getting hit. The weapon will " + "allow you to hit more often and do more damage. " + "I'd go with the weapon, personally, since the " + "early fights will be shorter and you won't have " + "as many opportunities to get hurt.") dialog.message("At the very beginning, you'll want to stick to " + "the area right outside of town. Then come back " + "to town after each fight. Heal and save, that " + "sort of thing. After you have a couple of " + "levels under your belt, and some decent " + "equiptment, you can head to the cave. Fight on " + "each level until you are comfortable with the " + "risk. That doesn't mean hang around levels " + "with no challenge! You won't get anywhere here " + "unless you take risks. The deeper you go into " + "the cave, the more money and experience you get.") elif choice == 3: dialog.message("Ummm... That really is about it. Oh yeah, if " + "you do manage to get rid of the evil Minotaur, " + "we'll make you mayor and all the girls will " + "want you. As mayor, you'll also have a nice " + "retirement plan and good benefits. The pay " + "isn't the greatest, but you'll get to live in " + "the town hall and have servants and food " + "provided for you. All in all, not a bad gig.")
def run_main_menu(): options = ("Inventory", "Save Game", "Load Game","New Game") choice = options[dialog.question("Main Menu", options)] if choice == "Inventory": core.game.show_inventory() elif choice == "Save Game": core.game.save() elif choice == "Load Game": core.game.load() elif choice == "New Game": core.game.start_new_game()
def run(self): monster = self.monster hero = self.hero dialog.message('You have been attacked by a %s!' % monster.get_name()) hero_initiative = hero.get_initiative() monster_initiative = monster.get_initiative() while True: if hero_initiative > monster_initiative: monster_initiative = monster_initiative + monster.get_initiative() action = dialog.question('What is your bidding?', \ ( 'Hack', 'Slash', 'Stab' )) if action == 0: thaco = hero.get_thaco() - 2 mult = 1.0 elif action == 1: thaco = hero.get_thaco() mult = 1.5 elif action == 2: thaco = hero.get_thaco() + 2 mult = 2.0 if thaco - monster.ac <= dice.roll('1d20'): damage = int(hero.weapon.get_damage() * mult * hero.strength / 10.0) if monster.damage(damage): gold = monster.get_gold() hero.add_gold(gold) hero.gain_exp(monster.get_exp_value()) mess = 'You hit the %s for %d points of damage, ' + \ 'killing it! You find %d gold. For valor ' + \ 'in combat, you receive %d experience points.' mess = mess % (monster.get_name(), damage, gold, monster.get_exp_value()) dialog.message(mess) hero.check_level() return 'win' else: dialog.message('You hit the %s for %d points of damage.' % \ (monster.get_name(), damage)) else: dialog.message('You missed!') else: hero_initiative = hero_initiative + hero.get_initiative() if monster.thaco - hero.get_ac() <= dice.roll('1d20'): damage = monster.do_damage() message = monster.damage_text(damage) if hero.damage(damage): dialog.message(message + ' You have died!') return 'lose' else: dialog.message(message) else: dialog.message('The %s misses you!' % monster.get_name())
def do_sell(self): all_items = core.game.save_data.hero.get_inventory()[:] items = filter(lambda x: x.get_value()>0, all_items) item_names = map(self.sell_text, items) item_names.append('Never mind') choice = dialog.question('Select the item you are interested in selling:', item_names) if choice == len(items): return else: item = items[choice] hero = core.game.save_data.hero hero.get_inventory().remove(item) hero.add_gold( int(item.get_value()*self.sell_factor) ) dialog.message('A bargain at twice the price!')
def walk_in_front_of_dude(self): dialog.message("You stand before the wise dude! Here is a lot " + "of text that you will need to split across at " + "least two lines, perhaps several more! And as " + "a special feature, if this first line is longer " + "than the next dialog, then it will even be trimmed " + "properly!") choice = dialog.question( "Since this is a very very wise man, he has much " + "to say to you. This may even spill over into " + "another dialog!", [ "No, make it stop!", "Yes, Continue!", "I can't decide", "Who knows?" ]) if choice == 0: dialog.message("No! Stopping is not an option!") elif choice == 1: dialog.message("Good, I appreciate your patience.") elif choice == 2: dialog.message("Well, hurry and make up your mind!") elif choice == 3: dialog.message("Ummm.. you're supposed to know that.")