mirror of
https://github.com/Terncode/pixel.horse.git
synced 2026-09-25 22:25:53 +02:00
Fix/Improve linting
This commit is contained in:
@@ -145,9 +145,15 @@ export class AdminAccountDetails implements OnInit, OnDestroy {
|
||||
}
|
||||
ngOnDestroy() {
|
||||
this.model.updated = () => { };
|
||||
this.authsSubscription && this.authsSubscription.unsubscribe();
|
||||
this.accountSubscription && this.accountSubscription.unsubscribe();
|
||||
this.originsSubscription && this.originsSubscription.unsubscribe();
|
||||
if (this.authsSubscription) {
|
||||
this.authsSubscription.unsubscribe();
|
||||
}
|
||||
if (this.accountSubscription) {
|
||||
this.accountSubscription.unsubscribe();
|
||||
}
|
||||
if (this.originsSubscription) {
|
||||
this.originsSubscription.unsubscribe();
|
||||
}
|
||||
}
|
||||
refresh() {
|
||||
const account = this.account;
|
||||
@@ -160,10 +166,14 @@ export class AdminAccountDetails implements OnInit, OnDestroy {
|
||||
this.accountObject = undefined;
|
||||
this.loadingDuplicates = false;
|
||||
|
||||
this.authsSubscription && this.authsSubscription.unsubscribe();
|
||||
if (this.authsSubscription) {
|
||||
this.authsSubscription.unsubscribe();
|
||||
}
|
||||
this.authsSubscription = undefined;
|
||||
|
||||
this.originsSubscription && this.originsSubscription.unsubscribe();
|
||||
if (this.originsSubscription) {
|
||||
this.originsSubscription.unsubscribe();
|
||||
}
|
||||
this.originsSubscription = undefined;
|
||||
|
||||
this.auths = [];
|
||||
@@ -201,7 +211,8 @@ export class AdminAccountDetails implements OnInit, OnDestroy {
|
||||
|
||||
this.originsSubscription = this.model.accountOrigins
|
||||
.subscribe(account._id, origins => this.origins = origins || []);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
this.duplicates = [];
|
||||
this.ignores = [];
|
||||
this.ignoredBy = [];
|
||||
@@ -468,7 +479,8 @@ export class AdminAccountDetails implements OnInit, OnDestroy {
|
||||
|
||||
if (merge.data) {
|
||||
return `${mergeInfo('ACCOUNT', merge.data.account)}\n\n${mergeInfo('MERGED', merge.data.merge)}`;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return '<empty>';
|
||||
}
|
||||
}
|
||||
@@ -552,7 +564,9 @@ export class AdminAccountDetails implements OnInit, OnDestroy {
|
||||
}
|
||||
private update() {
|
||||
if (this.id) {
|
||||
this.accountSubscription && this.accountSubscription.unsubscribe();
|
||||
if (this.accountSubscription) {
|
||||
this.accountSubscription.unsubscribe();
|
||||
}
|
||||
this.accountSubscription = this.id ? this.model.accounts.subscribe(this.id, a => this.setAccount(a)) : undefined;
|
||||
|
||||
this.events = this.model.events
|
||||
|
||||
@@ -49,7 +49,9 @@ export class AdminOther implements OnInit, OnDestroy {
|
||||
});
|
||||
}
|
||||
ngOnDestroy() {
|
||||
this.subscription && this.subscription.unsubscribe();
|
||||
if (this.subscription) {
|
||||
this.subscription.unsubscribe();
|
||||
}
|
||||
}
|
||||
saveFields() {
|
||||
let settings: any = {};
|
||||
@@ -67,7 +69,8 @@ export class AdminOther implements OnInit, OnDestroy {
|
||||
try {
|
||||
compact(this.suspiciousPonies!.split(/\n/g).map(x => x.trim())).map(x => JSON.parse(x));
|
||||
this.model.updateSettings({ suspiciousPonies: this.suspiciousPonies });
|
||||
} catch (e) {
|
||||
}
|
||||
catch (e) {
|
||||
this.suspiciousPoniesError = isErrorAlike(e) ? e.message : 'Unknown error';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -90,7 +90,8 @@ export class AdminPonies implements OnInit {
|
||||
}
|
||||
|
||||
this.items = result.items;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
this.items = [];
|
||||
}
|
||||
})
|
||||
|
||||
@@ -112,7 +112,8 @@ export class AdminReportsPerf {
|
||||
element.style.left = `${x + 10}px`;
|
||||
element.style.top = `${y + 10}px`;
|
||||
element.innerText = tooltip.text;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
element.style.display = 'none';
|
||||
}
|
||||
}
|
||||
@@ -208,8 +209,9 @@ export class AdminReportsPerf {
|
||||
|
||||
this.tooltips.length = 0;
|
||||
|
||||
if (!this.timings.length)
|
||||
if (!this.timings.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
const firstTime = this.timings[0].time;
|
||||
const startTime = this.startTime;
|
||||
@@ -254,7 +256,8 @@ export class AdminReportsPerf {
|
||||
for (const entry of this.timings) {
|
||||
if (entry.type === TimingEntryType.Start) {
|
||||
startStack.push(entry);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
const start = startStack.pop()!;
|
||||
const name = start.name!;
|
||||
const startX = timeToX(start.time);
|
||||
@@ -267,9 +270,11 @@ export class AdminReportsPerf {
|
||||
if (startStack.length === 0) {
|
||||
context.fillStyle = '#efc457';
|
||||
text = `${text} (${time.toFixed(2)} ms) ${(100 * time / frameTime).toFixed(0)}%`;
|
||||
} else if (/\(\)$/.test(name)) {
|
||||
}
|
||||
else if (/\(\)$/.test(name)) {
|
||||
context.fillStyle = '#d4ecc6';
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
context.fillStyle = '#c6dcec';
|
||||
}
|
||||
|
||||
@@ -298,7 +303,8 @@ export class AdminReportsPerf {
|
||||
for (const entry of this.timings) {
|
||||
if (entry.type === TimingEntryType.Start) {
|
||||
startStack.push({ ...entry, excludedTime: 0 });
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
const start = startStack.pop()!;
|
||||
const name = start.name!;
|
||||
const time = entry.time - start.time;
|
||||
|
||||
@@ -41,11 +41,14 @@ export class AdminApp {
|
||||
get loading() {
|
||||
if (!this.model.initialized) {
|
||||
return 'Initializing';
|
||||
} else if (!this.model.connected) {
|
||||
}
|
||||
else if (!this.model.connected) {
|
||||
return 'Connecting';
|
||||
} else if (!this.model.loaded) {
|
||||
}
|
||||
else if (!this.model.loaded) {
|
||||
return 'Loading';
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,7 +48,8 @@ export abstract class BaseTable<T> {
|
||||
sortBy(field: string) {
|
||||
if (this.sortedBy === field) {
|
||||
this.sortedAsc = !this.sortedAsc;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
this.sortedBy = field;
|
||||
this.sortedAsc = true;
|
||||
}
|
||||
|
||||
@@ -7,8 +7,9 @@ import { transliterate } from 'transliteration';
|
||||
})
|
||||
export class TranslitPipe implements PipeTransform {
|
||||
transform(value: string) {
|
||||
if (!value || /^[a-z0-9-_.,[]!@#$%^&*{}|\/\\ ]+$/i.test(value))
|
||||
if (!value || /^[a-z0-9-_.,[]!@#$%^&*{}|\/\\ ]+$/i.test(value)) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const translit = transliterate(value);
|
||||
return translit !== value ? translit : undefined;
|
||||
|
||||
@@ -20,7 +20,9 @@ export class AccountInfoRemote implements OnDestroy {
|
||||
constructor(private model: AdminModel) {
|
||||
}
|
||||
ngOnDestroy() {
|
||||
this.subscription && this.subscription.unsubscribe();
|
||||
if (this.subscription) {
|
||||
this.subscription.unsubscribe();
|
||||
}
|
||||
}
|
||||
get accountId() {
|
||||
return this._accountId;
|
||||
|
||||
@@ -134,11 +134,14 @@ export class AccountInfo implements OnInit, OnChanges {
|
||||
|
||||
if (this.account.flags) {
|
||||
return 'text-banned';
|
||||
} else if (!counters && !this.account.supporter) {
|
||||
}
|
||||
else if (!counters && !this.account.supporter) {
|
||||
return 'text-muted';
|
||||
} else if (counters && ((counters.spam || 0) > 100 || (counters.swears || 0) > 10)) {
|
||||
}
|
||||
else if (counters && ((counters.spam || 0) > 100 || (counters.swears || 0) > 10)) {
|
||||
return 'text-alert';
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return 'text-present';
|
||||
}
|
||||
}
|
||||
@@ -190,7 +193,9 @@ export class AccountInfo implements OnInit, OnChanges {
|
||||
this.alertModalRef = this.modalService.show(this.alertModal, { ignoreBackdropClick: true });
|
||||
}
|
||||
cancelAlert() {
|
||||
this.alertModalRef && this.alertModalRef.hide();
|
||||
if (this.alertModalRef) {
|
||||
this.alertModalRef.hide();
|
||||
}
|
||||
this.alertModalRef = undefined;
|
||||
}
|
||||
confirmAlert() {
|
||||
@@ -206,7 +211,8 @@ export class AccountInfo implements OnInit, OnChanges {
|
||||
|
||||
if (cached && cached.generatedAt > threshold.getTime()) {
|
||||
this.duplicates = cached;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
this.model.getAllDuplicatesQuickInfo(account._id)
|
||||
.then(duplicates => {
|
||||
if (duplicates) {
|
||||
|
||||
@@ -42,7 +42,8 @@ export class AdminChatLog implements OnDestroy {
|
||||
set autoRefresh(value: boolean) {
|
||||
if (value) {
|
||||
this.refreshInterval = this.refreshInterval || setInterval(() => this.refresh(), 10 * 1000);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
this.stopInterval();
|
||||
}
|
||||
}
|
||||
@@ -75,7 +76,8 @@ export class AdminChatLog implements OnDestroy {
|
||||
add(account: Account) {
|
||||
if (!this.account) {
|
||||
this.show(account);
|
||||
} else if (account !== this.account && !includes(this.accounts, account)) {
|
||||
}
|
||||
else if (account !== this.account && !includes(this.accounts, account)) {
|
||||
this.date = this.date || this.today;
|
||||
this.accounts.push(account);
|
||||
this.refresh();
|
||||
@@ -116,7 +118,8 @@ export class AdminChatLog implements OnDestroy {
|
||||
if (this.account) {
|
||||
const accounts = [this.account._id, ...this.accounts.map(a => a._id)];
|
||||
this.handleChat(this.model.accountsFormattedChat(accounts, date));
|
||||
} else if (this.search) {
|
||||
}
|
||||
else if (this.search) {
|
||||
this.handleChat(this.model.searchFormattedChat(this.search, date));
|
||||
}
|
||||
}
|
||||
@@ -177,7 +180,8 @@ export class AdminChatLog implements OnDestroy {
|
||||
|
||||
this.atNode += i;
|
||||
this.processIdle = requestIdleCallback(() => this.processNodes());
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
this.nodesToProcess = undefined;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,12 +30,16 @@ export class AuthInfoEdit implements OnDestroy {
|
||||
if (this.authId !== value) {
|
||||
this._authId = value;
|
||||
this.auth = undefined;
|
||||
this.subscription && this.subscription.unsubscribe();
|
||||
if (this.subscription) {
|
||||
this.subscription.unsubscribe();
|
||||
}
|
||||
this.subscription = value ? this.model.auths.subscribe(value, auth => this.auth = auth) : undefined;
|
||||
}
|
||||
}
|
||||
ngOnDestroy() {
|
||||
this.subscription && this.subscription.unsubscribe();
|
||||
if (this.subscription) {
|
||||
this.subscription.unsubscribe();
|
||||
}
|
||||
}
|
||||
removeAuth(auth: Auth | undefined) {
|
||||
if (auth && confirm('Are you sure?')) {
|
||||
|
||||
@@ -23,11 +23,15 @@ export class AuthInfoRemote implements OnDestroy {
|
||||
if (this.authId !== value) {
|
||||
this._authId = value;
|
||||
this.auth = undefined;
|
||||
this.subscription && this.subscription.unsubscribe();
|
||||
if (this.subscription) {
|
||||
this.subscription.unsubscribe();
|
||||
}
|
||||
this.subscription = value ? this.model.auths.subscribe(value, auth => this.auth = auth) : undefined;
|
||||
}
|
||||
}
|
||||
ngOnDestroy() {
|
||||
this.subscription && this.subscription.unsubscribe();
|
||||
if (this.subscription) {
|
||||
this.subscription.unsubscribe();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,9 @@ export class AuthListRemote implements OnDestroy {
|
||||
this._accountId = value;
|
||||
this.auths = [];
|
||||
this.loading = true;
|
||||
this.subscription && this.subscription.unsubscribe();
|
||||
if (this.subscription) {
|
||||
this.subscription.unsubscribe();
|
||||
}
|
||||
this.subscription = value ? this.model.accountAuths.subscribe(value, auths => {
|
||||
this.auths = auths || [];
|
||||
this.loading = false;
|
||||
@@ -34,6 +36,8 @@ export class AuthListRemote implements OnDestroy {
|
||||
}
|
||||
}
|
||||
ngOnDestroy() {
|
||||
this.subscription && this.subscription.unsubscribe();
|
||||
if (this.subscription) {
|
||||
this.subscription.unsubscribe();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,9 +37,11 @@ export class BanIcon implements OnInit, OnDestroy, OnChanges {
|
||||
get className() {
|
||||
if (this.isPerma) {
|
||||
return 'text-banned';
|
||||
} else if (this.isTimedOut) {
|
||||
}
|
||||
else if (this.isTimedOut) {
|
||||
return 'text-alert';
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return 'text-muted';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,7 +48,8 @@ export class EventsTable {
|
||||
onShowChat(e: MouseEvent, event: Event, account: Account | undefined) {
|
||||
if (e.shiftKey) {
|
||||
this.addChat.emit({ event, account });
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
this.showChat.emit({ event, account });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,9 @@ export class FromNow implements OnInit, OnDestroy, OnChanges {
|
||||
this.update();
|
||||
}
|
||||
ngOnDestroy() {
|
||||
this.unsubscribe && this.unsubscribe();
|
||||
if (this.unsubscribe) {
|
||||
this.unsubscribe();
|
||||
}
|
||||
}
|
||||
private update() {
|
||||
const text = this.date
|
||||
|
||||
@@ -23,11 +23,15 @@ export class OriginInfoRemote implements OnDestroy {
|
||||
if (this.originIP !== value) {
|
||||
this._originIP = value;
|
||||
this.origin = undefined;
|
||||
this.subscription && this.subscription.unsubscribe();
|
||||
if (this.subscription) {
|
||||
this.subscription.unsubscribe();
|
||||
}
|
||||
this.subscription = value ? this.model.origins.subscribe(value, origin => this.origin = origin) : undefined;
|
||||
}
|
||||
}
|
||||
ngOnDestroy() {
|
||||
this.subscription && this.subscription.unsubscribe();
|
||||
if (this.subscription) {
|
||||
this.subscription.unsubscribe();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,11 +24,15 @@ export class OriginListRemote implements OnDestroy {
|
||||
if (this.accountId !== value) {
|
||||
this._accountId = value;
|
||||
this.origins = [];
|
||||
this.subscription && this.subscription.unsubscribe();
|
||||
if (this.subscription) {
|
||||
this.subscription.unsubscribe();
|
||||
}
|
||||
this.subscription = value ? this.model.accountOrigins.subscribe(value, x => this.origins = x || []) : undefined;
|
||||
}
|
||||
}
|
||||
ngOnDestroy() {
|
||||
this.subscription && this.subscription.unsubscribe();
|
||||
if (this.subscription) {
|
||||
this.subscription.unsubscribe();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,11 +24,15 @@ export class PonyInfoRemote implements OnDestroy {
|
||||
if (this.ponyId !== value) {
|
||||
this._ponyId = value;
|
||||
this.pony = undefined;
|
||||
this.subscription && this.subscription.unsubscribe();
|
||||
if (this.subscription) {
|
||||
this.subscription.unsubscribe();
|
||||
}
|
||||
this.subscription = value ? this.model.ponies.subscribe(value, pony => this.pony = pony) : undefined;
|
||||
}
|
||||
}
|
||||
ngOnDestroy() {
|
||||
this.subscription && this.subscription.unsubscribe();
|
||||
if (this.subscription) {
|
||||
this.subscription.unsubscribe();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,9 +25,11 @@ export class PonyInfo implements OnChanges {
|
||||
if (this.pony) {
|
||||
if (isForbiddenName(this.pony.name)) {
|
||||
this.labelClass = 'badge-forbidden';
|
||||
} else if (hasFlag(this.pony.flags, CharacterFlags.BadCM)) {
|
||||
}
|
||||
else if (hasFlag(this.pony.flags, CharacterFlags.BadCM)) {
|
||||
this.labelClass = 'badge-danger';
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
this.labelClass = 'badge-none';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,7 +39,9 @@ export class PonyListRemote implements OnDestroy {
|
||||
this.ponies = [];
|
||||
this.ponyInfos = [];
|
||||
this.loading = true;
|
||||
this.subscription && this.subscription.unsubscribe();
|
||||
if (this.subscription) {
|
||||
this.subscription.unsubscribe();
|
||||
}
|
||||
this.subscription = value ? this.model.accountPonies.subscribe(value, (x = []) => {
|
||||
this.ponyInfos = x;
|
||||
this.updatePonies();
|
||||
@@ -48,7 +50,9 @@ export class PonyListRemote implements OnDestroy {
|
||||
}
|
||||
}
|
||||
ngOnDestroy() {
|
||||
this.subscription && this.subscription.unsubscribe();
|
||||
if (this.subscription) {
|
||||
this.subscription.unsubscribe();
|
||||
}
|
||||
}
|
||||
remove(characterId: string) {
|
||||
if (confirm('Are you sure?')) {
|
||||
|
||||
@@ -193,7 +193,8 @@ export class App implements OnInit, OnDestroy {
|
||||
if (isSelected(this.game, message.entityId)) {
|
||||
this.game.whisperTo = entity;
|
||||
chatBox.setChatType('whisper');
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
this.game.select(entity as Pony);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -490,8 +490,11 @@ export class Character implements OnInit, OnDestroy {
|
||||
await this.model.savePony(pony, true);
|
||||
imported++;
|
||||
}
|
||||
} catch (e) {
|
||||
DEVELOPMENT && console.error(e);
|
||||
}
|
||||
catch (e) {
|
||||
if (DEVELOPMENT) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,9 @@ export class Help {
|
||||
ngAfterViewInit() {
|
||||
this.route.fragment.subscribe(f => {
|
||||
const element = document.querySelector('#' + f);
|
||||
if (element) setTimeout(() => element.scrollIntoView(), 10);
|
||||
if (element) {
|
||||
setTimeout(() => element.scrollIntoView(), 10);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -177,8 +177,9 @@ export class AdminModel {
|
||||
return this.liveEvents.finished;
|
||||
}
|
||||
initialize(live: boolean) {
|
||||
if (this.initializedLive)
|
||||
if (this.initializedLive) {
|
||||
return;
|
||||
}
|
||||
|
||||
notification.requestPermission();
|
||||
|
||||
@@ -545,8 +546,9 @@ export class AdminModel {
|
||||
}
|
||||
private updateStateTimeout: any;
|
||||
private updateState(): void {
|
||||
if (!this.running)
|
||||
if (!this.running) {
|
||||
return;
|
||||
}
|
||||
|
||||
clearTimeout(this.updateStateTimeout);
|
||||
|
||||
@@ -590,7 +592,8 @@ export class AdminModel {
|
||||
function decodeDate(value: number | undefined, base: string | undefined): Date {
|
||||
if (value == null || base == null) {
|
||||
return new Date(0);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
const d = new Date(base);
|
||||
d.setTime(d.getTime() + value);
|
||||
return d;
|
||||
|
||||
@@ -76,7 +76,8 @@ function fadeOut(track: Track, id: number, volume: number) {
|
||||
howl
|
||||
.fade(volume, 0, 1000, id)
|
||||
.once('fade', () => howl.pause(id).stop(id), id);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
howl
|
||||
.volume(0, id)
|
||||
.pause(id)
|
||||
@@ -124,7 +125,8 @@ export class Audio {
|
||||
if (this.playing) {
|
||||
if (this.instance) {
|
||||
this.setInstanceVolume(this.instance, this.volume);
|
||||
} else if (this.volume) {
|
||||
}
|
||||
else if (this.volume) {
|
||||
this.playRandomTrack();
|
||||
}
|
||||
}
|
||||
@@ -137,12 +139,14 @@ export class Audio {
|
||||
if (this.volume) {
|
||||
if (this.instance) {
|
||||
this.resumeInstance(this.instance);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
this.playRandomTrack();
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
}
|
||||
catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
@@ -150,10 +154,12 @@ export class Audio {
|
||||
if (FADE_TRACKS) {
|
||||
if (this.playing && this.volume) {
|
||||
this.playRandomTrack();
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
this.play();
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
this.play();
|
||||
}
|
||||
}
|
||||
@@ -175,15 +181,15 @@ export class Audio {
|
||||
private switchToTrack(track: Track) {
|
||||
if (this.instance && this.instance.track === track) {
|
||||
return false;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
this.stopInstance(this.instance);
|
||||
this.instance = this.playTrack(track);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
playRandomTrack() {
|
||||
while (!this.switchToTrack(sample(this.tracks)!))
|
||||
;
|
||||
while (!this.switchToTrack(sample(this.tracks)!)) {}
|
||||
|
||||
this.loops = random(4, 7);
|
||||
}
|
||||
@@ -215,7 +221,8 @@ export class Audio {
|
||||
|
||||
if (volume && !howl.playing(instance.id)) {
|
||||
howl.play(instance.id);
|
||||
} else if (!volume && howl.playing(instance.id)) {
|
||||
}
|
||||
else if (!volume && howl.playing(instance.id)) {
|
||||
howl.pause(instance.id);
|
||||
}
|
||||
}
|
||||
@@ -243,7 +250,8 @@ export class Audio {
|
||||
|
||||
if (this.volume && this.playing) {
|
||||
this.playRandomTrack();
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
this.stopInstance(this.instance);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,8 @@ export class AuthGuard implements CanActivate {
|
||||
.then(account => {
|
||||
if (account) {
|
||||
return true;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
this.router.navigate(['/']);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ import { meetsRequirement } from '../../common/accountUtils';
|
||||
import { isLanguage, isFocused, sortServersForRussian } from '../../client/clientUtils';
|
||||
import { StorageService } from './storageService';
|
||||
|
||||
export interface ClientSocketService extends SocketService<ClientActions, IServerActions> { }
|
||||
export type ClientSocketService = SocketService<ClientActions, IServerActions>;
|
||||
|
||||
function createSocket(
|
||||
gameService: GameService, game: PonyTownGame, model: Model, zone: NgZone, options: ClientOptions,
|
||||
@@ -183,7 +183,8 @@ export class GameService {
|
||||
if (reason === LeaveReason.Swearing) {
|
||||
this.leftMessage = 'Kicked for swearing or inappropriate language';
|
||||
this.locked = true;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
this.leftMessage = undefined;
|
||||
}
|
||||
|
||||
@@ -233,11 +234,14 @@ export class GameService {
|
||||
private getAndUpdateStatus(account: AccountData | undefined) {
|
||||
if (this.joining || this.playing || !account || !isFocused()) {
|
||||
return Promise.resolve();
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return this.model.status(this.initialized)
|
||||
.then(status => this.updateStatus(account, status))
|
||||
.catch((e: RequestError) => {
|
||||
DEVELOPMENT && console.error(e);
|
||||
if (DEVELOPMENT) {
|
||||
console.error(e);
|
||||
}
|
||||
this.offline = e.message === OFFLINE_ERROR;
|
||||
this.versionError = e.message === VERSION_ERROR;
|
||||
this.protectionError = e.message === PROTECTION_ERROR;
|
||||
@@ -255,14 +259,16 @@ export class GameService {
|
||||
|
||||
if (existing) {
|
||||
merge(existing, server);
|
||||
} else if ('name' in server) {
|
||||
}
|
||||
else if ('name' in server) {
|
||||
const info = server as ServerInfo;
|
||||
info.countryFlags = info.flag && /^[a-z]{2}( [a-z]{2})*$/.test(info.flag) ? info.flag.split(/ /g) : [];
|
||||
|
||||
if (info.name && account && meetsRequirement(account, info.require)) {
|
||||
this.servers.push(info);
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
// got new server on the list
|
||||
this.initialized = false;
|
||||
}
|
||||
@@ -302,7 +308,8 @@ export class GameService {
|
||||
if (socket.isConnected) {
|
||||
clearInterval(interval);
|
||||
this.zone.run(resolve);
|
||||
} else if (!this.joining) {
|
||||
}
|
||||
else if (!this.joining) {
|
||||
clearInterval(interval);
|
||||
this.zone.run(() => reject(new Error('Cancelled (poll)')));
|
||||
}
|
||||
|
||||
@@ -35,7 +35,8 @@ export class IntervalUpdateService {
|
||||
return (on: boolean) => {
|
||||
if (on && !unsubscribe) {
|
||||
unsubscribe = this.subscribe(action);
|
||||
} else if (!on && unsubscribe) {
|
||||
}
|
||||
else if (!on && unsubscribe) {
|
||||
unsubscribe();
|
||||
unsubscribe = undefined;
|
||||
}
|
||||
|
||||
@@ -51,7 +51,8 @@ export class LiveCollection<T extends Document> {
|
||||
if (removeFromList || this.options.deleteItems) {
|
||||
removeItem(this.items, item);
|
||||
this.itemsMap.delete(key);
|
||||
} else if (deleted) {
|
||||
}
|
||||
else if (deleted) {
|
||||
item.deleted = true;
|
||||
}
|
||||
|
||||
@@ -64,8 +65,9 @@ export class LiveCollection<T extends Document> {
|
||||
return this.server.assignAccount(this.name, id, account);
|
||||
}
|
||||
live(): Promise<void> {
|
||||
if (!this.running)
|
||||
if (!this.running) {
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
clearTimeout(this.liveTimeout);
|
||||
|
||||
@@ -129,11 +131,13 @@ export class LiveCollection<T extends Document> {
|
||||
if (doc) {
|
||||
if (this.options.onUpdate) {
|
||||
this.options.onUpdate(doc, update);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
Object.assign(doc, update);
|
||||
}
|
||||
all.push(doc);
|
||||
} else if (!liveFetch || !this.options.ignore || !this.options.ignore(update)) {
|
||||
}
|
||||
else if (!liveFetch || !this.options.ignore || !this.options.ignore(update)) {
|
||||
this.push(update);
|
||||
added.push(update);
|
||||
all.push(update);
|
||||
|
||||
@@ -78,7 +78,8 @@ export function getPonyTag(pony: PonyObject, account: AccountData | undefined) {
|
||||
if (account) {
|
||||
const tag = canUseTag(account, pony.tag || '') ? pony.tag : undefined;
|
||||
return (!tag && account.supporter && !pony.hideSupport) ? `sup${account.supporter}` : tag;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
@@ -179,7 +180,8 @@ export class Model {
|
||||
modStatus.mod = isMod(account);
|
||||
modStatus.check = account.check;
|
||||
modStatus.editor = account.editor || modStatus.editor;
|
||||
} catch { }
|
||||
}
|
||||
catch { }
|
||||
|
||||
if (modStatus.editor) {
|
||||
modStatus.editor.typeToName.forEach(({ type, name }) => entityTypeToName.set(type, name));
|
||||
@@ -208,18 +210,22 @@ export class Model {
|
||||
if (e.message === ACCESS_ERROR) {
|
||||
this.loading = false;
|
||||
this.storage.setItem('vid', '---');
|
||||
} else if (e.message === LIMIT_ERROR) {
|
||||
}
|
||||
else if (e.message === LIMIT_ERROR) {
|
||||
this.loadingError = 'request-limit';
|
||||
return delay(5000).then(() => this.initializeAccount());
|
||||
} else if (e.message === OFFLINE_ERROR) {
|
||||
}
|
||||
else if (e.message === OFFLINE_ERROR) {
|
||||
this.loadingError = 'cannot-connect';
|
||||
return delay(5000).then(() => this.initializeAccount());
|
||||
} else if (e.message === PROTECTION_ERROR) {
|
||||
}
|
||||
else if (e.message === PROTECTION_ERROR) {
|
||||
this.loadingError = 'cloudflare-error';
|
||||
this.protectionErrors.next();
|
||||
// } else if (e.message === VERSION_ERROR) {
|
||||
// this.updating = true;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
setTimeout(() => this.loadingError = 'unexpected-error', 5 * SECOND);
|
||||
console.error(e);
|
||||
}
|
||||
@@ -240,7 +246,9 @@ export class Model {
|
||||
})).sort(compareFriends);
|
||||
})
|
||||
.catch(e => {
|
||||
DEVELOPMENT && console.error(e);
|
||||
if (DEVELOPMENT) {
|
||||
console.error(e);
|
||||
}
|
||||
setTimeout(() => this.fetchFriends(), 5000);
|
||||
});
|
||||
}
|
||||
@@ -275,7 +283,8 @@ export class Model {
|
||||
try {
|
||||
const ponyInfo = decompressPonyString(pony.info, true);
|
||||
return { ponyInfo, ...pony };
|
||||
} catch (e) {
|
||||
}
|
||||
catch (e) {
|
||||
this.errorReporter.reportError(e, { ponyInfo: pony.info });
|
||||
this.errorReporter.reportError('Pony info reading error', { originalError: isErrorAlike(e) ? e.message: '', ponyInfo: pony.info });
|
||||
throw new Error('Error while reading pony info');
|
||||
@@ -283,7 +292,9 @@ export class Model {
|
||||
}
|
||||
selectPony(pony: PonyObject) {
|
||||
const copy = this.parsePonyObject(pony);
|
||||
copy.ponyInfo && syncLockedPonyInfo(copy.ponyInfo);
|
||||
if (copy.ponyInfo) {
|
||||
syncLockedPonyInfo(copy.ponyInfo);
|
||||
}
|
||||
this._pony = copy;
|
||||
}
|
||||
// account
|
||||
@@ -308,7 +319,8 @@ export class Model {
|
||||
|
||||
if (isStandalone()) {
|
||||
window.open(url);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
location.href = url;
|
||||
}
|
||||
}
|
||||
@@ -394,7 +406,8 @@ export class Model {
|
||||
|
||||
if (pony.id) {
|
||||
removeById(this.ponies, pony.id);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
this.account!.characterCount++;
|
||||
}
|
||||
|
||||
@@ -443,7 +456,8 @@ export class Model {
|
||||
|
||||
if (this.account.birthyear) {
|
||||
age = currentYear - this.account.birthyear;
|
||||
} else if (this.account.birthdate) {
|
||||
}
|
||||
else if (this.account.birthdate) {
|
||||
const [year, month] = this.account.birthdate.split('-');
|
||||
const before = parseInt(month, 10) > currentMonth;
|
||||
age = Math.max(0, currentYear - parseInt(year, 10) - (before ? 1 : 0));
|
||||
@@ -458,12 +472,15 @@ export class Model {
|
||||
return observableToPromise(this.http.get<GameStatus>('/api2/game/status', { params }));
|
||||
}
|
||||
join(serverId: string, ponyId: string): Promise<JoinResponse> {
|
||||
if (this.pending)
|
||||
if (this.pending) {
|
||||
return Promise.reject(new Error('Joining in progress'));
|
||||
if (!serverId)
|
||||
}
|
||||
if (!serverId) {
|
||||
return Promise.reject(new Error('Invalid server ID'));
|
||||
if (!ponyId)
|
||||
}
|
||||
if (!ponyId) {
|
||||
return Promise.reject(new Error('Invalid pony ID'));
|
||||
}
|
||||
|
||||
this.pending = true;
|
||||
|
||||
|
||||
@@ -60,7 +60,8 @@ export class ModelSubscriber<T> {
|
||||
if (subscription.value !== undefined) {
|
||||
callback(subscription.value);
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
this.socket.server.subscribe(this.type, id);
|
||||
this.subscriptions.set(id, {
|
||||
value: this.defaultValue,
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
/* eslint-disable camelcase */
|
||||
import { ErrorHandler, Injectable, Injector, InjectionToken } from '@angular/core';
|
||||
import Rollbar from 'rollbar';
|
||||
import { version } from '../../client/data';
|
||||
@@ -34,7 +35,8 @@ export const RollbarService = new InjectionToken<Rollbar>('rollbar');
|
||||
export function rollbarFactory() {
|
||||
if (DEVELOPMENT) {
|
||||
return undefined;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
const rollbar = Rollbar.init(rollbarConfig);
|
||||
rollbar.configure({ checkIgnore: rollbarCheckIgnore });
|
||||
return rollbar;
|
||||
|
||||
@@ -25,7 +25,9 @@ export class RollbarErrorReporter extends ErrorReporter {
|
||||
}
|
||||
}
|
||||
reportError(error: any, data?: any) {
|
||||
DEVELOPMENT && console.error(error, data);
|
||||
if (DEVELOPMENT) {
|
||||
console.error(error, data);
|
||||
}
|
||||
|
||||
if (this.rollbar && !isIgnoredError(error)) {
|
||||
this.rollbar.error(error, data);
|
||||
|
||||
@@ -32,7 +32,8 @@ export class SettingsService {
|
||||
|
||||
if (this.save(settings)) {
|
||||
return Promise.resolve();
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return this.model.saveSettings(settings);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,18 +9,21 @@ export class StorageService {
|
||||
if (typeof localStorage === 'undefined') {
|
||||
this.data = new Map();
|
||||
}
|
||||
} catch {
|
||||
}
|
||||
catch {
|
||||
this.data = new Map();
|
||||
}
|
||||
}
|
||||
getItem(key: string) {
|
||||
if (this.data) {
|
||||
return this.data.get(key);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
try {
|
||||
const value = localStorage.getItem(key);
|
||||
return value == null ? undefined : value;
|
||||
} catch {
|
||||
}
|
||||
catch {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
@@ -29,7 +32,8 @@ export class StorageService {
|
||||
try {
|
||||
localStorage.setItem(key, data);
|
||||
this.data = undefined;
|
||||
} catch {
|
||||
}
|
||||
catch {
|
||||
if (!this.data) {
|
||||
this.data = new Map();
|
||||
}
|
||||
@@ -40,25 +44,30 @@ export class StorageService {
|
||||
removeItem(key: string) {
|
||||
if (this.data) {
|
||||
this.data.delete(key);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
try {
|
||||
localStorage.removeItem(key);
|
||||
} catch { }
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
}
|
||||
clear() {
|
||||
if (this.data) {
|
||||
this.data.clear();
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
try {
|
||||
localStorage.clear();
|
||||
} catch { }
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
}
|
||||
getJSON<T>(key: string, defaultValue: T): T {
|
||||
try {
|
||||
return JSON.parse(this.getItem(key) || '');
|
||||
} catch {
|
||||
}
|
||||
catch {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
@@ -77,7 +86,8 @@ export class StorageService {
|
||||
setBoolean(key: string, value: boolean) {
|
||||
if (value) {
|
||||
this.setItem(key, 'true');
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
this.removeItem(key);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,7 +117,8 @@ export class ActionBar {
|
||||
while (actions.length < 5 || (last(actions)!.action !== undefined && actions.length < ACTIONS_LIMIT)) {
|
||||
actions.push({ action: undefined });
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
while (actions.length > 0 && last(actions)!.action === undefined) {
|
||||
actions.pop();
|
||||
}
|
||||
|
||||
@@ -96,7 +96,9 @@ export class ActionsModal implements OnInit, OnDestroy {
|
||||
document.body.classList.remove('actions-modal-opened');
|
||||
this.game.editingActions = false;
|
||||
clearInterval(this.interval);
|
||||
this.subscription && this.subscription.unsubscribe();
|
||||
if (this.subscription) {
|
||||
this.subscription.unsubscribe();
|
||||
}
|
||||
this.close.emit(); // need to emit in case the menu wasn't closed with the Close button
|
||||
this.notify.emit();
|
||||
}
|
||||
|
||||
@@ -33,9 +33,11 @@ export class BitmapBox implements OnChanges {
|
||||
if (this.bitmap) {
|
||||
if (this.tool === 'eraser') {
|
||||
this.bitmap[index] = '';
|
||||
} else if (this.tool === 'brush') {
|
||||
}
|
||||
else if (this.tool === 'brush') {
|
||||
this.bitmap[index] = parseColor(this.bitmap[index]) === parseColor(this.color) ? '' : this.color;
|
||||
} else if (this.tool === 'eyedropper') {
|
||||
}
|
||||
else if (this.tool === 'eyedropper') {
|
||||
this.color = this.bitmap[index];
|
||||
this.colorChange.emit(this.color);
|
||||
}
|
||||
|
||||
@@ -16,9 +16,11 @@ function getSortTag(pony: PonyObject) {
|
||||
function sortTagToNumber(tag: string) {
|
||||
if (tag === 'top') {
|
||||
return -1;
|
||||
} else if (tag === 'end') {
|
||||
}
|
||||
else if (tag === 'end') {
|
||||
return 999999999;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return +tag;
|
||||
}
|
||||
}
|
||||
@@ -33,11 +35,14 @@ function comparePonies(a: PonyObject, b: PonyObject) {
|
||||
|
||||
if (aTag && bTag) {
|
||||
return (sortTagToNumber(aTag) - sortTagToNumber(bTag)) || fallbackComparePonies(a, b);
|
||||
} else if (aTag) {
|
||||
}
|
||||
else if (aTag) {
|
||||
return aTag === 'end' ? 1 : -1;
|
||||
} else if (bTag) {
|
||||
}
|
||||
else if (bTag) {
|
||||
return bTag === 'end' ? -1 : 1;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return fallbackComparePonies(a, b);
|
||||
}
|
||||
}
|
||||
@@ -93,20 +98,25 @@ export class CharacterList implements OnInit {
|
||||
e.stopPropagation();
|
||||
this.search = '';
|
||||
this.updatePonies();
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
this.closed();
|
||||
}
|
||||
} else if (e.keyCode === Key.ENTER) {
|
||||
}
|
||||
else if (e.keyCode === Key.ENTER) {
|
||||
const pony = this.ponies[this.selectedIndex];
|
||||
|
||||
if (pony) {
|
||||
this.select(pony);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
this.closed();
|
||||
}
|
||||
} else if (e.keyCode === Key.UP) {
|
||||
}
|
||||
else if (e.keyCode === Key.UP) {
|
||||
this.setSelectedIndex(this.selectedIndex <= 0 ? (this.ponies.length - 1) : (this.selectedIndex - 1));
|
||||
} else if (e.keyCode === Key.DOWN) {
|
||||
}
|
||||
else if (e.keyCode === Key.DOWN) {
|
||||
this.setSelectedIndex(this.selectedIndex === (this.ponies.length - 1) ? 0 : (this.selectedIndex + 1));
|
||||
}
|
||||
}
|
||||
@@ -141,7 +151,8 @@ export class CharacterList implements OnInit {
|
||||
const text = `${pony.name} ${pony.desc || ''}`.toLowerCase();
|
||||
return matchesWords(text, words);
|
||||
}).sort(comparePonies);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
this.ponies = this.model.ponies.slice().sort(comparePonies);
|
||||
}
|
||||
|
||||
@@ -166,7 +177,8 @@ export class CharacterList implements OnInit {
|
||||
|
||||
if (pony) {
|
||||
this.setPreview(pony);
|
||||
} else if (this.previewPony) {
|
||||
}
|
||||
else if (this.previewPony) {
|
||||
this.unsetPreview(this.previewPony);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -85,7 +85,8 @@ export class CharacterPreview implements OnDestroy, OnChanges, AfterViewInit {
|
||||
if (this.nextBlink < now) {
|
||||
this.blinkFrame = 0;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
this.blinkFrame++;
|
||||
|
||||
if (this.blinkFrame >= BLINK_FRAMES.length) {
|
||||
@@ -106,11 +107,13 @@ export class CharacterPreview implements OnDestroy, OnChanges, AfterViewInit {
|
||||
private tryDraw() {
|
||||
try {
|
||||
this.draw();
|
||||
} catch { }
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
private draw() {
|
||||
if (!this.initialized)
|
||||
if (!this.initialized) {
|
||||
return;
|
||||
}
|
||||
|
||||
const canvas = this.canvas.nativeElement as HTMLCanvasElement;
|
||||
|
||||
@@ -121,8 +124,9 @@ export class CharacterPreview implements OnDestroy, OnChanges, AfterViewInit {
|
||||
const bufferWidth = Math.round(canvas.width / scale);
|
||||
const bufferHeight = Math.round(canvas.height / scale);
|
||||
|
||||
if (!bufferWidth || !bufferHeight)
|
||||
if (!bufferWidth || !bufferHeight) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.batch = this.batch || new ContextSpriteBatch(createCanvas(bufferWidth, bufferHeight));
|
||||
resizeCanvas(this.batch.canvas, bufferWidth, bufferHeight);
|
||||
@@ -136,7 +140,8 @@ export class CharacterPreview implements OnDestroy, OnChanges, AfterViewInit {
|
||||
try {
|
||||
const options = { ...DEFAULT_OPTIONS, shadow: !this.noShadow, extra: !!this.extra };
|
||||
drawPony(this.batch, toPalette(this.pony), this.state || DEFAULT_STATE, x, y, options);
|
||||
} catch (e) {
|
||||
}
|
||||
catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
|
||||
@@ -145,8 +150,9 @@ export class CharacterPreview implements OnDestroy, OnChanges, AfterViewInit {
|
||||
|
||||
const viewContext = canvas.getContext('2d');
|
||||
|
||||
if (!viewContext)
|
||||
if (!viewContext) {
|
||||
return;
|
||||
}
|
||||
|
||||
disableImageSmoothing(viewContext);
|
||||
|
||||
|
||||
@@ -103,14 +103,16 @@ export class ChatBox implements AfterViewInit, OnDestroy {
|
||||
this.toggleEmojiBox();
|
||||
if (!this.message) {
|
||||
this.message = emoji;
|
||||
} else if (this.input.maxLength > this.message.length) {
|
||||
}
|
||||
else if (this.input.maxLength > this.message.length) {
|
||||
this.message += emoji;
|
||||
}
|
||||
}
|
||||
toggleEmojiBox() {
|
||||
if (this.emojiBoxState === 'none') {
|
||||
this.emojiBoxState = 'inline-block';
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
this.emojiBoxState = 'none';
|
||||
}
|
||||
}
|
||||
@@ -134,8 +136,9 @@ export class ChatBox implements AfterViewInit, OnDestroy {
|
||||
do {
|
||||
offset = message.indexOf(' ', offset);
|
||||
|
||||
if (offset === -1)
|
||||
if (offset === -1) {
|
||||
break;
|
||||
}
|
||||
|
||||
const name = message.substr(0, offset);
|
||||
entity = findBestEntityByName(this.game, name);
|
||||
@@ -145,7 +148,8 @@ export class ChatBox implements AfterViewInit, OnDestroy {
|
||||
if (entity) {
|
||||
message = message.substr(offset);
|
||||
entityId = entity.id;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
entityId = 0;
|
||||
}
|
||||
}
|
||||
@@ -176,20 +180,25 @@ export class ChatBox implements AfterViewInit, OnDestroy {
|
||||
if (names.length === 1) {
|
||||
this.message = `${this.message.substring(0, space)} ${names[0]}`;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
this.message = autocompleteMesssage(this.message, e.shiftKey, this.state);
|
||||
}
|
||||
}
|
||||
|
||||
e.preventDefault();
|
||||
} else if (e.keyCode === Key.ENTER && this.isOpen) {
|
||||
}
|
||||
else if (e.keyCode === Key.ENTER && this.isOpen) {
|
||||
this.send(e);
|
||||
} else if (e.keyCode === Key.ESCAPE) {
|
||||
}
|
||||
else if (e.keyCode === Key.ESCAPE) {
|
||||
this.close();
|
||||
e.preventDefault();
|
||||
} else if (e.keyCode === Key.SPACE) {
|
||||
if (!this.message)
|
||||
}
|
||||
else if (e.keyCode === Key.SPACE) {
|
||||
if (!this.message) {
|
||||
return;
|
||||
}
|
||||
|
||||
const isParty = /^\/(p|party)$/i.test(this.message);
|
||||
const isSay = /^\/(s|say)$/i.test(this.message);
|
||||
@@ -208,33 +217,43 @@ export class ChatBox implements AfterViewInit, OnDestroy {
|
||||
|
||||
if (isSayOrInvalid) {
|
||||
this.changeChatType(e, ChatType.Say);
|
||||
} else if (isParty) {
|
||||
}
|
||||
else if (isParty) {
|
||||
this.changeChatType(e, ChatType.Party);
|
||||
} else if (isSup) {
|
||||
}
|
||||
else if (isSup) {
|
||||
this.changeChatType(e, ChatType.Supporter);
|
||||
} else if (isSup1) {
|
||||
}
|
||||
else if (isSup1) {
|
||||
this.changeChatType(e, ChatType.Supporter1);
|
||||
} else if (isSup2) {
|
||||
}
|
||||
else if (isSup2) {
|
||||
this.changeChatType(e, ChatType.Supporter2);
|
||||
} else if (isSup3) {
|
||||
}
|
||||
else if (isSup3) {
|
||||
this.changeChatType(e, ChatType.Supporter3);
|
||||
} else if (/^\/(t|think)$/i.test(this.message)) {
|
||||
}
|
||||
else if (/^\/(t|think)$/i.test(this.message)) {
|
||||
if (isPartyChat(this.chatType)) {
|
||||
this.changeChatType(e, ChatType.PartyThink);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
this.changeChatType(e, ChatType.Think);
|
||||
}
|
||||
} else if (/^\/(r|reply)$/i.test(this.message)) {
|
||||
}
|
||||
else if (/^\/(r|reply)$/i.test(this.message)) {
|
||||
const lastWhisperFrom = this.game.lastWhisperFrom;
|
||||
const entity = lastWhisperFrom && findEntityOrMockByAnyMeans(this.game, lastWhisperFrom.entityId);
|
||||
|
||||
if (entity) {
|
||||
this.game.whisperTo = entity;
|
||||
this.changeChatType(e, ChatType.Whisper);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
this.changeChatType(e, ChatType.Say);
|
||||
}
|
||||
} else if (/^\/(w|whisper) .+$/i.test(this.message) && !e.shiftKey) {
|
||||
}
|
||||
else if (/^\/(w|whisper) .+$/i.test(this.message) && !e.shiftKey) {
|
||||
const name = this.message.substr(/^\/w /i.test(this.message) ? 3 : 9);
|
||||
const entity = findBestEntityByName(this.game, name);
|
||||
|
||||
@@ -252,7 +271,8 @@ export class ChatBox implements AfterViewInit, OnDestroy {
|
||||
return !!this.game.send(server =>
|
||||
server.say(entityId, ((rawMessage !== '') ? rawMessage + ' ' : '') + `¯\\_(ツ)_/¯`,
|
||||
chatType));
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return !!this.game.send(server => server.say(entityId, message, chatType));
|
||||
}
|
||||
}
|
||||
@@ -265,7 +285,8 @@ export class ChatBox implements AfterViewInit, OnDestroy {
|
||||
private chat(event: Event | undefined) {
|
||||
if (this.isOpen) {
|
||||
this.send(event);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
this.open();
|
||||
}
|
||||
}
|
||||
@@ -299,12 +320,15 @@ export class ChatBox implements AfterViewInit, OnDestroy {
|
||||
toggle() {
|
||||
if (this.isOpen) {
|
||||
this.close();
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
this.open();
|
||||
}
|
||||
}
|
||||
onMouseEnterEmojiButton(event: MouseEvent) {
|
||||
if (!event.target) return;
|
||||
if (!event.target) {
|
||||
return;
|
||||
}
|
||||
const emoji = sample(emojis)!;
|
||||
this.btnEmoji = emoji.names[0];
|
||||
}
|
||||
@@ -318,10 +342,12 @@ export class ChatBox implements AfterViewInit, OnDestroy {
|
||||
if (type === 'say') {
|
||||
this.chatType = ChatType.Say;
|
||||
this.open();
|
||||
} else if (type === 'party' && isInParty(this.game)) {
|
||||
}
|
||||
else if (type === 'party' && isInParty(this.game)) {
|
||||
this.chatType = ChatType.Party;
|
||||
this.open();
|
||||
} else if (type === 'whisper') {
|
||||
}
|
||||
else if (type === 'whisper') {
|
||||
this.chatType = ChatType.Whisper;
|
||||
this.open();
|
||||
}
|
||||
@@ -344,7 +370,8 @@ export class ChatBox implements AfterViewInit, OnDestroy {
|
||||
if (this.chatType === ChatType.Whisper) {
|
||||
typePrefix = 'To ';
|
||||
typeName = this.game.whisperTo && this.game.whisperTo.name || 'unknown';
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
typePrefix = '';
|
||||
typeName = chatTypeNames[this.chatType];
|
||||
}
|
||||
|
||||
@@ -145,7 +145,9 @@ export function updateChatLogLine(line: ChatLogLineDOM, entry: ChatLogMessage, h
|
||||
|
||||
function updateTime(line: ChatLogLineDOM, hourMode?: '12' | '24') {
|
||||
line.time.style.display = 'inline';
|
||||
if (!hourMode) return;
|
||||
if (!hourMode) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (hourMode === '24') {
|
||||
replaceNodes(line.timeContent, `[${format(new Date(), 'HH:mm:ss')}] `);
|
||||
@@ -157,9 +159,15 @@ function updateTime(line: ChatLogLineDOM, hourMode?: '12' | '24') {
|
||||
}
|
||||
|
||||
function setNameColors(line: ChatLogLineDOM | undefined, colors?: string[]) {
|
||||
if (!colors || !line) return;
|
||||
if (colors[1]) line.name.style.color = colors[1];
|
||||
if (colors[0]) line.nameContent.style.color = colors[0];
|
||||
if (!colors || !line) {
|
||||
return;
|
||||
}
|
||||
if (colors[1]) {
|
||||
line.name.style.color = colors[1];
|
||||
}
|
||||
if (colors[0]) {
|
||||
line.nameContent.style.color = colors[0];
|
||||
}
|
||||
}
|
||||
|
||||
function updateChatLogName(line: ChatLogLineDOM, { name, index }: ChatLogMessage) {
|
||||
@@ -168,7 +176,8 @@ function updateChatLogName(line: ChatLogLineDOM, { name, index }: ChatLogMessage
|
||||
replaceNodes(line.nameContent, name);
|
||||
line.index.style.display = (index > 0) ? 'inline' : 'none';
|
||||
line.indexText.nodeValue = (index > 0) ? ` #${index + 1}` : '';
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
line.name.style.display = 'none';
|
||||
}
|
||||
}
|
||||
@@ -302,7 +311,8 @@ export class ChatLog implements AfterViewInit, OnDestroy, DoCheck {
|
||||
this.setUnread(0);
|
||||
this.regenerateList();
|
||||
this.scrollToEnd();
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
this.clearList();
|
||||
}
|
||||
|
||||
@@ -333,7 +343,8 @@ export class ChatLog implements AfterViewInit, OnDestroy, DoCheck {
|
||||
if (this.scrollingToEnd) {
|
||||
this.scrolledToEnd = true;
|
||||
this.scrollingToEnd = false;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
const clientHeight = scroll.getBoundingClientRect().height;
|
||||
this.scrolledToEnd = scroll.scrollTop >= (scroll.scrollHeight - clientHeight - SCROLL_END_THRESHOLD);
|
||||
}
|
||||
@@ -468,7 +479,8 @@ export class ChatLog implements AfterViewInit, OnDestroy, DoCheck {
|
||||
this.clearTimeOutAutoClear();
|
||||
this.filterChatLogLines('', false);
|
||||
return;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
this.filterColor = this.bg;
|
||||
}
|
||||
|
||||
@@ -487,17 +499,22 @@ export class ChatLog implements AfterViewInit, OnDestroy, DoCheck {
|
||||
this.filterInput.nativeElement.style.color = '';
|
||||
if (value.startsWith('#')) {
|
||||
value = value.slice(1);
|
||||
} else if (value.startsWith('/')) {
|
||||
}
|
||||
else if (value.startsWith('/')) {
|
||||
value = value.slice(1);
|
||||
try {
|
||||
const regExp = new RegExp(value);
|
||||
this.filterChatLogLines(regExp, toLowerCase);
|
||||
} catch (err) {// If the user inputs invalid regExp we just notify him by changing text color to red
|
||||
if (DEVELOPMENT) console.error(err);
|
||||
}
|
||||
catch (err) {// If the user inputs invalid regExp we just notify him by changing text color to red
|
||||
if (DEVELOPMENT) {
|
||||
console.error(err);
|
||||
}
|
||||
this.filterInput.nativeElement.style.color = '#ff6666';
|
||||
}
|
||||
return;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
value = value.toLowerCase();
|
||||
toLowerCase = true;
|
||||
}
|
||||
@@ -515,10 +532,12 @@ export class ChatLog implements AfterViewInit, OnDestroy, DoCheck {
|
||||
if (typeof content === 'string') {
|
||||
if (caseSensitive) {
|
||||
lines[i].hidden = !textContent.toLowerCase().includes(content);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
lines[i].hidden = !textContent.includes(content);
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
lines[i].hidden = !textContent.match(content);
|
||||
}
|
||||
}
|
||||
@@ -534,18 +553,27 @@ export class ChatLog implements AfterViewInit, OnDestroy, DoCheck {
|
||||
if (hsl.l < 40) {
|
||||
if (hsl.l > 20 && hsl.l < 40) {
|
||||
hsl.l += 20;
|
||||
if (hsl.s > 11) hsl.s -= 11;
|
||||
} else {
|
||||
if (hsl.s > 11) {
|
||||
hsl.s -= 11;
|
||||
}
|
||||
}
|
||||
else {
|
||||
hsl.l = 40;
|
||||
if (hsl.s > 11) hsl.s = 0;
|
||||
if (hsl.s > 11) {
|
||||
hsl.s = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
return hsl;
|
||||
}
|
||||
private getCharacterColors(id: number | undefined) {
|
||||
if (!id) return;
|
||||
if (!id) {
|
||||
return;
|
||||
}
|
||||
const entity = findEntityById(this.game.map, id) as Pony;
|
||||
if (!entity || !entity.palettePonyInfo) return;
|
||||
if (!entity || !entity.palettePonyInfo) {
|
||||
return;
|
||||
}
|
||||
let colors = [];
|
||||
let { body, mane } = entity.palettePonyInfo;
|
||||
if (body && body.palette && body.palette.colors[1]) {
|
||||
@@ -559,29 +587,36 @@ export class ChatLog implements AfterViewInit, OnDestroy, DoCheck {
|
||||
const hsl = rgb2hsl(rgb);
|
||||
this.brightenDarkColors(hsl);
|
||||
colors.push(hsl2CSS(hsl));
|
||||
} else if (colors && colors[0]) {
|
||||
}
|
||||
else if (colors && colors[0]) {
|
||||
colors.push((colors[0]));
|
||||
}
|
||||
return colors;
|
||||
}
|
||||
clearTimeOutAutoClear() {
|
||||
if (this.autoClear) clearTimeout(this.autoClear);
|
||||
if (this.autoClear) {
|
||||
clearTimeout(this.autoClear);
|
||||
}
|
||||
this.autoClear = undefined;
|
||||
this.filterColor = this.inactiveBg;
|
||||
}
|
||||
clearTimeOutAutoUnfocus() {
|
||||
if (this.autoUnfocus) clearTimeout(this.autoUnfocus);
|
||||
if (this.autoUnfocus) {
|
||||
clearTimeout(this.autoUnfocus);
|
||||
}
|
||||
this.autoUnfocus = undefined;
|
||||
}
|
||||
focus() {
|
||||
this.clearTimeOutAutoUnfocus();
|
||||
if (this.filterInput.nativeElement)
|
||||
if (this.filterInput.nativeElement) {
|
||||
this.filterInput.nativeElement.focus();
|
||||
}
|
||||
}
|
||||
unFocus() {
|
||||
this.clearTimeOutAutoUnfocus();
|
||||
if (this.filterInput.nativeElement)
|
||||
if (this.filterInput.nativeElement) {
|
||||
this.filterInput.nativeElement.blur();
|
||||
}
|
||||
}
|
||||
addMessage(message: ChatMessage) {
|
||||
if (message.name && message.message) {
|
||||
@@ -681,10 +716,12 @@ export class ChatLog implements AfterViewInit, OnDestroy, DoCheck {
|
||||
tab.classList.add('active');
|
||||
tab.classList.remove('unread');
|
||||
tab.style.backgroundColor = this.bg;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
tab.classList.remove('active');
|
||||
if (!tab.classList.contains('unread'))
|
||||
if (!tab.classList.contains('unread')) {
|
||||
tab.style.backgroundColor = this.inactiveBg;
|
||||
}
|
||||
}
|
||||
}
|
||||
scrollToEnd() {
|
||||
@@ -762,7 +799,8 @@ export class ChatLog implements AfterViewInit, OnDestroy, DoCheck {
|
||||
if (value) {
|
||||
count.textContent = value > 99 ? '99+' : `${value}`;
|
||||
toggle.classList.add('has-unread');
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
count.textContent = '';
|
||||
toggle.classList.remove('has-unread');
|
||||
}
|
||||
|
||||
@@ -119,7 +119,8 @@ export class ColorPicker {
|
||||
if (!this.isDisabled) {
|
||||
if (this.isOpen) {
|
||||
this.close();
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
this.open();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,7 +51,8 @@ function getMonthNames() {
|
||||
date.setMonth(i);
|
||||
return format.format(date);
|
||||
});
|
||||
} catch {
|
||||
}
|
||||
catch {
|
||||
return MONTH_NAMES_EN;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,7 +89,9 @@ export function handleDrag(element: HTMLElement, emit: (event: AgDragEvent) => v
|
||||
send(lastEvent, 'end');
|
||||
window.removeEventListener(events.move, move);
|
||||
window.removeEventListener(events.up, up);
|
||||
events.up2 && window.removeEventListener(events.up2, up);
|
||||
if (events.up2) {
|
||||
window.removeEventListener(events.up2, up);
|
||||
}
|
||||
window.removeEventListener('blur', end);
|
||||
dragging = false;
|
||||
}
|
||||
@@ -106,7 +108,9 @@ export function handleDrag(element: HTMLElement, emit: (event: AgDragEvent) => v
|
||||
|
||||
window.addEventListener(events.move, move);
|
||||
window.addEventListener(events.up, up);
|
||||
events.up2 && window.addEventListener(events.up2, up);
|
||||
if (events.up2) {
|
||||
window.addEventListener(events.up2, up);
|
||||
}
|
||||
window.addEventListener('blur', end);
|
||||
e.stopPropagation();
|
||||
|
||||
|
||||
@@ -106,7 +106,8 @@ export class DraggableDrop<T> implements OnInit, OnDestroy {
|
||||
|
||||
if (active) {
|
||||
element.classList.add('draggable-hover');
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
element.classList.remove('draggable-hover');
|
||||
}
|
||||
}
|
||||
@@ -185,7 +186,9 @@ export class DraggableItem<T> implements OnInit, OnDestroy {
|
||||
|
||||
for (let i = 0; i < src.length; i++) {
|
||||
const context = dst.item(i).getContext('2d');
|
||||
context && context.drawImage(src.item(i), 0, 0);
|
||||
if (context) {
|
||||
context.drawImage(src.item(i), 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
this.service.startMove(this.draggable, this.item!);
|
||||
@@ -197,7 +200,8 @@ export class DraggableItem<T> implements OnInit, OnDestroy {
|
||||
this.draggable!.parentNode!.removeChild(this.draggable!);
|
||||
this.draggable = undefined;
|
||||
this.service.endMove();
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
const x = clamp(this.startX + e.dx, 0, window.innerWidth - this.width);
|
||||
const y = clamp(this.startY + e.dy, 0, window.innerHeight - this.height);
|
||||
setTransform(this.draggable, `translate3d(${x}px, ${y}px, 0px)`);
|
||||
|
||||
@@ -45,7 +45,8 @@ export class DropdownMenu {
|
||||
if (!this.ref) {
|
||||
if (useOutlet) {
|
||||
this.ref = this.service.viewContainer!.createEmbeddedView(this.templateRef);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
this.ref = this.viewContainer.createEmbeddedView(this.templateRef);
|
||||
}
|
||||
|
||||
@@ -63,7 +64,8 @@ export class DropdownMenu {
|
||||
if ((rect.bottom + menuRect.height) > window.innerHeight) {
|
||||
transform = `translate3d(${Math.round(rect.left)}px, ${Math.round(rect.top - menuRect.height)}px, 0)`;
|
||||
renderer.addClass(root, 'dropdown-menu-up');
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
transform = `translate3d(${Math.round(rect.left)}px, ${Math.round(rect.bottom)}px, 0)`;
|
||||
renderer.removeClass(root, 'dropdown-menu-up');
|
||||
}
|
||||
@@ -184,7 +186,8 @@ export class Dropdown {
|
||||
toggle() {
|
||||
if (this.isOpen) {
|
||||
this.close();
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
this.open();
|
||||
}
|
||||
}
|
||||
@@ -196,7 +199,8 @@ export class Dropdown {
|
||||
&& !(this.autoClose === 'outsideClick' && this.menu.checkTarget(e))
|
||||
) {
|
||||
this.close();
|
||||
} else if (this.autoClose && e.keyCode === 27) { // esc
|
||||
}
|
||||
else if (this.autoClose && e.keyCode === 27) { // esc
|
||||
this.close();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -32,7 +32,8 @@ export class FocusTrap implements OnInit, OnDestroy {
|
||||
if (!isParentOf(this.element.nativeElement, this.lastActiveElement)) {
|
||||
setTimeout(() => this.lastActiveElement = focusFirstElement(this.element.nativeElement));
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
this.lastActiveElement = undefined;
|
||||
document.removeEventListener('focusin', this.focus);
|
||||
}
|
||||
@@ -41,13 +42,15 @@ export class FocusTrap implements OnInit, OnDestroy {
|
||||
private focus = (e: Event) => {
|
||||
if (isParentOf(this.element.nativeElement, e.target as any)) {
|
||||
this.lastActiveElement = e.target as any;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
const focusable = findFocusableElements(this.element.nativeElement);
|
||||
|
||||
if (focusable.length) {
|
||||
if (this.lastActiveElement === focusable[0]) {
|
||||
this.lastActiveElement = focusable[focusable.length - 1];
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
this.lastActiveElement = focusable[0];
|
||||
}
|
||||
|
||||
|
||||
@@ -52,7 +52,8 @@ export class HasFeature implements AfterViewInit, OnDestroy {
|
||||
|
||||
if (show) {
|
||||
this.ref = this.ref || this.viewContainer.createEmbeddedView(this.templateRef);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
this.viewContainer.clear();
|
||||
this.ref = undefined;
|
||||
}
|
||||
|
||||
@@ -67,18 +67,21 @@ export class DiscordPony implements OnInit, OnDestroy {
|
||||
this.state.headAnimation = undefined;
|
||||
this.state.headAnimationFrame = 0;
|
||||
this.characterPreview.blink();
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
this.state.headAnimation = this.headAnimation;
|
||||
this.state.headAnimationFrame = frame % this.headAnimation.frames.length;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
this.state.headAnimation = undefined;
|
||||
|
||||
if (this.expression) {
|
||||
if (Math.random() < 0.01) {
|
||||
this.expression = undefined;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
if (Math.random() < 0.005) {
|
||||
this.expression = BLEP;
|
||||
}
|
||||
|
||||
@@ -70,7 +70,8 @@ export class EmoteBox implements AfterViewInit {
|
||||
image.alt = emote ? emote.symbol : '';
|
||||
image.style.visibility = 'visible';
|
||||
});
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
image.style.width = `0px`;
|
||||
image.style.height = `0px`;
|
||||
image.src = '';
|
||||
|
||||
@@ -49,7 +49,9 @@ export class PartyList implements OnInit, OnDestroy {
|
||||
this.resized();
|
||||
}
|
||||
ngOnDestroy() {
|
||||
this.subscription && this.subscription.unsubscribe();
|
||||
if (this.subscription) {
|
||||
this.subscription.unsubscribe();
|
||||
}
|
||||
}
|
||||
isMe(member: PartyMember) {
|
||||
return this.game.player && this.game.player.id === member.id;
|
||||
@@ -64,7 +66,8 @@ export class PartyList implements OnInit, OnDestroy {
|
||||
while (this.start > 0 && this.members.length <= this.start) {
|
||||
this.start = 0;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
this.members = [];
|
||||
this.start = 0;
|
||||
}
|
||||
|
||||
@@ -146,7 +146,9 @@ export class PlayBox implements OnInit {
|
||||
this.errorReporter.reportError(e, { status: e.status, text: e.text });
|
||||
}
|
||||
|
||||
DEVELOPMENT && console.error(e);
|
||||
if (DEVELOPMENT) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
})
|
||||
.finally(() => this.joining = false)
|
||||
|
||||
@@ -47,9 +47,11 @@ export class SetSelection implements OnChanges {
|
||||
|
||||
if (pat && !pat.colors) {
|
||||
return 0;
|
||||
} else if (pat) {
|
||||
}
|
||||
else if (pat) {
|
||||
return getColorCount(pat);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return this.nonLockable ? 1 : 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,13 +82,16 @@ export class SettingsBox implements OnInit, OnDestroy {
|
||||
.subscribe(text => {
|
||||
if (this.dropdown.isOpen) {
|
||||
this.zone.run(() => this.time = text);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
this.time = text;
|
||||
}
|
||||
});
|
||||
}
|
||||
ngOnDestroy() {
|
||||
this.subscription && this.subscription.unsubscribe();
|
||||
if (this.subscription) {
|
||||
this.subscription.unsubscribe();
|
||||
}
|
||||
}
|
||||
toggleVolume() {
|
||||
this.volume = this.volume === 0 ? 50 : 0;
|
||||
|
||||
@@ -102,7 +102,9 @@ export class SettingsModal implements OnInit, OnDestroy {
|
||||
this.cancel();
|
||||
}
|
||||
|
||||
this.subscription && this.subscription.unsubscribe();
|
||||
if (this.subscription) {
|
||||
this.subscription.unsubscribe();
|
||||
}
|
||||
}
|
||||
reset() {
|
||||
this.account = this.settingsService.account = {};
|
||||
@@ -125,7 +127,8 @@ export class SettingsModal implements OnInit, OnDestroy {
|
||||
|
||||
if (filter.length > MAX_FILTER_WORDS_LENGTH) {
|
||||
this.account.filterWords = '';
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
this.account.filterWords = filter;
|
||||
}
|
||||
}
|
||||
@@ -136,9 +139,15 @@ export class SettingsModal implements OnInit, OnDestroy {
|
||||
this.close.emit();
|
||||
}
|
||||
switchTimestamp(state?: string) {
|
||||
if (!state) this.browser.timestamp = undefined;
|
||||
else if (state === '12') this.browser.timestamp = '12';
|
||||
else if (state === '24') this.browser.timestamp = '24';
|
||||
if (!state) {
|
||||
this.browser.timestamp = undefined;
|
||||
}
|
||||
else if (state === '12') {
|
||||
this.browser.timestamp = '12';
|
||||
}
|
||||
else if (state === '24') {
|
||||
this.browser.timestamp = '24';
|
||||
}
|
||||
}
|
||||
updateChatlogRange(range: number | undefined) {
|
||||
document.body.classList.add('translucent-modals');
|
||||
|
||||
@@ -35,8 +35,9 @@ export class SliderBar {
|
||||
return clamp(((this.value - this.min) / (this.max - this.min)) * 100, 0, 100);
|
||||
}
|
||||
drag({ type, x, event }: AgDragEvent) {
|
||||
if (this.disabled)
|
||||
if (this.disabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
event.preventDefault();
|
||||
|
||||
@@ -58,21 +59,25 @@ export class SliderBar {
|
||||
}
|
||||
@HostListener('keydown', ['$event'])
|
||||
keydown(e: KeyboardEvent) {
|
||||
if (this.disabled)
|
||||
if (this.disabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
const step = this.step || 1;
|
||||
|
||||
if (e.keyCode === Key.LEFT || e.keyCode === Key.DOWN || e.keyCode === Key.PAGE_DOWN) {
|
||||
e.preventDefault();
|
||||
this.setValue(this.value - step * (e.keyCode === Key.PAGE_DOWN ? this.largeStep : 1), true);
|
||||
} else if (e.keyCode === Key.RIGHT || e.keyCode === Key.UP || e.keyCode === Key.PAGE_UP) {
|
||||
}
|
||||
else if (e.keyCode === Key.RIGHT || e.keyCode === Key.UP || e.keyCode === Key.PAGE_UP) {
|
||||
e.preventDefault();
|
||||
this.setValue(this.value + step * (e.keyCode === Key.PAGE_UP ? this.largeStep : 1), true);
|
||||
} else if (e.keyCode === Key.HOME) {
|
||||
}
|
||||
else if (e.keyCode === Key.HOME) {
|
||||
e.preventDefault();
|
||||
this.setValue(this.min, true);
|
||||
} else if (e.keyCode === Key.END) {
|
||||
}
|
||||
else if (e.keyCode === Key.END) {
|
||||
e.preventDefault();
|
||||
this.setValue(this.max, true);
|
||||
}
|
||||
|
||||
@@ -87,8 +87,9 @@ export class SpriteBox implements AfterViewInit, OnChanges, DoCheck {
|
||||
const scale = this.scale;
|
||||
const canvas = this.canvas.nativeElement as HTMLCanvasElement;
|
||||
|
||||
if (!size || this.invisible)
|
||||
if (!size || this.invisible) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (canvas.width !== size || canvas.height !== size) {
|
||||
canvas.width = size;
|
||||
@@ -97,8 +98,9 @@ export class SpriteBox implements AfterViewInit, OnChanges, DoCheck {
|
||||
|
||||
const context = canvas.getContext('2d');
|
||||
|
||||
if (!context)
|
||||
if (!context) {
|
||||
return;
|
||||
}
|
||||
|
||||
context.save();
|
||||
context.clearRect(0, 0, canvas.width, canvas.height);
|
||||
@@ -149,7 +151,8 @@ export class SpriteBox implements AfterViewInit, OnChanges, DoCheck {
|
||||
for (const color of sprite.colorMany) {
|
||||
batch.drawSprite(color, WHITE, palette, x, y);
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
batch.drawSprite(sprite.color, WHITE, palette, x, y);
|
||||
}
|
||||
|
||||
@@ -175,7 +178,8 @@ function addRect(rect: Rect, sprite: Sprite | undefined) {
|
||||
rect.y = sprite.oy;
|
||||
rect.w = sprite.w;
|
||||
rect.h = sprite.h;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
const x = Math.min(rect.x, sprite.ox);
|
||||
const y = Math.min(rect.y, sprite.oy);
|
||||
rect.w = Math.max(rect.x + rect.w, sprite.ox + sprite.w) - x;
|
||||
|
||||
@@ -78,18 +78,23 @@ export class SpriteSelection {
|
||||
if (keyCode === Key.RIGHT || keyCode === Key.DOWN) {
|
||||
if (this.selected >= (this.sprites.length - 1)) {
|
||||
return this.skip;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return this.selected + 1;
|
||||
}
|
||||
} else if (keyCode === Key.LEFT || keyCode === Key.UP) {
|
||||
}
|
||||
else if (keyCode === Key.LEFT || keyCode === Key.UP) {
|
||||
if (this.selected <= this.skip) {
|
||||
return this.sprites.length - 1;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return this.selected - 1;
|
||||
}
|
||||
} else if (keyCode === Key.HOME) {
|
||||
}
|
||||
else if (keyCode === Key.HOME) {
|
||||
return this.skip;
|
||||
} else if (keyCode === Key.END) {
|
||||
}
|
||||
else if (keyCode === Key.END) {
|
||||
return this.sprites.length - 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,9 @@ export class SwapBox {
|
||||
swapPony(pony: PonyObject) {
|
||||
this.game.send(server => server.actionParam(Action.SwapCharacter, pony.id));
|
||||
setTimeout(() => {
|
||||
this.dropdown && this.dropdown.close();
|
||||
if (this.dropdown) {
|
||||
this.dropdown.close();
|
||||
}
|
||||
pony.lastUsed = (new Date()).toISOString();
|
||||
this.model.sortPonies();
|
||||
});
|
||||
|
||||
@@ -49,7 +49,8 @@ export class Tabset {
|
||||
set justify(className: 'start' | 'center' | 'end' | 'fill' | 'justified') {
|
||||
if (className === 'fill' || className === 'justified') {
|
||||
this.justifyClass = `nav-${className}`;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
this.justifyClass = `justify-content-${className}`;
|
||||
}
|
||||
}
|
||||
@@ -75,20 +76,26 @@ export class Tabset {
|
||||
if (index !== undefined) {
|
||||
e.preventDefault();
|
||||
const element = document.getElementById(this.tabs.toArray()[index].id);
|
||||
element && element.focus();
|
||||
if (element) {
|
||||
element.focus();
|
||||
}
|
||||
this.select(index);
|
||||
}
|
||||
}
|
||||
private handleKey(keyCode: number) {
|
||||
if (keyCode === Key.LEFT) {
|
||||
return this.activeIndex === 0 ? this.tabs.length - 1 : this.activeIndex - 1;
|
||||
} else if (keyCode === Key.RIGHT) {
|
||||
}
|
||||
else if (keyCode === Key.RIGHT) {
|
||||
return this.activeIndex === this.tabs.length - 1 ? 0 : this.activeIndex + 1;
|
||||
} else if (keyCode === Key.HOME) {
|
||||
}
|
||||
else if (keyCode === Key.HOME) {
|
||||
return 0;
|
||||
} else if (keyCode === Key.END) {
|
||||
}
|
||||
else if (keyCode === Key.END) {
|
||||
return this.tabs.length - 1;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,7 +77,8 @@ export class VirtualFor<T> implements DoCheck, OnDestroy, AfterViewInit {
|
||||
if (!this.differ && value) {
|
||||
try {
|
||||
this.differ = this.differs.find(value).create();
|
||||
} catch {
|
||||
}
|
||||
catch {
|
||||
throw new Error(`Cannot find a differ`);
|
||||
}
|
||||
}
|
||||
@@ -130,7 +131,8 @@ export class VirtualFor<T> implements DoCheck, OnDestroy, AfterViewInit {
|
||||
view.context.$implicit = null!;
|
||||
view.context._currentIndex = index;
|
||||
viewContainer.insert(view, i);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
const context: Context<T> = { $implicit: null!, index: -1, count: -1, _currentIndex: index };
|
||||
view = viewContainer.createEmbeddedView(this.template, context, i);
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
/* eslint-disable camelcase */
|
||||
import { Component, OnInit, OnDestroy, Input, ViewChild, ChangeDetectionStrategy } from '@angular/core';
|
||||
import { defaultExpression } from '../../../common/ponyUtils';
|
||||
import { defaultPonyState } from '../../../common/ponyHelpers';
|
||||
@@ -81,18 +82,21 @@ export class VisitPTPony implements OnInit, OnDestroy {
|
||||
this.state.headAnimation = undefined;
|
||||
this.state.headAnimationFrame = 0;
|
||||
this.characterPreview.blink();
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
this.state.headAnimation = this.headAnimation;
|
||||
this.state.headAnimationFrame = frame % this.headAnimation.frames.length;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
this.state.headAnimation = undefined;
|
||||
|
||||
if (this.expression) {
|
||||
if (Math.random() < 0.01) {
|
||||
this.expression = undefined;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
if (Math.random() < 0.005) {
|
||||
this.expression = BLEP;
|
||||
}
|
||||
@@ -106,7 +110,8 @@ export class VisitPTPony implements OnInit, OnDestroy {
|
||||
this.bodyAnimation = undefined;
|
||||
this.state.animation = stand;
|
||||
this.state.animationFrame = 0;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
this.state.animation = this.bodyAnimation;
|
||||
this.state.animationFrame = frame % this.bodyAnimation.frames.length;
|
||||
}
|
||||
|
||||
@@ -42,6 +42,7 @@ export class ToolsFrame {
|
||||
openedPopover.popoverIsOpen = false;
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
||||
openedPopover = this;
|
||||
}
|
||||
|
||||
@@ -50,7 +51,8 @@ export class ToolsFrame {
|
||||
if (this.popoverIsOpen) {
|
||||
this.selected = false;
|
||||
window.addEventListener('mousedown', this.closePopover);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
window.removeEventListener('mousedown', this.closePopover);
|
||||
}
|
||||
|
||||
|
||||
@@ -43,7 +43,8 @@ function getSets(sheet: Sheet, key: string, override?: string): Sets | undefined
|
||||
|
||||
if (sheet.duplicateFirstFrame !== undefined) {
|
||||
return times(sheet.duplicateFirstFrame, () => sets[0]);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return sheet.single ? [sets] : sets;
|
||||
}
|
||||
}
|
||||
@@ -60,7 +61,8 @@ export function getCols(sheet: Sheet) {
|
||||
export function getRows(sheet: Sheet) {
|
||||
if (sheet.rows !== undefined) {
|
||||
return sheet.rows;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
const sets = getSetsForFirstKey(sheet);
|
||||
const maxFrames = sets && max(sets.map(f => f ? f.length : 0));
|
||||
return (maxFrames || 0) + 1;
|
||||
@@ -117,7 +119,8 @@ function drawPsdLayer(
|
||||
pony.head = ignoreSet();
|
||||
pony.nose = ignoreSet();
|
||||
pony.ears = ignoreSet();
|
||||
} else if (layer.noFace) {
|
||||
}
|
||||
else if (layer.noFace) {
|
||||
baseState.headAnimation = createHeadAnimation('', 1, false, [[]]);
|
||||
pony.head = ignoreSet();
|
||||
pony.nose = ignoreSet();
|
||||
@@ -143,7 +146,9 @@ function drawPsdLayer(
|
||||
options.no = setFlag(options.no, NoDraw.BackFarLeg, true);
|
||||
}
|
||||
|
||||
layer.setup && layer.setup(pony, baseState);
|
||||
if (layer.setup) {
|
||||
layer.setup(pony, baseState);
|
||||
}
|
||||
|
||||
syncLockedPonyInfoNumber(pony);
|
||||
|
||||
@@ -159,8 +164,12 @@ function drawPsdLayer(
|
||||
|
||||
const state = cloneDeep(baseState);
|
||||
|
||||
sheet.frame && sheet.frame(pony, state, options, xIndex, yIndex, pattern);
|
||||
layer.frame && layer.frame(pony, state, options, xIndex, yIndex, pattern);
|
||||
if (sheet.frame) {
|
||||
sheet.frame(pony, state, options, xIndex, yIndex, pattern);
|
||||
}
|
||||
if (layer.frame) {
|
||||
layer.frame(pony, state, options, xIndex, yIndex, pattern);
|
||||
}
|
||||
|
||||
state.animationFrame = xIndex;
|
||||
|
||||
@@ -183,10 +192,12 @@ function drawPsdLayer(
|
||||
|
||||
if (aframe && typeIndex < aframe.length && aframe[typeIndex] && pattern < aframe[typeIndex]!.length) {
|
||||
set.pattern = pattern;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
set.type = -1;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
set.fills = whiteColors;
|
||||
set.outlines = whiteColors;
|
||||
|
||||
@@ -195,7 +206,9 @@ function drawPsdLayer(
|
||||
}
|
||||
}
|
||||
|
||||
layer.frameSet && layer.frameSet(set, xIndex, yIndex, pattern);
|
||||
if (layer.frameSet) {
|
||||
layer.frameSet(set, xIndex, yIndex, pattern);
|
||||
}
|
||||
|
||||
(pony as any)[fieldName] = set.type === -1 ? ignoreSet() : set;
|
||||
}
|
||||
@@ -210,7 +223,8 @@ function drawPsdLayer(
|
||||
|
||||
if (extra) {
|
||||
set.palette = mockPaletteManager.add([0, BLACK, BLACK, BLACK, BLACK, BLACK, BLACK, BLACK, BLACK]);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
set.extraPalette = undefined;
|
||||
}
|
||||
}
|
||||
@@ -247,7 +261,8 @@ function createPsdLayer(sheet: Sheet, rows: number, cols: number, layer: SheetLa
|
||||
|
||||
if (layer.set) {
|
||||
return { name, children: createPsdPatternLayers(sheet, rows, cols, layer) };
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return { name, canvas: drawPsdLayer(sheet, rows, cols, layer) };
|
||||
}
|
||||
}
|
||||
@@ -352,7 +367,11 @@ export function drawPsd(psd: Psd, scale: number, canvas?: HTMLCanvasElement): HT
|
||||
|
||||
function drawLayer(layer: Layer, context: CanvasRenderingContext2D) {
|
||||
if (!layer.hidden) {
|
||||
layer.canvas && context.drawImage(layer.canvas, 0, 0);
|
||||
layer.children && layer.children.forEach(c => drawLayer(c, context));
|
||||
if (layer.canvas) {
|
||||
context.drawImage(layer.canvas, 0, 0);
|
||||
}
|
||||
if (layer.children) {
|
||||
layer.children.forEach(c => drawLayer(c, context));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -213,7 +213,8 @@ export class ToolsAnimation implements OnInit, OnDestroy {
|
||||
headFrame = Math.min(headFrame, headFrames - 1);
|
||||
this.state.headAnimationFrame = headFrame;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
this.state.headAnimationFrame = this.frame;
|
||||
}
|
||||
}
|
||||
@@ -301,7 +302,8 @@ export class ToolsAnimation implements OnInit, OnDestroy {
|
||||
.subscribe(({ type, animation }) => {
|
||||
if (type === 'body') {
|
||||
this.bodyAnimations.push(animation);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
this.headAnimations.push(animation);
|
||||
}
|
||||
|
||||
@@ -312,7 +314,8 @@ export class ToolsAnimation implements OnInit, OnDestroy {
|
||||
private createAnimation(): BodyAnimation | HeadAnimation {
|
||||
if (this.mode === 'body') {
|
||||
return { name: 'new animation', loop: true, fps: 24, frames: [createDefaultBodyFrame()] };
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return { name: 'new animation', loop: true, fps: 24, frames: [createDefaultHeadFrame()] };
|
||||
}
|
||||
}
|
||||
@@ -341,7 +344,8 @@ export class ToolsAnimation implements OnInit, OnDestroy {
|
||||
selectAnimation(animation: BodyAnimation | HeadAnimation) {
|
||||
if (this.mode === 'body') {
|
||||
this.selectBodyAnimation(animation as BodyAnimation);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
this.selectHeadAnimation(animation as HeadAnimation);
|
||||
}
|
||||
}
|
||||
@@ -435,11 +439,14 @@ export class ToolsAnimation implements OnInit, OnDestroy {
|
||||
handleKey(keyCode: number) {
|
||||
if (keyCode === Key.OPEN_BRACKET || keyCode === Key.LEFT || keyCode === Key.COMMA) {
|
||||
this.prevFrame();
|
||||
} else if (keyCode === Key.CLOSE_BRACKET || keyCode === Key.RIGHT || keyCode === Key.PERIOD) {
|
||||
}
|
||||
else if (keyCode === Key.CLOSE_BRACKET || keyCode === Key.RIGHT || keyCode === Key.PERIOD) {
|
||||
this.nextFrame();
|
||||
} else if (keyCode === Key.ENTER) {
|
||||
}
|
||||
else if (keyCode === Key.ENTER) {
|
||||
this.playing = !this.playing;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -470,7 +477,8 @@ export class ToolsAnimation implements OnInit, OnDestroy {
|
||||
const shadow = this.bodyAnimation.frames.map(f => [f.shadowFrame, f.shadowOffset]);
|
||||
console.log(`shadow: [${shadow.map(x => `[${x.join(', ')}]`).join(', ')}]`);
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
const frames = this.headAnimation.frames
|
||||
.map(f => [f.duration, '[' + compressHeadFrame(f).join(', ') + ']'])
|
||||
.map(([repeat, frame]) => parseInt(`${repeat}`, 10) > 1 ? `...repeat(${repeat}, ${frame})` : frame);
|
||||
@@ -555,7 +563,8 @@ export class ToolsAnimation implements OnInit, OnDestroy {
|
||||
this.state.animation = this.bodyAnimationsToPlay[this.bodyAnimationPlaying];
|
||||
this.state.animationFrame = 0;
|
||||
this.time = 0;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
this.state.animationFrame = frame % this.state.animation.frames.length;
|
||||
}
|
||||
}
|
||||
@@ -657,7 +666,8 @@ function fromBodyAnimation({ name, frames, fps, loop, shadow }: IBodyAnimation,
|
||||
&& l.wing === f.wing
|
||||
) {
|
||||
l.duration++;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
fs.push({
|
||||
duration: 1,
|
||||
...f,
|
||||
@@ -731,7 +741,8 @@ function fromHeadAnimation({ name, fps, loop, properties, frames }: IHeadAnimati
|
||||
|
||||
if (l && l.headX === f.headX && l.headY === f.headY && l.left === f.left && l.right === f.right && l.mouth === f.mouth) {
|
||||
l.duration++;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
fs.push({ duration: 1, ...f });
|
||||
}
|
||||
});
|
||||
|
||||
@@ -97,8 +97,9 @@ export class ToolsChat implements AfterViewInit {
|
||||
this.redraw();
|
||||
}
|
||||
redraw() {
|
||||
if (!this.initialized)
|
||||
if (!this.initialized) {
|
||||
return;
|
||||
}
|
||||
|
||||
const canvas1 = drawCanvas(500, 400, sprites.paletteSpriteSheet, undefined, batch => {
|
||||
const palettes = createCommonPalettes(mockPaletteManager);
|
||||
@@ -162,7 +163,7 @@ export class ToolsChat implements AfterViewInit {
|
||||
});
|
||||
|
||||
const canvas3 = drawCanvas(500, 400, sprites.paletteSpriteSheet, undefined, batch => {
|
||||
/* tslint:disable */
|
||||
// eslint-disable-next-line max-len
|
||||
const loremIpsum = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce scelerisque interdum scelerisque. Suspendisse malesuada, enim in viverra ornare, dui ex laoreet ipsum, at mollis orci felis vitae ipsum. In faucibus venenatis augue, ac ornare libero. Etiam vitae aliquet neque.';
|
||||
const text = lineBreak(loremIpsum, fontPal, 200);
|
||||
|
||||
|
||||
@@ -118,10 +118,12 @@ export class ToolsCollisions implements OnInit {
|
||||
if (shiftKey) {
|
||||
if (Math.abs(dx) > Math.abs(dy)) {
|
||||
this.target = toWorld({ x, y: toScreenY(this.start.y) });
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
this.target = toWorld({ x: toScreenX(this.start.x), y });
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
this.target = toWorld({ x, y });
|
||||
}
|
||||
|
||||
@@ -146,7 +148,8 @@ export class ToolsCollisions implements OnInit {
|
||||
this.steps.push(collision);
|
||||
current.x = collision.x;
|
||||
current.y = collision.y;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
this.steps.push(point(this.target.x, this.target.y));
|
||||
}
|
||||
|
||||
@@ -156,19 +159,22 @@ export class ToolsCollisions implements OnInit {
|
||||
if (steps <= 0) {
|
||||
console.error('Failed');
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
const collision = getClosestCollisionOld(this.start, this.target, this.rects);
|
||||
|
||||
if (equal(this.target, collision)) {
|
||||
this.deflection = { ...this.target };
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
const coll = getClosestCollisionOld(collision, this.target, this.rects);
|
||||
|
||||
if (equal(collision, coll)) {
|
||||
const horizontal = getClosestCollisionOld(collision, { x: this.target.x, y: collision.y }, this.rects);
|
||||
const vertical = getClosestCollisionOld(collision, { x: collision.x, y: this.target.y }, this.rects);
|
||||
this.deflection = equal(collision, horizontal) ? vertical : horizontal;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
console.log('not', collision, coll);
|
||||
}
|
||||
}
|
||||
@@ -214,13 +220,15 @@ export class ToolsCollisions implements OnInit {
|
||||
|
||||
if (ay < (y + 1)) {
|
||||
x++;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
y++;
|
||||
}
|
||||
|
||||
checkedTiles.add(`${x}-${y}`);
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
while (--steps && (x !== x1 || y !== y1)) {
|
||||
const dx = (x + 1) - srcX;
|
||||
const dy = dx * DYbyDX;
|
||||
@@ -228,7 +236,8 @@ export class ToolsCollisions implements OnInit {
|
||||
|
||||
if (ay >= y) {
|
||||
x++;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
y--;
|
||||
}
|
||||
|
||||
@@ -441,12 +450,14 @@ function getCollisionTest({ x, y }: Point, b: Point, r: Rect): Point | undefined
|
||||
if (q[i] < 0) {
|
||||
return undefined;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
const t = q[i] / p[i];
|
||||
|
||||
if (p[i] < 0 && u1 < t) {
|
||||
u1 = t;
|
||||
} else if (p[i] > 0 && u2 > t) {
|
||||
}
|
||||
else if (p[i] > 0 && u2 > t) {
|
||||
u2 = t;
|
||||
}
|
||||
}
|
||||
@@ -523,24 +534,29 @@ function checkInLine(srcX: number, srcY: number, dstX: number, dstY: number, col
|
||||
oy = 1;
|
||||
stepYT = 1 | 0;
|
||||
stepXF = 1 | 0;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
ox = 1;
|
||||
stepYT = -1 | 0;
|
||||
stepXF = 1 | 0;
|
||||
}
|
||||
} else if (srcX > dstX) {
|
||||
}
|
||||
else if (srcX > dstX) {
|
||||
if (srcY < dstY) {
|
||||
oy = 1;
|
||||
stepYT = 1 | 0;
|
||||
stepXF = -1 | 0;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
stepYT = -1 | 0;
|
||||
stepXF = -1 | 0;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
if (srcY < dstY) {
|
||||
stepYF = stepYT = 1 | 0;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
stepYF = stepYT = -1 | 0;
|
||||
}
|
||||
}
|
||||
@@ -555,7 +571,8 @@ function checkInLine(srcX: number, srcY: number, dstX: number, dstY: number, col
|
||||
if (useGt ? (fx > fy) : (fx < fy)) {
|
||||
tx = (tx + stepXT) | 0;
|
||||
ty = (ty + stepYT) | 0;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
tx = (tx + stepXF) | 0;
|
||||
ty = (ty + stepYF) | 0;
|
||||
}
|
||||
@@ -583,17 +600,20 @@ function checkInLine(srcX: number, srcY: number, dstX: number, dstY: number, col
|
||||
actualNY -= 1;
|
||||
dstY -= 1;
|
||||
collides = false;
|
||||
} else if (shiftDown && (canShiftDown = !isColliding(actualX, actualY + 1)) && !isColliding(actualNX, actualY + 1)) {
|
||||
}
|
||||
else if (shiftDown && (canShiftDown = !isColliding(actualX, actualY + 1)) && !isColliding(actualNX, actualY + 1)) {
|
||||
actualNX = actualX;
|
||||
actualNY += 1;
|
||||
dstY += 1;
|
||||
collides = false;
|
||||
} else if (shiftUp && canShiftUp && !isColliding(actualNX, actualY - 2)) {
|
||||
}
|
||||
else if (shiftUp && canShiftUp && !isColliding(actualNX, actualY - 2)) {
|
||||
actualNX = actualX;
|
||||
actualNY -= 1;
|
||||
dstY -= 1;
|
||||
collides = false;
|
||||
} else if (shiftDown && canShiftDown && !isColliding(actualNX, actualY + 2)) {
|
||||
}
|
||||
else if (shiftDown && canShiftDown && !isColliding(actualNX, actualY + 2)) {
|
||||
actualNX = actualX;
|
||||
actualNY += 1;
|
||||
dstY += 1;
|
||||
@@ -601,7 +621,8 @@ function checkInLine(srcX: number, srcY: number, dstX: number, dstY: number, col
|
||||
}
|
||||
|
||||
canMove = canShiftUp || canShiftDown;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
let canShiftLeft = false;
|
||||
let canShiftRight = false;
|
||||
|
||||
@@ -610,17 +631,20 @@ function checkInLine(srcX: number, srcY: number, dstX: number, dstY: number, col
|
||||
actualNY = actualY;
|
||||
dstX -= 1;
|
||||
collides = false;
|
||||
} else if (shiftRight && (canShiftRight = !isColliding(actualX + 1, actualY)) && !isColliding(actualX + 1, actualNY)) {
|
||||
}
|
||||
else if (shiftRight && (canShiftRight = !isColliding(actualX + 1, actualY)) && !isColliding(actualX + 1, actualNY)) {
|
||||
actualNX += 1;
|
||||
actualNY = actualY;
|
||||
dstX += 1;
|
||||
collides = false;
|
||||
} else if (shiftLeft && canShiftLeft && !isColliding(actualX - 2, actualNY)) {
|
||||
}
|
||||
else if (shiftLeft && canShiftLeft && !isColliding(actualX - 2, actualNY)) {
|
||||
actualNX -= 1;
|
||||
actualNY = actualY;
|
||||
dstX -= 1;
|
||||
collides = false;
|
||||
} else if (shiftRight && canShiftRight && !isColliding(actualX + 2, actualNY)) {
|
||||
}
|
||||
else if (shiftRight && canShiftRight && !isColliding(actualX + 2, actualNY)) {
|
||||
actualNX += 1;
|
||||
actualNY = actualY;
|
||||
dstX += 1;
|
||||
@@ -635,7 +659,8 @@ function checkInLine(srcX: number, srcY: number, dstX: number, dstY: number, col
|
||||
actualX = actualNX;
|
||||
actualY = actualNY;
|
||||
checks.push({ x: actualX, y: actualY });
|
||||
} else if (!canMove || horizontalOrVertical) {
|
||||
}
|
||||
else if (!canMove || horizontalOrVertical) {
|
||||
checks.push({ x: actualX, y: actualY, type: 'break' });
|
||||
break;
|
||||
}
|
||||
@@ -705,12 +730,14 @@ function getCollision(
|
||||
if (q < 0) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
const t = q / p;
|
||||
|
||||
if (p < 0 && u1 < t) {
|
||||
u1 = t;
|
||||
} else if (p > 0 && u2 > t) {
|
||||
}
|
||||
else if (p > 0 && u2 > t) {
|
||||
u2 = t;
|
||||
}
|
||||
}
|
||||
@@ -724,12 +751,14 @@ function getCollision(
|
||||
if (q < 0) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
const t = q / p;
|
||||
|
||||
if (p < 0 && u1 < t) {
|
||||
u1 = t;
|
||||
} else if (p > 0 && u2 > t) {
|
||||
}
|
||||
else if (p > 0 && u2 > t) {
|
||||
u2 = t;
|
||||
}
|
||||
}
|
||||
@@ -743,12 +772,14 @@ function getCollision(
|
||||
if (q < 0) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
const t = q / p;
|
||||
|
||||
if (p < 0 && u1 < t) {
|
||||
u1 = t;
|
||||
} else if (p > 0 && u2 > t) {
|
||||
}
|
||||
else if (p > 0 && u2 > t) {
|
||||
u2 = t;
|
||||
}
|
||||
}
|
||||
@@ -762,12 +793,14 @@ function getCollision(
|
||||
if (q < 0) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
const t = q / p;
|
||||
|
||||
if (p < 0 && u1 < t) {
|
||||
u1 = t;
|
||||
} else if (p > 0 && u2 > t) {
|
||||
}
|
||||
else if (p > 0 && u2 > t) {
|
||||
u2 = t;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -128,13 +128,17 @@ export class ToolsEntity implements OnInit {
|
||||
handleKey(keyCode: number) {
|
||||
if (keyCode === Key.UP) {
|
||||
this.movePart(0, -1);
|
||||
} else if (keyCode === Key.DOWN) {
|
||||
}
|
||||
else if (keyCode === Key.DOWN) {
|
||||
this.movePart(0, 1);
|
||||
} else if (keyCode === Key.LEFT) {
|
||||
}
|
||||
else if (keyCode === Key.LEFT) {
|
||||
this.movePart(-1, 0);
|
||||
} else if (keyCode === Key.RIGHT) {
|
||||
}
|
||||
else if (keyCode === Key.RIGHT) {
|
||||
this.movePart(1, 0);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -149,7 +153,8 @@ export class ToolsEntity implements OnInit {
|
||||
this.selectedPart = findLastIndex(this.parts, p => {
|
||||
if (this.drawHold) {
|
||||
return p.type === 'pickable';
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
const bounds = getBounds(p);
|
||||
return !!bounds && containsPoint(0, 0, bounds, x, y);
|
||||
}
|
||||
@@ -176,7 +181,8 @@ export class ToolsEntity implements OnInit {
|
||||
if (entity) {
|
||||
this.name = entity.name;
|
||||
this.parts = entity.parts;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
this.name = '';
|
||||
this.parts = [];
|
||||
}
|
||||
@@ -189,7 +195,8 @@ export class ToolsEntity implements OnInit {
|
||||
|
||||
if (existing) {
|
||||
existing.parts = cloneDeep(this.parts);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
this.entities.push({
|
||||
name: this.name,
|
||||
parts: cloneDeep(this.parts),
|
||||
@@ -260,7 +267,8 @@ export class ToolsEntity implements OnInit {
|
||||
|
||||
const state = { ...defaultPonyState(), holding };
|
||||
drawPony(batch, this.pony, state, X, Y, defaultDrawPonyOptions());
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
draw(batch);
|
||||
}
|
||||
});
|
||||
@@ -344,7 +352,8 @@ function getBounds(part: Part): Rect | undefined {
|
||||
h: color.h,
|
||||
};
|
||||
}
|
||||
} else if (part.type === 'cover' || part.type === 'collider') {
|
||||
}
|
||||
else if (part.type === 'cover' || part.type === 'collider') {
|
||||
return part;
|
||||
}
|
||||
|
||||
@@ -358,15 +367,20 @@ function getSprite(name: string): PaletteRenderable {
|
||||
function drawSpritePart(batch: PaletteSpriteBatch, part: SpritePart, px: number, py: number) {
|
||||
const sprite = getSprite(part.sprite);
|
||||
|
||||
if (!sprite)
|
||||
if (!sprite) {
|
||||
return;
|
||||
}
|
||||
|
||||
const x = px + part.x;
|
||||
const y = py + part.y;
|
||||
const palette = paletteManager.addArray(sprite.palettes![0]);
|
||||
|
||||
sprite.shadow && batch.drawSprite(sprite.shadow, SHADOW_COLOR, defaultPalette, x, y);
|
||||
sprite.color && batch.drawSprite(sprite.color, WHITE, palette, x, y);
|
||||
if (sprite.shadow) {
|
||||
batch.drawSprite(sprite.shadow, SHADOW_COLOR, defaultPalette, x, y);
|
||||
}
|
||||
if (sprite.color) {
|
||||
batch.drawSprite(sprite.color, WHITE, palette, x, y);
|
||||
}
|
||||
|
||||
releasePalette(palette);
|
||||
}
|
||||
@@ -374,11 +388,14 @@ function drawSpritePart(batch: PaletteSpriteBatch, part: SpritePart, px: number,
|
||||
function drawPart(batch: PaletteSpriteBatch, part: Part, x: number, y: number) {
|
||||
if (part.type === 'sprite') {
|
||||
return drawSpritePart(batch, part, x, y);
|
||||
} else if (part.type === 'cover' || part.type === 'collider') {
|
||||
}
|
||||
else if (part.type === 'cover' || part.type === 'collider') {
|
||||
return drawOutline(batch, colors[part.type], part.x + x, part.y + y, part.w, part.h);
|
||||
} else if (part.type === 'pickable') {
|
||||
}
|
||||
else if (part.type === 'pickable') {
|
||||
return drawOutline(batch, colors[part.type], part.x + x, part.y + y, 1, 1);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
throw new Error(`Invalid part type (${(part as any).type})`);
|
||||
}
|
||||
}
|
||||
@@ -395,8 +412,9 @@ function drawBufferScaled(canvas: HTMLCanvasElement, buffer: HTMLCanvasElement,
|
||||
function drawMixin(sprite: PaletteRenderable, dx: number, dy: number, paletteIndex = 0): EntityPart {
|
||||
const bounds = getRenderableBounds(sprite, dx, dy);
|
||||
|
||||
if (SERVER && !TESTS)
|
||||
if (SERVER && !TESTS) {
|
||||
return { bounds };
|
||||
}
|
||||
|
||||
const defaultPalette = sprite.shadow && createPalette(sprites.defaultPalette);
|
||||
const palette = createPalette(att(sprite.palettes, paletteIndex));
|
||||
|
||||
@@ -121,7 +121,8 @@ export class ToolsMap implements OnInit {
|
||||
if (this.map && this.info) {
|
||||
if (this.type === 'regular') {
|
||||
drawTheMap(this.canvas.nativeElement, this.map, this.info, this.scale, this.grid);
|
||||
} else if (this.type === 'minimap') {
|
||||
}
|
||||
else if (this.type === 'minimap') {
|
||||
drawMinimap(this.canvas.nativeElement, this.map, this.info, this.scale);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,8 @@ function forEachCharacter(value: string, callback: (code: number) => void) {
|
||||
callback(((code & 0x3ff) << 10) + (extra & 0x3ff) + 0x10000);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
callback(code);
|
||||
}
|
||||
}
|
||||
@@ -24,11 +25,14 @@ function forEachCharacter(value: string, callback: (code: number) => void) {
|
||||
function charLengthInBytes(code: number): number {
|
||||
if ((code & 0xffffff80) === 0) {
|
||||
return 1;
|
||||
} else if ((code & 0xfffff800) === 0) {
|
||||
}
|
||||
else if ((code & 0xfffff800) === 0) {
|
||||
return 2;
|
||||
} else if ((code & 0xffff0000) === 0) {
|
||||
}
|
||||
else if ((code & 0xffff0000) === 0) {
|
||||
return 3;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return 4;
|
||||
}
|
||||
}
|
||||
@@ -45,13 +49,16 @@ function encodeStringTo(buffer: Uint8Array | Buffer, offset: number, value: stri
|
||||
|
||||
if (length === 1) {
|
||||
buffer[offset++] = code;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
if (length === 2) {
|
||||
buffer[offset++] = ((code >> 6) & 0x1f) | 0xc0;
|
||||
} else if (length === 3) {
|
||||
}
|
||||
else if (length === 3) {
|
||||
buffer[offset++] = ((code >> 12) & 0x0f) | 0xe0;
|
||||
buffer[offset++] = ((code >> 6) & 0x3f) | 0x80;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
buffer[offset++] = ((code >> 18) & 0x07) | 0xf0;
|
||||
buffer[offset++] = ((code >> 12) & 0x3f) | 0x80;
|
||||
buffer[offset++] = ((code >> 6) & 0x3f) | 0x80;
|
||||
@@ -65,8 +72,9 @@ function encodeStringTo(buffer: Uint8Array | Buffer, offset: number, value: stri
|
||||
}
|
||||
|
||||
export function encodeString(value: string | null): Uint8Array | null {
|
||||
if (value == null)
|
||||
if (value == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const buffer = new Uint8Array(stringLengthInBytes(value));
|
||||
encodeStringTo(buffer, 0, value);
|
||||
@@ -74,8 +82,9 @@ export function encodeString(value: string | null): Uint8Array | null {
|
||||
}
|
||||
|
||||
export function encodeStringNew(value: string | null): Uint8Array | null {
|
||||
if (value == null)
|
||||
if (value == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const buffer = new Uint8Array(stringLengthInBytes2(value));
|
||||
encodeStringTo2(buffer, 0, value);
|
||||
@@ -87,11 +96,14 @@ export function encodeStringNew(value: string | null): Uint8Array | null {
|
||||
function charLengthInBytes2(code: number): number {
|
||||
if ((code & 0xffffff80) === 0) {
|
||||
return 1;
|
||||
} else if ((code & 0xfffff800) === 0) {
|
||||
}
|
||||
else if ((code & 0xfffff800) === 0) {
|
||||
return 2;
|
||||
} else if ((code & 0xffff0000) === 0) {
|
||||
}
|
||||
else if ((code & 0xffff0000) === 0) {
|
||||
return 3;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return 4;
|
||||
}
|
||||
}
|
||||
@@ -108,13 +120,16 @@ export function encodeStringTo2(buffer: Uint8Array, offset: number, value: strin
|
||||
|
||||
if (length === 1) {
|
||||
buffer[offset++] = code;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
if (length === 2) {
|
||||
buffer[offset++] = ((code >> 6) & 0x1f) | 0xc0;
|
||||
} else if (length === 3) {
|
||||
}
|
||||
else if (length === 3) {
|
||||
buffer[offset++] = ((code >> 12) & 0x0f) | 0xe0;
|
||||
buffer[offset++] = ((code >> 6) & 0x3f) | 0x80;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
buffer[offset++] = ((code >> 18) & 0x07) | 0xf0;
|
||||
buffer[offset++] = ((code >> 12) & 0x3f) | 0x80;
|
||||
buffer[offset++] = ((code >> 6) & 0x3f) | 0x80;
|
||||
@@ -143,10 +158,12 @@ function forEachCharacter2(value: string, callback: (code: number) => void) {
|
||||
if ((extra & 0xfc00) === 0xdc00) {
|
||||
i = (i + 1) | 0;
|
||||
code = (((((code & 0x3ff) << 10) + (extra & 0x3ff)) | 0) + 0x10000) | 0;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,8 +47,9 @@ export class ToolsPerf {
|
||||
}
|
||||
|
||||
function measure(name: string, iterations: number, func: (i: number) => void) {
|
||||
if (!iterations)
|
||||
if (!iterations) {
|
||||
return;
|
||||
}
|
||||
|
||||
const start = performance.now();
|
||||
let v: any;
|
||||
@@ -124,12 +125,14 @@ export function compareArrays() {
|
||||
let t: any;
|
||||
|
||||
function compareArrays(a: number[], b: number[]) {
|
||||
if (a.length !== b.length)
|
||||
if (a.length !== b.length) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (let i = 0; i < a.length; i++) {
|
||||
if (a[i] !== b[i])
|
||||
if (a[i] !== b[i]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@@ -107,7 +107,8 @@ export class ToolsRegions implements OnInit, OnDestroy {
|
||||
if (isAreaVisible(this.camera, x * regionWidth, y * regionHeight, regionWidth, regionHeight)) {
|
||||
if (this.regions[y][x] === 'Sienna') {
|
||||
this.regions[y][x] = 'SeaGreen';
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
this.regions[y][x] = 'Crimson';
|
||||
}
|
||||
}
|
||||
@@ -130,13 +131,17 @@ export class ToolsRegions implements OnInit, OnDestroy {
|
||||
if (e.keyCode === Key.KEY_P) {
|
||||
this.zoom = this.zoom === 4 ? 1 : (this.zoom + 1);
|
||||
this.update();
|
||||
} else if (e.keyCode === Key.RIGHT) {
|
||||
}
|
||||
else if (e.keyCode === Key.RIGHT) {
|
||||
this.right = true;
|
||||
} else if (e.keyCode === Key.LEFT) {
|
||||
}
|
||||
else if (e.keyCode === Key.LEFT) {
|
||||
this.left = true;
|
||||
} else if (e.keyCode === Key.UP) {
|
||||
}
|
||||
else if (e.keyCode === Key.UP) {
|
||||
this.up = true;
|
||||
} else if (e.keyCode === Key.DOWN) {
|
||||
}
|
||||
else if (e.keyCode === Key.DOWN) {
|
||||
this.down = true;
|
||||
}
|
||||
}
|
||||
@@ -144,11 +149,14 @@ export class ToolsRegions implements OnInit, OnDestroy {
|
||||
keyup(e: KeyboardEvent) {
|
||||
if (e.keyCode === Key.RIGHT) {
|
||||
this.right = false;
|
||||
} else if (e.keyCode === Key.LEFT) {
|
||||
}
|
||||
else if (e.keyCode === Key.LEFT) {
|
||||
this.left = false;
|
||||
} else if (e.keyCode === Key.UP) {
|
||||
}
|
||||
else if (e.keyCode === Key.UP) {
|
||||
this.up = false;
|
||||
} else if (e.keyCode === Key.DOWN) {
|
||||
}
|
||||
else if (e.keyCode === Key.DOWN) {
|
||||
this.down = false;
|
||||
}
|
||||
}
|
||||
@@ -160,10 +168,18 @@ export class ToolsRegions implements OnInit, OnDestroy {
|
||||
let dx = 0;
|
||||
let dy = 0;
|
||||
|
||||
if (this.right) dx += 1;
|
||||
if (this.left) dx -= 1;
|
||||
if (this.up) dy -= 1;
|
||||
if (this.down) dy += 1;
|
||||
if (this.right) {
|
||||
dx += 1;
|
||||
}
|
||||
if (this.left) {
|
||||
dx -= 1;
|
||||
}
|
||||
if (this.up) {
|
||||
dy -= 1;
|
||||
}
|
||||
if (this.down) {
|
||||
dy += 1;
|
||||
}
|
||||
|
||||
if (dx || dy) {
|
||||
this.player.x += dx * delta * PONY_SPEED_TROT;
|
||||
|
||||
@@ -176,7 +176,8 @@ export class ToolsUI implements OnInit, OnDestroy {
|
||||
if (this.spamChatInterval) {
|
||||
clearInterval(this.spamChatInterval);
|
||||
this.spamChatInterval = 0;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
this.spamChatInterval = 1;
|
||||
this.zone.runOutsideAngular(() => this.spamChatInterval = setInterval(() => {
|
||||
chatlog.addMessage({
|
||||
@@ -195,7 +196,8 @@ export class ToolsUI implements OnInit, OnDestroy {
|
||||
set isPartyLeader(value: boolean) {
|
||||
if (value) {
|
||||
this.game.party!.leaderId = this.game.player!.id;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
this.game.party!.leaderId = 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,7 +88,8 @@ export class ToolsVariants implements OnInit {
|
||||
|
||||
if (this.justHead) {
|
||||
viewContext.drawImage(buffer, 0, 0, 55, 45, x * 45 - 10, y * 45, 55, 45);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
viewContext.drawImage(buffer, x * 60 - 10, y * 60);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user