mirror of
https://github.com/Campofinale/CampofinaleBackup.git
synced 2025-12-12 22:54:37 +00:00
AdventureBookManager
This commit is contained in:
parent
35f8fbb2b2
commit
67d3acea54
@ -50,6 +50,9 @@
|
||||
<None Update="93_ScSceneMapMarkSync.json">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="Data\Conditions.json">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="Data\GachaHistory\index_noplayerfound.html">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
using Campofinale.Game.Character;
|
||||
using Campofinale.Game.Char;
|
||||
using Campofinale.Game.Inventory;
|
||||
using Campofinale.Packets.Sc;
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
using static Campofinale.Resource.ResourceManager;
|
||||
using Campofinale.Game.Character;
|
||||
using Campofinale.Game.Char;
|
||||
using Campofinale.Database;
|
||||
using Campofinale.Game.Inventory;
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
using Campofinale.Packets.Sc;
|
||||
using Campofinale.Resource;
|
||||
|
||||
namespace Campofinale.Game.Character
|
||||
namespace Campofinale.Game.Char
|
||||
{
|
||||
public static class CharacterManager
|
||||
{
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
using Campofinale.Database;
|
||||
using Campofinale.Game.Character;
|
||||
using Campofinale.Game.Char;
|
||||
using Campofinale.Packets.Sc;
|
||||
|
||||
namespace Campofinale.Commands.Handlers;
|
||||
|
||||
19
Campofinale/Data/Conditions.json
Normal file
19
Campofinale/Data/Conditions.json
Normal file
@ -0,0 +1,19 @@
|
||||
{
|
||||
"cond_ab_01_01":
|
||||
{
|
||||
"args": [
|
||||
"10"
|
||||
]
|
||||
},
|
||||
"cond_daily_001":{
|
||||
"args":[
|
||||
"DailyLogin"
|
||||
]
|
||||
},
|
||||
"cond_daily_005":
|
||||
{
|
||||
"args":[
|
||||
"DailyCharLevelUp"
|
||||
]
|
||||
}
|
||||
}
|
||||
@ -1,5 +1,6 @@
|
||||
using Campofinale.Game;
|
||||
using Campofinale.Game.Character;
|
||||
using Campofinale.Game.Adventure;
|
||||
using Campofinale.Game.Char;
|
||||
using Campofinale.Game.Gacha;
|
||||
using Campofinale.Game.Inventory;
|
||||
using Campofinale.Game.MissionSys;
|
||||
@ -9,6 +10,7 @@ using MongoDB.Bson.Serialization.Attributes;
|
||||
using MongoDB.Driver;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using static Campofinale.Game.Adventure.AdventureBookManager;
|
||||
using static Campofinale.Resource.ResourceManager;
|
||||
|
||||
namespace Campofinale.Database
|
||||
@ -33,6 +35,7 @@ namespace Campofinale.Database
|
||||
public long maxDashEnergy = 250;
|
||||
public uint curStamina;
|
||||
public long nextRecoverTime;
|
||||
public long nextDailyReset;
|
||||
public List<Scene> scenes = new();
|
||||
public Dictionary<int, List<int>> bitsets = new();
|
||||
public PlayerSafeZoneInfo savedSafeZone = new();
|
||||
@ -84,6 +87,10 @@ namespace Campofinale.Database
|
||||
{
|
||||
return _database.GetCollection<MissionData>("missionsData").Find(c => c.roleId == roleId).FirstOrDefault();
|
||||
}
|
||||
public AdventureBookData LoadAdventureBookData(ulong roleId)
|
||||
{
|
||||
return _database.GetCollection<AdventureBookData>("adventureBookData").Find(c => c.roleId == roleId).FirstOrDefault();
|
||||
}
|
||||
public List<Character> LoadCharacters(ulong roleId)
|
||||
{
|
||||
return _database.GetCollection<Character>("avatars").Find(c=>c.owner== roleId).ToList();
|
||||
@ -152,7 +159,8 @@ namespace Campofinale.Database
|
||||
bitsets=player.bitsetManager.bitsets,
|
||||
savedSafeZone = player.savedSaveZone,
|
||||
gender=player.gender,
|
||||
bag=player.inventoryManager.items.bag
|
||||
bag=player.inventoryManager.items.bag,
|
||||
nextDailyReset = player.nextDailyReset,
|
||||
};
|
||||
UpsertPlayerData(data);
|
||||
}
|
||||
@ -256,6 +264,23 @@ namespace Campofinale.Database
|
||||
new ReplaceOptions { IsUpsert = true }
|
||||
);
|
||||
}
|
||||
public void UpsertAdventureBookData(AdventureBookManager.AdventureBookData data)
|
||||
{
|
||||
if (data._id == ObjectId.Empty)
|
||||
{
|
||||
data._id = ObjectId.GenerateNewId();
|
||||
}
|
||||
var collection = _database.GetCollection<AdventureBookManager.AdventureBookData>("adventureBookData");
|
||||
|
||||
var filter =
|
||||
Builders<AdventureBookManager.AdventureBookData>.Filter.Eq(c => c.roleId, data.roleId);
|
||||
|
||||
var result = collection.ReplaceOne(
|
||||
filter,
|
||||
data,
|
||||
new ReplaceOptions { IsUpsert = true }
|
||||
);
|
||||
}
|
||||
public void UpsertCharacter(Character character)
|
||||
{
|
||||
if (character._id == ObjectId.Empty)
|
||||
@ -402,6 +427,6 @@ namespace Campofinale.Database
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
252
Campofinale/Game/Adventure/AdventureBookManager.cs
Normal file
252
Campofinale/Game/Adventure/AdventureBookManager.cs
Normal file
@ -0,0 +1,252 @@
|
||||
using Campofinale.Database;
|
||||
using Campofinale.Game.Factory;
|
||||
using Campofinale.Game.Spaceship;
|
||||
using Campofinale.Resource;
|
||||
using MongoDB.Bson.Serialization.Attributes;
|
||||
using MongoDB.Bson;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using static Campofinale.Resource.ResourceManager;
|
||||
using MongoDB.Bson.Serialization.IdGenerators;
|
||||
using Campofinale.Game.Char;
|
||||
using Campofinale.Resource.Json;
|
||||
using Campofinale.Protocol;
|
||||
|
||||
namespace Campofinale.Game.Adventure
|
||||
{
|
||||
public class AdventureBookManager
|
||||
{
|
||||
public Player player;
|
||||
public AdventureBookData data = new();
|
||||
|
||||
public AdventureBookManager(Player player)
|
||||
{
|
||||
this.player = player;
|
||||
}
|
||||
public void Load()
|
||||
{
|
||||
AdventureBookData toLoad= DatabaseManager.db.LoadAdventureBookData(player.roleId);
|
||||
if (toLoad != null)
|
||||
{
|
||||
data = toLoad;
|
||||
}
|
||||
else
|
||||
{
|
||||
data.roleId = player.roleId;
|
||||
}
|
||||
if (data.adventureBookStage == 0)
|
||||
{
|
||||
InitNextStage();
|
||||
}
|
||||
}
|
||||
|
||||
public void DailyReset()
|
||||
{
|
||||
data.tasks.RemoveAll(t => t.GetTaskTable().taskType == AdventureTaskType.Daily);
|
||||
data.dailyActivation = 0;
|
||||
data.dailyCharLevelUp = 0;
|
||||
data.dailyLogin = 0;
|
||||
ResourceManager.adventureTaskTable.Values.ToList().ForEach(task =>
|
||||
{
|
||||
if (task.taskType == AdventureTaskType.Daily)
|
||||
{
|
||||
data.tasks.Add(new GameAdventureTask()
|
||||
{
|
||||
adventureTaskId = task.adventureTaskId,
|
||||
claimed = false
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
public void Save()
|
||||
{
|
||||
DatabaseManager.db.UpsertAdventureBookData(data);
|
||||
}
|
||||
public void TaskUpdate(ConditionType condType, object obj=null)
|
||||
{
|
||||
List<GameAdventureTask> toUpdate = new();
|
||||
data.tasks.FindAll(t=>t.GetTaskTable().conditionType==condType).ForEach(task =>
|
||||
{
|
||||
if(task.TaskUpdate(this.player, obj))
|
||||
{
|
||||
toUpdate.Add(task);
|
||||
}
|
||||
});
|
||||
if (toUpdate.Count > 0)
|
||||
{
|
||||
ScAdventureTaskModify modify = new ScAdventureTaskModify()
|
||||
{
|
||||
|
||||
};
|
||||
toUpdate.ForEach(t =>
|
||||
{
|
||||
modify.Tasks.Add(t.ToProto());
|
||||
});
|
||||
player.Send(ScMsgId.ScAdventureTaskModify, modify);
|
||||
}
|
||||
}
|
||||
public void InitNextStage(bool notify=false)
|
||||
{
|
||||
data.adventureBookStage++;
|
||||
data.tasks.RemoveAll(t => t.GetTaskTable().taskType == AdventureTaskType.AdventureBook);
|
||||
ResourceManager.adventureTaskTable.Values.ToList().ForEach(task =>
|
||||
{
|
||||
if(task.adventureBookStage == data.adventureBookStage)
|
||||
{
|
||||
data.tasks.Add(new GameAdventureTask()
|
||||
{
|
||||
adventureTaskId = task.adventureTaskId,
|
||||
claimed=false
|
||||
});
|
||||
}
|
||||
});
|
||||
//TODO Update everything
|
||||
}
|
||||
|
||||
public void ClaimTask(string taskId)
|
||||
{
|
||||
data.tasks.ForEach(t =>
|
||||
{
|
||||
if (t.adventureTaskId == taskId && t.GetState() == AdventureTaskState.Completed)
|
||||
{
|
||||
t.ClaimRewards(player);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void ClaimTasks(AdventureTaskType taskType)
|
||||
{
|
||||
data.tasks.ForEach(t =>
|
||||
{
|
||||
if (t.GetTaskTable().taskType==taskType && t.GetState() == AdventureTaskState.Completed)
|
||||
{
|
||||
t.ClaimRewards(player);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public class GameAdventureTask
|
||||
{
|
||||
public string adventureTaskId;
|
||||
public int progress;
|
||||
public bool claimed;
|
||||
|
||||
public void ClaimRewards(Player player)
|
||||
{
|
||||
player.inventoryManager.AddRewards(GetTaskTable().rewardId, player.position, 0);
|
||||
claimed= true;
|
||||
ScAdventureTaskModify modify = new()
|
||||
{
|
||||
Tasks =
|
||||
{
|
||||
ToProto()
|
||||
}
|
||||
};
|
||||
player.Send(ScMsgId.ScAdventureTaskModify, modify);
|
||||
}
|
||||
public AdventureTaskState GetState()
|
||||
{
|
||||
if(progress < GetTaskTable().progressToCompare)
|
||||
{
|
||||
return AdventureTaskState.Processing;
|
||||
}else if (!claimed)
|
||||
{
|
||||
return AdventureTaskState.Completed;
|
||||
}
|
||||
else
|
||||
{
|
||||
return AdventureTaskState.Rewarded;
|
||||
}
|
||||
}
|
||||
public bool TaskUpdate(Player owner, object obj)
|
||||
{
|
||||
ConditionType condType = GetTaskTable().conditionType;
|
||||
ConditionData cond;
|
||||
if(ResourceManager.conditions.TryGetValue(GetTaskTable().conditionId, out cond))
|
||||
{
|
||||
int count = 0;
|
||||
switch (condType)
|
||||
{
|
||||
case ConditionType.CheckStatisticVal:
|
||||
switch (Enum.Parse(typeof(StatType), cond.Get(0)))
|
||||
{
|
||||
case StatType.DailyCharLevelUp:
|
||||
count = owner.adventureBookManager.data.dailyCharLevelUp;
|
||||
break;
|
||||
case StatType.DailyLogin:
|
||||
count = owner.adventureBookManager.data.dailyLogin;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (count > progress)
|
||||
{
|
||||
progress = count;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
case ConditionType.CheckGreaterCharLevelNum:
|
||||
count = 0;
|
||||
owner.chars.ForEach(c =>
|
||||
{
|
||||
if(c.level >= cond.ToInt(0))
|
||||
{
|
||||
count++;
|
||||
}
|
||||
});
|
||||
if (count > progress)
|
||||
{
|
||||
progress = count;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
public AdventureTaskTable GetTaskTable()
|
||||
{
|
||||
return ResourceManager.adventureTaskTable.Values.ToList().Find(a => a.adventureTaskId == adventureTaskId);
|
||||
}
|
||||
|
||||
public AdventureTask ToProto()
|
||||
{
|
||||
return new AdventureTask()
|
||||
{
|
||||
Progress = progress,
|
||||
State = (int)GetState(),
|
||||
TaskId = adventureTaskId,
|
||||
};
|
||||
}
|
||||
}
|
||||
public class AdventureBookData
|
||||
{
|
||||
[BsonId(IdGenerator = typeof(ObjectIdGenerator))]
|
||||
public ObjectId _id { get; set; }
|
||||
public ulong roleId;
|
||||
public int adventureBookStage = 0;
|
||||
public int dailyActivation = 0;
|
||||
public List<GameAdventureTask> tasks = new();
|
||||
public int dailyCharLevelUp = 0;
|
||||
public int dailyLogin = 0;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -10,7 +10,7 @@ using static Campofinale.Resource.ResourceManager;
|
||||
using static Campofinale.Resource.ResourceManager.CharGrowthTable;
|
||||
using static Campofinale.Resource.ResourceManager.WeaponUpgradeTemplateTable;
|
||||
|
||||
namespace Campofinale.Game.Character
|
||||
namespace Campofinale.Game.Char
|
||||
{
|
||||
public class Character
|
||||
{
|
||||
@ -459,8 +459,6 @@ namespace Campofinale.Game.Character
|
||||
ScCharLevelUp levelUp = new()
|
||||
{
|
||||
CharObjID = guid,
|
||||
|
||||
|
||||
};
|
||||
ScCharSyncLevelExp synclevel = new()
|
||||
{
|
||||
@ -471,6 +469,10 @@ namespace Campofinale.Game.Character
|
||||
GetOwner().Send(ScMsgId.ScCharSyncLevelExp, synclevel);
|
||||
GetOwner().Send(ScMsgId.ScCharLevelUp, levelUp);
|
||||
GetOwner().Send(new PacketScSyncWallet(GetOwner()));
|
||||
GetOwner().adventureBookManager.TaskUpdate(ConditionType.CheckGreaterCharLevelNum);
|
||||
GetOwner().adventureBookManager.TaskUpdate(ConditionType.CharMaxLevel);
|
||||
GetOwner().adventureBookManager.data.dailyCharLevelUp++;
|
||||
GetOwner().adventureBookManager.TaskUpdate(ConditionType.CheckStatisticVal);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -98,7 +98,7 @@ namespace Campofinale.Game.Entities
|
||||
GetOwner().Send(ScMsgId.ScCharSyncStatus, state);
|
||||
GetOwner().Send(ScMsgId.ScEntityPropertyChange, prop);
|
||||
}
|
||||
public Character.Character GetChar()
|
||||
public Char.Character GetChar()
|
||||
{
|
||||
return GetOwner().chars.Find(c => c.guid == guid);
|
||||
}
|
||||
|
||||
@ -63,8 +63,12 @@ namespace Campofinale.Game.Inventory
|
||||
{
|
||||
id=bundle.id
|
||||
};
|
||||
|
||||
if (!item.InstanceType())
|
||||
if(bundle.id == "item_daily_activation")
|
||||
{
|
||||
owner.adventureBookManager.data.dailyActivation += bundle.count;
|
||||
continue;
|
||||
}
|
||||
if (!item.InstanceType() || sourceType == 0)
|
||||
{
|
||||
item = AddItem(bundle.id, bundle.count);
|
||||
end.RewardVirtualList.Add(new RewardItem()
|
||||
|
||||
@ -46,7 +46,7 @@ namespace Campofinale.Game
|
||||
public void LoadCurrentTeamEntities()
|
||||
{
|
||||
globalEntities.RemoveAll(e => e is EntityCharacter);
|
||||
foreach (Character.Character chara in player.GetCurTeam())
|
||||
foreach (Char.Character chara in player.GetCurTeam())
|
||||
{
|
||||
EntityCharacter ch = new(chara.guid, player.roleId);
|
||||
globalEntities.Add(ch);
|
||||
|
||||
@ -156,7 +156,7 @@ namespace Campofinale.Http
|
||||
string appCode = ctx.Request.Query.Elements["appCode"];
|
||||
|
||||
|
||||
string resp = "{\"data\":{\"agreementUrl\":{\"register\":\"https://user.gryphline.com/{language}/protocol/plain/terms_of_service\",\"privacy\":\"https://user.gryphline.com/{language}/protocol/plain/privacy_policy\",\"unbind\":\"https://user.gryphline.com/{language}/protocol/plain/endfield/privacy_policy\",\"account\":\"https://user.gryphline.com/{language}/protocol/plain/terms_of_service\",\"game\":\"https://user.gryphline.com/{language}/protocol/plain/endfield/privacy_policy\"},\"app\":{\"googleAndroidClientId\":\"\",\"googleIosClientId\":\"\",\"enableAutoLogin\":true,\"enablePayment\":true,\"enableGuestRegister\":false,\"needShowName\":true,\"displayName\":{\"en-us\":\"Arknights: Endfield\",\"ja-jp\":\"アークナイツ:エンドフィールド\",\"ko-kr\":\"명일방주:엔드필드\",\"zh-cn\":\"明日方舟:终末地\",\"zh-tw\":\"明日方舟:終末地\"},\"unbindAgreement\":[],\"unbindLimitedDays\":30,\"unbindCoolDownDays\":14,\"customerServiceUrl\":\"https://gryphline.helpshift.com/hc/{language}/4-arknights-endfield\",\"enableUnbindGrant\":false},\"customerServiceUrl\":\"https://gryphline.helpshift.com/hc/{language}/4-arknights-endfield\",\"thirdPartyRedirectUrl\":\"https://web-api.gryphline.com/callback/thirdPartyAuth.html\",\"scanUrl\":{\"login\":\"yj://scan_login\"},\"loginChannels\":[],\"userCenterUrl\":\"https://user.gryphline.com/pcSdk/userInfo?language={language}\"},\"msg\":\"OK\",\"status\":0,\"type\":\"A\"}";
|
||||
string resp = "{\"data\":{\"agreementUrl\":{\"register\":\"https://user.gryphline.com/{language}/protocol/plain/terms_of_service\",\"privacy\":\"https://user.gryphline.com/{language}/protocol/plain/privacy_policy\",\"unbind\":\"https://user.gryphline.com/{language}/protocol/plain/endfield/privacy_policy\",\"account\":\"https://user.gryphline.com/{language}/protocol/plain/terms_of_service\",\"game\":\"https://user.gryphline.com/{language}/protocol/plain/endfield/privacy_policy\"},\"app\":{\"googleAndroidClientId\":\"\",\"googleIosClientId\":\"\",\"enableAutoLogin\":true,\"enablePayment\":true,\"enableGuestRegister\":true,\"needShowName\":true,\"displayName\":{\"en-us\":\"Arknights: Endfield\",\"ja-jp\":\"アークナイツ:エンドフィールド\",\"ko-kr\":\"명일방주:엔드필드\",\"zh-cn\":\"明日方舟:终末地\",\"zh-tw\":\"明日方舟:終末地\"},\"unbindAgreement\":[],\"unbindLimitedDays\":30,\"unbindCoolDownDays\":14,\"customerServiceUrl\":\"https://gryphline.helpshift.com/hc/{language}/4-arknights-endfield\",\"enableUnbindGrant\":false},\"customerServiceUrl\":\"https://gryphline.helpshift.com/hc/{language}/4-arknights-endfield\",\"thirdPartyRedirectUrl\":\"https://web-api.gryphline.com/callback/thirdPartyAuth.html\",\"scanUrl\":{\"login\":\"yj://scan_login\"},\"loginChannels\":[],\"userCenterUrl\":\"https://user.gryphline.com/pcSdk/userInfo?language={language}\"},\"msg\":\"OK\",\"status\":0,\"type\":\"A\"}";
|
||||
|
||||
if(appCode == "a65356244d22261b")
|
||||
{
|
||||
|
||||
19
Campofinale/Packets/Cs/HandleCsAdventureTakeRewardAll.cs
Normal file
19
Campofinale/Packets/Cs/HandleCsAdventureTakeRewardAll.cs
Normal file
@ -0,0 +1,19 @@
|
||||
using Campofinale.Network;
|
||||
using Campofinale.Protocol;
|
||||
using Campofinale.Resource;
|
||||
|
||||
namespace Campofinale.Packets.Cs
|
||||
{
|
||||
public class HandleCsAdventureTakeRewardAll
|
||||
{
|
||||
|
||||
[Server.Handler(CsMsgId.CsAdventureTakeRewardAll)]
|
||||
public static void Handle(Player session, CsMsgId cmdId, Packet packet)
|
||||
{
|
||||
CsAdventureTakeRewardAll req = packet.DecodeBody<CsAdventureTakeRewardAll>();
|
||||
//TODO
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@ -1,4 +1,4 @@
|
||||
using Campofinale.Game.Character;
|
||||
using Campofinale.Game.Char;
|
||||
using Campofinale.Game.Entities;
|
||||
using Campofinale.Network;
|
||||
using Campofinale.Protocol;
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
using Campofinale.Game.Character;
|
||||
using Campofinale.Game.Char;
|
||||
using Campofinale.Network;
|
||||
using Campofinale.Protocol;
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
using Campofinale.Game.Character;
|
||||
using Campofinale.Game.Char;
|
||||
using Campofinale.Network;
|
||||
using Campofinale.Protocol;
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
using Campofinale.Game.Character;
|
||||
using Campofinale.Game.Char;
|
||||
using Campofinale.Network;
|
||||
using Campofinale.Protocol;
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
using Campofinale.Game.Character;
|
||||
using Campofinale.Game.Char;
|
||||
using Campofinale.Network;
|
||||
using Campofinale.Protocol;
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
using Campofinale.Game.Character;
|
||||
using Campofinale.Game.Char;
|
||||
using Campofinale.Network;
|
||||
using Campofinale.Protocol;
|
||||
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
using BeyondTools.VFS.Crypto;
|
||||
using Campofinale.Database;
|
||||
using Campofinale.Game;
|
||||
using Campofinale.Game.Character;
|
||||
using Campofinale.Game.Char;
|
||||
using Campofinale.Network;
|
||||
using Campofinale.Packets.Sc;
|
||||
using Campofinale.Protocol;
|
||||
@ -211,8 +211,10 @@ namespace Campofinale.Packets.Cs
|
||||
session.EnterScene();
|
||||
session.Initialized = true;
|
||||
session.Update();
|
||||
|
||||
|
||||
session.adventureBookManager.data.dailyLogin++;
|
||||
session.adventureBookManager.TaskUpdate(ConditionType.CheckStatisticVal, null);
|
||||
|
||||
|
||||
}
|
||||
static byte[] GenerateRandomBytes(int length)
|
||||
{
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
using Campofinale.Game.Character;
|
||||
using Campofinale.Game.Char;
|
||||
using Campofinale.Game.Entities;
|
||||
using Campofinale.Network;
|
||||
using Campofinale.Protocol;
|
||||
|
||||
19
Campofinale/Packets/Cs/HandleCsTakeAdventureTaskReward.cs
Normal file
19
Campofinale/Packets/Cs/HandleCsTakeAdventureTaskReward.cs
Normal file
@ -0,0 +1,19 @@
|
||||
using Campofinale.Network;
|
||||
using Campofinale.Packets.Sc;
|
||||
using Campofinale.Protocol;
|
||||
|
||||
namespace Campofinale.Packets.Cs
|
||||
{
|
||||
public class HandleCsTakeAdventureTaskReward
|
||||
{
|
||||
|
||||
[Server.Handler(CsMsgId.CsTakeAdventureTaskReward)]
|
||||
public static void Handle(Player session, CsMsgId cmdId, Packet packet)
|
||||
{
|
||||
CsTakeAdventureTaskReward req = packet.DecodeBody<CsTakeAdventureTaskReward>();
|
||||
session.adventureBookManager.ClaimTask(req.TaskId);
|
||||
session.Send(new PacketScAdventureBookSync(session), packet.csHead.UpSeqid);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
20
Campofinale/Packets/Cs/HandleCsTakeAllAdventureTaskReward.cs
Normal file
20
Campofinale/Packets/Cs/HandleCsTakeAllAdventureTaskReward.cs
Normal file
@ -0,0 +1,20 @@
|
||||
using Campofinale.Network;
|
||||
using Campofinale.Packets.Sc;
|
||||
using Campofinale.Protocol;
|
||||
using Campofinale.Resource;
|
||||
|
||||
namespace Campofinale.Packets.Cs
|
||||
{
|
||||
public class HandleCsTakeAllAdventureTaskReward
|
||||
{
|
||||
|
||||
[Server.Handler(CsMsgId.CsTakeAllAdventureTaskReward)]
|
||||
public static void Handle(Player session, CsMsgId cmdId, Packet packet)
|
||||
{
|
||||
CsTakeAllAdventureTaskReward req = packet.DecodeBody<CsTakeAllAdventureTaskReward>();
|
||||
session.adventureBookManager.ClaimTasks((AdventureTaskType)req.TaskType);
|
||||
session.Send(new PacketScAdventureBookSync(session), packet.csHead.UpSeqid);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@ -1,4 +1,4 @@
|
||||
using Campofinale.Game.Character;
|
||||
using Campofinale.Game.Char;
|
||||
using Campofinale.Network;
|
||||
using Campofinale.Protocol;
|
||||
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
using Campofinale.Network;
|
||||
using Campofinale.Protocol;
|
||||
using Campofinale.Resource;
|
||||
using static Campofinale.Game.Adventure.AdventureBookManager;
|
||||
|
||||
namespace Campofinale.Packets.Sc
|
||||
{
|
||||
@ -8,19 +9,13 @@ namespace Campofinale.Packets.Sc
|
||||
{
|
||||
public PacketScAdventureBookSync(Player player) {
|
||||
ScAdventureBookSync proto = new ScAdventureBookSync() {
|
||||
AdventureBookStage=1,
|
||||
DailyActivation=100,
|
||||
AdventureBookStage=player.adventureBookManager.data.adventureBookStage,
|
||||
DailyActivation=player.adventureBookManager.data.dailyActivation,
|
||||
|
||||
};
|
||||
foreach(var i in ResourceManager.adventureTaskTable)
|
||||
foreach (GameAdventureTask task in player.adventureBookManager.data.tasks)
|
||||
{
|
||||
if (i.Value.adventureBookStage == 1)
|
||||
{
|
||||
proto.Tasks.Add(new AdventureTask()
|
||||
{
|
||||
TaskId = i.Value.adventureTaskId,
|
||||
State = 1
|
||||
});
|
||||
}
|
||||
proto.Tasks.Add(task.ToProto());
|
||||
}
|
||||
SetData(ScMsgId.ScAdventureBookSync, proto);
|
||||
}
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
using Campofinale.Game.Character;
|
||||
using Campofinale.Game.Char;
|
||||
using Campofinale.Network;
|
||||
using Campofinale.Protocol;
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
using Campofinale.Game.Character;
|
||||
using Campofinale.Game.Char;
|
||||
using Campofinale.Network;
|
||||
using Campofinale.Protocol;
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
using Campofinale.Game.Character;
|
||||
using Campofinale.Game.Char;
|
||||
using Campofinale.Network;
|
||||
using Campofinale.Protocol;
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@ using Campofinale.Protocol;
|
||||
using Google.Protobuf;
|
||||
using System.Net.Sockets;
|
||||
using Campofinale.Packets.Sc;
|
||||
using Campofinale.Game.Character;
|
||||
using Campofinale.Game.Char;
|
||||
using Campofinale.Resource;
|
||||
using Campofinale.Game.Inventory;
|
||||
using static Campofinale.Resource.ResourceManager;
|
||||
@ -16,6 +16,7 @@ using Campofinale.Game.Factory;
|
||||
using Campofinale.Game.MissionSys;
|
||||
using Pastel;
|
||||
using System.Drawing;
|
||||
using Campofinale.Game.Adventure;
|
||||
|
||||
|
||||
namespace Campofinale
|
||||
@ -98,6 +99,7 @@ namespace Campofinale
|
||||
public BitsetManager bitsetManager;
|
||||
public FactoryManager factoryManager;
|
||||
public MissionSystem missionSystem;
|
||||
public AdventureBookManager adventureBookManager;
|
||||
public int teamIndex = 0;
|
||||
public List<Team> teams = new List<Team>();
|
||||
public List<Mail> mails = new List<Mail>();
|
||||
@ -106,6 +108,7 @@ namespace Campofinale
|
||||
public long maxDashEnergy = 250;
|
||||
public uint curStamina = 10;
|
||||
public long nextRecoverTime = 0;
|
||||
public long nextDailyReset = 0;
|
||||
public Dungeon currentDungeon;
|
||||
public PlayerSafeZoneInfo savedSaveZone;
|
||||
|
||||
@ -128,6 +131,7 @@ namespace Campofinale
|
||||
spaceshipManager = new(this);
|
||||
factoryManager = new(this);
|
||||
missionSystem = new(this);
|
||||
adventureBookManager = new(this);
|
||||
receivorThread = new Thread(new ThreadStart(Receive));
|
||||
|
||||
}
|
||||
@ -168,6 +172,7 @@ namespace Campofinale
|
||||
{
|
||||
sceneManager.scenes = data.scenes;
|
||||
}
|
||||
nextDailyReset = data.nextDailyReset;
|
||||
bitsetManager.Load(data.bitsets);
|
||||
savedSaveZone = data.savedSafeZone;
|
||||
if(Server.config.serverOptions.missionsEnabled) missionSystem.Load();
|
||||
@ -176,7 +181,7 @@ namespace Campofinale
|
||||
{
|
||||
Initialize(); //only if no account found
|
||||
}
|
||||
|
||||
adventureBookManager.Load();
|
||||
sceneManager.Load();
|
||||
factoryManager.Load();
|
||||
return (data != null);
|
||||
@ -572,6 +577,7 @@ namespace Campofinale
|
||||
DatabaseManager.db.SavePlayerData(this);
|
||||
inventoryManager.Save();
|
||||
spaceshipManager.Save();
|
||||
adventureBookManager.Save();
|
||||
if(Server.config.serverOptions.missionsEnabled) missionSystem.Save();
|
||||
SaveCharacters();
|
||||
SaveMails();
|
||||
@ -579,6 +585,7 @@ namespace Campofinale
|
||||
}
|
||||
public void AddStamina(uint stamina)
|
||||
{
|
||||
|
||||
curStamina += stamina;
|
||||
if(curStamina > maxStamina)
|
||||
{
|
||||
@ -595,6 +602,12 @@ namespace Campofinale
|
||||
nextRecoverTime= DateTime.UtcNow.AddMinutes(7).ToUnixTimestampMilliseconds();
|
||||
AddStamina(1);
|
||||
}
|
||||
if(curtimestamp >= nextDailyReset && adventureBookManager.data!=null)
|
||||
{
|
||||
nextDailyReset = DateTime.UtcNow.GetNextDailyReset().ToUnixTimestampMilliseconds();
|
||||
adventureBookManager.DailyReset();
|
||||
this.Send(new PacketScAdventureBookSync(this));
|
||||
}
|
||||
if(LoadFinish)
|
||||
sceneManager.Update();
|
||||
factoryManager.Update();
|
||||
|
||||
@ -21,7 +21,8 @@ class Program
|
||||
}
|
||||
private static void FakeClientTester()
|
||||
{
|
||||
string serverIp = "beyond-ric.gryphline.com";
|
||||
//
|
||||
string serverIp = "beyond-tyo.gryphline.com";
|
||||
int serverPort = 30000;
|
||||
Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
|
||||
|
||||
|
||||
@ -17,6 +17,185 @@
|
||||
Completed = 3,
|
||||
Failed = 4,
|
||||
}
|
||||
public enum AdventureTaskState
|
||||
{
|
||||
None = 0,
|
||||
Processing = 1,
|
||||
Completed = 2,
|
||||
Rewarded = 3
|
||||
}
|
||||
public enum ConditionType
|
||||
{
|
||||
Combined = 0,
|
||||
NumberOfKills = 1,
|
||||
TotalOfKills = 2,
|
||||
MissionGroupComplete = 3,
|
||||
MissionAvailable = 4,
|
||||
MissionProcessing = 5,
|
||||
MissionCompleted = 6,
|
||||
MissionAction = 7,
|
||||
ReachDestination = 8,
|
||||
NumOfProduceItems = 9,
|
||||
TotalOfProduceItems = 10,
|
||||
GuideFinish = 11,
|
||||
RepairBuilding = 12,
|
||||
TotalOfOrder = 13,
|
||||
BlocLevel = 14,
|
||||
BlocExpFull = 15,
|
||||
CanChangeGold = 16,
|
||||
CharMaxLevel = 17,
|
||||
QuestStateEqual = 18,
|
||||
MissionStateEqual = 19,
|
||||
CheckMissionSucceedId = 20,
|
||||
ItemBagHasItem = 106,
|
||||
PlayerHasItem = 107,
|
||||
CastSkill = 108,
|
||||
DepotHasItem = 109,
|
||||
CheckGetEnoughItem = 110,
|
||||
CheckGetEnoughItemInBag = 111,
|
||||
CheckGetEnoughItemInDepot = 112,
|
||||
FacBuildingConnected = 501,
|
||||
FacBuildingUpgrade = 502,
|
||||
FacBuildingAdded = 503,
|
||||
FacBuildingWorking = 504,
|
||||
FacRepairBuilding = 505,
|
||||
FacProducePowerReach = 511,
|
||||
FacProductivityReach = 512,
|
||||
KillSpecificEnemy = 1000,
|
||||
CheckBaseAndPoleConnected = 1001,
|
||||
CheckBaseAndMinerRunning = 1002,
|
||||
CheckTotalMinerRunning = 1003,
|
||||
CheckInteract = 1004,
|
||||
OnInteract = 1005,
|
||||
CheckInteractiveBool = 1006,
|
||||
CheckPlayerInMap = 1007,
|
||||
CheckInteractiveInt = 1008,
|
||||
SceneCollectionProgress = 2000,
|
||||
CompareProperty = 4000,
|
||||
PlusThenCompareTargetInteractiveProperty = 4001,
|
||||
CheckTriggerSpecificInteractiveEvent = 4002,
|
||||
CheckClientObjectiveCommon = 4003,
|
||||
CompareTargetInteractiveProperty = 4004,
|
||||
HasItemCount = 4501,
|
||||
DungeonKeptTime = 4502,
|
||||
CheckDoodadIsPickable = 5000,
|
||||
CheckDoodadIsBreakable = 5001,
|
||||
CheckInteractiveDestroyed = 5002,
|
||||
CheckUnlockTech = 5003,
|
||||
CheckRepairBuilding = 5004,
|
||||
CheckStorageBoxHasEnoughItem = 5005,
|
||||
CheckBuildingConnected = 5006,
|
||||
CheckBuildingStateInArea = 5007,
|
||||
CheckBuildingConnectedAsMA2SB = 5008,
|
||||
CheckUnlockMultipleTech = 5009,
|
||||
DoFacTradeCashAnyOrder = 5010,
|
||||
CheckSceneAreaUnlocked = 5011,
|
||||
CheckUnlockTechPackage = 5012,
|
||||
CheckUnlockTechLayer = 5013,
|
||||
FacBuildingCountInScene = 5014,
|
||||
FacBuildingProducingCountInScene = 5015,
|
||||
FacProducingFormulaCountInScene = 5016,
|
||||
FacStatisticItemGenRate = 5017,
|
||||
FacStatisticItemGen = 5018,
|
||||
FacPowerCostSum = 5019,
|
||||
FacBoxConveyorLengthSum = 5020,
|
||||
FacStorageBoxHasItems = 5021,
|
||||
CheckSpaceshipRoomLevel = 5022,
|
||||
CheckAdventureLevel = 5023,
|
||||
CheckShopNothingToBuy = 5024,
|
||||
CheckLiquidInBag = 5025,
|
||||
SettlementCheckExpEnoughToLevelup = 5026,
|
||||
CheckBuildingConnectedSpecify = 5027,
|
||||
CheckSpaceshipRoomUnlock = 5028,
|
||||
CheckSpaceshipRoomBuilt = 5029,
|
||||
CheckSpaceshipRoomStationCount = 5030,
|
||||
CheckPassGameMechanicsId = 5031,
|
||||
FacBuildingFluidContainerHasItem = 5032,
|
||||
CheckFacSoilHarvest = 5033,
|
||||
CheckFacBuildingState = 5034,
|
||||
FacBattleBuildingCurEnergy = 5035,
|
||||
CheckSpaceshipGrowCabinHarvest = 5036,
|
||||
CheckGameInstCompletionStatus = 5037,
|
||||
CheckItemGot = 5038,
|
||||
CheckBuildingConnectedExist = 5039,
|
||||
CheckFacSoilPlacedInPanel = 5040,
|
||||
CheckWeaponGachaPoolIsOpen = 5041,
|
||||
CheckShopGoodsIsSoldOut = 5042,
|
||||
CheckPassedGameMechanicsNum = 5044,
|
||||
CheckSettlementLevelSum = 5045,
|
||||
CheckInteractiveLock = 5244,
|
||||
CheckRichContentReadingDone = 5245,
|
||||
CheckInteractiveSubmitSuccess = 5246,
|
||||
CheckInteractiveNextAvailableTime = 5247,
|
||||
CheckMonsterSpawnerComplete = 5248,
|
||||
CheckItemBagCanPutIn = 5249,
|
||||
CheckFluidVolume = 5250,
|
||||
CheckGreaterWeapeonStageNum = 5251,
|
||||
CheckRoleCreateTime = 5252,
|
||||
CheckSceneGrade = 5253,
|
||||
CheckUnlockGroupTechNum = 5254,
|
||||
CheckCharSkillLevel = 5255,
|
||||
CheckCharUnlockBreakTalentId = 5256,
|
||||
CheckFactoryBlackBoxStateNum = 5257,
|
||||
CheckDungeonTypePassNum = 5258,
|
||||
CheckEquipTierLevelNumCharNum = 5259,
|
||||
CheckInteractiveIsActivable = 5260,
|
||||
CheckInteractiveIsActived = 5261,
|
||||
CheckSceneScope = 5262,
|
||||
CheckGameInstStartDuration = 5263,
|
||||
CheckPlayerInDungeon = 5264,
|
||||
CheckCharUnlock = 5265,
|
||||
CheckCharFavorability = 5266,
|
||||
CheckEtherSubmitCount = 5267,
|
||||
CheckTDStart = 5600,
|
||||
CheckTDSettlement = 5601,
|
||||
CheckPanelOpen = 6000,
|
||||
CheckQuestSubmitItem = 6001,
|
||||
CheckLevelScriptProperty = 6002,
|
||||
CheckRepeatableTalkFinish = 6003,
|
||||
KillEnemyIdList = 6004,
|
||||
CheckCompletedBlocMissionNum = 6005,
|
||||
CheckSceneCollectionNum = 6006,
|
||||
CheckPRTSCollectionUnlock = 6007,
|
||||
CheckCostStamina = 6008,
|
||||
CheckTmpShopAlreadyBuyCount = 6009,
|
||||
CheckInPowerMinerCount = 6010,
|
||||
CheckTimestamp = 6011,
|
||||
CheckMissionProperty = 6012,
|
||||
CheckProperty = 6015,
|
||||
CheckClientGameVar = 6016,
|
||||
CheckServerGameVar = 6017,
|
||||
CheckPlayerHasEnoughItemList = 6018,
|
||||
CheckMiniGameCompletedCount = 6019,
|
||||
CheckMonsterKilledNum = 6020,
|
||||
CheckTerminalReadingDone = 6021,
|
||||
CheckScriptTaskStateEqual = 6022,
|
||||
CheckFactoryBlackBoxState = 6023,
|
||||
CheckTeamMemberNumberEven = 6024,
|
||||
CheckDaysNumAfterMissionComplete = 6025,
|
||||
CheckTimelineFinish = 6026,
|
||||
CheckFmvFinish = 6027,
|
||||
CheckRemoteCommFinish = 6028,
|
||||
CheckTalkFinish = 6029,
|
||||
CheckPrtsInvestigateFinish = 6030,
|
||||
CheckSNSDialogComplete = 6500,
|
||||
CheckSNSDialogContent = 6501,
|
||||
CheckGreaterCharLevelNum = 6502,
|
||||
CheckGreaterWeapeonLevelNum = 6503,
|
||||
CheckGreaterCharStageNum = 6504,
|
||||
CheckGreaterCharPotentialNum = 6505,
|
||||
CheckGreaterSettlementLevelNum = 6506,
|
||||
CheckStatisticVal = 6507,
|
||||
ClientOnly = 9999,
|
||||
SystemUnlocked = 10000,
|
||||
None = 2147483647
|
||||
}
|
||||
public enum AdventureTaskType
|
||||
{
|
||||
None = 0,
|
||||
Daily = 1,
|
||||
AdventureBook = 2
|
||||
}
|
||||
public enum LevelScriptState
|
||||
{
|
||||
None = 0,
|
||||
@ -358,13 +537,6 @@
|
||||
KeyStepFinish = 2,
|
||||
Completed = 3
|
||||
}
|
||||
public enum AdventureTaskState // TypeDefIndex: 33702
|
||||
{
|
||||
None = 0,
|
||||
Processing = 1,
|
||||
Completed = 2,
|
||||
Rewarded = 3
|
||||
}
|
||||
public enum EntryState // TypeDefIndex: 24402
|
||||
{
|
||||
Empty = 0,
|
||||
@ -373,12 +545,6 @@
|
||||
LevelLoaded = 3,
|
||||
Invalid = 4
|
||||
}
|
||||
public enum AdventureTaskType // TypeDefIndex: 33687
|
||||
{
|
||||
None = 0,
|
||||
Daily = 1,
|
||||
AdventureBook = 2
|
||||
}
|
||||
public enum ItemStorageSpace // TypeDefIndex: 33575
|
||||
{
|
||||
None = 0,
|
||||
|
||||
24
Campofinale/Resource/Json/ConditionData.cs
Normal file
24
Campofinale/Resource/Json/ConditionData.cs
Normal file
@ -0,0 +1,24 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Campofinale.Resource.Json
|
||||
{
|
||||
[TableCfgType("Data/Conditions.json", LoadPriority.LOW)]
|
||||
public class ConditionData
|
||||
{
|
||||
public List<string> args = new();
|
||||
|
||||
|
||||
public string Get(int index)
|
||||
{
|
||||
return args[index];
|
||||
}
|
||||
public int ToInt(int index)
|
||||
{
|
||||
return int.Parse(args[index]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -79,6 +79,7 @@ namespace Campofinale.Resource
|
||||
public static List<LevelScene> levelDatas = new();
|
||||
public static List<InteractiveData> interactiveData = new();
|
||||
public static List<SpawnerConfig> spawnerConfigs = new();
|
||||
public static Dictionary<string,ConditionData> conditions=new();
|
||||
public static int GetSceneNumIdFromLevelData(string name)
|
||||
{
|
||||
if (levelDatas.Find(a => a.id == name) == null) return 0;
|
||||
@ -409,13 +410,13 @@ namespace Campofinale.Resource
|
||||
public int adventureBookStage;
|
||||
public string adventureTaskId;
|
||||
public string conditionId;
|
||||
public int conditionType;
|
||||
public ConditionType conditionType;
|
||||
public string jumpSystemId;
|
||||
public int progressToCompare;
|
||||
public string rewardId;
|
||||
public int sortId;
|
||||
public TaskDescription taskDesc;
|
||||
public int taskType;
|
||||
public AdventureTaskType taskType;
|
||||
}
|
||||
public class TaskDescription
|
||||
{
|
||||
|
||||
14
Campofinale/Resource/ServerEnums.cs
Normal file
14
Campofinale/Resource/ServerEnums.cs
Normal file
@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Campofinale.Resource
|
||||
{
|
||||
public enum ServerEventExec
|
||||
{
|
||||
UpdateTasks=0
|
||||
}
|
||||
|
||||
}
|
||||
@ -21,6 +21,17 @@ namespace Campofinale
|
||||
{
|
||||
return (long)(dateTime - UnixEpoch).TotalMilliseconds;
|
||||
}
|
||||
public static DateTime GetNextDailyReset(this DateTime dateTime)
|
||||
{
|
||||
DateTime now = DateTime.UtcNow;
|
||||
DateTime todayReset = new DateTime(now.Year, now.Month, now.Day, 6, 0, 0, DateTimeKind.Utc);
|
||||
|
||||
// Se siamo già passati oltre le 6:00 AM di oggi, ritorna le 6:00 AM di domani
|
||||
if (now >= todayReset)
|
||||
return todayReset.AddDays(1);
|
||||
else
|
||||
return todayReset;
|
||||
}
|
||||
}
|
||||
public class Server
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user