forked from FOSS/BangleApps
commit
14c1f04d0d
13
apps.json
13
apps.json
|
@ -1747,5 +1747,18 @@
|
|||
{"name":"dotmatrixclock.app.js","url":"app.js"},
|
||||
{"name":"dotmatrixclock.img","url":"dotmatrixclock-icon.js","evaluate":true}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "jbm8b",
|
||||
"name": "Magic 8 Ball",
|
||||
"shortName": "Magic 8 Ball",
|
||||
"icon": "app.png",
|
||||
"description": "A simple fortune telling app",
|
||||
"tags": "game",
|
||||
"storage": [
|
||||
{ "name": "jbm8b.app.js", "url": "app.js" },
|
||||
{ "name": "jbm8b.img", "url": "app-icon.js", "evaluate": true }
|
||||
],
|
||||
"version": "0.03"
|
||||
}
|
||||
]
|
||||
|
|
|
@ -11,4 +11,4 @@
|
|||
{"name":"7chname.app.js","url":"app.js"},
|
||||
{"name":"7chname.img","url":"app-icon.js","evaluate":true}
|
||||
]
|
||||
}
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
0.01: First working version
|
||||
0.02: Added delay in replying for dramatic effect
|
||||
0.03: Fixed apps.json entry
|
|
@ -0,0 +1 @@
|
|||
require("heatshrink").decompress(atob("mEwhBC/AGMrq2B1gAEwNWlYthq2s64AKGYIydFpoAEGLUrFqIADqxcXFqhiDFymBFy7GCF1owTRjCSVlYudeiGsF7/XlaNqSKBeP1mBwJxQMBReO1gaEleBMDBLN1hAC1hhBAoIwNCwQAGlZINqxvFGAIXOSBAXQN4hPBC5yQIVBxfBCAgvQSBC+NFAYRDMwJHOF654DqxkBYooALF6+sbIhkEF8Z3CRIWBR6AvXFAzvQF6wnIYQJgNd5AWNdoLoGBBAvPO5pfYH4IvUUwS/GVBzXBYCpHCq2s1mBDwKOWDwRgNPAwVVMCRLCwIABCZ6OJJSAATLxZgRACJeLAAMrFz9WFxiRgRpoADwIub1guQGDmsXhqSfRiL0G1jqkMRYxRwKLUGK2sFryVEq2B1gAEwNWFkIA/AH4A/AH4AQ"))
|
|
@ -0,0 +1,80 @@
|
|||
const affirmative = [
|
||||
'It is\ncertain.',
|
||||
'It is\ndicededly\nso.',
|
||||
'Without\na doubt.',
|
||||
'Yes\ndefinitely.',
|
||||
'You may\nrely\non it.',
|
||||
'As I see,\nit yes.',
|
||||
'Most\nlikely.',
|
||||
'Outlook\ngood.',
|
||||
'Yes.',
|
||||
'Signs point\nto yes.'
|
||||
];
|
||||
const nonCommittal = [
|
||||
'Reply hazy,\ntry again.',
|
||||
'Ask again\nlater.',
|
||||
'Better not\ntell you\nnow.',
|
||||
'Cannot\npredict\nnow.',
|
||||
'Concentrate\nand\nask again.'
|
||||
];
|
||||
const negative = [
|
||||
'Don\'t\ncount on it.',
|
||||
'My reply\nis no.',
|
||||
'My sources\nsay no.',
|
||||
'Outlook\nis not\nso\ngood.',
|
||||
'Very\ndoubtful.'
|
||||
];
|
||||
|
||||
const title = 'Magic 8 Ball';
|
||||
|
||||
const answers = [affirmative, nonCommittal, negative];
|
||||
|
||||
function getRandomArbitrary(min, max) {
|
||||
return Math.random() * (max - min) + min;
|
||||
}
|
||||
|
||||
function predict() {
|
||||
// affirmative, negative or non-committal
|
||||
let max = answers.length;
|
||||
const a = Math.floor(getRandomArbitrary(0, max));
|
||||
// sets max compared to answer category
|
||||
max = answers[a].length;
|
||||
const b = Math.floor(getRandomArbitrary(0, max));
|
||||
// get the answer
|
||||
const response = answers[a][b];
|
||||
return response;
|
||||
}
|
||||
|
||||
function draw(msg) {
|
||||
// console.log(msg);
|
||||
g.clear();
|
||||
E.showMessage(msg, title);
|
||||
}
|
||||
|
||||
function reply(button) {
|
||||
const theButton = (typeof button === 'undefined' || isNaN(button)) ? 1 : button;
|
||||
const timer = Math.floor(getRandomArbitrary(0, theButton) * 1000);
|
||||
// Thinking...
|
||||
draw('...');
|
||||
setTimeout('draw(predict());', timer);
|
||||
}
|
||||
|
||||
function ask() {
|
||||
draw('Ask me a\nYes or No\nquestion\nand\ntouch the\nscreen');
|
||||
}
|
||||
|
||||
g.clear();
|
||||
|
||||
Bangle.loadWidgets();
|
||||
Bangle.drawWidgets();
|
||||
ask();
|
||||
|
||||
// Event Handlers
|
||||
|
||||
Bangle.on('touch', (button) => reply(button));
|
||||
|
||||
setWatch(ask, BTN1, { repeat: true, edge: "falling" });
|
||||
setWatch(reply, BTN3, { repeat: true, edge: "falling" });
|
||||
|
||||
// Back to launcher
|
||||
setWatch(Bangle.showLauncher, BTN2, { repeat: false, edge: "falling" });
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"name": "Magic 8 Ball",
|
||||
"icon": "*jbm8b",
|
||||
"src": "-jbm8b",
|
||||
"version": "1.1.0"
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 1.5 KiB |
Loading…
Reference in New Issue