def return_crafting_desc(self): """ :type self: ObjectDB """ string = "" adorns = self.adorns # adorns are a dict of the ID of the crafting material type to amount if adorns: adorn_strs = [ "%s %s" % (amt, mat.name) for mat, amt in adorns.items() ] string += "\nAdornments: %s" % ", ".join(adorn_strs) # recipe is an integer matching the CraftingRecipe ID if hasattr(self, 'type_description') and self.type_description: from server.utils.arx_utils import a_or_an td = self.type_description part = a_or_an(td) string += "\nIt is %s %s." % (part, td) if self.db.quality_level: string += self.get_quality_appearance() if self.db.quantity: string += "\nThere are %d units." % self.db.quantity if hasattr(self, 'origin_description') and self.origin_description: string += self.origin_description if self.db.translation: string += "\nIt contains script in a foreign tongue." # signed_by is a crafter's character object signed = self.db.signed_by if signed: string += "\n%s" % (signed.db.crafter_signature or "") return string
def magic_description(self): if self.db.magic_desc_override: return self.db.magic_desc_override if not self.alignment: return None noun = "blob of formless magic" second_noun = None if self.affinity: if self.practitioner: affinity_value = self.practitioner.resonance_for_affinity( self.affinity) else: affinity_value = self.primum if self.potential != self.primum: second_noun = self.affinity.description_for_value( self.potential) noun = self.affinity.description_for_value(affinity_value) adjective = self.alignment.adjective part = a_or_an(adjective) base_string = "{} {} {}".format(part.capitalize(), adjective, noun) if second_noun and (second_noun != noun): base_string = "Once {} {} {}, now only {} {}".format( part, adjective, second_noun, a_or_an(noun), noun) magic_desc_short = None if self.practitioner: magic_desc_short = self.practitioner.magic_desc_short if not magic_desc_short: magic_desc_short = self.db.magic_desc_short if magic_desc_short: base_string += ", {}.".format(magic_desc_short) else: base_string += "." return base_string
def see_through_contents(self): other_room = self.destination haven_square = None if hasattr(other_room, "shardhaven_square"): haven_square = other_room.shardhaven_square characters = [] character_string = None for testobj in other_room.contents: if testobj.has_account or (hasattr(testobj, "is_character") and testobj.is_character): characters.append(testobj.name) if len(characters): character_string = commafy(characters) elif haven_square and haven_square.monster: if haven_square.monster.npc_type == Monster.MOOKS: character_string = haven_square.monster.plural_name else: character_string = haven_square.monster.name puzzle_string = None if haven_square and haven_square.puzzle and not haven_square.puzzle_solved: puzzle_string = haven_square.puzzle.display_name result = "You see nothing of note in the next room." if character_string: result = "In the next room, you see " + character_string + "." if puzzle_string: puzzle_part = a_or_an(puzzle_string) result += " And {} {}.".format(puzzle_part, puzzle_string) elif puzzle_string: puzzle_part = a_or_an(puzzle_string) result = "In the next room, you see {} {}.".format( puzzle_part, puzzle_string) return result
def set(self, value, caller=None): if not value or value == -1: self._value = None return True, None final_value = self._get_value_for_name(value, caller) if not final_value: term = self.__class__.term termpart = a_or_an(term) return False, "You don't seem to know {} {} named '{}'!".format( termpart, term, value) self._value = final_value return True, None
def get_crafting_desc(self): """ :type self: ObjectDB """ string = "" adorns = self.adorn_objects # adorns are a dict of the ID of the crafting material type to amount if adorns: adorn_strs = ["%s %s" % (amt, mat.name) for mat, amt in adorns.items()] string += "\nAdornments: %s" % ", ".join(adorn_strs) # recipe is an integer matching the CraftingRecipe ID if hasattr(self.obj, "type_description") and self.obj.type_description: from server.utils.arx_utils import a_or_an td = self.obj.type_description part = a_or_an(td) string += "\nIt is %s %s." % (part, td) if self.quality_level: string += self.get_quality_appearance() if self.origin_description: string += self.origin_description if self.translation: string += "\nIt contains script in a foreign tongue." return string
def create_weapon(cls, haven, wpn_type=None): weapon_types = ( LootGenerator.WPN_SMALL, LootGenerator.WPN_MEDIUM, LootGenerator.WPN_HUGE, LootGenerator.WPN_BOW, ) if not wpn_type: wpn_type = random.choice(weapon_types) picker = WeightedPicker() difficulty = haven.difficulty_rating if difficulty < 3: picker.add_option("steel", 30) picker.add_option("rubicund", 50) picker.add_option("diamondplate", 1) elif difficulty < 5: picker.add_option("steel", 10) picker.add_option("rubicund", 40) picker.add_option("diamondplate", 5) elif difficulty < 8: picker.add_option("rubicund", 30) picker.add_option("diamondplate", 20) picker.add_option("alaricite", 5) else: picker.add_option("rubicund", 10) picker.add_option("diamondplate", 30) picker.add_option("alaricite", 5) material = picker.pick() should_name = material in ["diamondplate", "alaricite"] generator_wpn = GeneratedLootFragment.MEDIUM_WEAPON_TYPE if wpn_type == LootGenerator.WPN_SMALL: generator_wpn = GeneratedLootFragment.SMALL_WEAPON_TYPE elif wpn_type == LootGenerator.WPN_HUGE: generator_wpn = GeneratedLootFragment.HUGE_WEAPON_TYPE elif wpn_type == LootGenerator.WPN_BOW: generator_wpn = GeneratedLootFragment.BOW_WEAPON_TYPE name = GeneratedLootFragment.generate_weapon_name( material, include_name=should_name, wpn_type=generator_wpn) weapon = create.create_object( typeclass="world.exploration.loot.AncientWeapon", key=name) desc = "\n{particle} {adjective} ancient {material} weapon, with {decor} on the {element}.\n" if wpn_type == LootGenerator.WPN_BOW: desc = "\n{particle} {adjective} ancient {material} bow, decorated with {decor}.\n" adjective = GeneratedLootFragment.pick_random_fragment( GeneratedLootFragment.ADJECTIVE) decor = GeneratedLootFragment.pick_random_fragment( GeneratedLootFragment.WEAPON_DECORATION) element = GeneratedLootFragment.pick_random_fragment( GeneratedLootFragment.WEAPON_ELEMENT) particle = a_or_an(adjective).capitalize() desc = desc.replace("{particle}", particle) desc = desc.replace("{material}", material) desc = desc.replace("{adjective}", adjective) desc = desc.replace("{decor}", decor) desc = desc.replace("{element}", element) weapon.db.desc = desc quality_picker = WeightedPicker() quality_picker.add_option(4, 25) quality_picker.add_option(5, 45) quality_picker.add_option(6, 30) quality_picker.add_option(7, 10) quality_picker.add_option(8, 3) quality_picker.add_option(9, 1) weapon.item_data.quality_level = quality_picker.pick() weapon.db.found_shardhaven = haven.name weapon.item_data.recipe = LootGenerator.get_weapon_recipe( material, wpn_type=wpn_type) cls.set_alignment_and_affinity(haven, weapon) return weapon