Adjust the test based on the time range of the room injector.

调整测试基于时间范围的房间注入器。
This commit is contained in:
Cold-Mint 2024-05-31 20:37:15 +08:00
parent a957c91ffe
commit 91cffd4866
Signed by: Cold-Mint
GPG Key ID: C5A9BF8A98E0CE99
7 changed files with 50 additions and 23 deletions

View File

@ -46,7 +46,7 @@
"res://prefab/roomTemplates/dungeon/" "res://prefab/roomTemplates/dungeon/"
], ],
"Tags": null, "Tags": null,
"RoomInjectionProcessorData": "[\n {\n \"Id\": \"Chance\",\n \"Config\": \"{\\\"Chance\\\":35.5}\"\n }\n]" "RoomInjectionProcessorData": "[\n {\n \"Id\": \"TimeInterval\",\n \"Config\": \"{\\\"DateSpecifiesLevel\\\":0,\\\"StartTime\\\":\\\"2024/1/1 20:34:23\\\",\\\"EndTime\\\":\\\"2025/1/1 20:34:23\\\"}\"\n }\n]"
} }
] ]
} }

View File

@ -17,3 +17,4 @@ place_existing_rooms,放置已存在的房间{0}。,Place existing rooms {0}.,
room_placement_failed,房间{0}放置失败。,Room {0} placement failed.,部屋{0}の放置に失敗します。 room_placement_failed,房间{0}放置失败。,Room {0} placement failed.,部屋{0}の放置に失敗します。
room_placement_information,房间{0}已被成功放置在{1}。,Room {0} has been successfully placed in {1}.,部屋{0}を{1}に配置しました。 room_placement_information,房间{0}已被成功放置在{1}。,Room {0} has been successfully placed in {1}.,部屋{0}を{1}に配置しました。
room_injection_processor_does_not_exist,找不到房间注入处理器{0}请检测是否在MapGenerator内注册。,"Room injection processor {0} not found, check to see if it is registered in MapGenerator.",部屋注入プロセッサ{0}が見つかりません、MapGenerator内に登録されているかどうか検出してください。 room_injection_processor_does_not_exist,找不到房间注入处理器{0}请检测是否在MapGenerator内注册。,"Room injection processor {0} not found, check to see if it is registered in MapGenerator.",部屋注入プロセッサ{0}が見つかりません、MapGenerator内に登録されているかどうか検出してください。
time_range_debug,当前时间:{0}起始时间:{1},结束时间{2},是否在范围内{3},"Current time: {0} Start time: {1}, end time {2}, whether in range {3}",現在時間:{0}開始時間:{1}終了時間{2}範囲内かどうか{3}です
1 id zh en jp
17 room_placement_failed 房间{0}放置失败。 Room {0} placement failed. 部屋{0}の放置に失敗します。
18 room_placement_information 房间{0}已被成功放置在{1}。 Room {0} has been successfully placed in {1}. 部屋{0}を{1}に配置しました。
19 room_injection_processor_does_not_exist 找不到房间注入处理器{0},请检测是否在MapGenerator内注册。 Room injection processor {0} not found, check to see if it is registered in MapGenerator. 部屋注入プロセッサ{0}が見つかりません、MapGenerator内に登録されているかどうか検出してください。
20 time_range_debug 当前时间:{0}起始时间:{1},结束时间{2},是否在范围内{3} Current time: {0} Start time: {1}, end time {2}, whether in range {3} 現在時間:{0}開始時間:{1}終了時間{2}範囲内かどうか{3}です

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -35,16 +35,47 @@ public class
configData.EndTime = configData.StartTime; configData.EndTime = configData.StartTime;
} }
var now = DateTime.Now; if (configData.DateSpecifiesLevel == null)
if (!configData.SpecifiedYear)
{ {
//If no year is specified, it is automatically added to the current year //If no date level is specified, the default is 0
//若未指定年份,则自动补充为当前年份 //若未指定日期等级则默认为0
var nowYear = now.Year; configData.DateSpecifiesLevel = 0;
configData.StartTime = $"{nowYear}-{configData.StartTime}";
configData.EndTime = $"{nowYear}-{configData.EndTime}";
} }
var now = DateTime.Now;
var nowYear = now.Year;
var nowMonth = now.Month;
switch (configData.DateSpecifiesLevel)
{
case 0:
//The complete time is specified in the format yyyy/MM/dd hh:mm:ss
//指定了完整的时间格式如yyyy/MM/dd hh:mm:ss
break;
case 1:
//No year is specified. The format is mm/dd hh:mm:ss
//未指定年份。格式如MM/dd hh:mm:ss
configData.StartTime = $"{nowYear}/{configData.StartTime}";
configData.EndTime = $"{nowYear}/{configData.EndTime}";
break;
case 2:
//No year and month are specified. The format is dd hh:mm:ss
//未指定年份和月份。格式如dd hh:mm:ss
configData.StartTime = $"{nowYear}/{nowMonth}/{configData.StartTime}";
configData.EndTime = $"{nowYear}/{nowMonth}/{configData.EndTime}";
break;
case 3:
//No year, month, and day are specified. The format is hh:mm:ss
//未指定年份、月份和日期。格式如hh:mm:ss
configData.StartTime = $"{nowYear}/{nowMonth}/{now.Day} {configData.StartTime}";
configData.EndTime = $"{nowYear}/{nowMonth}/{now.Day} {configData.EndTime}";
break;
case 4:
//No year, month, day, and hour are specified. The format is mm:ss
//未指定年份、月份、日期和小时。格式如mm:ss
configData.StartTime = $"{nowYear}/{nowMonth}/{now.Day} {now.Hour}:{configData.StartTime}";
configData.EndTime = $"{nowYear}/{nowMonth}/{now.Day} {now.Hour}:{configData.EndTime}";
break;
}
return Task.FromResult(TimeUtils.IsBetweenTimeSpan(now, configData.StartTime, configData.EndTime)); return Task.FromResult(TimeUtils.IsBetweenTimeSpan(now, configData.StartTime, configData.EndTime));
} }
@ -52,33 +83,25 @@ public class
public class ConfigData public class ConfigData
{ {
/// <summary> /// <summary>
/// <para>Whether to specify a year</para> /// <para>Date specifies the level</para>
/// <para>是否指定年份</para> /// <para>日期指定的等级</para>
/// </summary> /// </summary>
/// <remarks> /// <remarks>
///<para>If true, then Year can be specified in StartTime and EndTime. The specified year is used to be executed only once in a given year, while configurations that do not specify a year are automatically replenished with the current year (performed annually).</para> ///<para>Level 0: Specify complete yyyy/MM/DD hh:mm:ss, level 1: yyyy (year automatically uses this year), Level 2: yyyy/MM (year and month automatically uses this month), Level 3: yyyy/MM/DD (automatically uses today), level 4: yyyy/MM/dd hh(The current hour is automatically used)</para>
///<para>如果为true那么可以在StartTime和EndTime内指定Year。指定年份被用于在特定的年份仅执行一次而未指定年份的配置会自动补充为当前年份每年执行</para> ///<para>等级0指定完整的yyyy/MM/dd hh:mm:ss等级1yyyy年份自动采用今年等级2yyyy/MM年份和月份自动采用本年本月等级3yyyy/MM/dd自动采用今天等级4yyyy/MM/dd hh(自动采用当前小时)</para>
/// </remarks> /// </remarks>
public bool SpecifiedYear { get; set; } public int? DateSpecifiesLevel { get; set; }
/// <summary> /// <summary>
/// <para>Start time</para> /// <para>Start time</para>
/// <para>起始时间</para> /// <para>起始时间</para>
/// </summary> /// </summary>
/// <remarks>
///<para>If the year is not specified, enter data in the format MM-DD hh:mm:ss. If the year is specified, enter data in the format yyyy-MM-dd hh:mm:ss.</para>
///<para>若未指定年份则可填入格式为MM-dd hh:mm:ss的数据若指定了年份那么请填入yyyy-MM-dd hh:mm:ss格式数据。</para>
/// </remarks>
public string? StartTime { get; set; } public string? StartTime { get; set; }
/// <summary> /// <summary>
/// <para>End time</para> /// <para>End time</para>
/// <para>结束时间</para> /// <para>结束时间</para>
/// </summary> /// </summary>
/// <remarks>
///<para>See StartTime</para>
///<para>同StartTime</para>
/// </remarks>
public string? EndTime { get; set; } public string? EndTime { get; set; }
} }
} }

View File

@ -1,4 +1,5 @@
using System; using System;
using ColdMint.scripts.debug;
namespace ColdMint.scripts.utils; namespace ColdMint.scripts.utils;
@ -27,6 +28,8 @@ public static class TimeUtils
var dtEndTime = Convert.ToDateTime(endTime); var dtEndTime = Convert.ToDateTime(endTime);
var compNum1 = DateTime.Compare(dateTime, dtStartTime); var compNum1 = DateTime.Compare(dateTime, dtStartTime);
var compNum2 = DateTime.Compare(dateTime, dtEndTime); var compNum2 = DateTime.Compare(dateTime, dtEndTime);
return compNum1 >= 0 && compNum2 <= 0; var result = compNum1 >= 0 && compNum2 <= 0;
LogCat.LogWithFormat("time_range_debug", dateTime, dtStartTime, dtEndTime, result);
return result;
} }
} }