--- /dev/null
+Name,Type,Sub Type,Profession,Cost,Required Level,Required STR,Required CON,Required DEX,Required INT,Boost STR,Boost CON,Boost DEX,Boost INT,Boost DMG,Armour Points\r
+Plain Helm,ARMOUR,HELM,Wanderer,3,1,0,0,0,0,0,0,0,0,0,20\r
+Gloves,ARMOUR,ARMS,Wanderer,2,1,0,0,0,0,0,0,0,0,0,20\r
+Tunic,ARMOUR,CHEST,Wanderer,5,1,0,0,0,0,0,0,0,0,0,20\r
+Boots,ARMOUR,LEGS,Wanderer,3,1,0,0,0,0,0,0,0,0,0,20\r
+Short Sword,WEAPON,BLADE,Wanderer,5,1,0,0,0,0,0,0,0,0,3,50\r
-import {ShopItem} from "../src/shared/inventory";
+import {ShopItem, InventoryType, SubType} from "../src/shared/inventory";
import { Knex } from "knex";
+import { join } from 'path';
+import { readFile } from 'fs';
+import { promisify } from 'util';
+import {Profession} from "../src/shared/player";
+
+const read = promisify(readFile);
export async function seed(knex: Knex): Promise<void> {
// Deletes ALL existing entries
await knex("equipped").del();
await knex("inventory").del();
- const data: Partial<ShopItem>[] = [
- {
- name: 'Tattered Helm',
- type: 'ARMOUR',
- subType: 'HELM',
- cost: 3,
- count: 1,
- requirement_level: 1,
- requirement_strength: 0,
- requirement_constitution: 0,
- requirement_dexterity: 0,
- requirement_intelligence: 0,
- profession: 'Wanderer',
- boost_strength: 0,
- boost_constitution: 0,
- boost_dexterity: 0,
- boost_intelligence: 0,
- boost_damage: 0,
- currentAp: 20,
- maxAp: 20
- },
- {
- name: 'Trainee\'s Helm',
- type: 'ARMOUR',
- subType: 'HELM',
- cost: 10,
- count: 1,
- requirement_level: 2,
- requirement_strength: 0,
- requirement_constitution: 0,
- requirement_dexterity: 0,
- requirement_intelligence: 0,
- profession: 'Wanderer',
- boost_strength: 0,
- boost_constitution: 0,
- boost_dexterity: 0,
- boost_intelligence: 0,
- boost_damage: 0,
- currentAp: 20,
- maxAp: 20
- },
- {
- name: 'Torn Leather Gauntlets',
- type: 'ARMOUR',
- subType: 'ARMS',
- cost: 3,
- count: 1,
- requirement_level: 1,
- requirement_strength: 0,
- requirement_constitution: 0,
- requirement_dexterity: 0,
- requirement_intelligence: 0,
- profession: 'Wanderer',
- boost_strength: 0,
- boost_constitution: 0,
- boost_dexterity: 0,
- boost_intelligence: 0,
- boost_damage: 0,
- currentAp: 20,
- maxAp: 20
- },
- {
- name: 'Short Sword',
- type: 'WEAPON',
- subType: 'BLADE',
- cost: 5,
- count: 1,
- requirement_level: 1,
- requirement_strength: 0,
- requirement_constitution: 0,
- requirement_dexterity: 0,
- requirement_intelligence: 0,
- profession: 'Wanderer',
- boost_strength: 0,
- boost_constitution: 0,
- boost_dexterity: 0,
- boost_intelligence: 0,
- boost_damage: 4,
- currentAp: 50,
- maxAp: 50
+ const data = await read(join(__dirname, '..', 'data', 'inventory.csv'), 'utf8');
+
+ const items: Omit<ShopItem, 'id'>[] = [];
+
+ data.split("\r\n").slice(1).forEach(line => {
+ let pieces = line.split(',');
+ if(pieces.length === 16) {
+ console.log('Adding', pieces[0]);
+ items.push({
+ name: pieces[0],
+ type: pieces[1] as InventoryType,
+ subType: pieces[2] as SubType,
+ profession: pieces[3] as Profession,
+ cost: parseInt(pieces[4]),
+ count: 1,
+ requirement_level: parseInt(pieces[5]),
+ requirement_strength: parseInt(pieces[6]),
+ requirement_constitution: parseInt(pieces[7]),
+ requirement_dexterity: parseInt(pieces[8]),
+ requirement_intelligence: parseInt(pieces[9]),
+ boost_strength: parseInt(pieces[10]),
+ boost_constitution: parseInt(pieces[11]),
+ boost_dexterity: parseInt(pieces[12]),
+ boost_intelligence: parseInt(pieces[13]),
+ boost_damage: parseInt(pieces[14]),
+ currentAp: parseInt(pieces[15]),
+ maxAp: parseInt(pieces[15])
+ });
+ }
+ else {
+ console.log(`Skipped ${line}`);
}
- ];
+ });
- await knex('shop_items').insert(data);
+ await knex('shop_items').insert(items);
};