Output to file
This commit is contained in:
@@ -9,7 +9,7 @@ module.exports = class Item {
|
||||
this.addPart('blueprint')
|
||||
}
|
||||
|
||||
addPart (part) {
|
||||
this.parts.push(new Part(this.name, part))
|
||||
addPart (part, amount) {
|
||||
this.parts.push(new Part(this.name, part, amount))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
module.exports = class Part {
|
||||
constructor (set, part) {
|
||||
constructor (set, part, amount) {
|
||||
this.part = part
|
||||
this.url = `${set}_prime_${part}`
|
||||
this.amount = amount ?? 1
|
||||
}
|
||||
|
||||
async getPrice (page) {
|
||||
@@ -10,6 +11,6 @@ module.exports = class Part {
|
||||
await page.goto(marketUrl + this.url)
|
||||
const element = await page.waitForSelector('b.price')
|
||||
const value = await element.evaluate(el => el.textContent)
|
||||
return Number(value)
|
||||
return Number(value) * this.amount
|
||||
}
|
||||
}
|
||||
|
||||
11
items/Primary.js
Normal file
11
items/Primary.js
Normal file
@@ -0,0 +1,11 @@
|
||||
const Item = require('./Item')
|
||||
|
||||
module.exports = class Primary extends Item {
|
||||
constructor (name) {
|
||||
super(name)
|
||||
|
||||
this.addPart('barrel')
|
||||
this.addPart('receiver')
|
||||
this.addPart('stock')
|
||||
}
|
||||
}
|
||||
11
items/Secondary.js
Normal file
11
items/Secondary.js
Normal file
@@ -0,0 +1,11 @@
|
||||
const Item = require('./Item')
|
||||
|
||||
module.exports = class Secondary extends Item {
|
||||
constructor (name) {
|
||||
super(name)
|
||||
|
||||
this.addPart('barrel', 2)
|
||||
this.addPart('receiver', 2)
|
||||
this.addPart('link')
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,29 @@
|
||||
const Warframe = require('./Warframe')
|
||||
const Primary = require('./Primary')
|
||||
// const Secondary = require('./Secondary')
|
||||
|
||||
module.exports = [
|
||||
new Warframe('ash'),
|
||||
new Warframe('atlas')
|
||||
const warframes = [
|
||||
'ash', 'atlas', 'banshee', 'chroma', 'ember',
|
||||
'equinox', 'frost', 'gara', 'harrow', 'hydroid',
|
||||
'inaros', 'ivara', 'limbo', 'loki', 'mag',
|
||||
'mesa', 'mirage', 'nekros', 'nezha', 'nidus',
|
||||
'nova', 'nyx', 'oberon', 'octavia', 'rhino',
|
||||
'saryn', 'titania', 'trinity', 'valkyr', 'vauban',
|
||||
'volt', 'wukong', 'zephyr'
|
||||
]
|
||||
|
||||
const primaries = [
|
||||
'astilla', 'baza', 'boar', 'boltor', 'braton'
|
||||
]
|
||||
|
||||
const items = []
|
||||
|
||||
warframes.forEach((name) => {
|
||||
items.push(new Warframe(name))
|
||||
})
|
||||
|
||||
primaries.forEach((name) => {
|
||||
items.push(new Primary(name))
|
||||
})
|
||||
|
||||
module.exports = items
|
||||
|
||||
Reference in New Issue
Block a user