Skip to content

Commit 4eac40f

Browse files
committed
Expose some variables in PartnerPawnData so that progress can be exposed to chat command /affection. Add /wallet to show hidden wallet values.
1 parent 5fc5505 commit 4eac40f

3 files changed

Lines changed: 71 additions & 3 deletions

File tree

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
using Arrowgene.Ddon.GameServer.Handler;
2+
using System.Collections.Generic;
3+
4+
public class ChatCommand : IChatCommand
5+
{
6+
public override AccountStateType AccountState => AccountStateType.User;
7+
public override string CommandName => "affection";
8+
public override string HelpText => "usage: `/affection` - Check pawn affection.";
9+
10+
public override void Execute(DdonGameServer server, string[] command, GameClient client, ChatMessage message, List<ChatResponse> responses)
11+
{
12+
List<string> strings = [];
13+
foreach (var pawn in client.Character.Pawns)
14+
{
15+
int level = (int)pawn.PartnerPawnData.CalculateLikability();
16+
17+
strings.Add($"{pawn.Name}{(client.Character.PartnerPawnId == pawn.PawnId ? " *" : " ")}");
18+
strings.Add($" Affection: {level} / {PartnerPawnData.MaxLevel}");
19+
strings.Add($" Progress: {pawn.PartnerPawnData.CalculateLikabilityXP()} / {PartnerPawnData.LikabilityCurve.ElementAtOrDefault(level+1)}");
20+
strings.Add($" ");
21+
}
22+
23+
client.Send(new S2CConnectionInformationNtc(strings));
24+
}
25+
}
26+
27+
return new ChatCommand();
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
using Arrowgene.Ddon.GameServer.Handler;
2+
using System.Collections.Generic;
3+
using System.Globalization;
4+
5+
public class ChatCommand : IChatCommand
6+
{
7+
public override AccountStateType AccountState => AccountStateType.User;
8+
public override string CommandName => "wallet";
9+
public override string HelpText => "usage: `/wallet` - Check hidden wallet amounts.";
10+
11+
public override void Execute(DdonGameServer server, string[] command, GameClient client, ChatMessage message, List<ChatResponse> responses)
12+
{
13+
S2CConnectionInformationNtc ntc = new(client.Character.WalletPointList.Select(x => $"{x.Type} : {x.Value.ToString("N0", CultureInfo.InvariantCulture)} / {server.GameSettings.GameServerSettings.WalletLimits.GetValueOrDefault(x.Type).ToString("N0", CultureInfo.InvariantCulture)}"));
14+
client.Send(ntc);
15+
}
16+
}
17+
18+
return new ChatCommand();

Arrowgene.Ddon.Shared/Model/PartnerPawnData.cs

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
using Arrowgene.Ddon.Shared.Entity.Structure;
22
using System;
3+
using System.Collections.Generic;
4+
using System.Linq;
35

46
namespace Arrowgene.Ddon.Shared.Model
57
{
@@ -10,11 +12,20 @@ public class PartnerPawnData
1012
public uint NumCrafts { get; set; }
1113
public uint NumAdventures { get; set; }
1214

15+
private static readonly double OffsetFactor = 65;
16+
private static readonly double ScaleFactor = 14.4;
17+
public static readonly uint MaxLevel = 25;
18+
19+
public uint CalculateLikabilityXP()
20+
{
21+
return (NumGifts * 20) + (NumCrafts * 20) + (NumAdventures * 10);
22+
}
23+
1324
public uint CalculateLikability()
1425
{
15-
uint totalXP = (NumGifts * 20) + (NumCrafts * 20) + (NumAdventures * 10);
16-
uint level = (totalXP < 65) ? 0 : (uint)Math.Sqrt((totalXP - 65) / 14.4);
17-
return Math.Min(level, 25); // Clamp 0 to 25
26+
uint totalXP = CalculateLikabilityXP();
27+
uint level = (totalXP < OffsetFactor) ? 0 : (uint)Math.Sqrt((totalXP - OffsetFactor) / ScaleFactor);
28+
return Math.Min(level, MaxLevel); // Clamp 0 to 25
1829
}
1930

2031
public CDataPartnerPawnData ToCDataPartnerPawnData(Pawn pawn)
@@ -26,5 +37,17 @@ public CDataPartnerPawnData ToCDataPartnerPawnData(Pawn pawn)
2637
Likability = CalculateLikability()
2738
};
2839
}
40+
41+
public static readonly List<uint> LikabilityCurve = [.. Enumerable.Range(0, (int)(MaxLevel + 1)).Select(x => CalculateLikabilityToLevel((uint)x))];
42+
43+
public static uint CalculateLikabilityToLevel(uint level)
44+
{
45+
if (level > MaxLevel)
46+
{
47+
return CalculateLikabilityToLevel(MaxLevel);
48+
}
49+
50+
return level > 0 ? (uint)(OffsetFactor + ScaleFactor * Math.Pow((level - 1),2)) : 0;
51+
}
2952
}
3053
}

0 commit comments

Comments
 (0)