Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,4 @@ xcuserdata
# Carthage/Checkouts

Carthage/Build
.DS_Store
Binary file added .prometheus/config/.config.json.swp
Binary file not shown.
17 changes: 17 additions & 0 deletions .prometheus/config/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"id": "486da85a-8a43-4eaf-bb1d-62dc3b90e28d",
"human_readable_name": "GildedRose",
"primary_language": "swift",
"framework": "Swift",
"created_at": "2023-10-02 13:14:55.108942",
"source_directory": "GildedRose",
"test_directory": "GildedRoseTests",
"documentation_directory": "docs",
"testing_framework": "xctest",
"main_file": "GildedRose/GildedRose.swift",
"package_manager": "swiftpackagemanager",
"package_manager_install_command": "pip install -e .",
"test_command": "xcodebuild test -scheme GildedRose",
"build_command": "xcodebuild",
"run_command": ""
}
4 changes: 2 additions & 2 deletions GildedRose.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
E2F4C3161B956316003632EA /* GildedRose.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E2F4C30B1B956315003632EA /* GildedRose.framework */; };
E2F4C31B1B956316003632EA /* GildedRoseTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = E2F4C31A1B956316003632EA /* GildedRoseTests.swift */; };
E2F4C3261B956365003632EA /* GildedRose.swift in Sources */ = {isa = PBXBuildFile; fileRef = E2F4C3251B956365003632EA /* GildedRose.swift */; };
E2F4C3281B956415003632EA /* Item.swift in Sources */ = {isa = PBXBuildFile; fileRef = E2F4C3271B956415003632EA /* Item.swift */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand All @@ -24,6 +23,7 @@
/* End PBXContainerItemProxy section */

/* Begin PBXFileReference section */
330B115D2AD33FFB00BACCD3 /* GildedRose.xctestplan */ = {isa = PBXFileReference; lastKnownFileType = text; path = GildedRose.xctestplan; sourceTree = "<group>"; };
E2F4C30B1B956315003632EA /* GildedRose.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = GildedRose.framework; sourceTree = BUILT_PRODUCTS_DIR; };
E2F4C3101B956315003632EA /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
E2F4C3151B956316003632EA /* GildedRoseTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = GildedRoseTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
Expand Down Expand Up @@ -55,6 +55,7 @@
E2F4C3011B956315003632EA = {
isa = PBXGroup;
children = (
330B115D2AD33FFB00BACCD3 /* GildedRose.xctestplan */,
E2F4C30D1B956315003632EA /* GildedRose */,
E2F4C3191B956316003632EA /* GildedRoseTests */,
E2F4C30C1B956315003632EA /* Products */,
Expand Down Expand Up @@ -197,7 +198,6 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
E2F4C3281B956415003632EA /* Item.swift in Sources */,
E2F4C3261B956365003632EA /* GildedRose.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down
83 changes: 83 additions & 0 deletions GildedRose.xcodeproj/xcshareddata/xcschemes/GildedRose.xcscheme
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1500"
version = "1.7">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "E2F4C30A1B956315003632EA"
BuildableName = "GildedRose.framework"
BlueprintName = "GildedRose"
ReferencedContainer = "container:GildedRose.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<TestPlans>
<TestPlanReference
reference = "container:GildedRose.xctestplan"
default = "YES">
</TestPlanReference>
</TestPlans>
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "E2F4C3141B956316003632EA"
BuildableName = "GildedRoseTests.xctest"
BlueprintName = "GildedRoseTests"
ReferencedContainer = "container:GildedRose.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "E2F4C30A1B956315003632EA"
BuildableName = "GildedRose.framework"
BlueprintName = "GildedRose"
ReferencedContainer = "container:GildedRose.xcodeproj">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
24 changes: 24 additions & 0 deletions GildedRose.xctestplan
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"configurations" : [
{
"id" : "14AC0DF2-788D-4831-88B9-75A057F66B04",
"name" : "Test Scheme Action",
"options" : {

}
}
],
"defaultOptions" : {

},
"testTargets" : [
{
"target" : {
"containerPath" : "container:GildedRose.xcodeproj",
"identifier" : "E2F4C3141B956316003632EA",
"name" : "GildedRoseTests"
}
}
],
"version" : 1
}
134 changes: 78 additions & 56 deletions GildedRose/GildedRose.swift
Original file line number Diff line number Diff line change
@@ -1,66 +1,88 @@
//
// GildedRose.swift
// GildedRose
//
// Created by Tom Heinan on 8/31/15.
// Copyright © 2015 Tom Heinan. All rights reserved.
//
/*

public class GildedRose {
Generated by Logomancy Prometheus

public static func updateQuality(_ items: Array<Item>) -> [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
Copyright © 2023 Ian McFarland and Logomancy
All Rights Reserved

Filename: GildedRose/GildedRose.swift
Language: Swift
Author: Paul Zabelin
* Base Prompt: Generate code that would make the tests in GildedRoseTests/GildedRoseTests.swift pass.

THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
It wasn't even made by humans, though the computers gave it their best shot.
Use at your own risk, and make sure it does what you want it to.

Learn more at https://prometheus.logomancy.co/


*/
import Foundation

class GildedRose {
class func updateQuality(_ items: [Item]) -> [Item] {
var updatedItems = [Item]()
for item in items {
let updatedItem = item
switch item.name {
case "Aged Brie":
updatedItem.sellIn -= 1
if updatedItem.quality < 50 {
updatedItem.quality += item.sellIn < 0 ? 2 : 1
if updatedItem.quality > 50 {
updatedItem.quality = 50
}
}
} 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
}
}
}
case "Sulfuras, Hand of Ragnaros":
break
case "Backstage passes to a TAFKAL80ETC concert":
updatedItem.sellIn -= 1
if updatedItem.sellIn < 0 {
updatedItem.quality = 0
} else if updatedItem.sellIn < 5 {
updatedItem.quality += 3
} else if updatedItem.sellIn < 10 {
updatedItem.quality += 2
} else if updatedItem.quality < 50 {
updatedItem.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
}
if updatedItem.quality > 50 {
updatedItem.quality = 50
}
case "Conjured Mana Cake":
updatedItem.sellIn -= 1
updatedItem.quality -= item.sellIn < 0 ? 4 : 2
if updatedItem.quality < 0 {
updatedItem.quality = 0
}
default:
updatedItem.sellIn -= 1
updatedItem.quality -= item.sellIn < 0 ? 2 : 1
if updatedItem.quality < 0 {
updatedItem.quality = 0
}
}
updatedItems.append(updatedItem)
}

return items
return updatedItems
}
}

class Item: Equatable {
var name: String
var sellIn: Int
var quality: Int

init(name: String, sellIn: Int, quality: Int) {
self.name = name
self.sellIn = sellIn
self.quality = quality
}

static func == (lhs: Item, rhs: Item) -> Bool {
return lhs.name == rhs.name && lhs.sellIn == rhs.sellIn && lhs.quality == rhs.quality
}

}