aaloo 1.0.0
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/.prettierignore +3 -0
- package/DEMO.md +10 -0
- package/README.md +42 -0
- package/assets/1.png +0 -0
- package/assets/2.png +0 -0
- package/assets/3.png +0 -0
- package/assets/4.png +0 -0
- package/assets/5.png +0 -0
- package/assets/6.png +0 -0
- package/cli/ask.js +17 -0
- package/index.js +38 -0
- package/install.sh +2 -0
- package/package.json +35 -0
- package/src/actions.js +41 -0
- package/src/energy.js +19 -0
- package/src/food.js +33 -0
- package/src/hunger.js +13 -0
- package/src/hungerTick.js +15 -0
- package/src/reward.js +12 -0
- package/src/stats.js +58 -0
- package/src/time.js +5 -0
- package/src/timeReward.js +41 -0
package/.prettierignore
ADDED
package/DEMO.md
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# How to get a demo of this game?
|
|
2
|
+
|
|
3
|
+
- Go to <a href='https://github.dev/bhatrichit10-ux/aaloo'>Github Dev </a>
|
|
4
|
+
- Go to Menu Bar > Terminal > New terminal
|
|
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 .`
|
package/README.md
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
<h1 align="center">Welcome to aaloo 👋</h1>
|
|
2
|
+
<p>
|
|
3
|
+
<img alt="Version" src="https://img.shields.io/badge/version-1.0.0-blue.svg?cacheSeconds=2592000" />
|
|
4
|
+
</p>
|
|
5
|
+
|
|
6
|
+
> a virtual pet potato that performs random culinary tasks when fed!
|
|
7
|
+
|
|
8
|
+
### 🏠 [Homepage](https://github.com/bhatrichit10-ux/aaloo#readme)
|
|
9
|
+
|
|
10
|
+
## Install
|
|
11
|
+
```
|
|
12
|
+
git clone https://github.com/bhatrichit10-ux/aaloo
|
|
13
|
+
cd aaloo
|
|
14
|
+
npm install
|
|
15
|
+
node .
|
|
16
|
+
```
|
|
17
|
+
## Images
|
|
18
|
+
 <br>
|
|
19
|
+
---
|
|
20
|
+
 <br>
|
|
21
|
+
---
|
|
22
|
+
 <br>
|
|
23
|
+
---
|
|
24
|
+
 <br>
|
|
25
|
+
---
|
|
26
|
+

|
|
27
|
+
## Author
|
|
28
|
+
|
|
29
|
+
👤 **Richit Bhat**
|
|
30
|
+
|
|
31
|
+
* Github: [@bhatrichit10-ux](https://github.com/bhatrichit10-ux)
|
|
32
|
+
|
|
33
|
+
## Show your support
|
|
34
|
+
|
|
35
|
+
Give a ⭐️ if this project helped you!
|
|
36
|
+
|
|
37
|
+
## 📝 License
|
|
38
|
+
|
|
39
|
+
Copyright © 2025 [Richit Bhat](https://github.com/bhatrichit10-ux).<br />
|
|
40
|
+
This project is [ISC](https://github.com/bhatrichit10-ux/aaloo/blob/master/LICENSE) licensed.
|
|
41
|
+
|
|
42
|
+
***
|
package/assets/1.png
ADDED
|
Binary file
|
package/assets/2.png
ADDED
|
Binary file
|
package/assets/3.png
ADDED
|
Binary file
|
package/assets/4.png
ADDED
|
Binary file
|
package/assets/5.png
ADDED
|
Binary file
|
package/assets/6.png
ADDED
|
Binary file
|
package/cli/ask.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
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
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
const { get } = require("./src/stats");
|
|
3
|
+
const { hungerTick } = require("./src/hungerTick");
|
|
4
|
+
const { applyTimeReward } = require("./src/timeReward");
|
|
5
|
+
const { actions } = require("./src/actions");
|
|
6
|
+
const { food, list } = require("./src/food");
|
|
7
|
+
const { ask } = require("./cli/ask");
|
|
8
|
+
let ac = ['play', 'run', 'sleep', 'feed', 'wake', 'exit'];
|
|
9
|
+
async function main() {
|
|
10
|
+
console.log("Welcome to the Aaloo Simulator!");
|
|
11
|
+
while (true) {
|
|
12
|
+
const stats = get();
|
|
13
|
+
console.log(`\nMood: ${stats.mood} | Hunger: ${stats.hunger} | Energy: ${stats.energy} | Activity: ${stats.activity}`);
|
|
14
|
+
const action = await ask("What do you want to do?", "list", ac);
|
|
15
|
+
if (action === "exit") {
|
|
16
|
+
console.log("Exiting the simulator. Goodbye!");
|
|
17
|
+
break;
|
|
18
|
+
} else if (action === "feed") {
|
|
19
|
+
const foodList = list();
|
|
20
|
+
const foodChoices = foodList.map(f => f.name);
|
|
21
|
+
const chosenFoodName = await ask("What do you want to feed?", "list", foodChoices);
|
|
22
|
+
const chosenFood = foodList.find(f => f.name === chosenFoodName);
|
|
23
|
+
if (chosenFood) {
|
|
24
|
+
const newHunger = chosenFood.effect();
|
|
25
|
+
console.log(`You fed your potato ${chosenFood.name}. Hunger changed by ${chosenFood.hungerRestore}. New hunger: ${newHunger}`);
|
|
26
|
+
} else if(action === 'wake'){
|
|
27
|
+
actions()['wake']();
|
|
28
|
+
console.log("Your potato is now awake!");
|
|
29
|
+
}
|
|
30
|
+
} else {
|
|
31
|
+
const result = actions()[action]();
|
|
32
|
+
console.log(result);
|
|
33
|
+
}
|
|
34
|
+
hungerTick();
|
|
35
|
+
applyTimeReward();
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
main();
|
package/install.sh
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "aaloo",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "a virtual pet potato that performs random culinary tasks when fed!",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"bin": {
|
|
7
|
+
"aaloo": "./index.js"
|
|
8
|
+
},
|
|
9
|
+
"scripts": {
|
|
10
|
+
"test": "npm test"
|
|
11
|
+
},
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "git+https://github.com/bhatrichit10-ux/aaloo.git"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"potato",
|
|
18
|
+
"virtual",
|
|
19
|
+
"pet",
|
|
20
|
+
"game",
|
|
21
|
+
"fun"
|
|
22
|
+
],
|
|
23
|
+
"author": "ghast9544",
|
|
24
|
+
"license": "ISC",
|
|
25
|
+
"bugs": {
|
|
26
|
+
"url": "https://github.com/bhatrichit10-ux/aaloo/issues"
|
|
27
|
+
},
|
|
28
|
+
"homepage": "https://github.com/bhatrichit10-ux/aaloo#readme",
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"prettier": "^3.7.4"
|
|
31
|
+
},
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"inquirer": "^12.11.1"
|
|
34
|
+
}
|
|
35
|
+
}
|
package/src/actions.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
const { decEnergy } = require("./energy");
|
|
2
|
+
const { get, set } = require("./stats");
|
|
3
|
+
// Actions that can be performed on the potato - play, run, sleep, wake
|
|
4
|
+
function actions() {
|
|
5
|
+
return {
|
|
6
|
+
run() {
|
|
7
|
+
const stats = get();
|
|
8
|
+
if (stats.activity === "sleeping") return "Potato is sleeping. Wake it up first."; // These strings were changed to be more descriptive
|
|
9
|
+
if (stats.hunger >= 80) return "Potato is too hungry to run."; // I used chatgpt for that. I hope it's okay.
|
|
10
|
+
if (stats.energy < 20) return "Potato is too tired to run.";
|
|
11
|
+
set("activity", "running");
|
|
12
|
+
decEnergy(20);
|
|
13
|
+
set("mood", stats.mood + 5);
|
|
14
|
+
return "You ran fast!";
|
|
15
|
+
},
|
|
16
|
+
|
|
17
|
+
play() {
|
|
18
|
+
const stats = get();
|
|
19
|
+
|
|
20
|
+
if (stats.activity === "sleeping") return "Potato is sleeping. Wake it up first.";
|
|
21
|
+
if (stats.hunger >= 80) return "Potato is too hungry to play.";
|
|
22
|
+
if (stats.energy < 10) return "Potato is too tired to play.";
|
|
23
|
+
|
|
24
|
+
set("activity", "playing");
|
|
25
|
+
decEnergy(10);
|
|
26
|
+
set("mood", stats.mood + 10);
|
|
27
|
+
return "Potato is having fun! It played around happily.";
|
|
28
|
+
},
|
|
29
|
+
|
|
30
|
+
sleep() {
|
|
31
|
+
set("activity", "sleeping");
|
|
32
|
+
return "The potato is now sleeping.\n Dont Disturb Him \n Zzz...";
|
|
33
|
+
},
|
|
34
|
+
wake() {
|
|
35
|
+
set("activity", "idle");
|
|
36
|
+
return "The potato woke up. He is a bit sleepy but now he is ready for action!";
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
module.exports = { actions };
|
package/src/energy.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
const { get, set } = require("./stats");
|
|
2
|
+
// just a alias to modify energy stat
|
|
3
|
+
function incEnergy(x) {
|
|
4
|
+
let stats = get();
|
|
5
|
+
let newEnergy = stats.energy + x;
|
|
6
|
+
set("energy", newEnergy);
|
|
7
|
+
return get().energy;
|
|
8
|
+
}
|
|
9
|
+
function decEnergy(x) {
|
|
10
|
+
let stats = get();
|
|
11
|
+
let newEnergy = stats.energy - x;
|
|
12
|
+
set("energy", newEnergy);
|
|
13
|
+
return get().energy;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
module.exports = {
|
|
17
|
+
incEnergy,
|
|
18
|
+
decEnergy,
|
|
19
|
+
};
|
package/src/food.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
const { incHunger, decHunger } = require("./hunger");
|
|
2
|
+
function food() {
|
|
3
|
+
// DIFFERENT FOOD ITEMS AND THEIR EFFECTS ON HUNGER
|
|
4
|
+
function apple() {
|
|
5
|
+
return decHunger(15);
|
|
6
|
+
}
|
|
7
|
+
function poisonousPotato() {
|
|
8
|
+
return incHunger(15);
|
|
9
|
+
}
|
|
10
|
+
function rice() {
|
|
11
|
+
return decHunger(2);
|
|
12
|
+
}
|
|
13
|
+
function susStew() {
|
|
14
|
+
const lucky = Math.random() < 0.5;
|
|
15
|
+
let newHunger;
|
|
16
|
+
if (lucky) {
|
|
17
|
+
newHunger = decHunger(50);
|
|
18
|
+
} else {
|
|
19
|
+
newHunger = incHunger(50);
|
|
20
|
+
}
|
|
21
|
+
return newHunger;
|
|
22
|
+
}
|
|
23
|
+
return { apple, rice, susStew, poisonousPotato };
|
|
24
|
+
}
|
|
25
|
+
function list() {
|
|
26
|
+
return [
|
|
27
|
+
{ name: "Apple", hungerRestore: 15, effect: food().apple },
|
|
28
|
+
{ name: "Rice", hungerRestore: 2, effect: food().rice },
|
|
29
|
+
{ name: "Sus Stew", hungerRestore: 50, effect: food().susStew },
|
|
30
|
+
{ name: "Poisonous Potato", hungerRestore: -15, effect: food().poisonousPotato },
|
|
31
|
+
];
|
|
32
|
+
}
|
|
33
|
+
module.exports = { food, list };
|
package/src/hunger.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const { get, set } = require("./stats");
|
|
2
|
+
// just a alias to modify hunger stat
|
|
3
|
+
function incHunger(x) {
|
|
4
|
+
const stats = get();
|
|
5
|
+
return set("hunger", stats.hunger + x).hunger;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
function decHunger(x) {
|
|
9
|
+
const stats = get();
|
|
10
|
+
return set("hunger", stats.hunger - x).hunger;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
module.exports = { incHunger, decHunger };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
const { get } = require("./stats");
|
|
2
|
+
const { incHunger } = require("./hunger");
|
|
3
|
+
// HUNGER TICK FUNCTION TO INCREASE HUNGER OVER TIME
|
|
4
|
+
function hungerTick() {
|
|
5
|
+
const stats = get();
|
|
6
|
+
|
|
7
|
+
if (stats.activity === "sleeping") {
|
|
8
|
+
return "Sleeping. Hunger not gonna increase";
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
incHunger(5);
|
|
12
|
+
return "Potato is hungry!";
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
module.exports = { hungerTick };
|
package/src/reward.js
ADDED
package/src/stats.js
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
const path = require("node:path");
|
|
2
|
+
const fs = require("node:fs");
|
|
3
|
+
const os = require("node:os");
|
|
4
|
+
|
|
5
|
+
const DATA_DIR = path.join(os.homedir(), "richpass");
|
|
6
|
+
const statsD = path.join(DATA_DIR, "stats.json");
|
|
7
|
+
|
|
8
|
+
const DEFAULT_STATS = {
|
|
9
|
+
name: "aaloo",
|
|
10
|
+
hunger: 0,
|
|
11
|
+
energy: 100,
|
|
12
|
+
mood: 100,
|
|
13
|
+
activity: "idle",
|
|
14
|
+
lastRewardCheck: 0
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
function ensureData() {
|
|
18
|
+
if (!fs.existsSync(DATA_DIR)) {
|
|
19
|
+
fs.mkdirSync(DATA_DIR, { recursive: true });
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
if (!fs.existsSync(statsD)) {
|
|
23
|
+
fs.writeFileSync(
|
|
24
|
+
statsD,
|
|
25
|
+
JSON.stringify(DEFAULT_STATS, null, 2)
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function get() {
|
|
31
|
+
ensureData();
|
|
32
|
+
const raw = fs.readFileSync(statsD, "utf-8");
|
|
33
|
+
return JSON.parse(raw);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function set(key, value) {
|
|
37
|
+
ensureData();
|
|
38
|
+
|
|
39
|
+
if (key !== "lastRewardCheck") {
|
|
40
|
+
if (value < 0) value = 0;
|
|
41
|
+
if (value > 100) value = 100;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const stats = get();
|
|
45
|
+
stats[key] = value;
|
|
46
|
+
|
|
47
|
+
fs.writeFileSync(
|
|
48
|
+
statsD,
|
|
49
|
+
JSON.stringify(stats, null, 2)
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
return stats;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
module.exports = {
|
|
56
|
+
get,
|
|
57
|
+
set
|
|
58
|
+
};
|
package/src/time.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
const { get, set } = require("./stats");
|
|
2
|
+
const { incEnergy } = require("./energy");
|
|
3
|
+
const { now } = require("./time");
|
|
4
|
+
|
|
5
|
+
const ONE_HOUR_MS = 60 * 60 * 1000;
|
|
6
|
+
const ENERGY_PER_HOUR = 40;
|
|
7
|
+
const HUNGER_PER_HOUR = 10;
|
|
8
|
+
|
|
9
|
+
function applyTimeReward() {
|
|
10
|
+
const stats = get();
|
|
11
|
+
const currentTime = now();
|
|
12
|
+
|
|
13
|
+
if (stats.lastRewardCheck === 0) {
|
|
14
|
+
set("lastRewardCheck", currentTime);
|
|
15
|
+
return stats;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const timePassed = currentTime - stats.lastRewardCheck;
|
|
19
|
+
const hoursPassed = Math.floor(timePassed / ONE_HOUR_MS);
|
|
20
|
+
|
|
21
|
+
if (hoursPassed <= 0) return stats;
|
|
22
|
+
|
|
23
|
+
if (stats.activity === "sleeping") {
|
|
24
|
+
let recovery = hoursPassed * ENERGY_PER_HOUR;
|
|
25
|
+
if (stats.hunger >= 60) recovery = Math.floor(recovery / 2);
|
|
26
|
+
incEnergy(recovery);
|
|
27
|
+
} else {
|
|
28
|
+
set("hunger", stats.hunger + hoursPassed * HUNGER_PER_HOUR);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
set("lastRewardCheck", stats.lastRewardCheck + hoursPassed * ONE_HOUR_MS);
|
|
32
|
+
|
|
33
|
+
const updated = get();
|
|
34
|
+
if (updated.activity === "sleeping" && updated.energy >= 100) {
|
|
35
|
+
set("activity", "idle");
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return get();
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
module.exports = { applyTimeReward };
|