aaloo 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/DEMO.md +4 -10
- package/README.md +17 -15
- package/cli/ask.js +17 -17
- package/index.js +37 -29
- package/package.json +1 -1
- package/src/actions.js +5 -3
- package/src/food.js +7 -3
- package/src/stats.js +4 -10
- package/install.sh +0 -2
package/DEMO.md
CHANGED
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
# How to get a demo of this game?
|
|
2
|
-
|
|
3
|
-
-
|
|
4
|
-
-
|
|
5
|
-

|
|
6
|
-
- Click on Continue Working in Github Codepspaces
|
|
7
|
-
- CLick on The 2GB Ram option on the top searchbar
|
|
8
|
-
- Wait for a few seconds
|
|
9
|
-
- Go to its terminal and write ` bash ./install.sh`
|
|
10
|
-
- Run using `node .`
|
|
1
|
+
# How to get a demo of this game?
|
|
2
|
+
|
|
3
|
+
- Install using `npm i -g aaloo`
|
|
4
|
+
- Run using `aaloo`
|
package/README.md
CHANGED
|
@@ -8,27 +8,29 @@
|
|
|
8
8
|
### 🏠 [Homepage](https://github.com/bhatrichit10-ux/aaloo#readme)
|
|
9
9
|
|
|
10
10
|
## Install
|
|
11
|
+
|
|
11
12
|
```
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
npm install
|
|
15
|
-
node .
|
|
13
|
+
npm i -g aaloo
|
|
14
|
+
aaloo
|
|
16
15
|
```
|
|
16
|
+
|
|
17
17
|
## Images
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
18
|
+
|
|
19
|
+
##  <br>
|
|
20
|
+
|
|
21
|
+
##  <br>
|
|
22
|
+
|
|
23
|
+
##  <br>
|
|
24
|
+
|
|
25
|
+
##  <br>
|
|
26
|
+
|
|
27
|
+

|
|
28
|
+
|
|
27
29
|
## Author
|
|
28
30
|
|
|
29
31
|
👤 **Richit Bhat**
|
|
30
32
|
|
|
31
|
-
|
|
33
|
+
- Github: [@bhatrichit10-ux](https://github.com/bhatrichit10-ux)
|
|
32
34
|
|
|
33
35
|
## Show your support
|
|
34
36
|
|
|
@@ -39,4 +41,4 @@ Give a ⭐️ if this project helped you!
|
|
|
39
41
|
Copyright © 2025 [Richit Bhat](https://github.com/bhatrichit10-ux).<br />
|
|
40
42
|
This project is [ISC](https://github.com/bhatrichit10-ux/aaloo/blob/master/LICENSE) licensed.
|
|
41
43
|
|
|
42
|
-
|
|
44
|
+
---
|
package/cli/ask.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
const inquirer = require(
|
|
2
|
-
|
|
3
|
-
async function ask(q, utype, ch) {
|
|
4
|
-
const ans = await inquirer.default.prompt([
|
|
5
|
-
{
|
|
6
|
-
type: utype,
|
|
7
|
-
name: "value",
|
|
8
|
-
message: `${q} > `,
|
|
9
|
-
mask: "*",
|
|
10
|
-
choices: ch
|
|
11
|
-
}
|
|
12
|
-
])
|
|
13
|
-
|
|
14
|
-
return ans.value
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
module.exports = { ask }
|
|
1
|
+
const inquirer = require("inquirer");
|
|
2
|
+
|
|
3
|
+
async function ask(q, utype, ch) {
|
|
4
|
+
const ans = await inquirer.default.prompt([
|
|
5
|
+
{
|
|
6
|
+
type: utype,
|
|
7
|
+
name: "value",
|
|
8
|
+
message: `${q} > `,
|
|
9
|
+
mask: "*",
|
|
10
|
+
choices: ch,
|
|
11
|
+
},
|
|
12
|
+
]);
|
|
13
|
+
|
|
14
|
+
return ans.value;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
module.exports = { ask };
|
package/index.js
CHANGED
|
@@ -4,35 +4,43 @@ const { hungerTick } = require("./src/hungerTick");
|
|
|
4
4
|
const { applyTimeReward } = require("./src/timeReward");
|
|
5
5
|
const { actions } = require("./src/actions");
|
|
6
6
|
const { food, list } = require("./src/food");
|
|
7
|
-
const { ask }
|
|
8
|
-
let ac = [
|
|
7
|
+
const { ask } = require("./cli/ask");
|
|
8
|
+
let ac = ["play", "run", "sleep", "feed", "wake", "exit"];
|
|
9
9
|
async function main() {
|
|
10
10
|
console.log("Welcome to the Aaloo Simulator!");
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
11
|
+
while (true) {
|
|
12
|
+
const stats = get();
|
|
13
|
+
console.log(
|
|
14
|
+
`\nMood: ${stats.mood} | Hunger: ${stats.hunger} | Energy: ${stats.energy} | Activity: ${stats.activity}`,
|
|
15
|
+
);
|
|
16
|
+
const action = await ask("What do you want to do?", "list", ac);
|
|
17
|
+
if (action === "exit") {
|
|
18
|
+
console.log("Exiting the simulator. Goodbye!");
|
|
19
|
+
break;
|
|
20
|
+
} else if (action === "feed") {
|
|
21
|
+
const foodList = list();
|
|
22
|
+
const foodChoices = foodList.map((f) => f.name);
|
|
23
|
+
const chosenFoodName = await ask(
|
|
24
|
+
"What do you want to feed?",
|
|
25
|
+
"list",
|
|
26
|
+
foodChoices,
|
|
27
|
+
);
|
|
28
|
+
const chosenFood = foodList.find((f) => f.name === chosenFoodName);
|
|
29
|
+
if (chosenFood) {
|
|
30
|
+
const newHunger = chosenFood.effect();
|
|
31
|
+
console.log(
|
|
32
|
+
`You fed your potato ${chosenFood.name}. Hunger changed by ${chosenFood.hungerRestore}. New hunger: ${newHunger}`,
|
|
33
|
+
);
|
|
34
|
+
} else if (action === "wake") {
|
|
35
|
+
actions()["wake"]();
|
|
36
|
+
console.log("Your potato is now awake!");
|
|
37
|
+
}
|
|
38
|
+
} else {
|
|
39
|
+
const result = actions()[action]();
|
|
40
|
+
console.log(result);
|
|
41
|
+
}
|
|
42
|
+
hungerTick();
|
|
43
|
+
applyTimeReward();
|
|
44
|
+
}
|
|
37
45
|
}
|
|
38
|
-
main();
|
|
46
|
+
main();
|
package/package.json
CHANGED
package/src/actions.js
CHANGED
|
@@ -5,7 +5,8 @@ function actions() {
|
|
|
5
5
|
return {
|
|
6
6
|
run() {
|
|
7
7
|
const stats = get();
|
|
8
|
-
if (stats.activity === "sleeping")
|
|
8
|
+
if (stats.activity === "sleeping")
|
|
9
|
+
return "Potato is sleeping. Wake it up first."; // These strings were changed to be more descriptive
|
|
9
10
|
if (stats.hunger >= 80) return "Potato is too hungry to run."; // I used chatgpt for that. I hope it's okay.
|
|
10
11
|
if (stats.energy < 20) return "Potato is too tired to run.";
|
|
11
12
|
set("activity", "running");
|
|
@@ -17,7 +18,8 @@ function actions() {
|
|
|
17
18
|
play() {
|
|
18
19
|
const stats = get();
|
|
19
20
|
|
|
20
|
-
if (stats.activity === "sleeping")
|
|
21
|
+
if (stats.activity === "sleeping")
|
|
22
|
+
return "Potato is sleeping. Wake it up first.";
|
|
21
23
|
if (stats.hunger >= 80) return "Potato is too hungry to play.";
|
|
22
24
|
if (stats.energy < 10) return "Potato is too tired to play.";
|
|
23
25
|
|
|
@@ -34,7 +36,7 @@ function actions() {
|
|
|
34
36
|
wake() {
|
|
35
37
|
set("activity", "idle");
|
|
36
38
|
return "The potato woke up. He is a bit sleepy but now he is ready for action!";
|
|
37
|
-
}
|
|
39
|
+
},
|
|
38
40
|
};
|
|
39
41
|
}
|
|
40
42
|
|
package/src/food.js
CHANGED
|
@@ -27,7 +27,11 @@ function list() {
|
|
|
27
27
|
{ name: "Apple", hungerRestore: 15, effect: food().apple },
|
|
28
28
|
{ name: "Rice", hungerRestore: 2, effect: food().rice },
|
|
29
29
|
{ name: "Sus Stew", hungerRestore: 50, effect: food().susStew },
|
|
30
|
-
{
|
|
30
|
+
{
|
|
31
|
+
name: "Poisonous Potato",
|
|
32
|
+
hungerRestore: -15,
|
|
33
|
+
effect: food().poisonousPotato,
|
|
34
|
+
},
|
|
31
35
|
];
|
|
32
|
-
}
|
|
33
|
-
module.exports = { food, list };
|
|
36
|
+
}
|
|
37
|
+
module.exports = { food, list };
|
package/src/stats.js
CHANGED
|
@@ -11,7 +11,7 @@ const DEFAULT_STATS = {
|
|
|
11
11
|
energy: 100,
|
|
12
12
|
mood: 100,
|
|
13
13
|
activity: "idle",
|
|
14
|
-
lastRewardCheck: 0
|
|
14
|
+
lastRewardCheck: 0,
|
|
15
15
|
};
|
|
16
16
|
|
|
17
17
|
function ensureData() {
|
|
@@ -20,10 +20,7 @@ function ensureData() {
|
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
if (!fs.existsSync(statsD)) {
|
|
23
|
-
fs.writeFileSync(
|
|
24
|
-
statsD,
|
|
25
|
-
JSON.stringify(DEFAULT_STATS, null, 2)
|
|
26
|
-
);
|
|
23
|
+
fs.writeFileSync(statsD, JSON.stringify(DEFAULT_STATS, null, 2));
|
|
27
24
|
}
|
|
28
25
|
}
|
|
29
26
|
|
|
@@ -44,15 +41,12 @@ function set(key, value) {
|
|
|
44
41
|
const stats = get();
|
|
45
42
|
stats[key] = value;
|
|
46
43
|
|
|
47
|
-
fs.writeFileSync(
|
|
48
|
-
statsD,
|
|
49
|
-
JSON.stringify(stats, null, 2)
|
|
50
|
-
);
|
|
44
|
+
fs.writeFileSync(statsD, JSON.stringify(stats, null, 2));
|
|
51
45
|
|
|
52
46
|
return stats;
|
|
53
47
|
}
|
|
54
48
|
|
|
55
49
|
module.exports = {
|
|
56
50
|
get,
|
|
57
|
-
set
|
|
51
|
+
set,
|
|
58
52
|
};
|
package/install.sh
DELETED