Compare commits
6 Commits
537cbb08c9
...
21561fa536
Author | SHA1 | Date |
---|---|---|
lee2sman | 21561fa536 | |
lee2sman | e010e40974 | |
lee2sman | ea1e906121 | |
lee2sman | acacbf2fa1 | |
lee2sman | 93be4609f6 | |
lee2sman | 4dd0ea745b |
|
@ -1919,3 +1919,17 @@ undefined
|
|||
undefined
|
||||
undefined
|
||||
undefined
|
||||
undefined
|
||||
undefined
|
||||
undefined
|
||||
undefined
|
||||
undefined
|
||||
undefined
|
||||
undefined
|
||||
undefined
|
||||
undefined
|
||||
undefined
|
||||
undefined
|
||||
undefined
|
||||
undefined
|
||||
undefined
|
||||
|
|
|
@ -1 +1 @@
|
|||
{"position":{"x":8,"y":0},"avatar":"@","movedToday":false,"life":null}
|
||||
{"position":{"x":15,"y":7},"avatar":"@","movedToday":false,"life":null}
|
|
@ -1 +1 @@
|
|||
[{"name":"","symbol":"a","description":"The rusted gates of an abandoned bemusement park","position":{"x":6,"y":5}},{"name":"","symbol":"(","description":"It's a solitary vacuum tube","position":{"x":16,"y":6}},{"name":"","symbol":"4","description":"A cheap ballpoint pen ","position":{"x":0,"y":4}},{"name":"A Cook's Guide to Tiny Arch","symbol":"⎅","description":"A well-written book on Tiny Arch. There is a faint musty odor.\n By Alisha Ledner.","position":{"x":3,"y":1}}]
|
||||
[{"name":"","symbol":"1","description":"It's the horizon. ","position":{"x":20,"y":3}},{"name":"A tale of Tired Cheese: on Jittery Jail","symbol":"◫","description":"A well-written book on Tired Cheese. Second edition.\n By Johnathon Hoppe.","position":{"x":15,"y":4}}]
|
File diff suppressed because one or more lines are too long
10
TODO.md
10
TODO.md
|
@ -8,10 +8,14 @@
|
|||
- [o]
|
||||
- [X] fixed number of moves limit before you *fall asleep*
|
||||
- [ ] background of tiles becomes gray (twilight), then black (nightfall) before you fall asleep?
|
||||
- [ ] ability to pray / sing / meditate / wonder / think / dance? / eat
|
||||
- [ ] ability to drop items
|
||||
- [.] ability to
|
||||
- [ ] pray
|
||||
- [ ] sing
|
||||
- [ ] read
|
||||
- [ ] meditate
|
||||
- [X] eat
|
||||
- [X] ability to drop items
|
||||
- [ ] programmable robot pet? - (you feed it logo commands to retrieve things?)
|
||||
- [ ] add parse (--view?) to look at/read items in inventory (can't be used? just read/looked at?)
|
||||
- [ ] help system
|
||||
|
||||
## Completed
|
||||
|
|
|
@ -4,6 +4,10 @@ lee2sman
|
|||
|
||||
# Devlog
|
||||
|
||||
## 4/1/21
|
||||
|
||||
I added ability to drop or eat items. The effect is almost exactly the same but with eating, the item is gone. With dropping, the item is left at the location the player is standing. You can eat any inventory item. Maybe I should add some funny saying or special abilities relating to this, like they each have some magic potion effect. I don't know. I've limited player to being able to hold up to 10 items, for convenience in keypress detection and max height of screen requirements).
|
||||
|
||||
## Day 8ish
|
||||
|
||||
Came back the next day to do more cleanup. Finished some detail/clean-up to move text to print out on the correct location on the screen. I'd say I'm at an alpha. The 'game' (zen-like simulation) now works okay and is playable. It's a bit much random, and maybe should be constrained more, and needs some refinement of the design. I'd also like to add in more actions the player can take beyond just picking items up. Now it's time to look at the roadmap and decide what I feel like adding on to decide what should be in the v1 release.
|
||||
|
|
126
village.js
126
village.js
|
@ -29,6 +29,7 @@ const movesInADay = 24;
|
|||
let dungeon;
|
||||
let roomItems = [];
|
||||
let today;
|
||||
let eating = false, dropping = false;
|
||||
let itemDescriptions = [];
|
||||
let verbs = [];
|
||||
let inventory = [];
|
||||
|
@ -74,7 +75,11 @@ function loop(){
|
|||
|
||||
resetScreen();
|
||||
|
||||
checkKeys(key);
|
||||
if (!eating && !dropping){
|
||||
checkKeys(key);
|
||||
} else {
|
||||
eatOrDrop(key);
|
||||
}
|
||||
|
||||
|
||||
updateDungeon();
|
||||
|
@ -131,21 +136,37 @@ function checkKeys(key){
|
|||
//program.write('list inventory');
|
||||
inv();
|
||||
break;
|
||||
case 'e': //eat
|
||||
eat();
|
||||
break;
|
||||
case 'd': //drop
|
||||
drop();
|
||||
break;
|
||||
default: //else
|
||||
program.write('hit another key');
|
||||
program.setx(0)
|
||||
program.down(10);
|
||||
program.write('Unknown action. Press another key');
|
||||
|
||||
program.up(10);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
function pickup(){
|
||||
for (let i = 0; i < roomItems.length; i++){
|
||||
if ((player.position.x == roomItems[i].position.x) && (player.position.y == roomItems[i].position.y)){
|
||||
console.log("you take "+roomItems[i].name);
|
||||
if (roomItems.length<10){
|
||||
console.log("You take "+roomItems[i].name);
|
||||
|
||||
//add to player inventory
|
||||
inventory.push(roomItems[i]);
|
||||
|
||||
//now remove from room since owned by player now
|
||||
roomItems.splice(i, 1);
|
||||
} else {
|
||||
console.log(roomItems);
|
||||
console.log("Your backpack is already full");
|
||||
}
|
||||
}
|
||||
}
|
||||
//save to inventory file
|
||||
|
@ -156,15 +177,100 @@ function pickup(){
|
|||
fs.writeFileSync(itemsFile, itemsData);
|
||||
}
|
||||
|
||||
function inv(){
|
||||
program.setx(1)
|
||||
function eat(){
|
||||
program.setx(0)
|
||||
program.down(9);
|
||||
program.write("Eat which item?: ");
|
||||
|
||||
for (let i = 0; i < inventory.length; i++){
|
||||
program.setx(0);
|
||||
program.down(2);
|
||||
program.down(1);
|
||||
program.write(i+": "+inventory[i].symbol+" "+inventory[i].description);
|
||||
}
|
||||
|
||||
program.setx(0)
|
||||
program.sety(0);
|
||||
|
||||
eating = true;
|
||||
}
|
||||
|
||||
function drop(){
|
||||
program.setx(0)
|
||||
program.down(9);
|
||||
program.write("Drop which item?: ");
|
||||
|
||||
for (let i = 0; i < inventory.length; i++){
|
||||
program.setx(0);
|
||||
program.down(1);
|
||||
program.write(i+": "+inventory[i].symbol+" "+inventory[i].description);
|
||||
}
|
||||
|
||||
program.setx(0)
|
||||
program.sety(0);
|
||||
|
||||
dropping = true;
|
||||
}
|
||||
|
||||
function inv(){
|
||||
|
||||
program.setx(0)
|
||||
program.down(9);
|
||||
program.write("In your backpack: ");
|
||||
|
||||
for (let i = 0; i < inventory.length; i++){
|
||||
program.setx(0);
|
||||
program.down(1);
|
||||
program.write(inventory[i].symbol+": "+inventory[i].description);
|
||||
}
|
||||
|
||||
program.setx(0)
|
||||
program.sety(0);
|
||||
}
|
||||
|
||||
function eatOrDrop(key){
|
||||
|
||||
if (key.full>=0 && key.full<=9){
|
||||
if (inventory[key.full]){
|
||||
|
||||
if (eating){
|
||||
console.log("Delicious, you ate "+lowerFirst(inventory[key.full].description));
|
||||
} else if (dropping){
|
||||
console.log("You dropped"+lowerFirst(inventory[key.full].description));
|
||||
//add back to room
|
||||
//
|
||||
//
|
||||
roomItems.push(
|
||||
{
|
||||
"name": "",
|
||||
"symbol": inventory[key.full].symbol,
|
||||
"description": inventory[key.full].description,
|
||||
"position":
|
||||
{
|
||||
"x": player.position.x,
|
||||
"y": player.position.y
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
}
|
||||
|
||||
inventory.splice(key.full, 1);
|
||||
|
||||
//save to inventory file
|
||||
let inventoryData = JSON.stringify(inventory);
|
||||
fs.writeFileSync(inventoryFile, inventoryData);
|
||||
|
||||
} else {
|
||||
console.log("You don't have that");
|
||||
}
|
||||
} else {
|
||||
console.log("You don't have that");
|
||||
}
|
||||
|
||||
eating = false
|
||||
dropping = false
|
||||
|
||||
}
|
||||
|
||||
function checkCollision() {
|
||||
|
@ -425,6 +531,14 @@ let capitalize = (str) => {
|
|||
return arr.join(' ');
|
||||
}
|
||||
|
||||
let lowerFirst = (str) => {
|
||||
let arr = str.split(' ');
|
||||
for(let i = 0; i < arr.length; i++ ) {
|
||||
arr[i] = arr[i].replace(arr[i].charAt(0), arr[i].charAt(0).toLowerCase());
|
||||
}
|
||||
return arr.join(' ');
|
||||
}
|
||||
|
||||
let createPlaces = () => {
|
||||
|
||||
let numToSpawn = Math.round(Math.random() * 3) + 4
|
||||
|
|
Loading…
Reference in New Issue