mirror of
https://github.com/Terncode/pixel.horse.git
synced 2026-09-25 06:05:52 +02:00
Season and holiday configuration options (#138)
* Added configuration options to change the season and holiday (per-server and globally) in config.json * Added documentation on newly added configuration options * Updated parseHoliday to recognize all current holidays * Moved parseSeason and parseHoliday functions from server/commands.ts to common/utils.ts
This commit is contained in:
committed by
Eliot Partridge
parent
a7d6a9f1e5
commit
8a4c8198b8
@@ -1,6 +1,6 @@
|
||||
import { range, compact, escapeRegExp } from 'lodash';
|
||||
import {
|
||||
MessageType, ChatType, Expression, Eye, Muzzle, Action, Season, Holiday, Weather, toAnnouncementMessageType,
|
||||
MessageType, ChatType, Expression, Eye, Muzzle, Action, Weather, toAnnouncementMessageType,
|
||||
} from '../common/interfaces';
|
||||
import { hasRole } from '../common/accountUtils';
|
||||
import { butterfly, bat, firefly, cloud, getEntityType, getEntityTypeName } from '../common/entities';
|
||||
@@ -17,7 +17,7 @@ import {
|
||||
setEntityExpression, execAction, teleportTo
|
||||
} from './playerUtils';
|
||||
import { ServerLiveSettings, GameServerSettings } from '../common/adminInterfaces';
|
||||
import { isCommand, processCommand, clamp, flatten, includes, randomPoint } from '../common/utils';
|
||||
import { isCommand, processCommand, clamp, flatten, includes, randomPoint, parseSeason, parseHoliday } from '../common/utils';
|
||||
import { createNotifyUpdate, createShutdownServer } from './api/internal';
|
||||
import { logger } from './logger';
|
||||
import { pathTo } from './paths';
|
||||
@@ -83,25 +83,6 @@ function adminModChat(names: string[], help: string, role: string, type: Message
|
||||
});
|
||||
}
|
||||
|
||||
function parseSeason(value: string): Season | undefined {
|
||||
switch (value.toLowerCase()) {
|
||||
case 'spring': return Season.Spring;
|
||||
case 'summer': return Season.Summer;
|
||||
case 'autumn': return Season.Autumn;
|
||||
case 'winter': return Season.Winter;
|
||||
default: return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
function parseHoliday(value: string): Holiday | undefined {
|
||||
switch (value.toLowerCase()) {
|
||||
case 'none': return Holiday.None;
|
||||
case 'halloween': return Holiday.Halloween;
|
||||
case 'christmas': return Holiday.Christmas;
|
||||
default: return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
function parseWeather(value: string): Weather | undefined {
|
||||
switch (value.toLowerCase()) {
|
||||
case 'none': return Weather.None;
|
||||
|
||||
@@ -29,6 +29,8 @@ export interface AppConfig {
|
||||
trackingID: string;
|
||||
};
|
||||
assetsPath?: string;
|
||||
season?: string;
|
||||
holiday?: string;
|
||||
oauth: { [key: string]: any };
|
||||
servers: ServerConfig[];
|
||||
facebookAppId?: string;
|
||||
|
||||
@@ -29,6 +29,8 @@ import { liveSettings } from './liveSettings';
|
||||
import { createIsSuspiciousMessage } from '../common/security';
|
||||
import { updateCharacterState } from './characterUtils';
|
||||
import { FriendsService } from './services/friends';
|
||||
import { config } from './config';
|
||||
import { parseSeason, parseHoliday } from '../common/utils';
|
||||
|
||||
async function refreshSettings(account: IAccount) {
|
||||
const a = await Account.findOne({ _id: account._id }, 'settings').exec();
|
||||
@@ -59,8 +61,8 @@ export function createServerActionsFactory(
|
||||
const statesCounter = new CounterService<CharacterState>(10 * SECOND);
|
||||
const logChatMessage: LogChat = (client, text, type, ignored, target) => chat(server, client, text, type, ignored, target);
|
||||
|
||||
world.season = SEASON;
|
||||
world.holiday = HOLIDAY;
|
||||
world.season = parseSeason(server.season) || parseSeason(config.season) || SEASON;
|
||||
world.holiday = parseHoliday(server.holiday) || parseHoliday(config.holiday) || HOLIDAY;
|
||||
|
||||
try {
|
||||
const hidingData = fs.readFileSync(hidingDataPath(server.id), 'utf8');
|
||||
|
||||
Reference in New Issue
Block a user