Skip to content

Commit 61aee5a

Browse files
committed
Merge branch 'next-rando-version' into exclude-locations
2 parents b09fd94 + 68511a7 commit 61aee5a

11 files changed

Lines changed: 155 additions & 35 deletions

src/services/__snapshots__/logic-helper.test.js.snap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,7 @@ exports[`LogicHelper ALL_ITEMS returns a list of all the items, including entran
241241
"Blue Chu Near Second Hole at Night",
242242
"Blue Chu Near Peak Chest",
243243
"Blue Chu Near Cave Entrance",
244+
"Blue Chu Jelly",
244245
]
245246
`;
246247

src/services/__snapshots__/logic-tweaks.test.js.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2489,7 +2489,7 @@ exports[`LogicTweaks applyTweaks when no options are set updates the locations 1
24892489
"types": "Short Sidequest",
24902490
},
24912491
"Chu Jelly Juice Shop - Give 15 Blue Chu Jelly": {
2492-
"need": "Can Obtain 15 Blue Chu Jelly",
2492+
"need": "Blue Chu Jelly x15",
24932493
"originalItem": "Blue Potion",
24942494
"types": "Spoils Trading, Long Sidequest",
24952495
},

src/services/__snapshots__/tracker-controller.test.js.snap

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

src/services/__snapshots__/tracker-state.test.js.snap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ exports[`TrackerState default initializes the items 1`] = `
1818
"Beedle's Chart": 0,
1919
"Blue Chu Atop Northeast Statue": 0,
2020
"Blue Chu Behind Face Rock": 0,
21+
"Blue Chu Jelly": 0,
2122
"Blue Chu Near Cave Entrance": 0,
2223
"Blue Chu Near Eastern Fairy Tree": 0,
2324
"Blue Chu Near Final Rock Spire": 0,

src/services/logic-calculation.test.js

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2136,4 +2136,77 @@ describe('LogicCalculation', () => {
21362136
});
21372137
});
21382138
});
2139+
2140+
describe('blue chus', () => {
2141+
beforeEach(() => {
2142+
fullSetup();
2143+
});
2144+
2145+
describe('when the player has no blue chus', () => {
2146+
test('blue chus location is unavailable', () => {
2147+
const isBlueChusLocationAvailable = logic.isLocationAvailable(
2148+
'Windfall Island',
2149+
'Chu Jelly Juice Shop - Give 15 Blue Chu Jelly',
2150+
);
2151+
expect(isBlueChusLocationAvailable).toEqual(false);
2152+
});
2153+
});
2154+
2155+
describe('when the player collects 1 blue chu', () => {
2156+
beforeEach(() => {
2157+
logic = new LogicCalculation(
2158+
logic.state().incrementItem('Second Blue Chu Near Chest'),
2159+
);
2160+
});
2161+
2162+
test('blue chus location is unavailable', () => {
2163+
const isBlueChusLocationAvailable = logic.isLocationAvailable(
2164+
'Windfall Island',
2165+
'Chu Jelly Juice Shop - Give 15 Blue Chu Jelly',
2166+
);
2167+
expect(isBlueChusLocationAvailable).toEqual(false);
2168+
});
2169+
2170+
test('blue chu count is 1', () => {
2171+
const blueChuCount = logic.state().getItemValue(LogicHelper.BLUE_CHU_JELLY_COUNT_ITEM);
2172+
expect(blueChuCount).toEqual(1);
2173+
});
2174+
});
2175+
2176+
describe('when the player collects 15 blue chus', () => {
2177+
beforeEach(() => {
2178+
logic = new LogicCalculation(
2179+
logic.state()
2180+
.incrementItem('Blue Chu Underneath Boulder')
2181+
.incrementItem('Blue Chu Near Northern Fairy Tree')
2182+
.incrementItem('First Blue Chu Near Chest')
2183+
.incrementItem('Blue Chu on High Ledge')
2184+
.incrementItem('Blue Chu on Highest Point')
2185+
.incrementItem('Blue Chu Near Southern Fairy Tree')
2186+
.incrementItem('Blue Chu on Highest Isle')
2187+
.incrementItem('Blue Chu Near Second Hole at Night')
2188+
.incrementItem('Blue Chu Near Peak Chest')
2189+
.incrementItem('Blue Chu Near Cave Entrance')
2190+
.incrementItem('Blue Chu Atop Northeast Statue')
2191+
.incrementItem('Blue Chu Near Western Fairy Tree')
2192+
.incrementItem('Blue Chu Near Final Rock Spire')
2193+
.incrementItem('Blue Chu Near Wooden Sign')
2194+
.incrementItem('Second Blue Chu Near Chest'),
2195+
);
2196+
});
2197+
2198+
test('blue chus location is available', () => {
2199+
const isBlueChusLocationAvailable = logic.isLocationAvailable(
2200+
'Windfall Island',
2201+
'Chu Jelly Juice Shop - Give 15 Blue Chu Jelly',
2202+
);
2203+
expect(isBlueChusLocationAvailable).toEqual(true);
2204+
});
2205+
2206+
test('blue chu count is 15', () => {
2207+
const blueChuCount = logic.state().getItemValue(LogicHelper.BLUE_CHU_JELLY_COUNT_ITEM);
2208+
expect(blueChuCount).toEqual(15);
2209+
});
2210+
});
2211+
});
21392212
});

src/services/logic-helper.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,10 @@ class LogicHelper {
141141
TRIFORCE: 'Triforce',
142142
};
143143

144+
static BLUE_CHU_JELLY_COUNT_REQUIRED = 15;
145+
146+
static BLUE_CHU_JELLY_COUNT_ITEM = 'Blue Chu Jelly';
147+
144148
static ALL_ITEMS = _.concat(
145149
_.map(ISLAND_ENTRANCES, (entranceData) => this.entryName(entranceData.internalName)),
146150
CHARTS,
@@ -149,6 +153,7 @@ class LogicHelper {
149153
_.keys(ITEMS),
150154
_.keys(KEYS),
151155
_.values(BLUE_CHUCHUS).flat(),
156+
[this.BLUE_CHU_JELLY_COUNT_ITEM],
152157
);
153158

154159
static ALL_TREASURE_CHARTS = _.range(1, CHARTS.length - this.NUM_TRIFORCE_CHARTS + 1).map((number) => `Treasure Chart ${number}`);
@@ -337,7 +342,7 @@ class LogicHelper {
337342
}
338343

339344
static parseItemCountRequirement(requirement) {
340-
const itemCountRequirementMatch = requirement.match(/((?:\w|\s)+) x(\d)/);
345+
const itemCountRequirementMatch = requirement.match(/((?:\w|\s)+) x(\d+)/);
341346

342347
if (itemCountRequirementMatch) {
343348
return {

src/services/logic-tweaks.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ class LogicTweaks {
5050
static #updateLocations() {
5151
this.#addDefeatGanondorf();
5252
this.#updateTingleStatueReward();
53+
this.#updateBlueChuJelly();
5354
this.#updateSunkenTriforceTypes();
5455
this.applyHasAccessedLocationTweaksForLocations();
5556
}
@@ -84,6 +85,15 @@ class LogicTweaks {
8485
);
8586
}
8687

88+
static #updateBlueChuJelly() {
89+
Locations.setLocation(
90+
LogicHelper.ISLANDS.WINDFALL_ISLAND,
91+
'Chu Jelly Juice Shop - Give 15 Blue Chu Jelly',
92+
Locations.KEYS.NEED,
93+
`${LogicHelper.BLUE_CHU_JELLY_COUNT_ITEM} x${LogicHelper.BLUE_CHU_JELLY_COUNT_REQUIRED}`,
94+
);
95+
}
96+
8797
static #updateSunkenTriforceTypes() {
8898
if (Settings.getOptionValue(Permalink.OPTIONS.RANDOMIZE_CHARTS)) {
8999
return;

src/services/tracker-state.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ class TrackerState {
6565
newItemCount = LogicHelper.startingItemCount(itemName);
6666
}
6767
_.set(newState.items, itemName, newItemCount);
68+
newState.#updateBlueChuTotalIfNecessary(itemName);
6869

6970
return newState;
7071
}
@@ -78,6 +79,7 @@ class TrackerState {
7879
newItemCount = LogicHelper.maxItemCount(itemName);
7980
}
8081
_.set(newState.items, itemName, newItemCount);
82+
newState.#updateBlueChuTotalIfNecessary(itemName);
8183

8284
return newState;
8385
}
@@ -222,7 +224,7 @@ class TrackerState {
222224
return newState;
223225
}
224226

225-
getMarkedBlueChuCount() {
227+
#getMarkedBlueChuCount() {
226228
const allChuItems = _.values(LogicHelper.BLUE_CHU_ITEMS);
227229
const numCollectedChus = _.sumBy(allChuItems, (chu) => this.getItemValue(chu));
228230
return numCollectedChus + LogicHelper.startingBlueChuJellyCount();
@@ -260,6 +262,13 @@ class TrackerState {
260262
const isChecked = this.isLocationChecked(generalLocation, detailedLocation);
261263
_.set(this.locationsChecked, [generalLocation, detailedLocation], !isChecked);
262264
}
265+
266+
#updateBlueChuTotalIfNecessary(itemName) {
267+
if (_.includes(LogicHelper.BLUE_CHU_ITEMS, itemName)) {
268+
const totalBlueChus = this.#getMarkedBlueChuCount();
269+
_.set(this.items, LogicHelper.BLUE_CHU_JELLY_COUNT_ITEM, totalBlueChus);
270+
}
271+
}
263272
}
264273

265274
export default TrackerState;

src/services/tracker-state.test.js

Lines changed: 44 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,29 @@ describe('TrackerState', () => {
205205
expect(newState.items['Deku Leaf']).toEqual(1);
206206
});
207207
});
208+
209+
describe('when incrementing a blue chu', () => {
210+
beforeEach(() => {
211+
state = TrackerState.default();
212+
});
213+
214+
test('updates blue chu jelly count for a single blue chu', () => {
215+
const newState = state.incrementItem('Blue Chu Underneath Boulder');
216+
217+
expect(newState.items['Blue Chu Underneath Boulder']).toEqual(1);
218+
expect(newState.items['Blue Chu Jelly']).toEqual(1);
219+
});
220+
221+
test('updates blue chu jelly count for all blue chus', () => {
222+
let newState = state;
223+
_.forEach(
224+
_.values(LogicHelper.BLUE_CHU_ITEMS),
225+
(chu) => { newState = newState.incrementItem(chu); },
226+
);
227+
228+
expect(newState.items['Blue Chu Jelly']).toEqual(23);
229+
});
230+
});
208231
});
209232

210233
describe('decrementItem', () => {
@@ -245,6 +268,27 @@ describe('TrackerState', () => {
245268
expect(newState.items['Deku Leaf']).toEqual(0);
246269
});
247270
});
271+
272+
describe('when decrementing a blue chu', () => {
273+
beforeEach(() => {
274+
state = TrackerState.default();
275+
state.items['Blue Chu Underneath Boulder'] = 1;
276+
state.items['Blue Chu on Top of Island'] = 1;
277+
state.items['Blue Chu Jelly'] = 2;
278+
});
279+
280+
test('updates blue chu jelly count', () => {
281+
const newState = state.decrementItem('Blue Chu Underneath Boulder');
282+
283+
expect(newState.items['Blue Chu Underneath Boulder']).toEqual(0);
284+
expect(newState.items['Blue Chu Jelly']).toEqual(1);
285+
286+
const newStateAfterSecondDecrement = newState.decrementItem('Blue Chu on Top of Island');
287+
288+
expect(newStateAfterSecondDecrement.items['Blue Chu on Top of Island']).toEqual(0);
289+
expect(newStateAfterSecondDecrement.items['Blue Chu Jelly']).toEqual(0);
290+
});
291+
});
248292
});
249293

250294
describe('getEntranceForExit', () => {
@@ -856,27 +900,4 @@ describe('TrackerState', () => {
856900
});
857901
});
858902
});
859-
860-
describe('getMarkedBlueChuCount', () => {
861-
let state;
862-
const allChuItems = _.values(LogicHelper.BLUE_CHU_ITEMS);
863-
864-
beforeEach(() => {
865-
state = new TrackerState();
866-
state.items = Object.fromEntries(allChuItems.map((chu) => [chu, 0]));
867-
});
868-
869-
test('counts a marked blue chu', () => {
870-
const newState = state.incrementItem('Blue Chu Underneath Boulder');
871-
872-
expect(newState.getMarkedBlueChuCount()).toEqual(1);
873-
});
874-
875-
test('counts every blue chu', () => {
876-
let newState = state;
877-
_.forEach(allChuItems, (chu) => { newState = newState.incrementItem(chu); });
878-
879-
expect(newState.getMarkedBlueChuCount()).toEqual(23);
880-
});
881-
});
882903
});

src/ui/items-table.jsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,18 +85,18 @@ class ItemsTable extends React.PureComponent {
8585
if (!trackNonProgressBlueChuJelly && !LogicHelper.blueChusAreUseful()) {
8686
return null;
8787
}
88-
const img = _.get(Images.IMAGES, ['BLUE_CHU_JELLY_COUNT']);
89-
const count = trackerState.getMarkedBlueChuCount();
90-
const textClass = count >= 15 ? 'chu-text-gold' : 'chu-text-white';
88+
const image = _.get(Images.IMAGES, ['BLUE_CHU_JELLY_COUNT']);
89+
const count = trackerState.getItemValue(LogicHelper.BLUE_CHU_JELLY_COUNT_ITEM);
90+
const textClass = count >= LogicHelper.BLUE_CHU_JELLY_COUNT_REQUIRED ? 'chu-text-gold' : 'chu-text-white';
9191
return (
9292
<div className="chu-count-container">
9393
<Item
9494
clearSelectedItem={this.clearSelectedItem}
9595
decrementItem={() => {}}
96-
images={img}
96+
images={image}
9797
incrementItem={() => {}}
9898
itemCount={0}
99-
itemName={`Blue Chu Jelly (${count}/15)`}
99+
itemName={`Blue Chu Jelly (${count}/${LogicHelper.BLUE_CHU_JELLY_COUNT_REQUIRED})`}
100100
locations={[]}
101101
setSelectedItem={this.setSelectedItem}
102102
spheres={spheres}

0 commit comments

Comments
 (0)