Weather values randomized if no number is given as a command argument
This commit is contained in:
parent
d7ac70662a
commit
edb7836e55
@ -22,7 +22,12 @@ export default class ToggleFogCommand extends BaseEvent {
|
||||
|
||||
const args = ChatService.getArgs('fog', data.message)
|
||||
|
||||
if (args![0]) {
|
||||
await WeatherManager.setFogValue(Number(args![0]))
|
||||
}
|
||||
else {
|
||||
await WeatherManager.setFogValue(null)
|
||||
}
|
||||
|
||||
} catch (error: any) {
|
||||
this.logger.error('command error', error.message)
|
||||
|
@ -22,8 +22,12 @@ export default class ToggleRainCommand extends BaseEvent {
|
||||
|
||||
let args = ChatService.getArgs('rain', data.message)
|
||||
|
||||
//if no arguments are given, should default to random
|
||||
if (args![0]) {
|
||||
await WeatherManager.setRainValue(Number(args![0]))
|
||||
}
|
||||
else {
|
||||
await WeatherManager.setRainValue(null)
|
||||
}
|
||||
|
||||
} catch (error: any) {
|
||||
this.logger.error('command error', error.message)
|
||||
|
@ -48,18 +48,18 @@ class WeatherManager {
|
||||
}
|
||||
}
|
||||
|
||||
public async setRainValue(value? : number): Promise<void> {
|
||||
if (value === undefined) {
|
||||
value = this.weatherState.rainPercentage > 0 ? 0 : this.randomWeatherValue('rain')
|
||||
public async setRainValue(value : number | null): Promise<void> {
|
||||
if (value === null) {
|
||||
value = this.randomWeatherValue('rain')
|
||||
}
|
||||
|
||||
this.updateWeatherProperty('rain', value)
|
||||
await this.saveAndEmitWeather()
|
||||
}
|
||||
|
||||
public async setFogValue(value? : number): Promise<void> {
|
||||
if (value === undefined) {
|
||||
value = this.weatherState.fogDensity > 0 ? 0 : this.randomWeatherValue('fog')
|
||||
public async setFogValue(value : number | null): Promise<void> {
|
||||
if (value === null) {
|
||||
value = this.randomWeatherValue('fog')
|
||||
}
|
||||
|
||||
this.updateWeatherProperty('fog', value)
|
||||
@ -127,7 +127,7 @@ class WeatherManager {
|
||||
let world = await worldRepository.getFirst()
|
||||
if (!world) world = new World()
|
||||
|
||||
//left them in here because the
|
||||
//the data model still contains the booleans
|
||||
await world
|
||||
.setRainPercentage(this.weatherState.rainPercentage)
|
||||
.setIsRainEnabled(this.weatherState.rainPercentage > 0)
|
||||
|
Loading…
x
Reference in New Issue
Block a user