-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathintro.js
141 lines (129 loc) · 4.74 KB
/
intro.js
1
2
3
4
5
6
7
8
9
10
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
/*jslint browser: true, devel: true, nomen: true, sloppy: true, vars: true, indent: 2 */
/*global GraphicsElement, animateElement, alertSplash, displayInfoscreen */
var intro = (function () {
var graph,
graphhider,
boughtPrice,
lowestPrice,
stocksToBuy,
startPrice,
states,
currentState = -1,
exitFunction;
function nextState() {
currentState += 1;
if (currentState < states.length) {
states[currentState]();
}
}
function startIntro() {
var graphElement = document.getElementById("graph");
graphElement.onload = nextState;
graphElement.src = "img/trade.png";
}
states = [
function () {
graph = new GraphicsElement("graph");
graphhider = new GraphicsElement("graphhider");
displayInfoscreen(
"",
[ "The future's looking grim for Italy's Tamagucci S.p.A.",
"Twenty years after their electronic egg toy took the world by storm, they have yet to repeat the success. " +
"The company's spent the past five years and almost all the money they made 20 years " +
"ago on trying to develop an advanced AI-driven toy that's advanced enough to impress today's kids. " +
"However the new toy has been hit by numerous delays, and its release date is uncertain.",
"Based on this pessimistic forcecast you decide to make a daring bet and short the company's stock (BIT:TAMA)."
],
nextState
);
},
function () {
graph.setVisible(true);
graph.setState("intro");
animateElement(
graphhider,
[{
visible: true,
state: "intro",
time: 0.5 * 1000
}, {
state: "moveout"
}]
);
setTimeout(nextState, 4.5 * 1000);
},
function () {
displayInfoscreen(
"Congratulations!",
[ "Tamagucci S.p.A. has finally launched their new electronic egg toy, and it looks like you made a wise decision. ",
"While the toy can talk, it seems the developers used Twitter as its data source. " +
"The tabloids are filled with articles about parents complaining that the eggs are calling their kids racial slurs. " +
"It's unlikely that the toy will be Christmas Present of the Year.",
"The stock has continued to plunge and is now down to €" + lowestPrice +
", meaning that the " + stocksToBuy + " stocks you shorted at €" + boughtPrice +
" will net you a whopping €" + ((boughtPrice - lowestPrice) * stocksToBuy) + "."
],
nextState
);
},
function () {
graph.setState("movetorebound");
setTimeout(
function () {
alertSplash(3);
},
3.7 * 1000
);
setTimeout(nextState, 4 * 1000);
},
function () {
displayInfoscreen(
"",
["\"Trump says he will MAGA by replacing the USD with the cryptocurrency TrumpCoin\"",
"\"Scientists say that electronic eggs are the best way to mine TrumpCoin\"",
"First you think it's a joke. Then you remember that it's current year. " +
"Then you realize the consequences. The BIT:TAMA stock price is already rising quickly on the news.",
"You decide to close your positions by buying the shorted stocks. " +
"If you manage to get out now at €" + startPrice + " you've still made €" + ((boughtPrice - startPrice) * stocksToBuy) + "."
],
function () {
alertSplash(3);
setTimeout(nextState, 1.5 * 1000);
}
);
},
function () {
displayInfoscreen(
"It's a Short Squeeze!",
[ "You're not the only one who wants to get away from their shorted positions, " +
"and the lucky fellows with the stock aren't eager to sell it.",
"You have to close your shorted position as soon as possible, or else the " +
"price might have risen so much that paying for the stocks you're short will " +
"force you to sell your precious Porsche. It's no longer just about " +
"securing your profit; now it's about your car.",
"You can still make it, but for that, you'll have to fight hard. Smash the " +
"buy button the fastest it has ever been smashed."
],
nextState
);
},
function () {
currentState = -1;
graph.setVisible(false);
graphhider.setVisible(false);
if (exitFunction) {
exitFunction();
}
}
];
return {
"start": function (callback, inStartPrice, inBoughtPrice, inLowestPrice, inStocksToBuy) {
startIntro();
exitFunction = callback;
boughtPrice = inBoughtPrice;
lowestPrice = inLowestPrice;
stocksToBuy = inStocksToBuy;
startPrice = inStartPrice;
}
};
}());