mirror of
https://github.com/MikuLeaks/MikuSB.git
synced 2026-06-04 11:24:00 +00:00
MoneySync
This commit is contained in:
@@ -205,6 +205,8 @@ public class PlayerInstance(PlayerGameData data)
|
||||
Pid = (ulong)Data.Uid,
|
||||
Account = displayName,
|
||||
Provider = displayName,
|
||||
Channel = "gm",
|
||||
Subchannel = "gm",
|
||||
Name = displayName,
|
||||
Level = Data.Level,
|
||||
Sex = Data.Gender,
|
||||
@@ -242,6 +244,11 @@ public class PlayerInstance(PlayerGameData data)
|
||||
proto.StrAttrs[ToShiftedAttrKey(x.Gid, x.Sid)] = x.Val;
|
||||
}
|
||||
|
||||
foreach (var (key, value) in BuildMoneySync())
|
||||
{
|
||||
proto.Money[key] = value;
|
||||
}
|
||||
|
||||
proto.ShowItems.AddRange(Data.ShowItems);
|
||||
|
||||
return proto;
|
||||
@@ -295,6 +302,24 @@ public class PlayerInstance(PlayerGameData data)
|
||||
return (gid << 16) | sid;
|
||||
}
|
||||
|
||||
public Dictionary<string, int> BuildMoneySync()
|
||||
{
|
||||
var currentMoney = (int)Math.Min(int.MaxValue, GetAttrValue(1, 3));
|
||||
var sync = new Dictionary<string, int>(StringComparer.OrdinalIgnoreCase)
|
||||
{
|
||||
["."] = currentMoney,
|
||||
["gm.gm"] = currentMoney,
|
||||
["jinshan.jinshan"] = currentMoney,
|
||||
["pc_jinshan.pc_jinshan"] = currentMoney
|
||||
};
|
||||
return sync;
|
||||
}
|
||||
|
||||
private uint GetAttrValue(uint gid, uint sid)
|
||||
{
|
||||
return Data.Attrs.FirstOrDefault(x => x.Gid == gid && x.Sid == sid)?.Val ?? 0;
|
||||
}
|
||||
|
||||
public void BuildPlayerAttr(bool additional = false)
|
||||
{
|
||||
var bootstrapAttrs = BuildLobbyBootstrapAttrs().ToList();
|
||||
@@ -445,4 +470,4 @@ public class PlayerInstance(PlayerGameData data)
|
||||
yield return (132, 1, 0);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user