83 lines
3.5 KiB
C#
83 lines
3.5 KiB
C#
using ServerCore;
|
|
using ServerBase;
|
|
using ServerCommon;
|
|
|
|
|
|
namespace GameServer;
|
|
|
|
[ChatCommandAttribute("caliumconverter", typeof(ChatCommandCaliumConverter), AuthAdminLevelType.Developer, AuthAdminLevelType.GmNormal, AuthAdminLevelType.GmSuper)]
|
|
internal class ChatCommandCaliumConverter : ChatCommandBase
|
|
{
|
|
public override async Task invoke(Player player, string token, string[] args)
|
|
{
|
|
Log.getLogger().info($"ChatCommandCaliumConverter");
|
|
|
|
var message = new ClientToGame();
|
|
message.Request = new ClientToGameReq();
|
|
message.Request.ReqCaliumConverter = new();
|
|
|
|
var result = await GameServerApp.getServerLogic().onCallProtocolHandler(player, message);
|
|
if (result.isFail())
|
|
{
|
|
Log.getLogger().error($"fail to run ConvertCaliumCommand!! : {result.toBasicString()}");
|
|
}
|
|
}
|
|
}
|
|
|
|
[ChatCommandAttribute("initcaliumforuser", typeof(ChatCommandInitCaliumForUser), AuthAdminLevelType.Developer, AuthAdminLevelType.GmNormal, AuthAdminLevelType.GmSuper)]
|
|
internal class ChatCommandInitCaliumForUser : ChatCommandBase
|
|
{
|
|
public override async Task invoke(Player player, string token, string[] args)
|
|
{
|
|
Log.getLogger().info($"InitCaliumForUserCommand");
|
|
|
|
var result = await player.runTransactionRunnerSafely(TransactionIdType.PrivateContents, "CheatInitCaliumForUserDaily", initCaliumDelegate);
|
|
if (result.isFail())
|
|
{
|
|
Log.getLogger().error($"fail to run InitCaliumForUserCommand!! : {result.toBasicString()} / {player.toBasicString()}");
|
|
}
|
|
|
|
return;
|
|
|
|
async Task<Result> initCaliumDelegate() => await initCalium(player);
|
|
}
|
|
|
|
private async Task<Result> initCalium(Player player)
|
|
{
|
|
var user_calium_attribute = player.getEntityAttribute<CaliumAttribute>();
|
|
NullReferenceCheckHelper.throwIfNull(user_calium_attribute, () => $"user_calium_attribute is null !!! - {player.toBasicString()}");
|
|
|
|
user_calium_attribute.DailyCalium = (double)MetaHelper.GameConfigMeta.CaliumConverterLimitPerPerson;
|
|
user_calium_attribute.modifiedEntityAttribute();
|
|
|
|
var batch = new QueryBatchEx<QueryRunnerWithDocument>(player, LogActionType.ConvertCalium, GameServerApp.getServerLogic().getDynamoDbClient(), true);
|
|
batch.addQuery(new DBQWriteToAttributeAllWithTransactionRunner());
|
|
|
|
return await QueryHelper.sendQueryAndBusinessLog(batch);
|
|
}
|
|
}
|
|
|
|
[ChatCommandAttribute("caliumcontentcreate", typeof(ChatCommandCaliumContentCreate), AuthAdminLevelType.Developer, AuthAdminLevelType.GmNormal, AuthAdminLevelType.GmSuper)]
|
|
internal class ChatCommandCaliumContentCreate : ChatCommandBase
|
|
{
|
|
public override async Task invoke(Player player, string token, string[] args)
|
|
{
|
|
Log.getLogger().info($"ChatCommandCaliumContentCreate");
|
|
|
|
if (args.Length < 2) return;
|
|
|
|
var content_id = args[0];
|
|
if (false == double.TryParse(args[1], out var calium)) return;
|
|
|
|
var server_logic = GameServerApp.getServerLogic();
|
|
|
|
var message = new ServerMessage();
|
|
message.ReqCreateContentStorage = new();
|
|
message.ReqCreateContentStorage.ContentId = content_id;
|
|
message.ReqCreateContentStorage.Calium = calium;
|
|
message.ReqCreateContentStorage.RequestServerName = server_logic.getServerName();
|
|
|
|
var handler = new ReqCreateCaliumContentStorageHandler();
|
|
var result = await handler.createCaliumContentStorage(message.ReqCreateContentStorage.ContentId, message.ReqCreateContentStorage.Calium);
|
|
}
|
|
} |