Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 40f46ea

Browse files
committed
blobobject#owner -> blobobject#username
1 parent 8811bc3 commit 40f46ea

File tree

1 file changed

+32
-56
lines changed

1 file changed

+32
-56
lines changed

‎public/js/game.ts‎

Lines changed: 32 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ if (["Android", "iOS"].some(v => window.navigator.userAgent.includes(v))) {
294294
static width: number = 30;
295295
static height: number = 30;
296296
public guest: boolean;
297-
public owner: string;
297+
public username: string;
298298
public br: number | undefined;
299299
public img: HTMLImageElement;
300300
public direction: number;
@@ -312,13 +312,13 @@ if (["Android", "iOS"].some(v => window.navigator.userAgent.includes(v))) {
312312
public hudColors: number[];
313313

314314
constructor(br: number,
315-
owner: string,
315+
username: string,
316316
x: number = window.innerWidth / 2,
317317
y: number = window.innerHeight / 2,
318318
blob: BlobType = BlobType.Blobowo) {
319319
this.blob = blob;
320320
this.guest = false;
321-
this.owner = owner;
321+
this.username = username;
322322
this.br = br;
323323
this.img = new Image();
324324
this.direction = 0;
@@ -397,7 +397,7 @@ if (["Android", "iOS"].some(v => window.navigator.userAgent.includes(v))) {
397397
canvasY: number = canvas.height / 2 - height;
398398
const tier: Tier = getTier(this.br || 0);
399399
if (!tier || !tier.tier) return;
400-
if (this.owner === ownBlob.owner && this.owner) {
400+
if (this.username === ownBlob.username && this.username) {
401401
ctx.fillStyle = `#${tier.colorCode}`;
402402
ctx.font = `${15 * scale}px Raleway`;
403403
ctx.drawImage(this.img,
@@ -406,8 +406,8 @@ if (["Android", "iOS"].some(v => window.navigator.userAgent.includes(v))) {
406406
width * scale,
407407
height * scale);
408408
ctx.font = "16px Raleway";
409-
ctx.fillText(this.owner,
410-
canvasX - this.owner.length,
409+
ctx.fillText(this.username,
410+
canvasX - this.username.length,
411411
canvasY - 27.5);
412412
ctx.font = "13px Raleway";
413413
ctx.fillText(`${this.br} BR`,
@@ -433,7 +433,7 @@ if (["Android", "iOS"].some(v => window.navigator.userAgent.includes(v))) {
433433
20 * scale,
434434
20 * scale);
435435
}
436-
} else if (this.owner) {
436+
} else if (this.username) {
437437
const { canvasX: blobCanvasX, canvasY: blobCanvasY } = getRelativeCoordinates(
438438
this.x,
439439
this.y,
@@ -462,8 +462,8 @@ if (["Android", "iOS"].some(v => window.navigator.userAgent.includes(v))) {
462462
ctx.drawImage(this.img, blobCanvasX, blobCanvasY, width * scale, height * scale);
463463
if (displayUser) {
464464
ctx.font = "16px Raleway";
465-
ctx.fillText(this.owner,
466-
blobCanvasX - this.owner.length,
465+
ctx.fillText(this.username,
466+
blobCanvasX - this.username.length,
467467
(blobCanvasY) - 27.5);
468468
ctx.font = "13px Raleway";
469469
ctx.fillText(`${this.br} BR`,
@@ -503,8 +503,8 @@ if (["Android", "iOS"].some(v => window.navigator.userAgent.includes(v))) {
503503
let obj;
504504
for(let i: number = 0; i < room.blobs.length; ++i) {
505505
if (x < (room.blobs[i].x + 30) && x > (room.blobs[i].x - 30)) {
506-
if (y < (room.blobs[i].y + 30) && y > (room.blobs[i].y - 30) && room.blobs[i].owner !== ownBlob.owner) {
507-
if (excludeSelf && room.blobs[i].owner === ownBlob.owner) continue;
506+
if (y < (room.blobs[i].y + 30) && y > (room.blobs[i].y - 30) && room.blobs[i].username !== ownBlob.username) {
507+
if (excludeSelf && room.blobs[i].username === ownBlob.username) continue;
508508
obj = room.blobs[i];
509509
break;
510510
}
@@ -784,15 +784,14 @@ if (["Android", "iOS"].some(v => window.navigator.userAgent.includes(v))) {
784784
const { op, t: eventType, d: eventData } = JSON.parse(data);
785785
if (op === OPCODE.EVENT) {
786786
if (eventType === EventType.HEARTBEAT) {
787+
console.log(eventData);
787788
if (eventData.user.role === -1 && !/[?&]guest=true/.test(window.location.search))
788789
return document.location.href = "/login/";
789790

790791
if (details.mode === Room.Type.ELIMINATION)
791792
room = new EliminationRoom();
792793
else room = new Room();
793794

794-
console.log(eventData);
795-
796795
// Items
797796
for(const item of eventData.items) {
798797
const itemObj: Item = new Item(item.type, item.x, item.y);
@@ -801,8 +800,8 @@ if (["Android", "iOS"].some(v => window.navigator.userAgent.includes(v))) {
801800
}
802801

803802
// Own blob
804-
ownBlob.owner = eventData.user.username;
805-
ownBlob.blob = <BlobType>blobIDToString(eventData.user.blob);
803+
ownBlob.username = eventData.user.username;
804+
ownBlob.blob = eventData.user.blob;
806805
ownBlob.directionChangedAt = Date.now();
807806
ownBlob.directionChangeCoordinates.x = ownBlob.x = eventData.user.x;
808807
ownBlob.directionChangeCoordinates.y = ownBlob.y = eventData.user.y;
@@ -817,9 +816,9 @@ if (["Android", "iOS"].some(v => window.navigator.userAgent.includes(v))) {
817816
eventData.users = [];
818817
for (let i: number = 0; i < eventData.users.length; ++i) {
819818
const currentBlob: any = eventData.users[i];
820-
if (currentBlob.owner === ownBlob.owner ||
821-
room.blobs.some((v: BlobObject) => v.owner === currentBlob.owner)) continue;
822-
const newBlob: BlobObject = new BlobObject(currentBlob.br, currentBlob.owner);
819+
if (currentBlob.username === ownBlob.username ||
820+
room.blobs.some((v: BlobObject) => v.username === currentBlob.username)) continue;
821+
const newBlob: BlobObject = new BlobObject(currentBlob.br, currentBlob.username);
823822
newBlob.directionChangeCoordinates = {
824823
x: currentBlob.x,
825824
y: currentBlob.y
@@ -854,20 +853,20 @@ if (["Android", "iOS"].some(v => window.navigator.userAgent.includes(v))) {
854853
if (!ownBlob || !ownBlob.ready) return;
855854
for (let i: number = 0; i < eventData.players.length; ++i) {
856855
const currentBlob: any = eventData.players[i];
857-
const target: BlobObject | undefined = room.blobs.find((v: BlobObject) => v.owner === currentBlob.owner);
856+
const target: BlobObject | undefined = room.blobs.find((v: BlobObject) => v.username === currentBlob.username);
858857
if (!target) {
859-
const newBlob: BlobObject = new BlobObject(currentBlob.br, currentBlob.owner, currentBlob.x, currentBlob.y);
858+
const newBlob: BlobObject = new BlobObject(currentBlob.br, currentBlob.username, currentBlob.x, currentBlob.y);
860859
newBlob.direction = currentBlob.direction;
861860
newBlob.directionChangedAt = currentBlob.directionChangedAt;
862861
newBlob.directionChangeCoordinates = currentBlob.directionChangeCoordinates;
863862
newBlob.health = currentBlob.health;
864863
newBlob
865864
.setBlob(<BlobType>`../assets/${currentBlob.blob}.png`)
866865
.then(() => newBlob.display(true, true));
867-
if (room.blobs.some((v: BlobObject) => v.owner === currentBlob.owner)) return;
866+
if (room.blobs.some((v: BlobObject) => v.username === currentBlob.username)) return;
868867
room.blobs.push(newBlob);
869868
} else {
870-
if (currentBlob.owner !== ownBlob.owner) {
869+
if (currentBlob.username !== ownBlob.username) {
871870
target.direction = currentBlob.direction;
872871
target.directionChangedAt = currentBlob.directionChangedAt;
873872
target.directionChangeCoordinates = currentBlob.directionChangeCoordinates;
@@ -879,9 +878,9 @@ if (["Android", "iOS"].some(v => window.navigator.userAgent.includes(v))) {
879878
}
880879

881880
for (let i: number = 0; i < room.blobs.length; ++i) {
882-
const blob: number = eventData.players.findIndex((v: BlobObject) => v.owner === room.blobs[i].owner);
881+
const blob: number = eventData.players.findIndex((v: BlobObject) => v.username === room.blobs[i].username);
883882
if (blob === -1) {
884-
room.blobs.splice(room.blobs.findIndex((v: BlobObject) => v.owner === room.blobs[i].owner), 1);
883+
room.blobs.splice(room.blobs.findIndex((v: BlobObject) => v.username === room.blobs[i].username), 1);
885884
}
886885
}
887886
}
@@ -954,7 +953,7 @@ if (["Android", "iOS"].some(v => window.navigator.userAgent.includes(v))) {
954953
if (showAlert) alert(kickReason)
955954
showWSCloseNotification = false;
956955
ownBlob.ready = false;
957-
room.blobs.splice(room.blobs.findIndex(b => b.owner === ownBlob.owner), 1);
956+
room.blobs.splice(room.blobs.findIndex(b => b.username === ownBlob.username), 1);
958957
}
959958
else if (eventType === EventType.STATECHANGE) {
960959
if (room instanceof EliminationRoom) {
@@ -964,8 +963,8 @@ if (["Android", "iOS"].some(v => window.navigator.userAgent.includes(v))) {
964963
}
965964
else if (eventType === EventType.PLAYER_NOMMED && room.type === Room.Type.FFA) {
966965
displayLeaderboard();
967-
const loser: BlobObject | undefined = room.blobs.find(b => b.owner === eventData.loser.owner);
968-
const winner: BlobObject | undefined = room.blobs.find(b => b.owner === eventData.winner.owner);
966+
const loser: BlobObject | undefined = room.blobs.find(b => b.username === eventData.loser.username);
967+
const winner: BlobObject | undefined = room.blobs.find(b => b.username === eventData.winner.username);
969968

970969
if (!loser || !winner) return;
971970

@@ -987,14 +986,14 @@ if (["Android", "iOS"].some(v => window.navigator.userAgent.includes(v))) {
987986
const nomUser = document.createElement("span");
988987
const targetUser = document.createElement("span");
989988
nomUser.className = "nom-user nom-entry";
990-
nomUser.innerHTML = `${winner.owner} (+${eventData.result})`;
989+
nomUser.innerHTML = `${winner.username} (+${eventData.result})`;
991990
const newBRLabel = document.createElement("span");
992991
const newBRLabelLoser = document.createElement("span");
993992
newBRLabel.className = "new-br";
994993
newBRLabel.innerHTML = winner.br + " BR";
995994
const linebreakWinner = document.createElement("br");
996995
targetUser.className = "target-user nom-entry";
997-
targetUser.innerHTML = `${loser.owner} (-${eventData.result})`;
996+
targetUser.innerHTML = `${loser.username} (-${eventData.result})`;
998997
newBRLabelLoser.className = "new-br";
999998
newBRLabelLoser.innerHTML = loser.br + " BR";
1000999
const linebreakLoser = document.createElement("br");
@@ -1351,7 +1350,7 @@ if (["Android", "iOS"].some(v => window.navigator.userAgent.includes(v))) {
13511350
context.fillStyle = "lightgreen";
13521351
context.fillRect(canvas.width - 225 + (65 / (mapSize.width / ownBlob.x)), canvas.height - 75 + (65 / (mapSize.height / ownBlob.y)), 10, 10);
13531352
for(let i: number = 0; i < room.blobs.length; ++i) {
1354-
if (room.blobs[i].owner !== ownBlob.owner) {
1353+
if (room.blobs[i].username !== ownBlob.username) {
13551354
context.fillStyle = "red";
13561355
context.fillRect(canvas.width - 225 + (65 / (mapSize.width / room.blobs[i].x)), canvas.height - 75 + (65 / (mapSize.height / room.blobs[i].y)), 10, 10);
13571356
}
@@ -1414,8 +1413,8 @@ if (["Android", "iOS"].some(v => window.navigator.userAgent.includes(v))) {
14141413
const linebreak = document.createElement("br");
14151414
leaderboardEntry.className = "leaderboard-entry";
14161415
usernameEntry.className = "user-entry";
1417-
if (typeof sortedblobs[i].owner === "undefined") return;
1418-
usernameEntry.innerHTML = (i + 1) + ". " + sortedblobs[i].owner;
1416+
if (typeof sortedblobs[i].username === "undefined") return;
1417+
usernameEntry.innerHTML = (i + 1) + ". " + sortedblobs[i].username;
14191418
brLabel.className = "user-br";
14201419
brLabel.innerHTML = sortedblobs[i].br + " BR";
14211420
leaderboardElement.appendChild(leaderboardEntry);
@@ -1567,29 +1566,6 @@ if (["Android", "iOS"].some(v => window.navigator.userAgent.includes(v))) {
15671566
wsc.onopen = (): any => wsc.send(data);
15681567
}
15691568
}
1570-
function blobIDToString(id: BlobID): string | null {
1571-
switch (id) {
1572-
case BlobID.Blobowo:
1573-
return BlobType.Blobowo;
1574-
break;
1575-
case BlobID.Blobevil:
1576-
return BlobType.Blobevil;
1577-
break;
1578-
case BlobID.Blobeyes:
1579-
return BlobType.Blobeyes;
1580-
break;
1581-
case BlobID.Blobkittenknife:
1582-
return BlobType.Blobkittenknife;
1583-
case BlobID.Blobpeek:
1584-
return BlobType.Blobpeek;
1585-
break;
1586-
case BlobID.Blobnom:
1587-
return BlobType.Blobnom;
1588-
default:
1589-
return null;
1590-
}
1591-
}
1592-
15931569

15941570

15951571
// -------------
@@ -1638,7 +1614,7 @@ if (["Android", "iOS"].some(v => window.navigator.userAgent.includes(v))) {
16381614
const tier: any = getTier(player.br || 0);
16391615
const spanElement: HTMLElement = document.createElement("span");
16401616
spanElement.className = "player";
1641-
spanElement.innerHTML = `<img src="../assets/emblems/${tier.emblemFile}" width="20" height="20" alt="Tier" /><span class="player-name" style="color: #${tier.colorCode};">${player.owner}</span> (${player.br} BR)</span>`;
1617+
spanElement.innerHTML = `<img src="../assets/emblems/${tier.emblemFile}" class="tier-image" width="20" height="20" alt="Tier" /><span class="player-name" style="color: #${tier.colorCode};">${player.username}</span> (${player.br} BR)</span>`;
16421618
const playersElement: HTMLElement | null = document.getElementById("players");
16431619
if (playersElement)
16441620
playersElement.appendChild(spanElement);

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /