mirror of
https://github.com/rafi1212122/PemukulPaku
synced 2025-12-13 10:24:34 +01:00
yae openworld but dialogs aren't triggered
This commit is contained in:
54
Common/Database/OpenWorld.cs
Normal file
54
Common/Database/OpenWorld.cs
Normal file
@@ -0,0 +1,54 @@
|
||||
using Common.Utils.ExcelReader;
|
||||
using MongoDB.Bson;
|
||||
using MongoDB.Driver;
|
||||
|
||||
namespace Common.Database
|
||||
{
|
||||
public class OpenWorld
|
||||
{
|
||||
public static readonly IMongoCollection<OpenWorldScheme> collection = Global.db.GetCollection<OpenWorldScheme>("OpenWorlds");
|
||||
public static readonly uint[] ShowMapList = new uint[] { 1, 2, 301, 401, 601, 701, 801, 1001 };
|
||||
|
||||
public static void InitData(uint uid)
|
||||
{
|
||||
collection.InsertMany(OpenWorldMap.GetInstance().All.Select(x => (uint)x.MapId).Select(mapId =>
|
||||
{
|
||||
return new OpenWorldScheme()
|
||||
{
|
||||
MapId = mapId,
|
||||
Cycle = OpenWorldCycleData.GetInstance().GetInitCycle(mapId),
|
||||
OwnerUid = uid,
|
||||
QuestLevel = 1,
|
||||
HasTakeFinishRewardCycle = 0,
|
||||
SpawnPoint = ""
|
||||
};
|
||||
}));
|
||||
}
|
||||
|
||||
public static List<OpenWorldScheme> FromUid(uint uid)
|
||||
{
|
||||
List<OpenWorldScheme> Data = collection.AsQueryable().Where(x => x.OwnerUid == uid && ShowMapList.Contains(x.MapId)).ToList();
|
||||
if(Data.Count > 0)
|
||||
return Data;
|
||||
InitData(uid);
|
||||
return collection.AsQueryable().Where(x => x.OwnerUid == uid && ShowMapList.Contains(x.MapId)).ToList(); ;
|
||||
}
|
||||
}
|
||||
|
||||
#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
|
||||
public class OpenWorldScheme
|
||||
{
|
||||
public ObjectId Id { get; set; }
|
||||
public uint OwnerUid { get; set; }
|
||||
public uint MapId { get; set; }
|
||||
public uint Cycle { get; set; }
|
||||
public uint QuestLevel { get; set; }
|
||||
public uint HasTakeFinishRewardCycle { get; set; }
|
||||
public string SpawnPoint { get; set; }
|
||||
|
||||
public void Save()
|
||||
{
|
||||
OpenWorld.collection.ReplaceOne(Builders<OpenWorldScheme>.Filter.Eq(x => x.Id, Id), this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -89,6 +89,7 @@ namespace Common.Database
|
||||
public uint AbyssGroupLevel { get; set; }
|
||||
public List<AvatarTeam> AvatarTeamList { get; set; }
|
||||
public List<CustomAvatarTeam> CustomAvatarTeamList { get; set; }
|
||||
public List<OpenWorldStoryScheme> OpenWorldStory { get; set; } = new();
|
||||
|
||||
public void Save()
|
||||
{
|
||||
@@ -108,6 +109,32 @@ namespace Common.Database
|
||||
Exp = PlayerLevelData.GetInstance().GetMaxPossibleExp();
|
||||
}
|
||||
}
|
||||
|
||||
public void AddOWStory(uint storyId)
|
||||
{
|
||||
OpenWorldStory.Add(new()
|
||||
{
|
||||
StoryId = storyId,
|
||||
StoryProgress = 0,
|
||||
AcceptTime = (uint)Global.GetUnixInSeconds(),
|
||||
IsDone = false
|
||||
});
|
||||
}
|
||||
|
||||
public class OpenWorldStoryScheme : OpenworldStory
|
||||
{
|
||||
public bool IsDone;
|
||||
|
||||
public OpenworldStory ToProto()
|
||||
{
|
||||
return new()
|
||||
{
|
||||
StoryId = StoryId,
|
||||
StoryProgress = StoryProgress,
|
||||
AcceptTime = AcceptTime
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
#pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ namespace Common
|
||||
public static readonly MongoClient MongoClient = new(config.DatabaseUri);
|
||||
public static readonly IMongoDatabase db = MongoClient.GetDatabase("PemukulPaku");
|
||||
public static long GetUnixInSeconds() => ((DateTimeOffset)DateTime.UtcNow).ToUnixTimeSeconds();
|
||||
public static uint GetRandomSeed() => (uint)(GetUnixInSeconds() * new Random().Next(1, 10) / 10);
|
||||
}
|
||||
|
||||
public interface IConfig
|
||||
|
||||
53
Common/Utils/ExcelReader/OpenWorldCycleData.cs
Normal file
53
Common/Utils/ExcelReader/OpenWorldCycleData.cs
Normal file
@@ -0,0 +1,53 @@
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Common.Utils.ExcelReader
|
||||
{
|
||||
public class OpenWorldCycleData : BaseExcelReader<OpenWorldCycleData, OpenWorldCycleDataExcel>
|
||||
{
|
||||
public override string FileName { get { return "OpenWorldCycleData.json"; } }
|
||||
|
||||
public uint GetInitCycle(uint mapId)
|
||||
{
|
||||
return (uint?)All.Where(x => x.CycleMap == mapId).OrderBy(x => x.Cycle).FirstOrDefault()?.Cycle ?? 0;
|
||||
}
|
||||
|
||||
public uint GetNextCycle(uint mapId, uint cycle)
|
||||
{
|
||||
return (uint?)All.Where(x => x.CycleMap == mapId && x.Cycle > cycle).OrderBy(x => x.Cycle).FirstOrDefault()?.Cycle ?? cycle;
|
||||
}
|
||||
}
|
||||
|
||||
#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
|
||||
public partial class OpenWorldCycleDataExcel
|
||||
{
|
||||
[JsonProperty("level")]
|
||||
public int Level { get; set; }
|
||||
|
||||
[JsonProperty("needstory")]
|
||||
public int Needstory { get; set; }
|
||||
|
||||
[JsonProperty("finishreward")]
|
||||
public int Finishreward { get; set; }
|
||||
|
||||
[JsonProperty("cycleMap")]
|
||||
public int CycleMap { get; set; }
|
||||
|
||||
[JsonProperty("hardLvKey")]
|
||||
public string HardLvKey { get; set; }
|
||||
|
||||
[JsonProperty("CycleName")]
|
||||
public HashName CycleName { get; set; }
|
||||
|
||||
[JsonProperty("EntranceScene")]
|
||||
public int EntranceScene { get; set; }
|
||||
|
||||
[JsonProperty("EntranceImg1")]
|
||||
public string EntranceImg1 { get; set; }
|
||||
|
||||
[JsonProperty("DataImpl")]
|
||||
public object DataImpl { get; set; }
|
||||
|
||||
[JsonProperty("cycle")]
|
||||
public int Cycle { get; set; }
|
||||
}
|
||||
}
|
||||
77
Common/Utils/ExcelReader/OpenWorldMap.cs
Normal file
77
Common/Utils/ExcelReader/OpenWorldMap.cs
Normal file
@@ -0,0 +1,77 @@
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Common.Utils.ExcelReader
|
||||
{
|
||||
public class OpenWorldMap : BaseExcelReader<OpenWorldMap, OpenWorldMapExcel>
|
||||
{
|
||||
public override string FileName { get { return "OpenWorldMap.json"; } }
|
||||
}
|
||||
|
||||
#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
|
||||
public partial class OpenWorldMapExcel
|
||||
{
|
||||
[JsonProperty("MapType")]
|
||||
public int MapType { get; set; }
|
||||
|
||||
[JsonProperty("UnlockLv")]
|
||||
public int UnlockLv { get; set; }
|
||||
|
||||
[JsonProperty("UnlockStoryId")]
|
||||
public int UnlockStoryId { get; set; }
|
||||
|
||||
[JsonProperty("ShowTime")]
|
||||
public string ShowTime { get; set; }
|
||||
|
||||
[JsonProperty("UnlockTime")]
|
||||
public string UnlockTime { get; set; }
|
||||
|
||||
[JsonProperty("QuestSlotNum")]
|
||||
public int QuestSlotNum { get; set; }
|
||||
|
||||
[JsonProperty("QuestSettleType")]
|
||||
public int QuestSettleType { get; set; }
|
||||
|
||||
[JsonProperty("MapNameText")]
|
||||
public HashName MapNameText { get; set; }
|
||||
|
||||
[JsonProperty("MapContentText")]
|
||||
public HashName MapContentText { get; set; }
|
||||
|
||||
[JsonProperty("HpRecoverInterval")]
|
||||
public int HpRecoverInterval { get; set; }
|
||||
|
||||
[JsonProperty("HpRecoverPercent")]
|
||||
public int HpRecoverPercent { get; set; }
|
||||
|
||||
[JsonProperty("QuestMapUIManager")]
|
||||
public string QuestMapUiManager { get; set; }
|
||||
|
||||
[JsonProperty("SelectDailyQuestPage")]
|
||||
public string SelectDailyQuestPage { get; set; }
|
||||
|
||||
[JsonProperty("SettlementPage")]
|
||||
public string SettlementPage { get; set; }
|
||||
|
||||
[JsonProperty("ShopOpenWorldPage")]
|
||||
public string ShopOpenWorldPage { get; set; }
|
||||
|
||||
[JsonProperty("ShopTypeList")]
|
||||
public object[] ShopTypeList { get; set; }
|
||||
|
||||
[JsonProperty("MapInfoText")]
|
||||
public HashName MapInfoText { get; set; }
|
||||
|
||||
[JsonProperty("QuestInfoText")]
|
||||
public HashName QuestInfoText { get; set; }
|
||||
|
||||
[JsonProperty("MapSelectPath")]
|
||||
public string MapSelectPath { get; set; }
|
||||
|
||||
[JsonProperty("DataImpl")]
|
||||
public object DataImpl { get; set; }
|
||||
|
||||
[JsonProperty("MapId")]
|
||||
public int MapId { get; set; }
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user