fix saving out inventory and player items
This commit is contained in:
parent
3c6c26426b
commit
e1c920b1c0
22
village.js
22
village.js
|
@ -23,7 +23,7 @@ const terrainFile = ".terrain.txt";
|
|||
// game vars
|
||||
program = blessed.program();
|
||||
|
||||
const width = 30;
|
||||
const width = 24;
|
||||
const height = 8;
|
||||
const movesInADay = 24;
|
||||
let dungeon;
|
||||
|
@ -124,7 +124,7 @@ function checkKeys(key){
|
|||
}
|
||||
break;
|
||||
case 'p':
|
||||
program.write('picked up something');
|
||||
//program.write('picked up something');
|
||||
pickup();
|
||||
break;
|
||||
case 'i':
|
||||
|
@ -148,6 +148,12 @@ function pickup(){
|
|||
roomItems.splice(i, 1);
|
||||
}
|
||||
}
|
||||
//save to inventory file
|
||||
let inventoryData = JSON.stringify(inventory);
|
||||
fs.writeFileSync(inventoryFile, inventoryData);
|
||||
//save changed items file (without the picked-up item)
|
||||
let itemsData = JSON.stringify(roomItems);
|
||||
fs.writeFileSync(itemsFile, itemsData);
|
||||
}
|
||||
|
||||
function inv(){
|
||||
|
@ -158,6 +164,7 @@ function inv(){
|
|||
program.down(2);
|
||||
program.write(inventory[i].symbol+": "+inventory[i].description);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function checkCollision() {
|
||||
|
@ -410,10 +417,10 @@ let createPlaces = () => {
|
|||
for (let i = 0; i < numToSpawn; i++){
|
||||
|
||||
//const buildings = ['🏛️','⛺','🏚️','⛩️','🗿']
|
||||
const buildings = ['⌂','⏏','☖','☗']
|
||||
const buildings = ['⌂','⏏','☖','☗','⛫']
|
||||
const placeTypes = ['Village','Village','Village','House','House','Market','Market','Market','Crossroads','Place','Outpost','Trading Post','House','Shack','Meeting Place','Saloon','Watering Hole','Stall','Hideout','Cart','Camp','Camp','Camp','Camp','','','','Zone of Ill Repute']
|
||||
|
||||
let whichBuilding = buildings[Math.floor(Math.random()*3)];
|
||||
let whichBuilding = buildings[Math.floor(Math.random()*buildings.length)];
|
||||
|
||||
let loc = generator.generate().spaced;
|
||||
|
||||
|
@ -443,7 +450,7 @@ let createGraves = () => {
|
|||
|
||||
let name = Charlatan.Name.name();
|
||||
|
||||
let gravestones = ['✝','✟','☨','✞'];
|
||||
let gravestones = ['✝','✟','☨','✞','⛼'];
|
||||
let whichGravestone = choose(gravestones);
|
||||
let prefix = ["Here lies","RIP","","","","Resting place of ","Beloved"]
|
||||
let reason = ["Made an enemy","Wasn't afraid to be","Tried","Died while","Passed while performing","Tried out","Dissapeared investingating","Wandered off while looking for","Last seen","Loved","Adored","A lifelong fan of","Our favorite at","The best at","Always in our hearts","Keep","Always be","Always","Just","Tried","Couldn't stop","Only ever found","Died","Passed while","Couldn't stop","Forgot to try","Never stopped","We'll always think of you when we're","It's not the same"]
|
||||
|
@ -480,11 +487,6 @@ function saveMap(){
|
|||
let itemsData = JSON.stringify(roomItems);
|
||||
fs.writeFileSync(itemsFile, itemsData);
|
||||
|
||||
//list of items saved to player's inventory
|
||||
console.log('inventory: '+inventory)
|
||||
let inventoryData = JSON.stringify(inventory);
|
||||
fs.writeFileSync(inventoryFile, inventoryData);
|
||||
|
||||
//save places to file
|
||||
let placesData = JSON.stringify(places);
|
||||
fs.writeFileSync(placesFile, placesData);
|
||||
|
|
Loading…
Reference in New Issue