notherbase-fs 4.4.7 → 4.5.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/notherbase-fs.js +39 -32
- package/package.json +1 -1
- package/public/js/base.js +1 -41
- package/server/creation.js +117 -0
- package/server/spirit-world.js +147 -0
- package/server/spirit.js +83 -0
- package/{controllers → server}/user.js +36 -37
- package/test/coast/tall-beach/nono-cove/index.ejs +3 -3
- package/test/the-front/add-gold.js +4 -12
- package/test/the-front/index.ejs +12 -6
- package/test2/the-front/index.ejs +0 -99
- package/views/explorer.ejs +1 -1
- package/views/footer.ejs +1 -1
- package/controllers/creation.js +0 -181
- package/controllers/spirit-world.js +0 -247
- package/models/index.js +0 -31
- package/models/spirit.js +0 -235
- package/test2/the-front/add-gold.js +0 -14
- package/test2/the-front/check/check.css +0 -3
- package/test2/the-front/check/emailTime.js +0 -10
- package/test2/the-front/check/flip.js +0 -10
- package/test2/the-front/check/index.ejs +0 -55
- package/test2/the-front/check/save-input.js +0 -8
- package/test2/the-front/keeper/clipboards.js +0 -134
- package/test2/the-front/keeper/index.ejs +0 -81
- package/test2/the-front/keeper/keeper.css +0 -158
- package/test2/the-front/keeper/keeper.js +0 -140
- package/test2/the-front/test-page/emailTime.js +0 -9
- package/test2/the-front/test-page/index.ejs +0 -74
- /package/{models → server}/send-mail.js +0 -0
- /package/{controllers → server}/util.js +0 -0
- /package/test/{the-front/void → void}/index.ejs +0 -0
- /package/test/{the-front/void → void}/void.css +0 -0
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
let $clipboard = $(".clipboard");
|
|
2
|
-
let $loginButton = $("#login-button");
|
|
3
|
-
let $loginInfo = $("#login-info");
|
|
4
|
-
let $resetInfo = $("#reset-info");
|
|
5
|
-
let $setInfo = $("#set-info");
|
|
6
|
-
let $registerButton = $("#register-button");
|
|
7
|
-
let $registerInfo = $("#register-info");
|
|
8
|
-
let $resetForm = $("#reset-form");
|
|
9
|
-
let $setForm = $("#set-form");
|
|
10
|
-
let $loginForm = $("#login-form");
|
|
11
|
-
let $changeButton = $("#change-button");
|
|
12
|
-
let $resetButton = $("#reset-button");
|
|
13
|
-
let $setButton = $("#set-button");
|
|
14
|
-
let $returnButtons = $(".return-button");
|
|
15
|
-
|
|
16
|
-
//try to login
|
|
17
|
-
$loginButton.on("click", async (e) => {
|
|
18
|
-
let response = await base.attemptLogin($("#login-email").val(), $("#login-pass").val());
|
|
19
|
-
|
|
20
|
-
if (response.status === "success") {
|
|
21
|
-
//Dialogue.addGlobalFlag("logged-in");
|
|
22
|
-
closeClipboard("for-login");
|
|
23
|
-
keeper.interrupt();
|
|
24
|
-
}
|
|
25
|
-
else {
|
|
26
|
-
$loginInfo.text(response.message);
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
//try to register an account
|
|
31
|
-
$registerButton.on("click", async function () {
|
|
32
|
-
let response = await base.attemptRegister(
|
|
33
|
-
$("#register-email").val(),
|
|
34
|
-
$("#register-user").val(),
|
|
35
|
-
$("#register-pass").val()
|
|
36
|
-
);
|
|
37
|
-
|
|
38
|
-
if (response.status === "success") {
|
|
39
|
-
$registerInfo.text("You hear a nod from deep within the shack. Your new account has been registered.");
|
|
40
|
-
}
|
|
41
|
-
else {
|
|
42
|
-
$registerInfo.text(response.message);
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
$changeButton.on("click", function () {
|
|
47
|
-
goToReset("");
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
$resetButton.on("click", async function () {
|
|
51
|
-
let response = await base.resetPassword($("#reset-email").val(), true);
|
|
52
|
-
|
|
53
|
-
if (response.status === "success") {
|
|
54
|
-
goToSet("");
|
|
55
|
-
}
|
|
56
|
-
else {
|
|
57
|
-
goToReset(response.message);
|
|
58
|
-
}
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
$setButton.on("click", async function () {
|
|
62
|
-
let response = await base.changePassword(
|
|
63
|
-
$("#change-token").val(),
|
|
64
|
-
$("#change-email").val(),
|
|
65
|
-
$("#change-password").val(),
|
|
66
|
-
$("#change-confirmation").val()
|
|
67
|
-
);
|
|
68
|
-
|
|
69
|
-
if (response.status === "success") {
|
|
70
|
-
goToLogin("Password changed successfully.");
|
|
71
|
-
}
|
|
72
|
-
else {
|
|
73
|
-
goToReset("Change Error: " + response.message);
|
|
74
|
-
}
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
$returnButtons.on("click", function () {
|
|
78
|
-
goToLogin("");
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
let goToLogin = function goToLogin(info) {
|
|
82
|
-
$loginInfo.text(info);
|
|
83
|
-
$resetForm.addClass("invisible");
|
|
84
|
-
$setForm.addClass("invisible");
|
|
85
|
-
$loginForm.removeClass("invisible");
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
let goToReset = function goToReset(info) {
|
|
89
|
-
$resetInfo.text(info);
|
|
90
|
-
$setForm.addClass("invisible");
|
|
91
|
-
$loginForm.addClass("invisible");
|
|
92
|
-
$resetForm.removeClass("invisible");
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
let goToSet = function goToSet(info) {
|
|
96
|
-
$setInfo.text(info);
|
|
97
|
-
$resetForm.addClass("invisible");
|
|
98
|
-
$loginForm.addClass("invisible");
|
|
99
|
-
$setForm.removeClass("invisible");
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
let clickClose = function clickClose(e) {
|
|
103
|
-
e.stopPropagation();
|
|
104
|
-
let $currentClipboard = $(e.currentTarget).parent();
|
|
105
|
-
|
|
106
|
-
if (!$currentClipboard.hasClass("on-counter")) {
|
|
107
|
-
$currentClipboard.addClass("on-counter");
|
|
108
|
-
$currentClipboard.find(".scribbles").removeClass("invisible");
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
let closeClipboard = function closeClipboard(which) {
|
|
113
|
-
let $currentClipboard = $(`.${which}`);
|
|
114
|
-
|
|
115
|
-
if (!$currentClipboard.hasClass("on-counter")) {
|
|
116
|
-
$currentClipboard.addClass("on-counter");
|
|
117
|
-
$currentClipboard.find(".scribbles").removeClass("invisible");
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
//pick up a clipboard
|
|
122
|
-
$clipboard.on("click", function clickClipboard(e) {
|
|
123
|
-
let $currentClipboard = $(e.currentTarget);
|
|
124
|
-
|
|
125
|
-
if ($currentClipboard.hasClass("on-counter")) {
|
|
126
|
-
$clipboard.addClass("on-counter");
|
|
127
|
-
$clipboard.find(".scribbles").removeClass("invisible");
|
|
128
|
-
$currentClipboard.removeClass("on-counter");
|
|
129
|
-
$currentClipboard.find(".scribbles").addClass("invisible");
|
|
130
|
-
}
|
|
131
|
-
});
|
|
132
|
-
|
|
133
|
-
//put down a clipboard
|
|
134
|
-
$(".close").on("click", clickClose);
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
<style>
|
|
2
|
-
<%- include("./keeper.css"); %>
|
|
3
|
-
</style>
|
|
4
|
-
|
|
5
|
-
<div class="shack">
|
|
6
|
-
<div class="dialogue" id="keeper"></div>
|
|
7
|
-
|
|
8
|
-
<div class="counter">
|
|
9
|
-
<div class="clipboard on-counter for-login">
|
|
10
|
-
<button class="close">X</button>
|
|
11
|
-
<div class="application">
|
|
12
|
-
<div class="auth-form" id="login-form">
|
|
13
|
-
<h5>NotherBase</h5>
|
|
14
|
-
<h6>Login to Your Account</h6>
|
|
15
|
-
<input type="email" name="email" placeholder="e@mail.com" id="login-email">
|
|
16
|
-
<input type="password" name="password" placeholder="password" id="login-pass">
|
|
17
|
-
<button id="login-button">Login</button>
|
|
18
|
-
<button class="subtle" id="change-button">Change Your Password</button>
|
|
19
|
-
<p id="login-info"></p>
|
|
20
|
-
</div>
|
|
21
|
-
<div class="auth-form invisible" id="reset-form">
|
|
22
|
-
<h5>NotherBase</h5>
|
|
23
|
-
<h6>Reset Your Password</h6>
|
|
24
|
-
<input type="email" name="email" placeholder="e@mail.com" id="reset-email">
|
|
25
|
-
<button id="reset-button">Send Reset Code to Your Email</button>
|
|
26
|
-
<button class="subtle return-button">Return to Login</button>
|
|
27
|
-
<p id="reset-info"></p>
|
|
28
|
-
</div>
|
|
29
|
-
<div class="auth-form invisible" id="set-form">
|
|
30
|
-
<h5>NotherBase</h5>
|
|
31
|
-
<h6>Change Your Password</h6>
|
|
32
|
-
<p>Reset code sent to your email.</p>
|
|
33
|
-
<input type="email" name="email" placeholder="e@mail.com" id="change-email">
|
|
34
|
-
<input type="number" name="token" placeholder="0000" id="change-token">
|
|
35
|
-
<input type="password" name="password" placeholder="new password" id="change-password">
|
|
36
|
-
<input type="password" name="confirmation" placeholder="new password again" id="change-confirmation">
|
|
37
|
-
<button id="set-button">Set Password</button>
|
|
38
|
-
<button class="subtle return-button">Return to Login</button>
|
|
39
|
-
<p id="set-info"></p>
|
|
40
|
-
</div>
|
|
41
|
-
</div>
|
|
42
|
-
<div ></div>
|
|
43
|
-
<div class="clamp"></div>
|
|
44
|
-
<div class="scribbles" id="login-scribbles">Login<br><br>If you can read this you're a nerd.</div>
|
|
45
|
-
</div>
|
|
46
|
-
|
|
47
|
-
<div class="clipboard on-counter for-register">
|
|
48
|
-
<button class="close">X</button>
|
|
49
|
-
<div class="application">
|
|
50
|
-
<div class="auth-form" id="register-form">
|
|
51
|
-
<h5>NotherBase</h5>
|
|
52
|
-
<h6>Register a New Account</h6>
|
|
53
|
-
<input type="email" name="email" placeholder="e@mail.com" id="register-email">
|
|
54
|
-
<input type="text" name="username" placeholder="username" id="register-user">
|
|
55
|
-
<input type="password" name="password" placeholder="password" id="register-pass">
|
|
56
|
-
<input type="password" name="confirmation" placeholder="password again" id="register-confirmation">
|
|
57
|
-
<button id="register-button">Register</button>
|
|
58
|
-
<p id="register-info"></p>
|
|
59
|
-
</div>
|
|
60
|
-
</div>
|
|
61
|
-
<div class="clamp"></div>
|
|
62
|
-
<div class="scribbles" id="register-scribbles">Register<br><br>If you can read this you're a nerd.</div>
|
|
63
|
-
</div>
|
|
64
|
-
</div>
|
|
65
|
-
</div>
|
|
66
|
-
|
|
67
|
-
<hr>
|
|
68
|
-
|
|
69
|
-
<a class="to gate" href="/the-front/gate">
|
|
70
|
-
Go to the Fence Gate
|
|
71
|
-
</a>
|
|
72
|
-
|
|
73
|
-
<hr>
|
|
74
|
-
|
|
75
|
-
<a class="return" href="/the-front">
|
|
76
|
-
Back Away
|
|
77
|
-
</a>
|
|
78
|
-
|
|
79
|
-
<script>
|
|
80
|
-
<%- include("./clipboards.js"); %>
|
|
81
|
-
</script>
|
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
:root {
|
|
2
|
-
--gate: rgba(128, 128, 128, 0.678);
|
|
3
|
-
--paperWhite: rgb(231, 231, 231);
|
|
4
|
-
--inkBlack: rgb(22, 22, 22);
|
|
5
|
-
--woodColor: rgb(110, 76, 37);
|
|
6
|
-
--darkWoodColor: rgb(70, 48, 23);
|
|
7
|
-
--gateColor: rgba(128, 128, 128, 0.678);
|
|
8
|
-
--gateColorBright: rgba(187, 187, 187, 0.678);
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
.shack {
|
|
12
|
-
background-color: rgb(20, 15, 11);
|
|
13
|
-
border: 3px solid var(--woodColor);
|
|
14
|
-
width: 100%;
|
|
15
|
-
height: 500px;
|
|
16
|
-
position: relative;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
.counter {
|
|
20
|
-
width: 100%;
|
|
21
|
-
height: 25%;
|
|
22
|
-
position: absolute;
|
|
23
|
-
left: 0;
|
|
24
|
-
bottom: 0;
|
|
25
|
-
background-color: var(--woodColor);
|
|
26
|
-
border-bottom: 3vh solid var(--darkWoodColor);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
.clipboard {
|
|
30
|
-
background-color: rgb(73, 47, 28);
|
|
31
|
-
width: 240px;
|
|
32
|
-
height: 420px;
|
|
33
|
-
position: absolute;
|
|
34
|
-
left: 5%;
|
|
35
|
-
bottom: 5px;
|
|
36
|
-
padding: 5px;
|
|
37
|
-
cursor: initial;
|
|
38
|
-
transition: all .5s ease;
|
|
39
|
-
z-index: 10;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
.clipboard.for-register {
|
|
43
|
-
left: initial;
|
|
44
|
-
right: 5%;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
.clipboard.on-counter {
|
|
48
|
-
width: 75px;
|
|
49
|
-
height: 110px;
|
|
50
|
-
position: absolute;
|
|
51
|
-
left: 10%;
|
|
52
|
-
top: -25%;
|
|
53
|
-
padding: 5px;
|
|
54
|
-
transform: rotate3d(1, 1, 1, -70deg);
|
|
55
|
-
cursor: pointer;
|
|
56
|
-
z-index: 5;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
.clipboard.on-counter.for-register {
|
|
60
|
-
left: initial;
|
|
61
|
-
right: 10%;
|
|
62
|
-
transform: rotate3d(1, -1, -1, -70deg);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
.close {
|
|
66
|
-
display: initial;
|
|
67
|
-
color: black;
|
|
68
|
-
border-radius: 50%;
|
|
69
|
-
background-color: rgba(255, 0, 0, 0.63);
|
|
70
|
-
border: 1px solid black;
|
|
71
|
-
position: absolute;
|
|
72
|
-
right: var(--padding);
|
|
73
|
-
top: var(--padding);
|
|
74
|
-
width: 25px;
|
|
75
|
-
height: 25px;
|
|
76
|
-
padding: 0;
|
|
77
|
-
z-index: 11;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
.clipboard.on-counter .close {
|
|
81
|
-
display: none;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
.clipboard.on-counter .auth-form {
|
|
85
|
-
display: none;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
.application {
|
|
89
|
-
background-color: rgb(231, 231, 231);
|
|
90
|
-
width: calc(100% - 10px);
|
|
91
|
-
height: calc(100% - 10px);
|
|
92
|
-
position: absolute;
|
|
93
|
-
left: 5px;
|
|
94
|
-
top: 5px;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
.clamp {
|
|
98
|
-
background-color: rgb(155, 155, 155);
|
|
99
|
-
width: 30%;
|
|
100
|
-
height: 5%;
|
|
101
|
-
position: absolute;
|
|
102
|
-
left: 35%;
|
|
103
|
-
top: 0;
|
|
104
|
-
border-radius: 1px;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
.application * {
|
|
108
|
-
color: var(--inkBlack);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
.auth-form {
|
|
112
|
-
height: 100%;
|
|
113
|
-
width: 100%;
|
|
114
|
-
padding: 40px 5px;
|
|
115
|
-
overflow: hidden;
|
|
116
|
-
display: flex;
|
|
117
|
-
justify-content: center;
|
|
118
|
-
flex-wrap: wrap;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
.auth-form p {
|
|
122
|
-
width: 100%;
|
|
123
|
-
text-align: center;
|
|
124
|
-
margin: 0;
|
|
125
|
-
font-size: 15px;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
.auth-form input, .auth-form button {
|
|
129
|
-
background-color: var(--paperWhite);
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
.auth-form button {
|
|
133
|
-
width: 60%;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
.auth-form p.error {
|
|
137
|
-
color: rgb(160, 19, 19);
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
.scribbles {
|
|
141
|
-
color: var(--inkBlack);
|
|
142
|
-
font-size: 10px;
|
|
143
|
-
width: 100%;
|
|
144
|
-
height: 100%;
|
|
145
|
-
position: absolute;
|
|
146
|
-
left: 0;
|
|
147
|
-
top: 0;
|
|
148
|
-
font-family: 'Redacted Script', cursive;
|
|
149
|
-
padding: 10px;
|
|
150
|
-
line-height: normal;
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
.subtle, .subtle:hover {
|
|
154
|
-
border: none !important;
|
|
155
|
-
width: 100% !important;
|
|
156
|
-
height: 25px !important;
|
|
157
|
-
text-decoration: underline;
|
|
158
|
-
}
|
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
let keeper = new Dialogue("keeper", 2000, function () {
|
|
2
|
-
//if logged in
|
|
3
|
-
if (Dialogue.checkGlobalFlag("logged-in")) {
|
|
4
|
-
Dialogue.removeGlobalFlag("logged-in");
|
|
5
|
-
|
|
6
|
-
return [
|
|
7
|
-
Dialogue.textSlide("Did you hear that?", 1),
|
|
8
|
-
Dialogue.textSlide("You've logged in successfully!"),
|
|
9
|
-
Dialogue.textSlide("Head on in through the gate.")
|
|
10
|
-
]
|
|
11
|
-
}
|
|
12
|
-
// about nb
|
|
13
|
-
else if (this.checkFlag("what-kind")) {
|
|
14
|
-
this.removeFlag("what-kind");
|
|
15
|
-
this.removeFlag("about-nb");
|
|
16
|
-
this.addFlag("human")
|
|
17
|
-
|
|
18
|
-
return [
|
|
19
|
-
Dialogue.textSlide("Oh, I love this question!"),
|
|
20
|
-
Dialogue.textSlide("NotherBase has a variety of web apps and games."),
|
|
21
|
-
Dialogue.textSlide("You can even interact with other humans in certain places.")
|
|
22
|
-
]
|
|
23
|
-
}
|
|
24
|
-
else if (this.checkFlag("who-made")) {
|
|
25
|
-
this.removeFlag("who-made");
|
|
26
|
-
this.removeFlag("about-nb");
|
|
27
|
-
|
|
28
|
-
return [
|
|
29
|
-
Dialogue.textSlide("Uh- well, God did.", 3),
|
|
30
|
-
Dialogue.textSlide("Same as the way every other place was made, right?"),
|
|
31
|
-
Dialogue.textSlide("Wait, you mean to ask who made the fence and buildings within?"),
|
|
32
|
-
Dialogue.textSlide("That's just Nother.", 1),
|
|
33
|
-
Dialogue.textSlide("But, I think they're still working for God.")
|
|
34
|
-
]
|
|
35
|
-
}
|
|
36
|
-
else if (this.checkFlag("how-big")) {
|
|
37
|
-
this.removeFlag("how-big");
|
|
38
|
-
this.removeFlag("about-nb");
|
|
39
|
-
|
|
40
|
-
return [
|
|
41
|
-
Dialogue.textSlide("How big?", 1),
|
|
42
|
-
Dialogue.textSlide("Um..."),
|
|
43
|
-
Dialogue.textSlide("I'm really not sure to be honest."),
|
|
44
|
-
Dialogue.textSlide("I think it's pretty big, though. Should be.")
|
|
45
|
-
]
|
|
46
|
-
}
|
|
47
|
-
else if (this.checkFlag("about-nb")) {
|
|
48
|
-
return [
|
|
49
|
-
Dialogue.buttonSlide([
|
|
50
|
-
Dialogue.button("What kind of website is this?", "what-kind"),
|
|
51
|
-
Dialogue.button("Who made this place?", "who-made"),
|
|
52
|
-
Dialogue.button("How big is NotherBase?", "how-big")
|
|
53
|
-
])
|
|
54
|
-
]
|
|
55
|
-
}
|
|
56
|
-
// about account
|
|
57
|
-
else if (this.checkFlag("why-account")) {
|
|
58
|
-
this.removeFlag("why-account");
|
|
59
|
-
this.removeFlag("about-account");
|
|
60
|
-
|
|
61
|
-
return [
|
|
62
|
-
Dialogue.textSlide("Registering an account allows NotherBase to indentify you."),
|
|
63
|
-
Dialogue.textSlide("This way, NotherBase can provide features like game saves synced across all your devices.")
|
|
64
|
-
]
|
|
65
|
-
}
|
|
66
|
-
else if (this.checkFlag("why-email")) {
|
|
67
|
-
this.removeFlag("why-email");
|
|
68
|
-
this.removeFlag("about-account");
|
|
69
|
-
|
|
70
|
-
return [
|
|
71
|
-
Dialogue.textSlide("Your email is needed in for account recovery."),
|
|
72
|
-
Dialogue.textSlide("My boss said he didn't want everyone calling him when they forget their passwords.")
|
|
73
|
-
]
|
|
74
|
-
}
|
|
75
|
-
else if (this.checkFlag("what-info")) {
|
|
76
|
-
this.removeFlag("what-info");
|
|
77
|
-
this.removeFlag("about-account");
|
|
78
|
-
|
|
79
|
-
return [
|
|
80
|
-
Dialogue.textSlide("Only information about you that has been generated on NotherBase will be saved.", 4),
|
|
81
|
-
Dialogue.textSlide("For example, imagine you are choosing an alias for a game."),
|
|
82
|
-
Dialogue.textSlide("NotherBase servers will save that info in order to sync across your devices.")
|
|
83
|
-
]
|
|
84
|
-
}
|
|
85
|
-
else if (this.checkFlag("about-account")) {
|
|
86
|
-
return [
|
|
87
|
-
Dialogue.buttonSlide([
|
|
88
|
-
Dialogue.button("Why is an account needed?", "why-account"),
|
|
89
|
-
Dialogue.button("Why is my email address needed?", "why-email"),
|
|
90
|
-
Dialogue.button("What information is saved about me?", "what-info")
|
|
91
|
-
])
|
|
92
|
-
]
|
|
93
|
-
}
|
|
94
|
-
//about self
|
|
95
|
-
else if (this.checkFlag("about-self")) {
|
|
96
|
-
this.removeFlag("about-self");
|
|
97
|
-
|
|
98
|
-
return [
|
|
99
|
-
Dialogue.textSlide("Oh we don't need to talk about little 'ol me."),
|
|
100
|
-
Dialogue.textSlide("I'm no important person.", 1)
|
|
101
|
-
]
|
|
102
|
-
}
|
|
103
|
-
//about self
|
|
104
|
-
else if (this.checkFlag("poke")) {
|
|
105
|
-
this.removeFlag("poke");
|
|
106
|
-
|
|
107
|
-
return [
|
|
108
|
-
Dialogue.textSlide("It's true that you can interact with other people like myself, but..."),
|
|
109
|
-
Dialogue.textSlide("You already knew that.", 1),
|
|
110
|
-
Dialogue.textSlide("I was just trying to emphasize that you can interact with others like yourself, too.")
|
|
111
|
-
]
|
|
112
|
-
}
|
|
113
|
-
//start
|
|
114
|
-
else if (this.checkFlag("greeted")) {
|
|
115
|
-
if (this.checkFlag("human")) return [
|
|
116
|
-
Dialogue.textSlide("Let me know if you have any questions."),
|
|
117
|
-
Dialogue.buttonSlide([
|
|
118
|
-
Dialogue.button("About NotherBase...", "about-nb"),
|
|
119
|
-
Dialogue.button("About Accounts...", "about-account"),
|
|
120
|
-
Dialogue.button("Why did you say other humans and not other people?", "poke")
|
|
121
|
-
])
|
|
122
|
-
];
|
|
123
|
-
else return [
|
|
124
|
-
Dialogue.textSlide("Let me know if you have any questions.", 1),
|
|
125
|
-
Dialogue.buttonSlide([
|
|
126
|
-
Dialogue.button("About NotherBase...", "about-nb"),
|
|
127
|
-
Dialogue.button("About Accounts...", "about-account"),
|
|
128
|
-
Dialogue.button("About Yourself...", "about-self")
|
|
129
|
-
])
|
|
130
|
-
];
|
|
131
|
-
}
|
|
132
|
-
else {
|
|
133
|
-
this.addFlag("greeted");
|
|
134
|
-
|
|
135
|
-
return [
|
|
136
|
-
Dialogue.textSlide("Hi!", 1),
|
|
137
|
-
Dialogue.textSlide("Welcome to NotherBase!", 2)
|
|
138
|
-
]
|
|
139
|
-
}
|
|
140
|
-
});
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
<div class="chatter" id="adam"></div>
|
|
2
|
-
<input type="text" id="adam">
|
|
3
|
-
<button id="adam">Chat</button>
|
|
4
|
-
|
|
5
|
-
<script>
|
|
6
|
-
class Spirit {
|
|
7
|
-
constructor(name) {
|
|
8
|
-
this.name = name;
|
|
9
|
-
this.children = {};
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
addChild(child, parent) {
|
|
13
|
-
if (!this.children[child.name]) {
|
|
14
|
-
this.children[child.name] = 1;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
this.children[child.name]++;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
class Chatter {
|
|
22
|
-
constructor(id) {
|
|
23
|
-
this.name = id;
|
|
24
|
-
this.brain = new Spirit("i");
|
|
25
|
-
this.$div = $(`.chatter#${id}`);
|
|
26
|
-
this.$input = $(`input#${id}`);
|
|
27
|
-
this.$submit = $(`button#${id}`);
|
|
28
|
-
|
|
29
|
-
this.$submit.click(() => {
|
|
30
|
-
this.listen(this.$input.val());
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
register = (word) => {
|
|
35
|
-
if (!this.brain[word]) {
|
|
36
|
-
this.brain[word] = new Spirit(word);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
return this.brain[word];
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
think = () => {
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
listen = (message) => {
|
|
47
|
-
message = message.toLowerCase();
|
|
48
|
-
let words = message.split(" ");
|
|
49
|
-
|
|
50
|
-
//add words to the dialogue tree
|
|
51
|
-
this.register(words[0]);
|
|
52
|
-
for (let i = 0; i < words.length; i++) {
|
|
53
|
-
if (i < words.length - 1) {
|
|
54
|
-
let child = this.register(words[i + 1]);
|
|
55
|
-
if (i > 0) this.brain[words[i]].addChild(child, this.brain[words[i - 1]]);
|
|
56
|
-
else this.brain[words[i]].addChild(child, null);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
//think
|
|
61
|
-
|
|
62
|
-
this.respond(message);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
respond(message) {
|
|
66
|
-
this.$div.append(`<p>${this.name}: ${message}</p>`);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
const adam = new Chatter("adam");
|
|
71
|
-
adam.listen(`In the beginning God created the heavens and the earth`);
|
|
72
|
-
adam.listen("if i have the first two words in a three word relationship can the third word be guessed")
|
|
73
|
-
</script>
|
|
74
|
-
</html>
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|