Skip to content
This repository has been archived by the owner on Jan 5, 2019. It is now read-only.

Commit

Permalink
refactor(deprecation): switch from max to maxSockets
Browse files Browse the repository at this point in the history
Should avoid confusions with maxLinks
  • Loading branch information
eps1lon committed Jun 9, 2018
1 parent df67cdd commit 445d51f
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 25 deletions.
26 changes: 22 additions & 4 deletions src/containers/item/components/Sockets/Sockets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,14 @@ import { SocketColor, SocketGroup, SocketId, Socket } from './types';

export interface Sockets<T> {
/**
* @deprecated use maxSockets() instead
* @returns the maximum amount of sockets
*/
max(): number;
/**
* @returns the maximum amount of sockets
*/
maxSockets(): number;
/**
* @returns current amount of sockets
*/
Expand Down Expand Up @@ -70,9 +75,23 @@ export default class ItemSockets
};
}

// TODO: what about Corroded Blades or other similar 1x4 Items. Confirm
// that they also only can have max 4 sockets like Rods or act like small_Staff
/**
* @deprecated
*/
public max(): number {
console.warn(
'poe-mods DEPRECATION: use Sockets.maxSockets() instead of Sockets.max()',
);
return this.maxSockets();
}

/**
* calculates the maximum amount of sockets possible on this item
*
* TODO: what about Corroded Blades or other similar 1x4 Items. Confirm
* that they also only can have max 4 sockets like Rods or act like small_Staff
*/
public maxSockets(): number {
const by_stats = this.maxOverride();

// tags take priority
Expand All @@ -84,7 +103,6 @@ export default class ItemSockets
this.maxByLevel(),
this.maxByMetaData(),
);
false;
}
}

Expand Down Expand Up @@ -161,7 +179,7 @@ export default class ItemSockets
force = false,
} = options;

const max_count = this.max();
const max_count = this.maxSockets();
if (!force && n > max_count) {
throw new SocketOverflow(max_count);
}
Expand Down
42 changes: 21 additions & 21 deletions src/containers/item/components/Sockets/__tests__/Sockets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,44 +110,44 @@ describe('links', () => {

describe('max()', () => {
it('should have no more than 4 on boots, gloves, helmets', () => {
expect(items.fromName('Bone Helmet').sockets.max()).toBe(4);
expect(items.fromName('Iron Gauntlets').sockets.max()).toBe(4);
expect(items.fromName('Iron Greaves').sockets.max()).toBe(4);
expect(items.fromName('Fishing Rod').sockets.max()).toBe(4);
expect(items.fromName('Bone Helmet').sockets.maxSockets()).toBe(4);
expect(items.fromName('Iron Gauntlets').sockets.maxSockets()).toBe(4);
expect(items.fromName('Iron Greaves').sockets.maxSockets()).toBe(4);
expect(items.fromName('Fishing Rod').sockets.maxSockets()).toBe(4);
});

it('should have no more than 3 on shields and 1H', () => {
expect(items.fromName('Rusted Sword').sockets.max()).toBe(3);
expect(items.fromName('Siege Axe').sockets.max()).toBe(3);
expect(items.fromName('Estoc').sockets.max()).toBe(3);
expect(items.fromName('War Buckler').sockets.max()).toBe(3);
expect(items.fromName('Driftwood Wand').sockets.max()).toBe(3);
expect(items.fromName('Rusted Sword').sockets.maxSockets()).toBe(3);
expect(items.fromName('Siege Axe').sockets.maxSockets()).toBe(3);
expect(items.fromName('Estoc').sockets.maxSockets()).toBe(3);
expect(items.fromName('War Buckler').sockets.maxSockets()).toBe(3);
expect(items.fromName('Driftwood Wand').sockets.maxSockets()).toBe(3);
});

it('should have no sockets on jewelry', () => {
expect(items.fromName('Amber Amulet').sockets.max()).toBe(0);
expect(items.fromName('Amber Amulet').sockets.maxSockets()).toBe(0);
});

it('should have no more than 6 on armour and 2H', () => {
expect(items.fromName('Plate Vest').sockets.max()).toBe(6);
expect(items.fromName('Keyblade').sockets.max()).toBe(6);
expect(items.fromName('Judgement Staff').sockets.max()).toBe(6);
expect(items.fromName('Plate Vest').sockets.maxSockets()).toBe(6);
expect(items.fromName('Keyblade').sockets.maxSockets()).toBe(6);
expect(items.fromName('Judgement Staff').sockets.maxSockets()).toBe(6);
});

it('should check level restrictions', () => {
const staff = items.fromName('Judgement Staff');

expect(staff.setProperty('item_level', 1).sockets.max()).toBe(2);
expect(staff.setProperty('item_level', 2).sockets.max()).toBe(3);
expect(staff.setProperty('item_level', 25).sockets.max()).toBe(4);
expect(staff.setProperty('item_level', 35).sockets.max()).toBe(5);
expect(staff.setProperty('item_level', 67).sockets.max()).toBe(6);
expect(staff.setProperty('item_level', 1).sockets.maxSockets()).toBe(2);
expect(staff.setProperty('item_level', 2).sockets.maxSockets()).toBe(3);
expect(staff.setProperty('item_level', 25).sockets.maxSockets()).toBe(4);
expect(staff.setProperty('item_level', 35).sockets.maxSockets()).toBe(5);
expect(staff.setProperty('item_level', 67).sockets.maxSockets()).toBe(6);
});

it('should check tags', () => {
expect(items.fromName('Gnarled Branch').sockets.max()).toBe(3);
expect(items.fromName('Unset Ring').sockets.max()).toBe(1);
expect(items.fromName('Black Maw Talisman').sockets.max()).toBe(1);
expect(items.fromName('Gnarled Branch').sockets.maxSockets()).toBe(3);
expect(items.fromName('Unset Ring').sockets.maxSockets()).toBe(1);
expect(items.fromName('Black Maw Talisman').sockets.maxSockets()).toBe(1);
});

it('should have not have any currently', () => {
Expand Down

0 comments on commit 445d51f

Please sign in to comment.