示例#1
0
文件: __init__.py 项目: JimBean1/cuwo
    def has_illegal_consumable(self):
        entity_data = self.connection.entity_data
        item = entity_data.consumable

        # no consumable equiped
        if item.type == 0:
            return False

        if self.is_item_illegal(item):
            return True

        power_item = get_power(item.level)
        power_char = get_power(entity_data.level)
        if power_item > power_char:
            self.log(
                (
                    "consumable level too high for character "
                    + "item: level:{level1} (power: {power1}) "
                    + "character: level:{level2} (power: {power2})"
                ).format(level1=item.level, power1=power_item, level2=entity_data.level, power2=power_char),
                LOG_LEVEL_VERBOSE,
            )
            return True

        return False
示例#2
0
文件: commands.py 项目: MazeXD/cuwo
def player(script, name):
    player = script.get_player(name)
    entity_data = player.entity_data

    character = NPC_NAMES[entity_data.entity_type]

    class_type = entity_data.class_type
    class_spec = entity_data.specialization
    klass = CLASS_NAMES[class_type]
    spec = CLASS_SPECIALIZATIONS[class_type][class_spec]

    level = entity_data.level
    power = get_power(level)

    hp = entity_data.hp
    max_hp = get_entity_max_health(entity_data)

    info = ["%s" % character,
            "Class: %s (%s)" % (klass, spec),
            "Level: %d (+%d)" % (level, power),
            "Health: %d / %d" % (hp, max_hp)]
    for idx, line in enumerate(info):
        info[idx] = ('[%s] ' + line) % name

    if isinstance(script, ScriptInterface):
        for line in info:
            print line
    else:
        script.connection.send_lines(info)
示例#3
0
文件: __init__.py 项目: JimBean1/cuwo
    def is_equipped_illegal(self, item, in_slotindex):
        entity_data = self.connection.entity_data

        power_item = get_power(item.level)
        power_char = get_power(entity_data.level)
        if power_item > power_char:
            self.log(
                (
                    "item level too high for character "
                    + "item: level:{level1} (power: {power1}) "
                    + "character: level:{level2} (power: {power2})"
                ).format(level1=item.level, power1=power_item, level2=entity_data.level, power2=power_char),
                LOG_LEVEL_VERBOSE,
            )
            return True

        if not item.type in LEGAL_ITEMSLOTS:
            self.log(
                "non equipable item slot:"
                + "type={type} subtype={subtype} slot={slot}".format(
                    type=item.type, subtype=item.sub_type, slot=in_slotindex
                ),
                LOG_LEVEL_VERBOSE,
            )
            return True

        if not in_slotindex in LEGAL_ITEMSLOTS[item.type]:
            self.log(
                "item in invalid slot:"
                + "type={type} subtype={subtype} slot={slot}".format(
                    type=item.type, subtype=item.sub_type, slot=in_slotindex
                ),
                LOG_LEVEL_VERBOSE,
            )
            return True

        if in_slotindex == 6 and item.sub_type in TWOHANDED_WEAPONS:
            if self.allow_dual_wield is False and entity_data.equipment[7].type != 0:
                self.log(
                    "dual wield bug"
                    + (" weapon (slot6) = {item1}" + " weapon (slot7) = {item2}").format(
                        item1=item.sub_type, item2=entity_data.equipment[7].sub_type
                    ),
                    LOG_LEVEL_VERBOSE,
                )
                return True
            if entity_data.equipment[7].sub_type in TWOHANDED_WEAPONS:
                self.log(
                    "dual wield two handers"
                    + (" weapon (slot6) = {item1}" + " weapon (slot7) = {item2}").format(
                        item1=entity_data.equipment[6].sub_type, item2=entity_data.equipment[7].sub_type
                    ),
                    LOG_LEVEL_VERBOSE,
                )
                return True

        if in_slotindex == 7 and item.sub_type in TWOHANDED_WEAPONS:
            if self.allow_dual_wield is False and entity_data.equipment[6].type != 0:
                self.log(
                    "dual wield bug"
                    + (" weapon (slot6) = {item1}" + " weapon (slot7) = {item2}").format(
                        item1=entity_data.equipment[6].sub_type, item2=item.sub_type
                    ),
                    LOG_LEVEL_VERBOSE,
                )
                return True

        if item.type == 3 and not item.sub_type in CLASS_WEAPONS[entity_data.class_type]:
            self.log(
                "weapon not allowed for class"
                + " subtype={subtype} class={classid} item={item}".format(
                    subtype=item.sub_type, classid=entity_data.class_type, item=get_item_name(item)
                ),
                LOG_LEVEL_VERBOSE,
            )
            return True

        if item.type in ARMOR_IDS and not item.material in CLASS_ARMOR[entity_data.class_type]:
            self.log(
                "armor not allowed for class "
                + " material={material} class={classid} item={item}".format(
                    material=item.material, classid=entity_data.class_type, item=get_item_name(item)
                ),
                LOG_LEVEL_VERBOSE,
            )
            return True

        return False