diff --git a/Library/Main.cs b/Library/Main.cs index 0f6b26f..103cacd 100644 --- a/Library/Main.cs +++ b/Library/Main.cs @@ -1,14 +1,14 @@ using Microsoft.Extensions.Logging; using Milimoe.FunGame.Core.Api.Utility; -using Oshima.FunGame.WebAPI.Controllers; using Oshima.FunGame.OshimaModules; using Oshima.FunGame.OshimaServers.Service; +using Oshima.FunGame.WebAPI.Controllers; -_ = new Milimoe.FunGame.Testing.Tests.CheckDLL(); +//_ = new Milimoe.FunGame.Testing.Tests.CheckDLL(); Console.WriteLine(); -_ = new Milimoe.FunGame.Testing.Tests.WebSocketTest(); +//_ = new Milimoe.FunGame.Testing.Tests.WebSocketTest(); CharacterModule cm = new(); cm.Load(); @@ -67,7 +67,7 @@ FunGameController controller = new(new Logger(new LoggerFacto //Console.WriteLine(user.Inventory.Characters.First().GetInfo(showEXP: true)); -Console.WriteLine(string.Join("", controller.FightCustom(1, 2, true))); +//Console.WriteLine(string.Join("", controller.FightCustom(1, 2, true))); //FunGameActionQueue.StartSimulationGame(true, true, true, true); //foreach (string str in controller.GetTest(false, true)) @@ -169,4 +169,4 @@ while (true) { Console.WriteLine(e); } -} +} diff --git a/Library/Solutions/Activity.cs b/Library/Solutions/Activity.cs index a946cae..409725e 100644 --- a/Library/Solutions/Activity.cs +++ b/Library/Solutions/Activity.cs @@ -3,6 +3,21 @@ using Milimoe.FunGame.Core.Library.Constant; namespace Milimoe.FunGame.Testing.Solutions { + public enum ActivityState + { + Future, + Upcoming, + InProgress, + Ended + } + + public enum RedeemResult + { + Success, + StockNotEnough, + PointsNotEnough + } + public class Activity(long id, string name, DateTime startTime, DateTime endTime) { public long Id { get; set; } = id; @@ -14,7 +29,6 @@ namespace Milimoe.FunGame.Testing.Solutions public Store Store { get; set; } = new Store(); // 事件 - public event EventHandler? ActivityStateChanged; public event EventHandler? UserAccessCheck; public void UpdateState() @@ -42,15 +56,9 @@ namespace Milimoe.FunGame.Testing.Solutions if (State != newState) { State = newState; - OnActivityStateChanged(new ActivityStateChangedEventArgs(State)); } } - protected virtual void OnActivityStateChanged(ActivityStateChangedEventArgs e) - { - ActivityStateChanged?.Invoke(this, e); - } - public bool AllowUserAccess(long userId) { UserAccessEventArgs args = new(userId, State, StartTime, EndTime); @@ -74,16 +82,11 @@ namespace Milimoe.FunGame.Testing.Solutions if (quest != null) { quest.Status = newStatus; - // 可选:触发任务状态更新事件 + Console.WriteLine($"活动状态已改变为:{newStatus}"); } } } - public class ActivityStateChangedEventArgs(ActivityState newState) : EventArgs - { - public ActivityState NewState { get; } = newState; - } - public class UserAccessEventArgs(long userId, ActivityState activityState, DateTime startTime, DateTime endTime) : EventArgs { public long UserId { get; } = userId; diff --git a/Library/Tests/ActivityExample.cs b/Library/Tests/ActivityExample.cs index e4f7d1d..7682463 100644 --- a/Library/Tests/ActivityExample.cs +++ b/Library/Tests/ActivityExample.cs @@ -2,6 +2,8 @@ using Milimoe.FunGame.Core.Entity; using Milimoe.FunGame.Core.Library.Constant; using Milimoe.FunGame.Testing.Solutions; +using ActivityState = Milimoe.FunGame.Testing.Solutions.ActivityState; +using RedeemResult = Milimoe.FunGame.Testing.Solutions.RedeemResult; namespace Milimoe.FunGame.Testing.Tests { @@ -56,12 +58,6 @@ namespace Milimoe.FunGame.Testing.Tests activity.Store.AddItem(item1, 100, 10); activity.Store.AddItem(item2, 200, 10); - // 订阅活动状态改变事件 - activity.ActivityStateChanged += (sender, e) => - { - Console.WriteLine($"活动状态已改变为:{e.NewState}"); - }; - // 订阅用户访问检查事件 activity.UserAccessCheck += (sender, e) => {