-- BEGIN CHANGE: Combos Donate com set fixo + escolha de arma
-- Knight: set + Club/Sword/Axe
-- Paladin: set + Crossbow+Bolt / Bow+Arrow
-- Variantes antigas ficam active=0
-- Mage permanece oferta unica (sem escolha)

START TRANSACTION;

-- Knight: reusa id 12726
UPDATE `z_shop_offer`
SET
  `offer_type` = 'bundle',
  `offer_name` = 'COMBO KNIGHT',
  `offer_description` = 'Set completo de Knight (helmet, armor, legs, boots, shield e ring). Na compra voce escolhe a arma: Club, Sword ou Axe.',
  `points` = 65,
  `active` = 1,
  `sort_order` = 1
WHERE `id` = 12726 AND `catalog` = 'donate';

DELETE oi FROM `z_shop_offer_option_item` oi
INNER JOIN `z_shop_offer_option` op ON op.id = oi.option_id
INNER JOIN `z_shop_offer_group` g ON g.id = op.group_id
WHERE g.offer_id = 12726;

DELETE op FROM `z_shop_offer_option` op
INNER JOIN `z_shop_offer_group` g ON g.id = op.group_id
WHERE g.offer_id = 12726;

DELETE FROM `z_shop_offer_group` WHERE offer_id = 12726;

INSERT INTO `z_shop_offer_group` (`offer_id`, `label`, `sort_order`, `min_select`, `max_select`)
VALUES (12726, 'Set', 0, 1, 1);
SET @g_set_k := LAST_INSERT_ID();

INSERT INTO `z_shop_offer_option` (`group_id`, `label`, `sort_order`)
VALUES (@g_set_k, 'Full set', 0);
SET @o_set_k := LAST_INSERT_ID();

INSERT INTO `z_shop_offer_option_item` (`option_id`, `itemid`, `count`, `sort_order`, `slot_role`) VALUES
(@o_set_k, 12624, 1, 0, 'helmet'),
(@o_set_k, 12623, 1, 1, 'armor'),
(@o_set_k, 12646, 1, 2, 'legs'),
(@o_set_k, 12621, 1, 3, 'boots'),
(@o_set_k, 12622, 1, 4, 'shield'),
(@o_set_k, 2166, 1, 5, 'ring');

INSERT INTO `z_shop_offer_group` (`offer_id`, `label`, `sort_order`, `min_select`, `max_select`)
VALUES (12726, 'Arma', 1, 1, 1);
SET @g_wep_k := LAST_INSERT_ID();

INSERT INTO `z_shop_offer_option` (`group_id`, `label`, `sort_order`) VALUES
(@g_wep_k, 'Club', 0);
SET @o_club := LAST_INSERT_ID();
INSERT INTO `z_shop_offer_option_item` (`option_id`, `itemid`, `count`, `sort_order`, `slot_role`)
VALUES (@o_club, 12635, 1, 0, 'weapon');

INSERT INTO `z_shop_offer_option` (`group_id`, `label`, `sort_order`) VALUES
(@g_wep_k, 'Sword', 1);
SET @o_sword := LAST_INSERT_ID();
INSERT INTO `z_shop_offer_option_item` (`option_id`, `itemid`, `count`, `sort_order`, `slot_role`)
VALUES (@o_sword, 12636, 1, 0, 'weapon');

INSERT INTO `z_shop_offer_option` (`group_id`, `label`, `sort_order`) VALUES
(@g_wep_k, 'Axe', 2);
SET @o_axe := LAST_INSERT_ID();
INSERT INTO `z_shop_offer_option_item` (`option_id`, `itemid`, `count`, `sort_order`, `slot_role`)
VALUES (@o_axe, 12631, 1, 0, 'weapon');

UPDATE `z_shop_offer` SET `active` = 0 WHERE `id` IN (12751, 12752) AND `catalog` = 'donate';

-- Paladin: reusa id 12727
UPDATE `z_shop_offer`
SET
  `offer_type` = 'bundle',
  `offer_name` = 'COMBO PALADIN',
  `offer_description` = 'Set completo de Paladin (hat, armor, legs, boots e shield). Na compra voce escolhe Crossbow+Bolt ou Bow+Arrow.',
  `points` = 65,
  `active` = 1,
  `sort_order` = 1
WHERE `id` = 12727 AND `catalog` = 'donate';

DELETE oi FROM `z_shop_offer_option_item` oi
INNER JOIN `z_shop_offer_option` op ON op.id = oi.option_id
INNER JOIN `z_shop_offer_group` g ON g.id = op.group_id
WHERE g.offer_id = 12727;

DELETE op FROM `z_shop_offer_option` op
INNER JOIN `z_shop_offer_group` g ON g.id = op.group_id
WHERE g.offer_id = 12727;

DELETE FROM `z_shop_offer_group` WHERE offer_id = 12727;

INSERT INTO `z_shop_offer_group` (`offer_id`, `label`, `sort_order`, `min_select`, `max_select`)
VALUES (12727, 'Set', 0, 1, 1);
SET @g_set_p := LAST_INSERT_ID();

INSERT INTO `z_shop_offer_option` (`group_id`, `label`, `sort_order`)
VALUES (@g_set_p, 'Full set', 0);
SET @o_set_p := LAST_INSERT_ID();

INSERT INTO `z_shop_offer_option_item` (`option_id`, `itemid`, `count`, `sort_order`, `slot_role`) VALUES
(@o_set_p, 12686, 1, 0, 'helmet'),
(@o_set_p, 12687, 1, 1, 'armor'),
(@o_set_p, 12646, 1, 2, 'legs'),
(@o_set_p, 12621, 1, 3, 'boots'),
(@o_set_p, 12622, 1, 4, 'shield');

INSERT INTO `z_shop_offer_group` (`offer_id`, `label`, `sort_order`, `min_select`, `max_select`)
VALUES (12727, 'Arma', 1, 1, 1);
SET @g_wep_p := LAST_INSERT_ID();

INSERT INTO `z_shop_offer_option` (`group_id`, `label`, `sort_order`) VALUES
(@g_wep_p, 'Crossbow e Bolt', 0);
SET @o_xbow := LAST_INSERT_ID();
INSERT INTO `z_shop_offer_option_item` (`option_id`, `itemid`, `count`, `sort_order`, `slot_role`) VALUES
(@o_xbow, 12729, 1, 0, 'weapon'),
(@o_xbow, 12661, 1, 1, 'ammo');

INSERT INTO `z_shop_offer_option` (`group_id`, `label`, `sort_order`) VALUES
(@g_wep_p, 'Bow e Arrow', 1);
SET @o_bow := LAST_INSERT_ID();
INSERT INTO `z_shop_offer_option_item` (`option_id`, `itemid`, `count`, `sort_order`, `slot_role`) VALUES
(@o_bow, 12659, 1, 0, 'weapon'),
(@o_bow, 12700, 1, 1, 'ammo');

UPDATE `z_shop_offer` SET `active` = 0 WHERE `id` = 12753 AND `catalog` = 'donate';

-- Mage: so limpa o nome
UPDATE `z_shop_offer`
SET
  `offer_name` = 'COMBO MAGE',
  `offer_description` = 'Set completo de Mage (hat, cape, legs, boots, spellbook, staff e ring).'
WHERE `id` = 12728 AND `catalog` = 'donate';

COMMIT;
-- END CHANGE
