Last active
December 27, 2023 03:23
-
-
Save zyzsdy/ecf41a4cc04e2f95839a72291a207347 to your computer and use it in GitHub Desktop.
FFXIV简易版时间和天气计算库
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//I 艾欧泽亚时间 | |
//1. 当前艾欧泽亚时间 | |
let nowET = new EorzeaClock(); // EorzeaClock {date: Sun Jul 27 2955 22:23:11 GMT+0800 (中国标准时间)} | |
// 注意这里的date元素在打印的时候加上了本地时区,但是实际的艾欧泽亚时间是取UTC的时间 | |
//2. 小时分钟字符串(常见表示形式) | |
nowET.toHourMinuteString(); // 14:24 | |
//3. 基于小时的时间差计算(其他的不常用就没有提供) | |
// 这里返回的是一个新的EorzeaClock | |
nowET.addHours(8); // EorzeaClock {date: Mon Jul 28 2955 06:23:11 GMT+0800 (中国标准时间)} | |
//4. 转换回当地时间 | |
// 返回值是一个Date对象 | |
nowET.getLocalTime(); // Tue Nov 28 2017 22:51:57 GMT+0800 (中国标准时间) | |
// II 艾欧泽亚天气 | |
// FF14生成天气的原理是:根据当前时间生成一个天气种子,值可能是0~99,然后根据各地区天气出现的比例确定最后的天气。 | |
// 任何一个时间,不管在什么地区,这个天气种子总是一致的。因此可以根据一个种子生成当时所有地区的天气。 | |
//例子: 生成当前黄金港的天气 | |
// nowET是一个EorzeaClock对象,表示当前艾欧泽亚时间 | |
let weatherSeeds = EorzeaWeather.forecastSeed(nowET, [0]); // [5] | |
// 上面这里生成的weatherSeed可以用来当前所有地区的天气 | |
EorzeaWeather.getForecast("area.Kugane", weatherSeeds); // ["weather.Rain"] | |
//函数说明: | |
// EorzeaWeather.forecastSeed用于获得一段时间的天气种子。 | |
// 参数1: 需要计算的艾欧泽亚时间,EorzeaClock对象 | |
// 参数2: 偏移数组,n表示当前天气的下n个天气,n为负数时表示之前n个天气。当前天气n取0。比如[-2, 0, 5]就表示计算出前两个,当前,下五个三个天气种子。 | |
EorzeaWeather.forecastSeed(nowET, [-1, 0, 1, 2, 3]); | |
// 返回值:这些对应时间的天气种子 | |
// EorzeaWeather.getForecast用于计算某地区在给定种子下的天气信息。 | |
// 参数1,地区名,需要用本代码中定义的token形式。比如"area.Kugane"表示黄金港。 | |
// 参数2,种子数组,是前一个函数getForecast的返回值 | |
// 返回值:这些对应时间的实际天气,是本代码中定义的token形式表示的,比如"weather.Rain"表示小雨。 | |
// 辅助函数 | |
EorzeaWeather.calcBaseDate(nowET); //EorzeaClock {date: Sun Jul 27 2955 16:00:00 GMT+0800 (中国标准时间)} | |
EorzeaWeather.calcBaseDate(nowET).toHourMinuteString(); // 08:00 | |
//这个函数的参数是一个EorzeaClock对象,返回一个新的EorzeaClock对象,这个新的对象所表示的艾欧泽亚时间是当前时间的天气基准时间(08:00,16:00, 24:00) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict"; | |
var EorzeaAreaWeather = { | |
"area.LimsaLominsa": { | |
name: "area.LimsaLominsa", | |
weatherRate: [ | |
{ rate: 20, weather: "weather.Clouds" }, | |
{ rate: 30, weather: "weather.ClearSkies" }, | |
{ rate: 30, weather: "weather.FairSkies" }, | |
{ rate: 10, weather: "weather.Fog" }, | |
{ rate: -1, weather: "weather.Rain" } | |
] | |
}, | |
"area.MiddleLa": { | |
name: "area.MiddleLa", | |
weatherRate: [ | |
{ rate: 20, weather: "weather.Clouds" }, | |
{ rate: 30, weather: "weather.ClearSkies" }, | |
{ rate: 20, weather: "weather.FairSkies" }, | |
{ rate: 10, weather: "weather.Wind" }, | |
{ rate: 10, weather: "weather.Fog" }, | |
{ rate: -1, weather: "weather.Rain" }, | |
] | |
}, | |
"area.LowerLa": { | |
name: "area.LowerLa", | |
weatherRate: [ | |
{ rate: 20, weather: "weather.Clouds" }, | |
{ rate: 30, weather: "weather.ClearSkies" }, | |
{ rate: 20, weather: "weather.FairSkies" }, | |
{ rate: 10, weather: "weather.Wind" }, | |
{ rate: 10, weather: "weather.Fog" }, | |
{ rate: -1, weather: "weather.Rain" }, | |
] | |
}, | |
"area.EasternLa": { | |
name: "area.EasternLa", | |
weatherRate: [ | |
{ rate: 5, weather: "weather.Fog" }, | |
{ rate: 45, weather: "weather.ClearSkies" }, | |
{ rate: 30, weather: "weather.FairSkies" }, | |
{ rate: 10, weather: "weather.Clouds" }, | |
{ rate: 5, weather: "weather.Rain" }, | |
{ rate: -1, weather: "weather.Showers" }, | |
] | |
}, | |
"area.WesternLa": { | |
name: "area.WesternLa", | |
weatherRate: [ | |
{ rate: 10, weather: "weather.Fog" }, | |
{ rate: 30, weather: "weather.ClearSkies" }, | |
{ rate: 20, weather: "weather.FairSkies" }, | |
{ rate: 20, weather: "weather.Clouds" }, | |
{ rate: 10, weather: "weather.Wind" }, | |
{ rate: -1, weather: "weather.Gales" }, | |
] | |
}, | |
"area.UpperLa": { | |
name: "area.UpperLa", | |
weatherRate: [ | |
{ rate: 30, weather: "weather.ClearSkies" }, | |
{ rate: 20, weather: "weather.FairSkies" }, | |
{ rate: 20, weather: "weather.Clouds" }, | |
{ rate: 10, weather: "weather.Fog" }, | |
{ rate: 10, weather: "weather.Thunder" }, | |
{ rate: -1, weather: "weather.Thunderstorms" }, | |
] | |
}, | |
"area.OuterLa": { | |
name: "area.OuterLa", | |
weatherRate: [ | |
{ rate: 30, weather: "weather.ClearSkies" }, | |
{ rate: 20, weather: "weather.FairSkies" }, | |
{ rate: 20, weather: "weather.Clouds" }, | |
{ rate: 15, weather: "weather.Fog" }, | |
{ rate: -1, weather: "weather.Rain" }, | |
] | |
}, | |
"area.Mist": { | |
name: "area.Mist", | |
weatherRate: [ | |
{ rate: 20, weather: "weather.Clouds" }, | |
{ rate: 30, weather: "weather.ClearSkies" }, | |
{ rate: 20, weather: "weather.FairSkies" }, | |
{ rate: 10, weather: "weather.FairSkies" }, | |
{ rate: 10, weather: "weather.Fog" }, | |
{ rate: -1, weather: "weather.Rain" }, | |
] | |
}, | |
"area.Wolves": { | |
name: "area.Wolves", | |
weatherRate: [ | |
{ rate: 20, weather: "weather.Clouds" }, | |
{ rate: 30, weather: "weather.ClearSkies" }, | |
{ rate: 30, weather: "weather.FairSkies" }, | |
{ rate: 10, weather: "weather.Fog" }, | |
{ rate: -1, weather: "weather.Thunderstorms" }, | |
] | |
}, | |
"area.Gridania": { | |
name: "area.Gridania", | |
weatherRate: [ | |
{ rate: 5, weather: "weather.Rain" }, | |
{ rate: 15, weather: "weather.Rain" }, | |
{ rate: 10, weather: "weather.Fog" }, | |
{ rate: 10, weather: "weather.Clouds" }, | |
{ rate: 15, weather: "weather.FairSkies" }, | |
{ rate: 30, weather: "weather.ClearSkies" }, | |
{ rate: -1, weather: "weather.FairSkies" }, | |
] | |
}, | |
"area.CentralShroud": { | |
name: "area.CentralShroud", | |
weatherRate: [ | |
{ rate: 5, weather: "weather.Thunder" }, | |
{ rate: 15, weather: "weather.Rain" }, | |
{ rate: 10, weather: "weather.Fog" }, | |
{ rate: 10, weather: "weather.Clouds" }, | |
{ rate: 15, weather: "weather.FairSkies" }, | |
{ rate: 30, weather: "weather.ClearSkies" }, | |
{ rate: -1, weather: "weather.FairSkies" }, | |
] | |
}, | |
"area.EastShroud": { | |
name: "area.EastShroud", | |
weatherRate: [ | |
{ rate: 5, weather: "weather.Thunder" }, | |
{ rate: 15, weather: "weather.Rain" }, | |
{ rate: 10, weather: "weather.Fog" }, | |
{ rate: 10, weather: "weather.Clouds" }, | |
{ rate: 15, weather: "weather.FairSkies" }, | |
{ rate: 30, weather: "weather.ClearSkies" }, | |
{ rate: -1, weather: "weather.FairSkies" }, | |
] | |
}, | |
"area.SouthShroud": { | |
name: "area.SouthShroud", | |
weatherRate: [ | |
{ rate: 5, weather: "weather.Fog" }, | |
{ rate: 5, weather: "weather.Thunderstorms" }, | |
{ rate: 15, weather: "weather.Thunder" }, | |
{ rate: 5, weather: "weather.Fog" }, | |
{ rate: 10, weather: "weather.Clouds" }, | |
{ rate: 30, weather: "weather.FairSkies" }, | |
{ rate: -1, weather: "weather.ClearSkies" }, | |
] | |
}, | |
"area.NorthShroud": { | |
name: "area.NorthShroud", | |
weatherRate: [ | |
{ rate: 5, weather: "weather.Fog" }, | |
{ rate: 5, weather: "weather.Showers" }, | |
{ rate: 15, weather: "weather.Rain" }, | |
{ rate: 5, weather: "weather.Fog" }, | |
{ rate: 10, weather: "weather.Clouds" }, | |
{ rate: 30, weather: "weather.FairSkies" }, | |
{ rate: -1, weather: "weather.ClearSkies" }, | |
] | |
}, | |
"area.TheLavenderBeds": { | |
name: "area.TheLavenderBeds", | |
weatherRate: [ | |
{ rate: 5, weather: "weather.Clouds" }, | |
{ rate: 15, weather: "weather.Rain" }, | |
{ rate: 10, weather: "weather.Fog" }, | |
{ rate: 10, weather: "weather.Clouds" }, | |
{ rate: 15, weather: "weather.FairSkies" }, | |
{ rate: 30, weather: "weather.ClearSkies" }, | |
{ rate: -1, weather: "weather.FairSkies" }, | |
] | |
}, | |
"area.Uldah": { | |
name: "area.Uldah", | |
weatherRate: [ | |
{ rate: 40, weather: "weather.ClearSkies" }, | |
{ rate: 20, weather: "weather.FairSkies" }, | |
{ rate: 25, weather: "weather.Clouds" }, | |
{ rate: 10, weather: "weather.Fog" }, | |
{ rate: -1, weather: "weather.Rain" }, | |
] | |
}, | |
"area.WesternThanalan": { | |
name: "area.WesternThanalan", | |
weatherRate: [ | |
{ rate: 40, weather: "weather.ClearSkies" }, | |
{ rate: 20, weather: "weather.FairSkies" }, | |
{ rate: 25, weather: "weather.Clouds" }, | |
{ rate: 10, weather: "weather.Fog" }, | |
{ rate: -1, weather: "weather.Rain" }, | |
] | |
}, | |
"area.CentralThanalan": { | |
name: "area.CentralThanalan", | |
weatherRate: [ | |
{ rate: 15, weather: "weather.DustStorms" }, | |
{ rate: 40, weather: "weather.ClearSkies" }, | |
{ rate: 20, weather: "weather.FairSkies" }, | |
{ rate: 10, weather: "weather.Clouds" }, | |
{ rate: 10, weather: "weather.Fog" }, | |
{ rate: -1, weather: "weather.Rain" }, | |
] | |
}, | |
"area.EasternThanalan": { | |
name: "area.EasternThanalan", | |
weatherRate: [ | |
{ rate: 40, weather: "weather.ClearSkies" }, | |
{ rate: 20, weather: "weather.FairSkies" }, | |
{ rate: 10, weather: "weather.Clouds" }, | |
{ rate: 10, weather: "weather.Fog" }, | |
{ rate: 5, weather: "weather.Rain" }, | |
{ rate: -1, weather: "weather.Showers" }, | |
] | |
}, | |
"area.SouthernThanalan": { | |
name: "area.SouthernThanalan", | |
weatherRate: [ | |
{ rate: 20, weather: "weather.HeatWaves" }, | |
{ rate: 40, weather: "weather.ClearSkies" }, | |
{ rate: 20, weather: "weather.FairSkies" }, | |
{ rate: 10, weather: "weather.Clouds" }, | |
{ rate: -1, weather: "weather.Fog" }, | |
] | |
}, | |
"area.NorthernThanalan": { | |
name: "area.NorthernThanalan", | |
weatherRate: [ | |
{ rate: 5, weather: "weather.ClearSkies" }, | |
{ rate: 15, weather: "weather.FairSkies" }, | |
{ rate: 30, weather: "weather.Clouds" }, | |
{ rate: -1, weather: "weather.Fog" }, | |
] | |
}, | |
"area.TheGoblet": { | |
name: "area.TheGoblet", | |
weatherRate: [ | |
{ rate: 40, weather: "weather.ClearSkies" }, | |
{ rate: 20, weather: "weather.FairSkies" }, | |
{ rate: 25, weather: "weather.Clouds" }, | |
{ rate: 10, weather: "weather.Fog" }, | |
{ rate: -1, weather: "weather.Rain" }, | |
] | |
}, | |
"area.MorDhona": { | |
name: "area.MorDhona", | |
weatherRate: [ | |
{ rate: 15, weather: "weather.Clouds" }, | |
{ rate: 15, weather: "weather.Fog" }, | |
{ rate: 30, weather: "weather.Gloom" }, | |
{ rate: 15, weather: "weather.ClearSkies" }, | |
{ rate: -1, weather: "weather.FairSkies" }, | |
] | |
}, | |
"area.Ishgard": { | |
name: "area.Ishgard", | |
weatherRate: [ | |
{ rate: 60, weather: "weather.Snow" }, | |
{ rate: 10, weather: "weather.FairSkies" }, | |
{ rate: 5, weather: "weather.ClearSkies" }, | |
{ rate: 15, weather: "weather.Clouds" }, | |
{ rate: -1, weather: "weather.Fog" }, | |
] | |
}, | |
"area.CoerthasCentral": { | |
name: "area.CoerthasCentral", | |
weatherRate: [ | |
{ rate: 20, weather: "weather.Blizzards" }, | |
{ rate: 40, weather: "weather.Snow" }, | |
{ rate: 10, weather: "weather.FairSkies" }, | |
{ rate: 5, weather: "weather.ClearSkies" }, | |
{ rate: 15, weather: "weather.Clouds" }, | |
{ rate: -1, weather: "weather.Fog" }, | |
] | |
}, | |
"area.CoerthasWestern": { | |
name: "area.CoerthasWestern", | |
weatherRate: [ | |
{ rate: 20, weather: "weather.Blizzards" }, | |
{ rate: 40, weather: "weather.Snow" }, | |
{ rate: 10, weather: "weather.FairSkies" }, | |
{ rate: 5, weather: "weather.ClearSkies" }, | |
{ rate: 15, weather: "weather.Clouds" }, | |
{ rate: -1, weather: "weather.Fog" }, | |
] | |
}, | |
"area.TheSeaofClouds": { | |
name: "area.TheSeaofClouds", | |
weatherRate: [ | |
{ rate: 30, weather: "weather.ClearSkies" }, | |
{ rate: 30, weather: "weather.FairSkies" }, | |
{ rate: 10, weather: "weather.Clouds" }, | |
{ rate: 10, weather: "weather.Fog" }, | |
{ rate: 10, weather: "weather.Wind" }, | |
{ rate: -1, weather: "weather.UmbralWind" }, | |
] | |
}, | |
"area.AzysLla": { | |
name: "area.AzysLla", | |
weatherRate: [ | |
{ rate: 35, weather: "weather.FairSkies" }, | |
{ rate: 35, weather: "weather.Clouds" }, | |
{ rate: -1, weather: "weather.Thunder" }, | |
] | |
}, | |
"area.DravanianForelands": { | |
name: "area.DravanianForelands", | |
weatherRate: [ | |
{ rate: 10, weather: "weather.Clouds" }, | |
{ rate: 10, weather: "weather.Fog" }, | |
{ rate: 10, weather: "weather.Thunder" }, | |
{ rate: 10, weather: "weather.DustStorms" }, | |
{ rate: 30, weather: "weather.ClearSkies" }, | |
{ rate: -1, weather: "weather.FairSkies" }, | |
] | |
}, | |
"area.DravanianHinterlands": { | |
name: "area.DravanianHinterlands", | |
weatherRate: [ | |
{ rate: 10, weather: "weather.Clouds" }, | |
{ rate: 10, weather: "weather.Fog" }, | |
{ rate: 10, weather: "weather.Rain" }, | |
{ rate: 10, weather: "weather.Showers" }, | |
{ rate: 30, weather: "weather.ClearSkies" }, | |
{ rate: -1, weather: "weather.FairSkies" }, | |
] | |
}, | |
"area.ChurningMists": { | |
name: "area.ChurningMists", | |
weatherRate: [ | |
{ rate: 10, weather: "weather.Clouds" }, | |
{ rate: 10, weather: "weather.Gales" }, | |
{ rate: 20, weather: "weather.UmbralStatic" }, | |
{ rate: 30, weather: "weather.ClearSkies" }, | |
{ rate: -1, weather: "weather.FairSkies" }, | |
] | |
}, | |
"area.Idyllshire": { | |
name: "area.Idyllshire", | |
weatherRate: [ | |
{ rate: 10, weather: "weather.Clouds" }, | |
{ rate: 10, weather: "weather.Fog" }, | |
{ rate: 10, weather: "weather.Rain" }, | |
{ rate: 10, weather: "weather.Showers" }, | |
{ rate: 30, weather: "weather.ClearSkies" }, | |
{ rate: -1, weather: "weather.FairSkies" }, | |
] | |
}, | |
"area.RhalgrsReach": { | |
name: "area.RhalgrsReach", | |
weatherRate: [ | |
{ rate: 15, weather: "weather.ClearSkies" }, | |
{ rate: 45, weather: "weather.FairSkies" }, | |
{ rate: 20, weather: "weather.Clouds" }, | |
{ rate: 10, weather: "weather.Fog" }, | |
{ rate: -1, weather: "weather.Thunder" }, | |
] | |
}, | |
"area.TheFringes": { | |
name: "area.TheFringes", | |
weatherRate: [ | |
{ rate: 15, weather: "weather.ClearSkies" }, | |
{ rate: 45, weather: "weather.FairSkies" }, | |
{ rate: 20, weather: "weather.Clouds" }, | |
{ rate: 10, weather: "weather.Fog" }, | |
{ rate: -1, weather: "weather.Thunder" }, | |
] | |
}, | |
"area.ThePeaks": { | |
name: "area.ThePeaks", | |
weatherRate: [ | |
{ rate: 10, weather: "weather.ClearSkies" }, | |
{ rate: 50, weather: "weather.FairSkies" }, | |
{ rate: 15, weather: "weather.Clouds" }, | |
{ rate: 10, weather: "weather.Fog" }, | |
{ rate: 10, weather: "weather.Wind" }, | |
{ rate: -1, weather: "weather.DustStorms" }, | |
] | |
}, | |
"area.TheLochs": { | |
name: "area.TheLochs", | |
weatherRate: [ | |
{ rate: 20, weather: "weather.ClearSkies" }, | |
{ rate: 40, weather: "weather.FairSkies" }, | |
{ rate: 20, weather: "weather.Clouds" }, | |
{ rate: 10, weather: "weather.Fog" }, | |
{ rate: -1, weather: "weather.Thunderstorms" }, | |
] | |
}, | |
"area.Kugane": { | |
name: "area.Kugane", | |
weatherRate: [ | |
{ rate: 10, weather: "weather.Rain" }, | |
{ rate: 10, weather: "weather.Fog" }, | |
{ rate: 20, weather: "weather.Clouds" }, | |
{ rate: 40, weather: "weather.FairSkies" }, | |
{ rate: -1, weather: "weather.ClearSkies" }, | |
] | |
}, | |
"area.Shirogane": { | |
name: "area.Shirogane", | |
weatherRate: [ | |
{ rate: 10, weather: "weather.Rain" }, | |
{ rate: 10, weather: "weather.Fog" }, | |
{ rate: 20, weather: "weather.Clouds" }, | |
{ rate: 40, weather: "weather.FairSkies" }, | |
{ rate: -1, weather: "weather.ClearSkies" }, | |
] | |
}, | |
"area.RubySea": { | |
name: "area.RubySea", | |
weatherRate: [ | |
{ rate: 10, weather: "weather.Thunder" }, | |
{ rate: 10, weather: "weather.Wind" }, | |
{ rate: 15, weather: "weather.Clouds" }, | |
{ rate: 40, weather: "weather.FairSkies" }, | |
{ rate: -1, weather: "weather.ClearSkies" }, | |
] | |
}, | |
"area.Yanxia": { | |
name: "area.Yanxia", | |
weatherRate: [ | |
{ rate: 5, weather: "weather.Showers" }, | |
{ rate: 10, weather: "weather.Rain" }, | |
{ rate: 10, weather: "weather.Fog" }, | |
{ rate: 15, weather: "weather.Clouds" }, | |
{ rate: 40, weather: "weather.FairSkies" }, | |
{ rate: -1, weather: "weather.ClearSkies" }, | |
] | |
}, | |
"area.AzimSteppe": { | |
name: "area.AzimSteppe", | |
weatherRate: [ | |
{ rate: 5, weather: "weather.Gales" }, | |
{ rate: 5, weather: "weather.Wind" }, | |
{ rate: 7, weather: "weather.Rain" }, | |
{ rate: 8, weather: "weather.Fog" }, | |
{ rate: 10, weather: "weather.Clouds" }, | |
{ rate: 40, weather: "weather.FairSkies" }, | |
{ rate: -1, weather: "weather.ClearSkies" }, | |
] | |
} | |
}; | |
var EorzeaClock = /** @class */ (function () { | |
function EorzeaClock(ts) { | |
if (ts === void 0) { ts = undefined; } | |
if (ts !== undefined) { | |
this.date = new Date(ts); | |
} | |
else { | |
this.date = new Date(((new Date()).getTime()) * EorzeaClock.ratio); | |
} | |
} | |
EorzeaClock.prototype.getHours = function () { | |
return this.date.getUTCHours(); | |
}; | |
EorzeaClock.prototype.addHours = function (hourspan) { | |
return new EorzeaClock(this.date.getTime() + (hourspan * 3600000)); | |
}; | |
EorzeaClock.prototype.getMinutes = function () { | |
return this.date.getUTCMinutes(); | |
}; | |
EorzeaClock.prototype.getDays = function () { | |
return Math.floor(this.date.getTime() / 86400000); | |
}; | |
EorzeaClock.prototype.getLocalTime = function () { | |
return new Date(this.date.getTime() / EorzeaClock.ratio); | |
}; | |
EorzeaClock.prototype.toHourMinuteString = function () { | |
var hour = this.getHours(); | |
var hs = ""; | |
if (hour < 10) { | |
hs = "0" + hour; | |
} | |
else { | |
hs += hour; | |
} | |
var min = this.getMinutes(); | |
var ms = ""; | |
if (min < 10) { | |
ms = "0" + min; | |
} | |
else { | |
ms += min; | |
} | |
return hs + ":" + ms; | |
}; | |
EorzeaClock.ratio = 1440 / 70; | |
return EorzeaClock; | |
}()); | |
var EorzeaWeather = /** @class */ (function () { | |
function EorzeaWeather() { | |
} | |
EorzeaWeather.calcBaseDate = function (time) { | |
var tempDate = new EorzeaClock(time.date.getTime()); | |
var bh = tempDate.getHours() - tempDate.getHours() % 8; | |
tempDate.date.setUTCHours(bh); | |
tempDate.date.setMinutes(0); | |
tempDate.date.setSeconds(0); | |
return tempDate; | |
}; | |
EorzeaWeather.forecastSeed = function (time, initSeeds) { | |
if (initSeeds === void 0) { initSeeds = [0]; } | |
function calcSeed(base) { | |
var step1 = (base << 11 ^ base) >>> 0; | |
var step2 = (step1 >>> 8 ^ step1) >>> 0; | |
return step2 % 100; | |
} | |
return initSeeds | |
.map(function (x) { return time.addHours(8 * x); }) | |
.map(function (t) { return t.getDays() * 100 + ((t.getHours() + 8 - t.getHours() % 8) % 24); }) | |
.map(function (i) { return calcSeed(i); }); | |
}; | |
EorzeaWeather.getForecast = function (areaName, seeds) { | |
function getWeather(rates, seed) { | |
for (var _i = 0, rates_1 = rates; _i < rates_1.length; _i++) { | |
var r = rates_1[_i]; | |
if (r.rate == -1) { | |
return r.weather; | |
} | |
if (seed < r.rate) { | |
return r.weather; | |
} | |
else { | |
seed -= r.rate; | |
} | |
} | |
return "N/A"; | |
} | |
try { | |
var areaRateData_1 = EorzeaAreaWeather[areaName]; | |
return seeds.map(function (s) { return getWeather(areaRateData_1.weatherRate, s); }); | |
} | |
catch (err) { | |
throw new ReferenceError("requested area name is not exist."); | |
} | |
}; | |
return EorzeaWeather; | |
}()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict";var EorzeaAreaWeather={"area.LimsaLominsa":{name:"area.LimsaLominsa",weatherRate:[{rate:20,weather:"weather.Clouds"},{rate:30,weather:"weather.ClearSkies"},{rate:30,weather:"weather.FairSkies"},{rate:10,weather:"weather.Fog"},{rate:-1,weather:"weather.Rain"}]},"area.MiddleLa":{name:"area.MiddleLa",weatherRate:[{rate:20,weather:"weather.Clouds"},{rate:30,weather:"weather.ClearSkies"},{rate:20,weather:"weather.FairSkies"},{rate:10,weather:"weather.Wind"},{rate:10,weather:"weather.Fog"},{rate:-1,weather:"weather.Rain"}]},"area.LowerLa":{name:"area.LowerLa",weatherRate:[{rate:20,weather:"weather.Clouds"},{rate:30,weather:"weather.ClearSkies"},{rate:20,weather:"weather.FairSkies"},{rate:10,weather:"weather.Wind"},{rate:10,weather:"weather.Fog"},{rate:-1,weather:"weather.Rain"}]},"area.EasternLa":{name:"area.EasternLa",weatherRate:[{rate:5,weather:"weather.Fog"},{rate:45,weather:"weather.ClearSkies"},{rate:30,weather:"weather.FairSkies"},{rate:10,weather:"weather.Clouds"},{rate:5,weather:"weather.Rain"},{rate:-1,weather:"weather.Showers"}]},"area.WesternLa":{name:"area.WesternLa",weatherRate:[{rate:10,weather:"weather.Fog"},{rate:30,weather:"weather.ClearSkies"},{rate:20,weather:"weather.FairSkies"},{rate:20,weather:"weather.Clouds"},{rate:10,weather:"weather.Wind"},{rate:-1,weather:"weather.Gales"}]},"area.UpperLa":{name:"area.UpperLa",weatherRate:[{rate:30,weather:"weather.ClearSkies"},{rate:20,weather:"weather.FairSkies"},{rate:20,weather:"weather.Clouds"},{rate:10,weather:"weather.Fog"},{rate:10,weather:"weather.Thunder"},{rate:-1,weather:"weather.Thunderstorms"}]},"area.OuterLa":{name:"area.OuterLa",weatherRate:[{rate:30,weather:"weather.ClearSkies"},{rate:20,weather:"weather.FairSkies"},{rate:20,weather:"weather.Clouds"},{rate:15,weather:"weather.Fog"},{rate:-1,weather:"weather.Rain"}]},"area.Mist":{name:"area.Mist",weatherRate:[{rate:20,weather:"weather.Clouds"},{rate:30,weather:"weather.ClearSkies"},{rate:20,weather:"weather.FairSkies"},{rate:10,weather:"weather.FairSkies"},{rate:10,weather:"weather.Fog"},{rate:-1,weather:"weather.Rain"}]},"area.Wolves":{name:"area.Wolves",weatherRate:[{rate:20,weather:"weather.Clouds"},{rate:30,weather:"weather.ClearSkies"},{rate:30,weather:"weather.FairSkies"},{rate:10,weather:"weather.Fog"},{rate:-1,weather:"weather.Thunderstorms"}]},"area.Gridania":{name:"area.Gridania",weatherRate:[{rate:5,weather:"weather.Rain"},{rate:15,weather:"weather.Rain"},{rate:10,weather:"weather.Fog"},{rate:10,weather:"weather.Clouds"},{rate:15,weather:"weather.FairSkies"},{rate:30,weather:"weather.ClearSkies"},{rate:-1,weather:"weather.FairSkies"}]},"area.CentralShroud":{name:"area.CentralShroud",weatherRate:[{rate:5,weather:"weather.Thunder"},{rate:15,weather:"weather.Rain"},{rate:10,weather:"weather.Fog"},{rate:10,weather:"weather.Clouds"},{rate:15,weather:"weather.FairSkies"},{rate:30,weather:"weather.ClearSkies"},{rate:-1,weather:"weather.FairSkies"}]},"area.EastShroud":{name:"area.EastShroud",weatherRate:[{rate:5,weather:"weather.Thunder"},{rate:15,weather:"weather.Rain"},{rate:10,weather:"weather.Fog"},{rate:10,weather:"weather.Clouds"},{rate:15,weather:"weather.FairSkies"},{rate:30,weather:"weather.ClearSkies"},{rate:-1,weather:"weather.FairSkies"}]},"area.SouthShroud":{name:"area.SouthShroud",weatherRate:[{rate:5,weather:"weather.Fog"},{rate:5,weather:"weather.Thunderstorms"},{rate:15,weather:"weather.Thunder"},{rate:5,weather:"weather.Fog"},{rate:10,weather:"weather.Clouds"},{rate:30,weather:"weather.FairSkies"},{rate:-1,weather:"weather.ClearSkies"}]},"area.NorthShroud":{name:"area.NorthShroud",weatherRate:[{rate:5,weather:"weather.Fog"},{rate:5,weather:"weather.Showers"},{rate:15,weather:"weather.Rain"},{rate:5,weather:"weather.Fog"},{rate:10,weather:"weather.Clouds"},{rate:30,weather:"weather.FairSkies"},{rate:-1,weather:"weather.ClearSkies"}]},"area.TheLavenderBeds":{name:"area.TheLavenderBeds",weatherRate:[{rate:5,weather:"weather.Clouds"},{rate:15,weather:"weather.Rain"},{rate:10,weather:"weather.Fog"},{rate:10,weather:"weather.Clouds"},{rate:15,weather:"weather.FairSkies"},{rate:30,weather:"weather.ClearSkies"},{rate:-1,weather:"weather.FairSkies"}]},"area.Uldah":{name:"area.Uldah",weatherRate:[{rate:40,weather:"weather.ClearSkies"},{rate:20,weather:"weather.FairSkies"},{rate:25,weather:"weather.Clouds"},{rate:10,weather:"weather.Fog"},{rate:-1,weather:"weather.Rain"}]},"area.WesternThanalan":{name:"area.WesternThanalan",weatherRate:[{rate:40,weather:"weather.ClearSkies"},{rate:20,weather:"weather.FairSkies"},{rate:25,weather:"weather.Clouds"},{rate:10,weather:"weather.Fog"},{rate:-1,weather:"weather.Rain"}]},"area.CentralThanalan":{name:"area.CentralThanalan",weatherRate:[{rate:15,weather:"weather.DustStorms"},{rate:40,weather:"weather.ClearSkies"},{rate:20,weather:"weather.FairSkies"},{rate:10,weather:"weather.Clouds"},{rate:10,weather:"weather.Fog"},{rate:-1,weather:"weather.Rain"}]},"area.EasternThanalan":{name:"area.EasternThanalan",weatherRate:[{rate:40,weather:"weather.ClearSkies"},{rate:20,weather:"weather.FairSkies"},{rate:10,weather:"weather.Clouds"},{rate:10,weather:"weather.Fog"},{rate:5,weather:"weather.Rain"},{rate:-1,weather:"weather.Showers"}]},"area.SouthernThanalan":{name:"area.SouthernThanalan",weatherRate:[{rate:20,weather:"weather.HeatWaves"},{rate:40,weather:"weather.ClearSkies"},{rate:20,weather:"weather.FairSkies"},{rate:10,weather:"weather.Clouds"},{rate:-1,weather:"weather.Fog"}]},"area.NorthernThanalan":{name:"area.NorthernThanalan",weatherRate:[{rate:5,weather:"weather.ClearSkies"},{rate:15,weather:"weather.FairSkies"},{rate:30,weather:"weather.Clouds"},{rate:-1,weather:"weather.Fog"}]},"area.TheGoblet":{name:"area.TheGoblet",weatherRate:[{rate:40,weather:"weather.ClearSkies"},{rate:20,weather:"weather.FairSkies"},{rate:25,weather:"weather.Clouds"},{rate:10,weather:"weather.Fog"},{rate:-1,weather:"weather.Rain"}]},"area.MorDhona":{name:"area.MorDhona",weatherRate:[{rate:15,weather:"weather.Clouds"},{rate:15,weather:"weather.Fog"},{rate:30,weather:"weather.Gloom"},{rate:15,weather:"weather.ClearSkies"},{rate:-1,weather:"weather.FairSkies"}]},"area.Ishgard":{name:"area.Ishgard",weatherRate:[{rate:60,weather:"weather.Snow"},{rate:10,weather:"weather.FairSkies"},{rate:5,weather:"weather.ClearSkies"},{rate:15,weather:"weather.Clouds"},{rate:-1,weather:"weather.Fog"}]},"area.CoerthasCentral":{name:"area.CoerthasCentral",weatherRate:[{rate:20,weather:"weather.Blizzards"},{rate:40,weather:"weather.Snow"},{rate:10,weather:"weather.FairSkies"},{rate:5,weather:"weather.ClearSkies"},{rate:15,weather:"weather.Clouds"},{rate:-1,weather:"weather.Fog"}]},"area.CoerthasWestern":{name:"area.CoerthasWestern",weatherRate:[{rate:20,weather:"weather.Blizzards"},{rate:40,weather:"weather.Snow"},{rate:10,weather:"weather.FairSkies"},{rate:5,weather:"weather.ClearSkies"},{rate:15,weather:"weather.Clouds"},{rate:-1,weather:"weather.Fog"}]},"area.TheSeaofClouds":{name:"area.TheSeaofClouds",weatherRate:[{rate:30,weather:"weather.ClearSkies"},{rate:30,weather:"weather.FairSkies"},{rate:10,weather:"weather.Clouds"},{rate:10,weather:"weather.Fog"},{rate:10,weather:"weather.Wind"},{rate:-1,weather:"weather.UmbralWind"}]},"area.AzysLla":{name:"area.AzysLla",weatherRate:[{rate:35,weather:"weather.FairSkies"},{rate:35,weather:"weather.Clouds"},{rate:-1,weather:"weather.Thunder"}]},"area.DravanianForelands":{name:"area.DravanianForelands",weatherRate:[{rate:10,weather:"weather.Clouds"},{rate:10,weather:"weather.Fog"},{rate:10,weather:"weather.Thunder"},{rate:10,weather:"weather.DustStorms"},{rate:30,weather:"weather.ClearSkies"},{rate:-1,weather:"weather.FairSkies"}]},"area.DravanianHinterlands":{name:"area.DravanianHinterlands",weatherRate:[{rate:10,weather:"weather.Clouds"},{rate:10,weather:"weather.Fog"},{rate:10,weather:"weather.Rain"},{rate:10,weather:"weather.Showers"},{rate:30,weather:"weather.ClearSkies"},{rate:-1,weather:"weather.FairSkies"}]},"area.ChurningMists":{name:"area.ChurningMists",weatherRate:[{rate:10,weather:"weather.Clouds"},{rate:10,weather:"weather.Gales"},{rate:20,weather:"weather.UmbralStatic"},{rate:30,weather:"weather.ClearSkies"},{rate:-1,weather:"weather.FairSkies"}]},"area.Idyllshire":{name:"area.Idyllshire",weatherRate:[{rate:10,weather:"weather.Clouds"},{rate:10,weather:"weather.Fog"},{rate:10,weather:"weather.Rain"},{rate:10,weather:"weather.Showers"},{rate:30,weather:"weather.ClearSkies"},{rate:-1,weather:"weather.FairSkies"}]},"area.RhalgrsReach":{name:"area.RhalgrsReach",weatherRate:[{rate:15,weather:"weather.ClearSkies"},{rate:45,weather:"weather.FairSkies"},{rate:20,weather:"weather.Clouds"},{rate:10,weather:"weather.Fog"},{rate:-1,weather:"weather.Thunder"}]},"area.TheFringes":{name:"area.TheFringes",weatherRate:[{rate:15,weather:"weather.ClearSkies"},{rate:45,weather:"weather.FairSkies"},{rate:20,weather:"weather.Clouds"},{rate:10,weather:"weather.Fog"},{rate:-1,weather:"weather.Thunder"}]},"area.ThePeaks":{name:"area.ThePeaks",weatherRate:[{rate:10,weather:"weather.ClearSkies"},{rate:50,weather:"weather.FairSkies"},{rate:15,weather:"weather.Clouds"},{rate:10,weather:"weather.Fog"},{rate:10,weather:"weather.Wind"},{rate:-1,weather:"weather.DustStorms"}]},"area.TheLochs":{name:"area.TheLochs",weatherRate:[{rate:20,weather:"weather.ClearSkies"},{rate:40,weather:"weather.FairSkies"},{rate:20,weather:"weather.Clouds"},{rate:10,weather:"weather.Fog"},{rate:-1,weather:"weather.Thunderstorms"}]},"area.Kugane":{name:"area.Kugane",weatherRate:[{rate:10,weather:"weather.Rain"},{rate:10,weather:"weather.Fog"},{rate:20,weather:"weather.Clouds"},{rate:40,weather:"weather.FairSkies"},{rate:-1,weather:"weather.ClearSkies"}]},"area.Shirogane":{name:"area.Shirogane",weatherRate:[{rate:10,weather:"weather.Rain"},{rate:10,weather:"weather.Fog"},{rate:20,weather:"weather.Clouds"},{rate:40,weather:"weather.FairSkies"},{rate:-1,weather:"weather.ClearSkies"}]},"area.RubySea":{name:"area.RubySea",weatherRate:[{rate:10,weather:"weather.Thunder"},{rate:10,weather:"weather.Wind"},{rate:15,weather:"weather.Clouds"},{rate:40,weather:"weather.FairSkies"},{rate:-1,weather:"weather.ClearSkies"}]},"area.Yanxia":{name:"area.Yanxia",weatherRate:[{rate:5,weather:"weather.Showers"},{rate:10,weather:"weather.Rain"},{rate:10,weather:"weather.Fog"},{rate:15,weather:"weather.Clouds"},{rate:40,weather:"weather.FairSkies"},{rate:-1,weather:"weather.ClearSkies"}]},"area.AzimSteppe":{name:"area.AzimSteppe",weatherRate:[{rate:5,weather:"weather.Gales"},{rate:5,weather:"weather.Wind"},{rate:7,weather:"weather.Rain"},{rate:8,weather:"weather.Fog"},{rate:10,weather:"weather.Clouds"},{rate:40,weather:"weather.FairSkies"},{rate:-1,weather:"weather.ClearSkies"}]}};var EorzeaClock=function(){function EorzeaClock(ts){if(ts===void 0){ts=undefined}if(ts!==undefined){this.date=new Date(ts)}else{this.date=new Date((new Date).getTime()*EorzeaClock.ratio)}}EorzeaClock.prototype.getHours=function(){return this.date.getUTCHours()};EorzeaClock.prototype.addHours=function(hourspan){return new EorzeaClock(this.date.getTime()+hourspan*36e5)};EorzeaClock.prototype.getMinutes=function(){return this.date.getUTCMinutes()};EorzeaClock.prototype.getDays=function(){return Math.floor(this.date.getTime()/864e5)};EorzeaClock.prototype.getLocalTime=function(){return new Date(this.date.getTime()/EorzeaClock.ratio)};EorzeaClock.prototype.toHourMinuteString=function(){var hour=this.getHours();var hs="";if(hour<10){hs="0"+hour}else{hs+=hour}var min=this.getMinutes();var ms="";if(min<10){ms="0"+min}else{ms+=min}return hs+":"+ms};EorzeaClock.ratio=1440/70;return EorzeaClock}();var EorzeaWeather=function(){function EorzeaWeather(){}EorzeaWeather.calcBaseDate=function(time){var tempDate=new EorzeaClock(time.date.getTime());var bh=tempDate.getHours()-tempDate.getHours()%8;tempDate.date.setUTCHours(bh);tempDate.date.setMinutes(0);tempDate.date.setSeconds(0);return tempDate};EorzeaWeather.forecastSeed=function(time,initSeeds){if(initSeeds===void 0){initSeeds=[0]}function calcSeed(base){var step1=(base<<11^base)>>>0;var step2=(step1>>>8^step1)>>>0;return step2%100}return initSeeds.map(function(x){return time.addHours(8*x)}).map(function(t){return t.getDays()*100+(t.getHours()+8-t.getHours()%8)%24}).map(function(i){return calcSeed(i)})};EorzeaWeather.getForecast=function(areaName,seeds){function getWeather(rates,seed){for(var _i=0,rates_1=rates;_i<rates_1.length;_i++){var r=rates_1[_i];if(r.rate==-1){return r.weather}if(seed<r.rate){return r.weather}else{seed-=r.rate}}return"N/A"}try{var areaRateData_1=EorzeaAreaWeather[areaName];return seeds.map(function(s){return getWeather(areaRateData_1.weatherRate,s)})}catch(err){throw new ReferenceError("requested area name is not exist.")}};return EorzeaWeather}(); |
请问不同区域的天气概率表是怎么得到的 有没有关于记录这个表的项目。
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
不好意思,经过时间很长才看到,您的问题是否已经解决了?
优雷卡天气是 30% - 晴朗, 30% - 强风, 30% - 暴雨, 剩余10% - 小雪。
在本库中的表示方法如下:
这段代码是与其他的工具开发者交流时分享使用的,这一交流结果是这个项目:https://github.com/AnnAngela/FFXIVSightseeingGuide
如果你对这些工作感兴趣,请关注上面这个项目而不是这段分享的代码。