From 5d62803293c68e3c716d652b8ba4a75aeec6114d Mon Sep 17 00:00:00 2001 From: Paul Zabelin Date: Tue, 10 Oct 2023 17:47:46 -0700 Subject: [PATCH] Use OpenAI to refactor, took multiple attempts --- GildedRose/GildedRose.swift | 113 ++++++++++++++++++++---------------- 1 file changed, 62 insertions(+), 51 deletions(-) diff --git a/GildedRose/GildedRose.swift b/GildedRose/GildedRose.swift index 36154f7..cf0ed94 100644 --- a/GildedRose/GildedRose.swift +++ b/GildedRose/GildedRose.swift @@ -7,60 +7,71 @@ // public class GildedRose { - + public static func updateQuality(_ items: Array) -> [Item] { - var items = items - for i in 0 ..< items.count { - if items[i].name != "Aged Brie" && items[i].name != "Backstage passes to a TAFKAL80ETC concert" { - if items[i].quality > 0 { - if items[i].name != "Sulfuras, Hand of Ragnaros" { - items[i].quality = items[i].quality - 1 - } - } - } else { - if items[i].quality < 50 { - items[i].quality = items[i].quality + 1 - - if items[i].name == "Backstage passes to a TAFKAL80ETC concert" { - if items[i].sellIn < 11 { - if items[i].quality < 50 { - items[i].quality = items[i].quality + 1 - } - } - - if items[i].sellIn < 6 { - if items[i].quality < 50 { - items[i].quality = items[i].quality + 1 - } - } - } - } - } - - if items[i].name != "Sulfuras, Hand of Ragnaros" { - items[i].sellIn = items[i].sellIn - 1 - } - - if items[i].sellIn < 0 { - if items[i].name != "Aged Brie" { - if items[i].name != "Backstage passes to a TAFKAL80ETC concert" { - if items[i].quality > 0 { - if items[i].name != "Sulfuras, Hand of Ragnaros" { - items[i].quality = items[i].quality - 1 - } - } - } else { - items[i].quality = items[i].quality - items[i].quality - } - } else { - if items[i].quality < 50 { - items[i].quality = items[i].quality + 1 - } - } + var updatedItems = items + for i in 0..