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 3fbea55

Browse files
committed
changes
1 parent bc8c9fe commit 3fbea55

File tree

3 files changed

+30
-10
lines changed

3 files changed

+30
-10
lines changed

‎models/room/room.go‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"github.com/blobs-io/blobsgame/models/item"
66
"github.com/blobs-io/blobsgame/models/player"
77
"strconv"
8+
"strings"
89
)
910

1011
const (
@@ -30,7 +31,7 @@ func New(mode uint8) *Room {
3031
r := Room {
3132
Mode: mode,
3233
}
33-
r.ID = r.ModeToString() + strconv.Itoa(len(Rooms))
34+
r.ID = strings.ToLower(r.ModeToString()) + strconv.Itoa(len(Rooms))
3435

3536
r.Players = make([]player.Player, 0)
3637
r.Items = make([]item.Item, 0)

‎models/user/user.go‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,9 @@ const (
6868
DailyCoins = 100
6969

7070
// Roles
71+
GuestRole = -1
7172
UserRole = 0
73+
AdminRole = 1
7274

7375
// GetUser flags
7476
UserDefaultSearch = 1

‎public/js/Game.ts‎

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,25 @@
11
declare const io: Function;
22
declare const socket: any;
33
declare const server: string;
4+
declare class RestClient {
5+
public _key: string;
6+
public key: string;
7+
public authType: string;
8+
public api: string;
9+
public computedHeaders: any;
10+
11+
constructor(key: string, authType: "Session", api?: string);
12+
13+
fetchPromotions(): Promise<any[]>;
14+
fetchUser(user: string): Promise<any>;
15+
fetchRooms(): Promise<any>;
16+
switchBlob(newBlob: string): Promise<any>;
17+
redeemDailyBonus(): Promise<any>;
18+
ping(): Promise<number>;
19+
static extractSessionID(): string;
20+
}
21+
22+
const rest: RestClient = new RestClient(RestClient.extractSessionID(), "Session");
423

524
function randomNumber(min: number, max: number): number {
625
return Math.floor(Math.random() * (max - min) + min);
@@ -626,7 +645,7 @@ if (["Android", "iOS"].some(v => window.navigator.userAgent.includes(v))) {
626645
// -------------
627646
// Canvas
628647
// -------------
629-
function animationFrame(): any {
648+
asyncfunction animationFrame(): Promise<any> {
630649
if (windowBlur) {
631650
return window.requestAnimationFrame(animationFrame);
632651
}
@@ -647,14 +666,12 @@ if (["Android", "iOS"].some(v => window.navigator.userAgent.includes(v))) {
647666
// Ping
648667
if (Date.now() - lastTick > 2500) {
649668
displayLeaderboard();
650-
const timestampBefore: number = Date.now();
651-
fetch("/api/ping").then(async res => {
652-
const request: any = await res.json();
653-
const diff: number = ping = (request.arrived - timestampBefore);
654-
const latencyElement: HTMLElement | null = document.getElementById("latency");
655-
if (!latencyElement) return;
656-
latencyElement.innerHTML = `• Ping: <span style="color: #${diff < 100 ? '00ff00' : (diff < 200 ? 'ccff99' : (diff < 250 ? 'ffff99': (diff < 500 ? 'ff9966' : 'ff0000')))}">${diff}ms</span>`;
657-
});
669+
ping = await rest.ping();
670+
671+
const latencyElement: HTMLElement | null = document.getElementById("latency");
672+
if (!latencyElement) return;
673+
674+
latencyElement.innerHTML = `• Ping: <span style="color: #${ping < 100 ? '00ff00' : (ping < 200 ? 'ccff99' : (ping < 250 ? 'ffff99': (ping < 500 ? 'ff9966' : 'ff0000')))}">${ping}ms</span>`;
658675
lastTick = Date.now();
659676
}
660677

0 commit comments

Comments
(0)

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