Add logic for Conjured Mana Cake#1
Open
AlanProphettSoftwire wants to merge 4 commits intomainfrom
Open
Conversation
Co-authored-by: tmgls <tmgls@users.noreply.github.com>
Co-authored-by: tmgls <tmgls@users.noreply.github.com>
LukeJStuart
reviewed
Sep 26, 2025
LukeJStuart
left a comment
There was a problem hiding this comment.
Good job adding this new functionality, I added some comments but have realised they are refacotring suggestions and this PR is about adding the new logic, so may be superfluous
| @@ -19,50 +19,52 @@ export class GildedRose { | |||
|
|
|||
| updateQuality() { | |||
| for (let i = 0; i < this.items.length; i++) { | |||
There was a problem hiding this comment.
Could consider doing something like for (const item of this.items) and then referring to item so you don't have to keep repeating this.items[i]
| break; | ||
| case "Aged Brie": | ||
| if (this.items[i].sellIn < 0) { | ||
| this.items[i].quality = Math.min(this.items[i].quality + 2, 50); |
There was a problem hiding this comment.
Could pull out values like 50 here into well-named consts to increase clarity and reduce risk of typos
| if (this.items[i].sellIn < 0) { | ||
| this.items[i].quality = Math.min(this.items[i].quality + 2, 50); | ||
| } else { | ||
| this.items[i].quality = Math.min(this.items[i].quality + 1, 50); |
There was a problem hiding this comment.
could create a helper function for clamping values so don't need to repeatedly use Math.min and Math.max throughout the switch statement
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Introduction ✏️
Add logic for
Conjured Mana Cake. This item depreciates in quality twice as fast as a standard item.Conjured Mana Cakehas a depreciation of2if thesellInis>=0and a depreciation of4is thesellIndate is<0.Resolution ✔️
updateQualityto set behavior for non standard items.Conjured Mana Cake, depreciate the quality at twice the rate of a standard item.Note⚠️