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