forked from le-jeu/iitc-plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
508 additions
and
453 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,178 @@ | ||
import { getItemName } from '../extract'; | ||
import type { Inventory } from '../inventory'; | ||
|
||
const C_R_VR = ['COMMON', 'RARE', 'VERY_RARE'] as const; | ||
|
||
export default function ({ inventory }: { inventory: Inventory }) { | ||
const total = inventory.items['PORTAL_LINK_KEY'].total; | ||
const inventoryCount = inventory.items['PORTAL_LINK_KEY'].counts['VERY_COMMON'][inventory.name] || 0; | ||
const otherCount = total - inventoryCount - inventory.keyLockersCount; | ||
let beacon = 0; | ||
for (const type in inventory.items) { | ||
if (type.startsWith('PORTAL_POWERUP')) { | ||
switch (type) { | ||
case 'PORTAL_POWERUP:FRACK': | ||
case 'PORTAL_POWERUP:BB_BATTLE_RARE': | ||
case 'PORTAL_POWERUP:BB_BATTLE': | ||
case 'PORTAL_POWERUP:FW_ENL': | ||
case 'PORTAL_POWERUP:FW_RES': | ||
break; | ||
default: | ||
beacon++; | ||
} | ||
} | ||
} | ||
return ( | ||
<div> | ||
<table> | ||
<tr> | ||
<th>Portal Keys</th> | ||
<th>⌂</th> | ||
<th>Lockers</th> | ||
<th>Other</th> | ||
</tr> | ||
<tr> | ||
<th>{total}</th> | ||
<td>{inventoryCount}</td> | ||
<td>{inventory.keyLockersCount}</td> | ||
<td>{otherCount}</td> | ||
</tr> | ||
</table> | ||
<table> | ||
{( | ||
[ | ||
['EMITTER_A', 'R'], | ||
['EMP_BURSTER', 'B'], | ||
['ULTRA_STRIKE', 'US'], | ||
['POWER_CUBE', 'PC'], | ||
] as const | ||
).map(([type, short]) => ( | ||
<> | ||
<tr> | ||
<th>{getItemName(type)}</th> | ||
{[1, 2, 3, 4, 5, 6, 7, 8].map((i) => ( | ||
<th className={'level_L' + i}>{short + i}</th> | ||
))} | ||
</tr> | ||
<tr> | ||
<th>{inventory.countType(type)}</th> | ||
{([1, 2, 3, 4, 5, 6, 7, 8] as const).map((i) => ( | ||
<td>{inventory.countType(type, i)}</td> | ||
))} | ||
</tr> | ||
</> | ||
))} | ||
</table> | ||
<table> | ||
<tr> | ||
<th>Hypercube</th> | ||
<th>ADA Refactor</th> | ||
<th>JARVIS Virus</th> | ||
</tr> | ||
<tr> | ||
<td>{inventory.countType('BOOSTED_POWER_CUBE') + inventory.countType('BOOSTED_POWER_CUBE_K')}</td> | ||
<td>{inventory.countType('FLIP_CARD:ADA')}</td> | ||
<td>{inventory.countType('FLIP_CARD:JARVIS')}</td> | ||
</tr> | ||
</table> | ||
<table> | ||
<tr> | ||
<th>Shield</th> | ||
<th className="rarity_C">C</th> | ||
<th className="rarity_R">R</th> | ||
<th className="rarity_VR">VR</th> | ||
<th className="rarity_VR">Aegis</th> | ||
</tr> | ||
<tr> | ||
<th>{inventory.countType('RES_SHIELD') + inventory.countType('EXTRA_SHIELD')}</th> | ||
{C_R_VR.map((k) => ( | ||
<td>{inventory.countType('RES_SHIELD', k)}</td> | ||
))} | ||
<td>{inventory.countType('EXTRA_SHIELD')}</td> | ||
</tr> | ||
</table> | ||
<table> | ||
<tr> | ||
<th>Turret</th> | ||
<th>Force Amp</th> | ||
<th>Link Amp</th> | ||
{inventory.countType('LINK_AMPLIFIER', 'VERY_RARE') ? <th className="rarity_VR">LA VR</th> : null} | ||
<th>Ultra Link</th> | ||
<th>ITO +</th> | ||
<th>ITO -</th> | ||
</tr> | ||
<tr> | ||
<td>{inventory.countType('TURRET')}</td> | ||
<td>{inventory.countType('FORCE_AMP')}</td> | ||
<td>{inventory.countType('LINK_AMPLIFIER', 'RARE')}</td> | ||
{inventory.countType('LINK_AMPLIFIER', 'VERY_RARE') ? <td>{inventory.countType('LINK_AMPLIFIER', 'VERY_RARE')}</td> : null} | ||
<td>{inventory.countType('ULTRA_LINK_AMP')}</td> | ||
<td>{inventory.countType('TRANSMUTER_DEFENSE')}</td> | ||
<td>{inventory.countType('TRANSMUTER_ATTACK')}</td> | ||
</tr> | ||
</table> | ||
<table> | ||
<tr> | ||
<th>HeatSink</th> | ||
<th className="rarity_C">C</th> | ||
<th className="rarity_R">R</th> | ||
<th className="rarity_VR">VR</th> | ||
<th>MultiHack</th> | ||
<th className="rarity_C">C</th> | ||
<th className="rarity_R">R</th> | ||
<th className="rarity_VR">VR</th> | ||
</tr> | ||
<tr> | ||
<th>{inventory.countType('HEATSINK')}</th> | ||
{C_R_VR.map((k) => ( | ||
<td>{inventory.countType('HEATSINK', k)}</td> | ||
))} | ||
<th>{inventory.countType('MULTIHACK')}</th> | ||
{C_R_VR.map((k) => ( | ||
<td>{inventory.countType('MULTIHACK', k)}</td> | ||
))} | ||
</tr> | ||
</table> | ||
<table> | ||
<tr> | ||
<th>Capsule</th> | ||
<th>Quantum</th> | ||
<th>KeyLocker</th> | ||
<th>Kinetic</th> | ||
<th>Media</th> | ||
</tr> | ||
<tr> | ||
<td>{inventory.countType('CAPSULE')}</td> | ||
<td>{inventory.countType('INTEREST_CAPSULE')}</td> | ||
<td>{inventory.countType('KEY_CAPSULE')}</td> | ||
<td> | ||
<span className="rarity_C">{inventory.countType('KINETIC_CAPSULE', 'COMMON')}</span> | ||
{' + '} | ||
<span className="rarity_R">{inventory.countType('KINETIC_CAPSULE', 'RARE')}</span> | ||
</td> | ||
<td>{inventory.countType('MEDIA')}</td> | ||
</tr> | ||
</table> | ||
<table> | ||
<tr> | ||
<th>Apex</th> | ||
<th>Fracker</th> | ||
<th className="rarity_R">BB R</th> | ||
<th className="rarity_VR">BB VR</th> | ||
<th>Beacon</th> | ||
<th>FW ENL</th> | ||
<th>FW RES</th> | ||
</tr> | ||
<tr> | ||
<td>{inventory.countType('PLAYER_POWERUP:APEX')}</td> | ||
<td>{inventory.countType('PORTAL_POWERUP:FRACK')}</td> | ||
<td>{inventory.countType('PORTAL_POWERUP:BB_BATTLE_RARE')}</td> | ||
<td>{inventory.countType('PORTAL_POWERUP:BB_BATTLE')}</td> | ||
<td>{beacon}</td> | ||
<td>{inventory.countType('PORTAL_POWERUP:FW_ENL')}</td> | ||
<td>{inventory.countType('PORTAL_POWERUP:FW_RES')}</td> | ||
</tr> | ||
</table> | ||
</div> | ||
); | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import type { Inventory, ItemType, LevelRarity } from '../inventory'; | ||
import ItemRow from './ItemRow'; | ||
|
||
export default function createAllTable({ inventory }: { inventory: Inventory }) { | ||
const table = <table></table>; | ||
for (const type in inventory.items) { | ||
const total = inventory.countType(type as ItemType); | ||
if (total === 0) continue; | ||
const item = inventory.items[type]; | ||
for (const i in item.counts) { | ||
const num = inventory.countType(type as ItemType, i as LevelRarity); | ||
if (num > 0) { | ||
table.append(<ItemRow item={item} count={num} lvl={i} />); | ||
} | ||
} | ||
} | ||
return table; | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { InventoryCapsule, orderedTypes } from '../inventory'; | ||
import { localeCompare } from '../utils'; | ||
import ItemRow from './ItemRow'; | ||
import PortalKeyLink from './PortalKeyLink'; | ||
|
||
export default function ({ capsule }: { capsule: InventoryCapsule }) { | ||
const keys = Object.values(capsule.keys).sort((a, b) => localeCompare(a.title, b.title)); | ||
const medias = Object.values(capsule.medias).sort((a, b) => localeCompare(a.name, b.name)); | ||
return ( | ||
<table> | ||
{keys.map((item) => ( | ||
<tr> | ||
<td>{item.count}</td> | ||
{capsule.type !== 'KEY_CAPSULE' ? <td></td> : null} | ||
<td> | ||
<PortalKeyLink item={item} /> | ||
</td> | ||
</tr> | ||
))} | ||
{medias.map((item) => ( | ||
<tr className="level_L1"> | ||
<td>{item.count}</td> | ||
<td>M</td> | ||
<td> | ||
<a href={item.url}>{item.name}</a> | ||
</td> | ||
</tr> | ||
))} | ||
{orderedTypes.map((type) => { | ||
const item = capsule.items[type]; | ||
if (item) { | ||
return Object.keys(item.count).map((i) => <ItemRow count={item.count[i]} item={item} lvl={i} />); | ||
} | ||
})} | ||
</table> | ||
); | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
import { Inventory } from '../inventory'; | ||
import { localeCompare } from '../utils'; | ||
import { getItemName } from '../extract'; | ||
import AllTable from './AllTable'; | ||
import AllSumTable from './AllSumTable'; | ||
import KeysTable from './KeysTable'; | ||
import MediaTable from './MediaTable'; | ||
import CapsuleTable from './CapsuleTable'; | ||
|
||
import { storeSettings } from '../storage'; | ||
import playerInventory from '../plugin'; | ||
|
||
export default function ({ inventory }: { inventory: Inventory }) { | ||
const inventoryCount = inventory.count - inventory.keyLockersCount; | ||
const keyInInventory = inventory.keys.size > 0 ? inventory.items['PORTAL_LINK_KEY'].counts['VERY_COMMON'][inventory.name] || 0 : 0; | ||
const container = ( | ||
<div className="container"> | ||
<b>{`Summary I:${inventoryCount - keyInInventory} K:${keyInInventory} T:${inventoryCount}/2500 KL:${inventory.keyLockersCount}`}</b> | ||
<div className="sum"> | ||
<AllSumTable inventory={inventory} /> | ||
</div> | ||
|
||
<b>Details</b> | ||
<div className="all"> | ||
<AllTable inventory={inventory} /> | ||
</div> | ||
</div> | ||
); | ||
|
||
if (inventory.keys.size > 0) { | ||
container.append( | ||
<> | ||
<b>Keys</b> | ||
<div className="medias"> | ||
<KeysTable inventory={inventory} /> | ||
</div> | ||
</> | ||
); | ||
} | ||
|
||
if (inventory.medias.size > 0) { | ||
container.append( | ||
<> | ||
<b>Medias</b> | ||
<div className="all"> | ||
<MediaTable inventory={inventory} /> | ||
</div> | ||
</> | ||
); | ||
} | ||
|
||
const onHand = inventory.onHand(); | ||
container.append( | ||
<> | ||
<b>On Hand ({onHand.size})</b> | ||
<div className="capsule"> | ||
<CapsuleTable capsule={onHand} /> | ||
</div> | ||
</> | ||
); | ||
|
||
const mapping = playerInventory.settings.capsuleNameMap; | ||
const capsulesName = Object.keys(inventory.capsules).sort((a, b) => { | ||
if (mapping[a] && !mapping[b]) return -1; | ||
if (!mapping[a] && mapping[b]) return 1; | ||
a = mapping[a] || a; | ||
b = mapping[b] || b; | ||
return localeCompare(a, b); | ||
}); | ||
const keyLockers = capsulesName.filter((name) => inventory.capsules[name].type === 'KEY_CAPSULE'); | ||
const quantums = capsulesName.filter((name) => inventory.capsules[name].type === 'INTEREST_CAPSULE'); | ||
const commonCapsules = capsulesName.filter((name) => inventory.capsules[name].type === 'CAPSULE'); | ||
for (const names of [keyLockers, quantums, commonCapsules]) { | ||
for (const name of names) { | ||
const capsule = inventory.capsules[name]; | ||
if (capsule.size > 0) { | ||
const displayName = mapping[name] ? `${mapping[name]} [${name}]` : name; | ||
const typeName = getItemName(capsule.type); | ||
const size = capsule.size; | ||
|
||
const head = <b>{`${typeName}: ${displayName} (${size})`}</b>; | ||
|
||
container.append( | ||
<> | ||
{head} | ||
<div className="capsule"> | ||
<div> | ||
<a | ||
className="edit-name-icon" | ||
title="Change capsule name" | ||
onclick={(ev) => { | ||
const input = ev.target.nextElementSibling; | ||
input.style.display = input.style.display === 'unset' ? null : 'unset'; | ||
}} | ||
> | ||
✏️ | ||
</a> | ||
<input | ||
className="edit-name-input" | ||
value={mapping[name] || ''} | ||
placeholder="Enter capsule name" | ||
oninput={(ev) => { | ||
mapping[name] = ev.target.value; | ||
storeSettings(playerInventory.settings); | ||
const displayName = mapping[name] ? `${mapping[name]} [${name}]` : name; | ||
head.textContent = `${typeName}: ${displayName} (${size})`; | ||
}} | ||
/> | ||
</div> | ||
<CapsuleTable capsule={capsule} /> | ||
</div> | ||
</> | ||
); | ||
} | ||
} | ||
} | ||
return container; | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { shortenRarity } from '../utils'; | ||
import { getItemName } from '../extract'; | ||
|
||
import type { ItemType, LevelRarity } from '../inventory'; | ||
|
||
export default function (props: { item: { type: ItemType; leveled: boolean }; lvl: LevelRarity | string; count: number }) { | ||
const { item, lvl, count } = props; | ||
const lr = item.leveled ? 'L' + lvl : shortenRarity(lvl as string); | ||
const className = (item.leveled ? 'level_' : 'rarity_') + lr; | ||
const name = getItemName(item.type); | ||
return ( | ||
<tr className={className}> | ||
<td>{count}</td> | ||
<td>{lr}</td> | ||
<td>{name}</td> | ||
</tr> | ||
); | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
export default function (props) { | ||
const { item, children } = props; | ||
const details = Array.from(item.count) | ||
.map(([name, count]) => `${name}: ${count}`) | ||
.join(', '); | ||
return ( | ||
<tr> | ||
<td> | ||
<a title={details}>{item.total}</a> | ||
</td> | ||
<td>{children}</td> | ||
</tr> | ||
); | ||
} |
Oops, something went wrong.