/* * This file is part of the L2J Mobius project. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ package com.l2jmobius.gameserver.model; import java.util.Collection; import java.util.Collections; import com.l2jmobius.gameserver.enums.AttributeType; import com.l2jmobius.gameserver.model.ensoul.EnsoulOption; import com.l2jmobius.gameserver.model.items.L2Item; import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance; public class TradeItem { private int _objectId; private final L2Item _item; private final int _location; private int _enchant; private final int _type1; private final int _type2; private long _count; private long _storeCount; private long _price; private final byte _elemAtkType; private final int _elemAtkPower; private final int[] _elemDefAttr = { 0, 0, 0, 0, 0, 0 }; private final int[] _enchantOptions; private final Collection _soulCrystalOptions; private final Collection _soulCrystalSpecialOptions; private int _visualId; private int _augmentId; public TradeItem(L2ItemInstance item, long count, long price) { _objectId = item.getObjectId(); _item = item.getItem(); _location = item.getLocationSlot(); _enchant = item.getEnchantLevel(); _type1 = item.getCustomType1(); _type2 = item.getCustomType2(); _count = count; _price = price; _elemAtkType = item.getAttackAttributeType().getClientId(); _elemAtkPower = item.getAttackAttributePower(); for (AttributeType type : AttributeType.ATTRIBUTE_TYPES) { _elemDefAttr[type.getClientId()] = item.getDefenceAttribute(type); } _enchantOptions = item.getEnchantOptions(); _soulCrystalOptions = item.getSpecialAbilities(); _soulCrystalSpecialOptions = item.getAdditionalSpecialAbilities(); _visualId = item.getVisualId(); _augmentId = item.isAugmented() ? item.getAugmentation().getId() : 0; } public TradeItem(L2Item item, long count, long price) { _objectId = 0; _item = item; _location = 0; _enchant = 0; _type1 = 0; _type2 = 0; _count = count; _storeCount = count; _price = price; _elemAtkType = Elementals.NONE; _elemAtkPower = 0; _enchantOptions = L2ItemInstance.DEFAULT_ENCHANT_OPTIONS; _soulCrystalOptions = Collections.emptyList(); _soulCrystalSpecialOptions = Collections.emptyList(); } public TradeItem(TradeItem item, long count, long price) { _objectId = item.getObjectId(); _item = item.getItem(); _location = item.getLocationSlot(); _enchant = item.getEnchant(); _type1 = item.getCustomType1(); _type2 = item.getCustomType2(); _count = count; _storeCount = count; _price = price; _elemAtkType = item.getAttackElementType(); _elemAtkPower = item.getAttackElementPower(); for (byte i = 0; i < 6; i++) { _elemDefAttr[i] = item.getElementDefAttr(i); } _enchantOptions = item.getEnchantOptions(); _soulCrystalOptions = item.getSoulCrystalOptions(); _soulCrystalSpecialOptions = item.getSoulCrystalSpecialOptions(); _visualId = item.getVisualId(); } public void setObjectId(int objectId) { _objectId = objectId; } public int getObjectId() { return _objectId; } public L2Item getItem() { return _item; } public int getLocationSlot() { return _location; } public void setEnchant(int enchant) { _enchant = enchant; } public int getEnchant() { return _enchant; } public int getCustomType1() { return _type1; } public int getCustomType2() { return _type2; } public void setCount(long count) { _count = count; } public long getCount() { return _count; } public long getStoreCount() { return _storeCount; } public void setPrice(long price) { _price = price; } public long getPrice() { return _price; } public byte getAttackElementType() { return _elemAtkType; } public int getAttackElementPower() { return _elemAtkPower; } public int getElementDefAttr(byte i) { return _elemDefAttr[i]; } public int[] getEnchantOptions() { return _enchantOptions; } public Collection getSoulCrystalOptions() { return _soulCrystalOptions; } public Collection getSoulCrystalSpecialOptions() { return _soulCrystalSpecialOptions; } public int getAugmentId() { return _augmentId; } public int getVisualId() { return _visualId; } }