forked from zombieb/galvanic-corrosion-rewrite
g
This commit is contained in:
@@ -8,6 +8,9 @@ export class ServerContentBase {
|
||||
constructor(server: ServerBase, id: string, kv?: boolean) {
|
||||
this.server = server;
|
||||
this.kv = new KV(id, kv);
|
||||
|
||||
server.on('server.start', this.start);
|
||||
server.on('server.destroy', this.destroy);
|
||||
}
|
||||
|
||||
async kvInit() {
|
||||
@@ -19,7 +22,7 @@ export class ServerContentBase {
|
||||
*
|
||||
* Override me!
|
||||
*/
|
||||
start() {
|
||||
protected start() {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -28,7 +31,7 @@ export class ServerContentBase {
|
||||
*
|
||||
* Override me!
|
||||
*/
|
||||
destroy() {
|
||||
protected destroy() {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -45,6 +45,7 @@ export class AvatarContentBase extends ServerContentBase {
|
||||
return this.#rawImport;
|
||||
}
|
||||
|
||||
// unused
|
||||
formatAllPossibleCombinations() {
|
||||
const parsed = JSON.parse(Deno.readTextFileSync(path.join(RootPath, '/res/avatar.json'))) as AvatarImport;
|
||||
function formatVisualData(data: {
|
||||
@@ -68,8 +69,11 @@ export class AvatarContentBase extends ServerContentBase {
|
||||
Rarity: ItemRarity.None
|
||||
}));
|
||||
}
|
||||
importAllItems() {
|
||||
this.#rawImport = JSON.parse(Deno.readTextFileSync(path.join(RootPath, '/res/AvatarItems.json'))) as AvatarItemExport[];
|
||||
}
|
||||
|
||||
override start() {
|
||||
this.formatAllPossibleCombinations();
|
||||
this.importAllItems();
|
||||
}
|
||||
}
|
||||
@@ -23,7 +23,7 @@ interface MetaFile {
|
||||
SavedBy?: Profile
|
||||
OriginalFilename?: string
|
||||
}
|
||||
interface File {
|
||||
export interface File {
|
||||
Meta: MetaFile,
|
||||
Data: Uint8Array<ArrayBufferLike>
|
||||
}
|
||||
@@ -172,8 +172,7 @@ export class ServerContentManager extends ServerContentBase {
|
||||
Data: data
|
||||
}
|
||||
return file;
|
||||
} catch (err) {
|
||||
this.#log.w(`Could not get file "${path}": ${err}`);
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { CloudRegionCode } from "../../util/photon.ts";
|
||||
import type Profile from "../profiles/profile.ts";
|
||||
import { RoomLocation } from "./base.ts";
|
||||
import { RoomInstance, RoomLocation } from "./base.ts";
|
||||
|
||||
export class Instance {
|
||||
|
||||
@@ -8,7 +9,18 @@ export class Instance {
|
||||
#players: Set<Profile> = new Set();
|
||||
|
||||
#instanceId: number;
|
||||
//#roomId: number;
|
||||
//#subRoomId: number;
|
||||
#location: RoomLocation;
|
||||
//#name: string;
|
||||
//#maxCapacity: number;
|
||||
#isFull: boolean = false;
|
||||
//#isPrivate: boolean;
|
||||
#isInProgress: boolean = false;
|
||||
#photonRegionId: string = CloudRegionCode.us;
|
||||
//#photonRoomId: string;
|
||||
#dataBlob?: string;
|
||||
#eventId?: string
|
||||
|
||||
constructor(options: {
|
||||
id: number,
|
||||
@@ -30,10 +42,18 @@ export class Instance {
|
||||
}
|
||||
addPlayer(profile: Profile) {
|
||||
this.#players.add(profile);
|
||||
|
||||
}
|
||||
|
||||
getCreatedAt() {
|
||||
return this.#createdAt;
|
||||
}
|
||||
|
||||
export() {
|
||||
/*const inst: RoomInstance = {
|
||||
roomInstanceId: this.#instanceId,
|
||||
|
||||
}*/
|
||||
}
|
||||
|
||||
}
|
||||
@@ -53,7 +53,7 @@ export interface RoomInstance {
|
||||
photonRegionId: string,
|
||||
photonRoomId: string,
|
||||
dataBlob?: string,
|
||||
eventId?: string
|
||||
eventId?: number
|
||||
}
|
||||
|
||||
export class InstanceManager extends ServerContentBase {
|
||||
|
||||
@@ -55,7 +55,6 @@ export class Presence {
|
||||
isOnline ?
|
||||
this.#statusVisibility :
|
||||
PlayerStatusVisibility.Offline;
|
||||
this.#roomInstance = this.#profile.getInstance();
|
||||
|
||||
this.#server.emit('presence.update', { profile: this.#profile, presence: this });
|
||||
}
|
||||
|
||||
40
src/server/profiles/content/Messages.ts
Normal file
40
src/server/profiles/content/Messages.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
import ProfileContentManager from "./base.ts";
|
||||
|
||||
enum MessageType {
|
||||
GameInvite,
|
||||
GameInviteDeclined,
|
||||
GameJoinFailed,
|
||||
PartyActivitySwitch,
|
||||
FriendInvite,
|
||||
VoteToKick,
|
||||
GameInviteV2,
|
||||
PartyActivitySwitchV2,
|
||||
RequestGameInvite = 10,
|
||||
RequestGameInviteDeclined,
|
||||
FriendStatusOnline = 20,
|
||||
TextMessage = 30,
|
||||
FriendRequestAccepted = 40,
|
||||
PlayerCheer = 50,
|
||||
PlayerCheerAnonymous,
|
||||
RoomCoOwnerAdded = 60,
|
||||
RoomCoOwnerRemoved,
|
||||
RoomCoOwnerInvited,
|
||||
CreatorPublishedNewRoom = 70,
|
||||
PlayerAttendingEvent = 80,
|
||||
PlayerEventInvitation,
|
||||
GroupInvitation = 90,
|
||||
PlayerJoinedGroup,
|
||||
CoachMessage = 100
|
||||
}
|
||||
|
||||
interface MessageBase {
|
||||
Id: number,
|
||||
FromPlayerId: number,
|
||||
SentTime: string,
|
||||
Type: MessageType,
|
||||
Data: string,
|
||||
}
|
||||
|
||||
export class ProfileMessageManager extends ProfileContentManager {
|
||||
|
||||
}
|
||||
5
src/server/profiles/content/Reputation.ts
Normal file
5
src/server/profiles/content/Reputation.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
import ProfileContentManager from "./base.ts";
|
||||
|
||||
export class ProfileReputationManager extends ProfileContentManager {
|
||||
|
||||
}
|
||||
5
src/server/profiles/content/Subscriptions.ts
Normal file
5
src/server/profiles/content/Subscriptions.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
import ProfileContentManager from "./base.ts";
|
||||
|
||||
export class ProfileSubscriptionsManager extends ProfileContentManager {
|
||||
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
import { RoomInstance } from "../instances/base.ts";
|
||||
import { Instance } from "../instances/Instance.ts";
|
||||
import KV from "../persistence/kv.ts";
|
||||
import { PlatformMask, ProfileRole } from "../platforms/types.ts";
|
||||
import { type ServerBase } from "../server.ts";
|
||||
@@ -6,7 +6,10 @@ import { type SignalRSocketHandler } from "../socket/signalr/socket.ts";
|
||||
import { ProfileAvatarManager } from "./content/Avatar.ts";
|
||||
import ProfileContentManager from "./content/base.ts";
|
||||
import { ProfileMatchmakingManager } from "./content/Matchmaking.ts";
|
||||
import { ProfileMessageManager } from "./content/Messages.ts";
|
||||
import { ProfileReputationManager } from "./content/Reputation.ts";
|
||||
import { ProfileSettingsManager } from "./content/Settings.ts";
|
||||
import { ProfileSubscriptionsManager } from "./content/Subscriptions.ts";
|
||||
import ProfileManagerBase from "./manager.ts";
|
||||
import { recNetAccountSchema, SelfAccount, type RecNetAccount } from "./types/profile.ts";
|
||||
|
||||
@@ -16,7 +19,7 @@ class Profile {
|
||||
#kv: KV;
|
||||
|
||||
#socket: SignalRSocketHandler | null = null;
|
||||
#instance: RoomInstance | null = null;
|
||||
#instance: Instance | null = null;
|
||||
|
||||
#server: ServerBase;
|
||||
#selfAcc: SelfAccount;
|
||||
@@ -26,6 +29,9 @@ class Profile {
|
||||
Settings: ProfileSettingsManager;
|
||||
Avatar: ProfileAvatarManager;
|
||||
Matchmaking: ProfileMatchmakingManager;
|
||||
Reputation: ProfileReputationManager;
|
||||
Subscriptions: ProfileSubscriptionsManager;
|
||||
Messages: ProfileMessageManager;
|
||||
|
||||
constructor(acc: SelfAccount, kv: KV, server: ServerBase) {
|
||||
this.#id = acc.accountId;
|
||||
@@ -36,6 +42,9 @@ class Profile {
|
||||
this.Settings = new ProfileSettingsManager(this, this.#kv);
|
||||
this.Avatar = new ProfileAvatarManager(this, this.#kv);
|
||||
this.Matchmaking = new ProfileMatchmakingManager(this, this.#kv);
|
||||
this.Reputation = new ProfileReputationManager(this, this.#kv);
|
||||
this.Subscriptions = new ProfileSubscriptionsManager(this, this.#kv);
|
||||
this.Messages = new ProfileMessageManager(this, this.#kv);
|
||||
}
|
||||
|
||||
async #saveSelfAcc() {
|
||||
@@ -121,7 +130,7 @@ class Profile {
|
||||
getInstance() {
|
||||
return this.#instance;
|
||||
}
|
||||
setInstance(inst: RoomInstance) {
|
||||
setInstance(inst: Instance) {
|
||||
this.#instance = inst;
|
||||
}
|
||||
|
||||
|
||||
@@ -14,6 +14,8 @@ interface ServerEvents {
|
||||
'profile.roleupdate': RoleUpdateEvent,
|
||||
'profile.update': ProfileUpdateEvent,
|
||||
'presence.update': PresenceUpdateEvent,
|
||||
'server.start': undefined,
|
||||
'server.destroy': undefined,
|
||||
}
|
||||
|
||||
class ServerBase extends EventManager<ServerEvents> {
|
||||
|
||||
0
src/server/storefronts/test.ts
Normal file
0
src/server/storefronts/test.ts
Normal file
Reference in New Issue
Block a user