implement outpost reward buffs

This commit is contained in:
Mikhail
2024-09-02 16:32:42 -04:00
parent ed3c6bb6a0
commit 61075aae37
7 changed files with 108 additions and 37 deletions

View File

@@ -84,6 +84,38 @@ namespace EpinelPS.Database
public bool ClearedSimulationRoom = false;
public int InterceptionTickets = 3;
}
public class OutpostBuffs
{
public List<int> CreditPercentages = new List<int>();
public List<int> CoreDustPercentages = new List<int>();
public List<int> BattleDataPercentages = new List<int>();
public List<int> UserExpPercentages = new List<int>();
public List<int> GetPercentages(CurrencyType currency)
{
if (currency == CurrencyType.Gold)
return CreditPercentages;
else if (currency == CurrencyType.UserExp)
return UserExpPercentages;
else if (currency == CurrencyType.CharacterExp)
return BattleDataPercentages;
else if (currency == CurrencyType.CharacterExp2)
return CoreDustPercentages;
throw new InvalidOperationException();
}
public int GetTotalPercentages(CurrencyType currency)
{
int result = 0;
var numbs = GetPercentages(currency);
foreach (var item in numbs)
{
result += item;
}
return result;
}
}
public class User
{
// User info
@@ -142,7 +174,9 @@ namespace EpinelPS.Database
// Event data
public Dictionary<int, EventData> EventInfo = new();
public OutpostBuffs OutpostBuffs = new();
public void SetQuest(int tid, bool recievedReward)
{
if (MainQuestData.ContainsKey(tid))

View File

@@ -306,27 +306,10 @@ namespace EpinelPS.StaticInfo
Console.WriteLine("failed to read character level table entry");
}
var tacticLessonTable = await LoadZip("TacticAcademyFunctionTable.json", progress);
foreach (JToken item in tacticLessonTable)
var tacticLessonTable = await LoadZip<TacticAcademyLessonTable>("TacticAcademyFunctionTable.json", progress);
foreach (var obj in tacticLessonTable.records)
{
var idRaw = item["id"];
var groupidRaw = item["group_id"];
var currencyIdRaw = item["currency_id"];
var currencyValueRaw = item["currency_value"];
if (idRaw == null) throw new InvalidDataException();
if (groupidRaw == null) throw new InvalidDataException();
if (currencyIdRaw == null) throw new InvalidDataException();
if (currencyValueRaw == null) throw new InvalidDataException();
var id = idRaw.ToObject<int>();
var currencyId = currencyIdRaw.ToObject<int>();
var currencyValue = currencyValueRaw.ToObject<int>();
var groupid = groupidRaw.ToObject<int>();
var fullId = int.Parse(groupid.ToString() + id.ToString());
TacticAcademyLessons.Add(id, new TacticAcademyLessonRecord() { CurrencyId = (CurrencyType)currencyId, CurrencyValue = currencyValue, GroupId = groupid, Id = id });
TacticAcademyLessons.Add(obj.id, obj);
}
var sideStoryTable = await LoadZip("SideStoryStageTable.json", progress);

View File

@@ -95,12 +95,24 @@
public int character_exp2 = 0;
}
public class TacticAcademyLessonReward
{
public int lesson_reward_id;
public int lesson_reward_value;
}
public class TacticAcademyLessonRecord
{
public CurrencyType CurrencyId;
public int CurrencyValue;
public int Id;
public int GroupId;
public int currency_id;
public int currency_value;
public int id;
public int group_id;
public string lesson_type = "";
public TacticAcademyLessonReward[]? lesson_reward;
}
public class TacticAcademyLessonTable
{
public List<TacticAcademyLessonRecord> records;
}
public class CampaignChapterRecord

View File

@@ -10,7 +10,7 @@ namespace EpinelPS.LobbyServer.Msgs.Character
var req = await ReadData<ReqGetAttractiveList>();
var response = new ResGetAttractiveList();
response.CounselAvailableCount = 3; // TODO
response.CounselAvailableCount = 0; // TODO
// TODO: Validate response from real server and pull info from user info
await WriteDataAsync(response);

View File

@@ -1,4 +1,5 @@
using EpinelPS.StaticInfo;
using EpinelPS.Database;
using EpinelPS.StaticInfo;
using EpinelPS.Utils;
namespace EpinelPS.LobbyServer.Msgs.Outpost
@@ -16,16 +17,19 @@ namespace EpinelPS.LobbyServer.Msgs.Outpost
var x = GameData.Instance.GetTacticAcademyLesson(req.LessonTid);
if (user.CanSubtractCurrency(x.CurrencyId, x.CurrencyValue))
if (user.CanSubtractCurrency((CurrencyType)x.currency_id, x.currency_value))
{
user.SubtractCurrency(x.CurrencyId, x.CurrencyValue);
user.SubtractCurrency((CurrencyType)x.currency_id, x.currency_value);
user.CompletedTacticAcademyLessons.Add(req.LessonTid);
ProcessLessonReward(user, x);
foreach (var currency in user.Currency)
{
response.Currencies.Add(new NetUserCurrencyData() { Type = (int)currency.Key, Value = currency.Value });
}
JsonDb.Save();
}
else
{
@@ -33,5 +37,29 @@ namespace EpinelPS.LobbyServer.Msgs.Outpost
}
await WriteDataAsync(response);
}
private void ProcessLessonReward(Database.User user, TacticAcademyLessonRecord r)
{
if (r.lesson_reward == null)
{
Console.WriteLine("Warning: lesson_reward shouldnt be null");
return;
}
if (r.lesson_type == "OutpostBattle")
{
foreach (var item in r.lesson_reward)
{
if (item.lesson_reward_id != 0 && item.lesson_reward_value != 0)
{
user.OutpostBuffs.GetPercentages((CurrencyType)item.lesson_reward_id).Add(item.lesson_reward_value);
}
}
}
else
{
Console.WriteLine("Warning: unknown lesson type: " + r.lesson_type);
}
}
}
}

View File

@@ -83,6 +83,7 @@ namespace EpinelPS.LobbyServer.Msgs.User
response.Outposts.Add(new NetUserOutpostData() { SlotId = 38, BuildingId = 33601, IsDone = true, StartAt = 638549982076760660, CompleteAt = 638549982076760660 });
response.LastClearedNormalMainStageId = user.LastNormalStageCleared;
response.TimeRewardBuffs.AddRange(NetUtils.GetOutpostTimeReward(user));
await WriteDataAsync(response);
}

View File

@@ -156,13 +156,7 @@ namespace EpinelPS.Utils
public static double CalculateBoostValueForOutpost(User user, CurrencyType type)
{
double boost = 1.0;
if (user.CompletedTacticAcademyLessons.Contains(1003) && type == CurrencyType.Gold)
{
boost += .10;
}
return boost;
return user.OutpostBuffs.GetTotalPercentages(type) / 100.0;
}
public static long GetOutpostRewardAmount(User user, CurrencyType type, double mins, bool includeBoost)
@@ -249,14 +243,21 @@ namespace EpinelPS.Utils
{
List<NetTimeReward> res = new List<NetTimeReward>();
// NetTimeRewardBuff
// FunctionType: 1: value increase, 2: percentage increase
// Tid: Outpost building ID
var goldBuff = new NetTimeReward()
{
UseId = 1,
ValuePerMinAfterBuff = GetOutpostRewardAmount(user, CurrencyType.Gold, 1, true) * 10000,
ValuePerMinBeforeBuff = GetOutpostRewardAmount(user, CurrencyType.Gold, 1, false) * 10000
};
foreach (var item in user.OutpostBuffs.CreditPercentages)
{
goldBuff.Buffs.Add(new NetTimeRewardBuff() { Tid = 22401, FunctionType = 2, SourceType = OutpostBuffSourceType.OutpostBuffSourceTypeTacticAcademy, Value = item });
}
// goldBuff.Buffs.Add(new NetTimeRewardBuff() { Tid = 110101, FunctionType = 1, SourceType = OutpostBuffSourceType.OutpostBuffSourceTypeTacticAcademy, Value = 1000 });
var battleDataBuff = new NetTimeReward()
{
@@ -264,6 +265,10 @@ namespace EpinelPS.Utils
ValuePerMinAfterBuff = GetOutpostRewardAmount(user, CurrencyType.CharacterExp, 1, true) * 10000,
ValuePerMinBeforeBuff = GetOutpostRewardAmount(user, CurrencyType.CharacterExp, 1, false) * 10000
};
foreach (var item in user.OutpostBuffs.BattleDataPercentages)
{
battleDataBuff.Buffs.Add(new NetTimeRewardBuff() { Tid = 22401, FunctionType = 2, SourceType = OutpostBuffSourceType.OutpostBuffSourceTypeTacticAcademy, Value = item });
}
var xpBuff = new NetTimeReward()
{
@@ -271,6 +276,10 @@ namespace EpinelPS.Utils
ValuePerMinAfterBuff = GetOutpostRewardAmount(user, CurrencyType.UserExp, 1, true) * 10000,
ValuePerMinBeforeBuff = GetOutpostRewardAmount(user, CurrencyType.UserExp, 1, false) * 10000
};
foreach (var item in user.OutpostBuffs.UserExpPercentages)
{
xpBuff.Buffs.Add(new NetTimeRewardBuff() { Tid = 22401, FunctionType = 2, SourceType = OutpostBuffSourceType.OutpostBuffSourceTypeTacticAcademy, Value = item });
}
var coredustBuff = new NetTimeReward()
{
@@ -278,6 +287,10 @@ namespace EpinelPS.Utils
ValuePerMinAfterBuff = GetOutpostRewardAmount(user, CurrencyType.CharacterExp2, 60, true) * 100,
ValuePerMinBeforeBuff = GetOutpostRewardAmount(user, CurrencyType.CharacterExp2, 60, false) * 100
};
foreach (var item in user.OutpostBuffs.CoreDustPercentages)
{
coredustBuff.Buffs.Add(new NetTimeRewardBuff() { Tid = 22401, FunctionType = 2, SourceType = OutpostBuffSourceType.OutpostBuffSourceTypeTacticAcademy, Value = item });
}
res.Add(battleDataBuff);
res.Add(goldBuff);