1+ /*
2+ Copyright (C) 2025 Alexander Emanuelsson (alexemanuelol)
3+
4+ This program is free software: you can redistribute it and/or modify
5+ it under the terms of the GNU General Public License as published by
6+ the Free Software Foundation, either version 3 of the License, or
7+ (at your option) any later version.
8+
9+ This program is distributed in the hope that it will be useful,
10+ but WITHOUT ANY WARRANTY; without even the implied warranty of
11+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+ GNU General Public License for more details.
13+
14+ You should have received a copy of the GNU General Public License
15+ along with this program. If not, see <https://www.gnu.org/licenses/>.
16+
17+ https://github.com/alexemanuelol/rustplusplus
18+
19+ */
20+
21+ import * as rp from 'rustplus-ts' ;
22+
23+ import { RustPlusInstance } from '../managers/rustPlusManager' ;
24+ import { secondsToFullScale } from '../utils/timer' ;
25+
26+ export class RustPlusTeamInfo {
27+ public rpInstance : RustPlusInstance ;
28+ public appTeamInfo : rp . AppTeamInfo ;
29+
30+ constructor ( rpInstance : RustPlusInstance , appTeamInfo : rp . AppTeamInfo ) {
31+ this . rpInstance = rpInstance ;
32+ this . appTeamInfo = appTeamInfo ;
33+ }
34+
35+ public updateTeamInfo ( appTeamInfo : rp . AppTeamInfo ) {
36+ this . appTeamInfo = appTeamInfo ;
37+ }
38+
39+ public isNameChanged ( appInfo : rp . AppInfo ) : boolean {
40+ return this . appInfo . name !== appInfo . name ;
41+ }
42+
43+ public isHeaderImageChanged ( appInfo : rp . AppInfo ) : boolean {
44+ return this . appInfo . headerImage !== appInfo . headerImage ;
45+ }
46+
47+ public isUrlChanged ( appInfo : rp . AppInfo ) : boolean {
48+ return this . appInfo . url !== appInfo . url ;
49+ }
50+
51+ public isMapChanged ( appInfo : rp . AppInfo ) : boolean {
52+ return this . appInfo . map !== appInfo . map ;
53+ }
54+
55+ public isMapSizeChanged ( appInfo : rp . AppInfo ) : boolean {
56+ return this . appInfo . mapSize !== appInfo . mapSize ;
57+ }
58+
59+ public isWipeTimeChanged ( appInfo : rp . AppInfo ) : boolean {
60+ return this . appInfo . wipeTime !== appInfo . wipeTime ;
61+ }
62+
63+ public isPlayersChanged ( appInfo : rp . AppInfo ) : boolean {
64+ return this . appInfo . players !== appInfo . players ;
65+ }
66+
67+ public isMaxPlayersChanged ( appInfo : rp . AppInfo ) : boolean {
68+ return this . appInfo . maxPlayers !== appInfo . maxPlayers ;
69+ }
70+
71+ public isQueuedPlayersChanged ( appInfo : rp . AppInfo ) : boolean {
72+ return this . appInfo . queuedPlayers !== appInfo . queuedPlayers ;
73+ }
74+
75+ public isSeedChanged ( appInfo : rp . AppInfo ) : boolean {
76+ return this . appInfo . seed !== appInfo . seed ;
77+ }
78+
79+ public isSaltChanged ( appInfo : rp . AppInfo ) : boolean {
80+ return this . appInfo . salt !== appInfo . salt ;
81+ }
82+
83+ public isLogoImageChanged ( appInfo : rp . AppInfo ) : boolean {
84+ return this . appInfo . logoImage !== appInfo . logoImage ;
85+ }
86+
87+ public isNexusChanged ( appInfo : rp . AppInfo ) : boolean {
88+ return this . appInfo . nexus !== appInfo . nexus ;
89+ }
90+
91+ public isNexusIdChanged ( appInfo : rp . AppInfo ) : boolean {
92+ return this . appInfo . nexusId !== appInfo . nexusId ;
93+ }
94+
95+ public isNexusZoneChanged ( appInfo : rp . AppInfo ) : boolean {
96+ return this . appInfo . nexusZone !== appInfo . nexusZone ;
97+ }
98+
99+ public isCamerasEnabledChanged ( appInfo : rp . AppInfo ) : boolean {
100+ return this . appInfo . camerasEnabled !== appInfo . camerasEnabled ;
101+ }
102+
103+ /**
104+ * Other methods
105+ */
106+
107+ public isMaxPlayersIncreased ( appInfo : rp . AppInfo ) {
108+ return ( ( this . appInfo . maxPlayers ) < ( appInfo . maxPlayers ) ) ;
109+ }
110+
111+ public isMaxPlayersDecreased ( appInfo : rp . AppInfo ) {
112+ return ( ( this . appInfo . maxPlayers ) > ( appInfo . maxPlayers ) ) ;
113+ }
114+
115+ public isQueue ( ) : boolean {
116+ return this . appInfo . queuedPlayers !== 0 ;
117+ }
118+
119+ public getSecondsSinceWipe ( ) : number {
120+ return Math . floor ( ( Date . now ( ) / 1000 ) - this . appInfo . wipeTime ) ;
121+ }
122+
123+ public getTimeSinceWipe ( ignore : string = '' ) : string {
124+ return secondsToFullScale ( this . getSecondsSinceWipe ( ) , ignore ) ;
125+ }
126+ }
0 commit comments