package emu.grasscutter.server.packet.send;

import emu.grasscutter.game.avatar.GenshinAvatar;
import emu.grasscutter.game.inventory.GenshinItem;
import emu.grasscutter.net.packet.GenshinPacket;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.WeaponAwakenRspOuterClass.WeaponAwakenRsp;

public class PacketWeaponAwakenRsp extends GenshinPacket {
	
	public PacketWeaponAwakenRsp(GenshinAvatar avatar, GenshinItem item, GenshinItem feedWeapon, int oldRefineLevel) {
		super(PacketOpcodes.WeaponAwakenRsp);

		WeaponAwakenRsp.Builder proto = WeaponAwakenRsp.newBuilder()
				.setTargetWeaponGuid(item.getGuid())
				.setTargetWeaponAwakenLevel(item.getRefinement());
		
		for (int affixId : item.getAffixes()) {
			proto.putOldAffixLevelMap(affixId, oldRefineLevel);
			proto.putCurAffixLevelMap(affixId, item.getRefinement());
		}
		
		if (avatar != null) {
			proto.setAvatarGuid(avatar.getGuid());
		}
		
		this.setData(proto);
	}
}
