Exemple #1
0
 def move_item(self, item, value):
     if item not in self.items:
         return
     if value > 0:
         if is_type(item, "droid_module"):
             self.unequip_module(item)
         if is_type(item, "droid_part"):
             self.unequip_part(item)
     item.equipped_quantity += value
     if item.equipped_quantity > item.total_quantity:
         item.equipped_quantity = item.total_quantity
     if item.equipped_quantity < 0:
         item.equipped_quantity = 0
Exemple #2
0
 def get_abilities(self):
     abilities = set()  # TODO fix later
     for item in self.items:
         for bonus in item.bonuses:
             if is_type(bonus, "ability"):
                 abilities.add(bonus)
     return self.abilities | abilities
Exemple #3
0
 def unequip_module(self, module):
     name = module.name
     for item in self.items:
         if not is_type(item, "droid_module"):
             continue
         if module.ID == item.ID:
             continue
         if name == item.name:
             self.move_item(item, -1)
Exemple #4
0
 def unequip_part(self, part):
     part_type = part.type
     if part_type == "droid_other":
         return
     for item in self.items:
         if not is_type(item, part_type):
             continue
         if part.ID == item.ID:
             continue
         self.move_item(item, -1)
Exemple #5
0
    def get_equipped_weapons(self):
        items = []
        for item in self.items:
            if not item.equipped_quantity:
                continue
            if not is_type(item, "ranged_weapon"):
                continue
            items.append(item)

        return items
 def fill_values(self):
     self.weapon_name.set_text(translate(self.item.display) if self.item.display else self.item.name)
     self.weapon_damage.set_text(str(self.item.damage))
     self.weapon_damage_type.set_text(self.item.damage_type)
     self.weapon_pp.set_text(str(self.item.ap))
     if is_type(self.item, "ranged_weapon"):
         self.weapon_ammo_cost.set_text(str(self.item.shot_cost))
         self.weapon_current_power.link_value(self.item.power_magazine)
     self.weapon_value.set_text(str(self.item.price))
     self.weapon_weight.set_text(str(self.item.weight))
     self.equipped_checkbox.setChecked(self.item.equipped_quantity > 0)
     self.weapon_type.set_text(translate(self.item.weapon_type))
 def __init__(self, weapon):
     View.__init__(self)
     self.item = weapon
     self.name = weapon.ID
     p = self.palette()
     p.setColor(self.backgroundRole(), QColor(240, 240, 240))
     self.setPalette(p)
     self.setAutoFillBackground(True)
     layout = QVBoxLayout()
     layout.setSpacing(1)
     line1_layout = QHBoxLayout()
     line1_layout.setSpacing(4)
     line2_layout = QHBoxLayout()
     line1_layout.setSpacing(4)
     self.equipped_checkbox = EquippedCheckbox()
     self.equipped_checkbox.setChecked(self.item.equipped_quantity > 0)
     self.equipped_checkbox.stateChanged.connect(self.equip)
     line1_layout.addWidget(self.equipped_checkbox)
     self.weapon_name = LabelledLabel(label=translate("ui_item_name"))
     # self.weapon_name.setFixedWidth(120
     self.weapon_name.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Minimum)
     line1_layout.addWidget(self.weapon_name, stretch=0)
     self.weapon_type = LabelledLabel(label=translate("ui_weapon_type"), align_flag=Qt.AlignCenter)
     line1_layout.addWidget(self.weapon_type, stretch=0)
     self.weapon_damage = LabelledLabel(label=translate("ui_weapon_damage"), align_flag=Qt.AlignCenter)
     line1_layout.addWidget(self.weapon_damage, stretch=0)
     self.weapon_pp = LabelledLabel(label=translate("ui_weapon_ap"), align_flag=Qt.AlignCenter)
     line1_layout.addWidget(self.weapon_pp, stretch=0)
     self.weapon_damage_type = LabelledLabel(label=translate("ui_weapon_damage_type"), align_flag=Qt.AlignCenter)
     line1_layout.addWidget(self.weapon_damage_type, stretch=0)
     if is_type(self.item, "ranged_weapon"):
         self.weapon_ammo_cost = LabelledLabel(label=translate("ui_weapon_shotcost"), align_flag=Qt.AlignCenter)
         line1_layout.addWidget(self.weapon_ammo_cost, stretch=0)
         self.weapon_current_power = InputLine(name="power_magazine", label=translate("ui_weapon_magazine"),
                                               dtype="int", maxwidth=60, align_flag=Qt.AlignCenter)
         line1_layout.addWidget(self.weapon_current_power, stretch=0)
         self.weapon_current_power.value_changed.connect(self.modify_item)
     self.weapon_weight = LabelledLabel(label=translate("ui_item_weight"), align_flag=Qt.AlignCenter)
     line2_layout.addWidget(self.weapon_weight, stretch=0)
     self.weapon_value = LabelledLabel(label=translate("ui_item_price"), align_flag=Qt.AlignCenter)
     line2_layout.addWidget(self.weapon_value, stretch=0)
     self.weapon_traits = LabelledLabel(label=translate("ui_item_traits"))  # TODO!
     self.weapon_traits.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Minimum)
     line2_layout.addWidget(self.weapon_traits, stretch=0)
     layout.addLayout(line1_layout, stretch=0)
     layout.addLayout(line2_layout, stretch=0)
     # layout.addSpacerItem(QSpacerItem(20, 20, QSizePolicy.Minimum, QSizePolicy.Expanding))
     layout.setContentsMargins(1, 1, 1, 1)
     self.fill_values()
     self.add_header_option("Edit", self.edit)
     self.setLayout(layout)
Exemple #8
0
 def remove_item(self, equipped, _item):
     found = False
     for item in self.items:
         if _item.ID == item.ID:
             found = True
             break
     if not found:
         return
     if is_type(_item, "equipment_item"):
         self.items.remove(item)
         return
     if equipped:
         item.total_quantity -= item.equipped_quantity
         item.equipped_quantity = 0
     else:
         item.total_quantity -= item.total_quantity - item.equipped_quantity
     if item.total_quantity == 0:
         self.items.remove(item)
Exemple #9
0
    def get_skill_bonuses(self, skill):
        ski_value1 = self.skill_bonuses[skill]
        ski_value2 = self.skill_bonuses2[skill]
        for item in self.items:
            if not item.equipped_quantity:
                continue
            if is_type(item, "droid_module") and self.is_robot:
                for bonus in item.bonuses:
                    if bonus.name == skill:
                        if item.slot == 0:
                            ski_value1 += bonus.value
                        elif item.slot == 1:
                            ski_value2 += bonus.value
                continue
            for bonus in item.bonuses:
                if bonus.name == skill:
                    ski_value1 += bonus.value

        return ski_value1, ski_value2