Skip to content

Commit bb5a9c2

Browse files
committed
initial commit
0 parents  commit bb5a9c2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+1497
-0
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# html5cpps

index.html

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<html>
2+
<header>
3+
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/phaser.js"></script>
4+
<link rel="stylehseet" src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css"></link>
5+
<link rel="stylesheet" href="/media/cp/content/base/css/cpStyle.css"></link>
6+
<style>
7+
@font-face { font-family: cpBurbankSmall; src: url('/media/cp/content/base/fonts/cpBurbankSmall.ttf'); }
8+
@font-face { font-family: ArialNarrow; src: url('/media/cp/content/base/fonts/ArialNarrow.ttf'); }
9+
@font-face { font-family: cpCCFace; src: url('/media/cp/content/base/fonts/cpCCFaceFrontBoldItalic.ttf'); }
10+
@font-face { font-family: cpBurbankMedium; src: url('/media/cp/content/base/fonts/cpBurbankMedium.ttf');};
11+
</style>
12+
</header>
13+
<body>
14+
<script>
15+
media = "/media/cp/";
16+
</script>
17+
<div id="ClubPenguin">
18+
<script src="media/cp/client/club_penguin.js"></script>
19+
</div>
20+
</body>
21+
</html>

media/cp/client/airtower.js

+163
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
class airtower {
2+
start() {
3+
cp._airtower = this;
4+
this.server = null;
5+
this.rndk = null;
6+
this.world = false;
7+
this.parser = new DOMParser();
8+
this.username = null;
9+
this.password = null;
10+
this.extention = "xt";
11+
this.divider = "%";
12+
this.xmlData = {
13+
msg: {
14+
"@t": "sys",
15+
body: {
16+
"@r": "0",
17+
},
18+
},
19+
};
20+
this.XmlListeners = {};
21+
this.Listeners = {};
22+
this.addXmlListener("apiOK", cp.handlers.apiOKHandler);
23+
this.addXmlListener("apiKO", cp.handlers.apiKOHandler);
24+
this.addXmlListener("rndK", cp.handlers.rndkHandler);
25+
this.addListener("l", cp.handlers.loginHandler);
26+
this.addListener("e", cp.handlers.errorHandler);
27+
this.addListener("js", cp.handlers.joinServerHandler);
28+
}
29+
createLoginConnection(username, password) {
30+
this.username = username;
31+
this.password = password;
32+
this.server = new WebSocket(
33+
`${cp.crumbs.protocol}://${cp.crumbs.loginServer}:${cp.crumbs.loginPort}`
34+
);
35+
this.server.onopen = this.connectionEstablished;
36+
this.server.onmessage = cp.handlers.handleMessage;
37+
}
38+
createWorldConnection(server) {
39+
this.world = true;
40+
this.server = new WebSocket(
41+
`${cp.crumbs.protocol}://${cp.crumbs.worlds[server].ip}:${cp.crumbs.worlds[server].port}`
42+
);
43+
this.server.onopen = this.connectionEstablished;
44+
this.server.onmessage = cp.handlers.handleMessage;
45+
}
46+
sendLogin() {
47+
const SHELL = cp.getCurrentShell;
48+
if (this.world) {
49+
const loginUsername = [
50+
SHELL.userId,
51+
0,
52+
this.username,
53+
SHELL.loginKey,
54+
0,
55+
1,
56+
0,
57+
].join("|");
58+
const passwordHashes = [
59+
cp.hash.hashLoginKey(SHELL.loginKey, this.rndk),
60+
SHELL.confirmationHash,
61+
].join("#");
62+
this.sendXmlData("login", [
63+
[
64+
"login",
65+
{
66+
"@z": "w1",
67+
nick: { "#cdata": loginUsername },
68+
pword: { "#cdata": passwordHashes },
69+
},
70+
],
71+
]);
72+
} else {
73+
this.password = cp.hash.hashPass(this.password, this.rndk);
74+
this.sendXmlData("login", [
75+
[
76+
"login",
77+
{
78+
"@z": "w1",
79+
nick: { "#cdata": this.username },
80+
pword: { "#cdata": this.password },
81+
},
82+
],
83+
]);
84+
}
85+
}
86+
joinServer() {
87+
const SHELL = cp.getCurrentShell;
88+
this.sendXt("s", "j#js", [-1, SHELL.userId, SHELL.loginKey, "en"]);
89+
}
90+
sendXmlData(action, extra) {
91+
this.server.send(this.createXMLPacket(action, extra));
92+
}
93+
sendXt(attr, action, extra) {
94+
let packetBase = `${this.divider}${this.extention}${this.divider}`;
95+
packetBase += attr + this.divider;
96+
packetBase += action + this.divider;
97+
// if extra is an array we could
98+
// extra.reduce((i) => extra[i] + this.divider, packetBase);
99+
//it looks like extra is an object so i guess this works too
100+
Object.keys(extra).reduce((i) => extra[i] + this.divider, packetBase);
101+
console.log(packetBase);
102+
this.server.send(packetBase);
103+
}
104+
addXmlListener(action, callback) {
105+
this.XmlListeners[action] = callback;
106+
}
107+
addListener(action, callback) {
108+
this.Listeners[action] = callback;
109+
}
110+
connectionEstablished() {
111+
const AIRTOWER = cp.getCurrentAirtower;
112+
AIRTOWER.sendVerChk("253");
113+
}
114+
sendVerChk(version) {
115+
this.sendXmlData("verChk", [
116+
[
117+
"ver",
118+
{
119+
"@v": version,
120+
},
121+
],
122+
]);
123+
}
124+
createXMLPacket(action, extra) {
125+
const tempXml = JSON.parse(JSON.stringify(this.xmlData));
126+
127+
tempXml["msg"]["body"]["@action"] = action;
128+
// should rewrite this but it is one am and i dont care. i'll do this later
129+
if (extra != undefined) {
130+
for (var extNum in extra) {
131+
var node = extra[extNum];
132+
tempXml["msg"]["body"][node[0]] = node[1];
133+
console.log(tempXml);
134+
}
135+
}
136+
return json2xml(tempXml, "");
137+
}
138+
parseXml(xml) {
139+
let dom = null;
140+
if (window.DOMParser) {
141+
try {
142+
dom = new DOMParser().parseFromString(xml, "text/xml");
143+
} catch (e) {
144+
dom = null;
145+
}
146+
} else if (window.ActiveXObject) {
147+
try {
148+
dom = new ActiveXObject("Microsoft.XMLDOM");
149+
dom.async = false;
150+
if (!dom.loadXML(xml)) {
151+
// parse error ..
152+
153+
window.alert(dom.parseError.reason + dom.parseError.srcText);
154+
}
155+
} catch (e) {
156+
dom = null;
157+
}
158+
} else {
159+
alert("cannot parse xml string!");
160+
}
161+
return dom;
162+
}
163+
}

media/cp/client/club_penguin.js

+133
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
class clubpenguin {
2+
constructor(width, height) {
3+
this.width = width;
4+
this.height = height;
5+
this._loader = null;
6+
this._shell = null;
7+
this._airtower = null;
8+
this._engine = null;
9+
this._login = null;
10+
this._crumbs = null;
11+
this.myScene = null;
12+
this.dependencies = null;
13+
}
14+
15+
startGame() {
16+
this.cpConfig = {
17+
type: Phaser.AUTO,
18+
width: this.width,
19+
height: this.height,
20+
parent: "ClubPenguin",
21+
dom: {
22+
createContainer: true,
23+
},
24+
scale: {
25+
autoCenter: Phaser.Scale.CENTER_BOTH,
26+
},
27+
scene: {
28+
preload: function(){
29+
this.played = false;
30+
console.log(`${media}content/base/shell/background.svg`);
31+
this.load.svg("cp_bc", `${media}content/base/shell/background.svg`);
32+
33+
this.load.script("loader", `${media}client/loader.js`);
34+
this.load.spritesheet(
35+
"loader_im",
36+
`${media}content/base/loader/minecart.png`,
37+
{ frameWidth: 195, frameHeight: 197, startFrame: 0, endFrame: 53 }
38+
);
39+
},
40+
create: function() {
41+
// SET THE BACKGROUND
42+
cp.myScene = this;
43+
this.cp_bc = this.add.image(0, 0, "cp_bc");
44+
this.cp_bc.setOrigin(0);
45+
this.cp_bc.displayWidth = this.game.canvas.width;
46+
this.cp_bc.displayHeight = this.game.canvas.height;
47+
48+
this._loader = new loader();
49+
this._loader.startLoaderScreen();
50+
},
51+
update: function() {
52+
if (!this.played) {
53+
this._loader.loadFiles(
54+
"xmlConvert",
55+
[`${media}content/libraries/xml2json.js`],
56+
() => {}
57+
);
58+
this._loader.loadFiles(
59+
"jsonConvert",
60+
[`${media}content/libraries/json2xml.js`],
61+
() => {}
62+
);
63+
this._loader.loadFiles(
64+
"crypt",
65+
[`${media}content/libraries/md5.js`],
66+
() => {}
67+
);
68+
this._loader.getPlugins(function() {
69+
if (this.readyState == 4 && this.status == 200) {
70+
console.log(this.responseText);
71+
const plugins = JSON.parse(this.responseText);
72+
console.log(plugins);
73+
cp.getCurrentLoader.handleDependencies(
74+
"plugins",
75+
plugins,
76+
true
77+
);
78+
}
79+
});
80+
this._loader.getDependencies(function() {
81+
if (this.readyState == 4 && this.status == 200) {
82+
const dependencies = JSON.parse(this.responseText);
83+
cp.getCurrentLoader.handleDependencies(
84+
"boot",
85+
dependencies,
86+
false
87+
);
88+
// LOAD LOGIN FILES - PUT THIS IN CALLBACK TO PREVENT THEM FROM BEING
89+
// EXECUTED AT THE SAME TIME
90+
cp.getCurrentLoader.handleDependencies(
91+
"login",
92+
dependencies,
93+
false
94+
);
95+
}
96+
});
97+
98+
this.played = true;
99+
}
100+
},
101+
},
102+
};
103+
104+
this.game = new Phaser.Game(this.cpConfig, "game");
105+
}
106+
get getAllScenes() {
107+
return this.game.scene.scenes;
108+
}
109+
110+
get getCurrentLoader() {
111+
return this._loader;
112+
}
113+
get getCurrentLogin() {
114+
return this._login.__proto__;
115+
}
116+
get getCurrentShell() {
117+
return this._shell;
118+
}
119+
get getCurrentEngine() {
120+
return this._engine;
121+
}
122+
get getCurrentAirtower() {
123+
return this._airtower;
124+
}
125+
get getCurrentCrumbs() {
126+
return this._crumbs;
127+
}
128+
}
129+
130+
window.onload = function () {
131+
cp = new clubpenguin(1000, 630);
132+
cp.startGame();
133+
};

media/cp/client/crumbs.js

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
class crumbs {
2+
start() {
3+
this.loginServer = "100.115.92.199";
4+
this.protocol = "ws";
5+
this.loginPort = "6112";
6+
this.magic = "Y(02.>'H}t\":E1";
7+
this.worlds = {
8+
"3100": {
9+
name: "Wind",
10+
ip: "100.115.92.199",
11+
port: "9875",
12+
},
13+
"101": {
14+
name: "Blizzard",
15+
ip: "100.115.92.199",
16+
port: "9876",
17+
},
18+
};
19+
this.serverBaseMap = {
20+
div: {
21+
"@class": "serverSelectContainer",
22+
input: {
23+
"@src":
24+
`${media}content/base/login/images/server_background.png`,
25+
"@onmouseover":
26+
`this.setAttribute('src', '${media}content/base/login/images/server_background_down.png')`,
27+
"@onmouseleave":
28+
`this.setAttribute('src', '${media}content/base/login/images/server_background.png')`,
29+
"@onclick": "cp.getCurrentLogin.joinWorld(this)",
30+
"@class": "serverSelectContainer",
31+
"@type": "image",
32+
},
33+
img: [
34+
{
35+
"@src":
36+
`${media}content/base/login/images/server_icon.png`,
37+
"@class": "serverIcon",
38+
},
39+
],
40+
span: {
41+
"@class": "serverText",
42+
"#text": "",
43+
},
44+
},
45+
};
46+
cp.crumbs = this;
47+
}
48+
}

0 commit comments

Comments
 (0)