Magic 8 Ball Italiano : like Magic 8 Ball but in italian :D
parent
c341947e7d
commit
b166efc912
14
apps.json
14
apps.json
|
|
@ -2110,6 +2110,20 @@
|
|||
{ "name": "jbm8b.img", "url": "app-icon.js", "evaluate": true }
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "jbm8b_IT",
|
||||
"name": "Magic 8 Ball Italiano",
|
||||
"shortName": "Magic 8 Ball IT",
|
||||
"icon": "app.png",
|
||||
"description": "La palla predice il futuro",
|
||||
"tags": "game",
|
||||
"version": "0.03",
|
||||
"allow_emulator":true,
|
||||
"storage": [
|
||||
{ "name": "jbm8b_IT.app.js", "url": "app.js" },
|
||||
{ "name": "jbm8b_IT.img", "url": "app-icon.js", "evaluate": true }
|
||||
]
|
||||
},
|
||||
{ "id": "BLEcontroller",
|
||||
"name": "BLE Customisable Controller with Joystick",
|
||||
"shortName": "BLE Controller",
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
0.01: Cloning Magic 8 Ball and make it speak italian
|
||||
|
|
@ -0,0 +1 @@
|
|||
require("heatshrink").decompress(atob("mEwhBC/AGMrq2B1gAEwNWlYthq2s64AKGYIydFpoAEGLUrFqIADqxcXFqhiDFymBFy7GCF1owTRjCSVlYudeiGsF7/XlaNqSKBeP1mBwJxQMBReO1gaEleBMDBLN1hAC1hhBAoIwNCwQAGlZINqxvFGAIXOSBAXQN4hPBC5yQIVBxfBCAgvQSBC+NFAYRDMwJHOF654DqxkBYooALF6+sbIhkEF8Z3CRIWBR6AvXFAzvQF6wnIYQJgNd5AWNdoLoGBBAvPO5pfYH4IvUUwS/GVBzXBYCpHCq2s1mBDwKOWDwRgNPAwVVMCRLCwIABCZ6OJJSAATLxZgRACJeLAAMrFz9WFxiRgRpoADwIub1guQGDmsXhqSfRiL0G1jqkMRYxRwKLUGK2sFryVEq2B1gAEwNWFkIA/AH4A/AH4AQ"))
|
||||
|
|
@ -0,0 +1,79 @@
|
|||
const affirmative = [
|
||||
'È certo.',
|
||||
'È decisamente\ncosì.',
|
||||
'Senza alcun\ndubbio.',
|
||||
'Sì,\nsenza dubbio.',
|
||||
'Ci puoi\ncontare.',
|
||||
'Da quanto\nvedo,\nsì.',
|
||||
'Molto\nprobabilmente.',
|
||||
'Le prospettive\nsono buone.',
|
||||
'Sì.',
|
||||
'I segni\nindicano\ndi sì.'
|
||||
];
|
||||
const nonCommittal = [
|
||||
'È difficile\ndirlo,\nprova di nuovo.',
|
||||
'Rifai la domanda\npiù tardi.',
|
||||
'Meglio non\nrisponderti\nadesso.',
|
||||
'Non posso\npredirlo ora.',
|
||||
'Concentrati e\nrifai la\ndomanda.'
|
||||
];
|
||||
const negative = [
|
||||
'Non ci\ncontare.',
|
||||
'La mia\nrisposta\nè no.',
|
||||
'Le mie\nfonti dicono\ndi no.',
|
||||
'Le prospettive\nnon sono\nbuone.',
|
||||
'È molto\ndubbio.'
|
||||
];
|
||||
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('Ponimi una\ndomanda\nSì/No e\ntocca lo\nschermo');
|
||||
}
|
||||
|
||||
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" });
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 1.5 KiB |
Loading…
Reference in New Issue