초기커밋
This commit is contained in:
117
GameServer/Entity/Money/MoneyCheat.cs
Normal file
117
GameServer/Entity/Money/MoneyCheat.cs
Normal file
@@ -0,0 +1,117 @@
|
||||
using ServerCommon;
|
||||
using ServerCore; using ServerBase;
|
||||
|
||||
namespace GameServer;
|
||||
|
||||
[ChatCommandAttribute("currencymodify", typeof(ChatCommandModifyCurrency), AuthAdminLevelType.Developer, AuthAdminLevelType.GmNormal, AuthAdminLevelType.GmSuper)]
|
||||
internal class ChatCommandModifyCurrency : ChatCommandBase
|
||||
{
|
||||
public override async Task invoke(Player player, string token, string[] args)
|
||||
{
|
||||
Log.getLogger().info($"Call currencymodify !!! - {player.toBasicString()}");
|
||||
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
if (args.Length < 2)
|
||||
{
|
||||
err_msg = $"Not enough argument !!! : argCount:{args.Length} == 2 - {player.toBasicString()}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return;
|
||||
}
|
||||
|
||||
if (int.TryParse(args[0], out int currency_type) == false || double.TryParse(args[1], out double amount) == false)
|
||||
{
|
||||
err_msg = $"Invalid argument !!! - {player.toBasicString()}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return;
|
||||
}
|
||||
|
||||
if ((CurrencyType)currency_type == CurrencyType.Beam)
|
||||
{
|
||||
err_msg = $"Invalid CurrencyType !!! : {currency_type} - {player.toBasicString()}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return;
|
||||
}
|
||||
|
||||
var server_logic = GameServerApp.getServerLogic();
|
||||
NullReferenceCheckHelper.throwIfNull(player, () => $"server_logic is null !! - {player.toBasicString()}");
|
||||
|
||||
var fn_currency_modify = async delegate ()
|
||||
{
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
ClientToGame clientToGame = new();
|
||||
clientToGame.Response = new();
|
||||
clientToGame.Response.GetCurrencyInfoRes = new();
|
||||
|
||||
var money_action = player.getEntityAction<MoneyAction>();
|
||||
NullReferenceCheckHelper.throwIfNull(money_action, () => $"money_action is null !!! - {player.toBasicString()}");
|
||||
|
||||
result = await money_action.changeMoney((CurrencyType)currency_type, amount, true, false);
|
||||
if(result.isFail())
|
||||
{
|
||||
err_msg = $"Failed to changeMoney() !!! : {result.toBasicString()} - {player.toBasicString()}";
|
||||
Log.getLogger().error(err_msg);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
var batch = new QueryBatchEx<QueryRunnerWithDocument>( player, LogActionType.MoneyChange
|
||||
, server_logic.getDynamoDbClient());
|
||||
{
|
||||
batch.addQuery(new DBQWriteToAttributeAllWithTransactionRunner());
|
||||
}
|
||||
|
||||
result = await QueryHelper.sendQueryAndBusinessLog(batch);
|
||||
if (result.isFail())
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
clientToGame.Response.GetCurrencyInfoRes.CurrencyInfo = money_action.toCurrency4Client();
|
||||
|
||||
player.sendPacket(clientToGame);
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
result = await player.runTransactionRunnerSafely(TransactionIdType.PrivateContents, "Cheat.CurrencyModify", fn_currency_modify);
|
||||
if (result.isFail())
|
||||
{
|
||||
err_msg = $"Failed to runTransactionRunnerSafely()!!! : {result.toBasicString()} - {player.toBasicString()}";
|
||||
Log.getLogger().error(err_msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[ChatCommandAttribute("beamcharge", typeof(ChatCommandBeamCharge), AuthAdminLevelType.Developer, AuthAdminLevelType.GmNormal, AuthAdminLevelType.GmSuper)]
|
||||
internal class ChatCommandBeamCharge : ChatCommandBase
|
||||
{
|
||||
public override async Task invoke(Player player, string token, string[] args)
|
||||
{
|
||||
Log.getLogger().info($"Call beamcharge !!! - {player.toBasicString()}");
|
||||
|
||||
if (args.Length < 1)
|
||||
return;
|
||||
|
||||
if (int.TryParse(args[0], out int amount) == false)
|
||||
return;
|
||||
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var ai_chat_action = player.getEntityAction<AIChatAction>();
|
||||
NullReferenceCheckHelper.throwIfNull(ai_chat_action, () => $"money_action is null !!! - {player.toBasicString()}");
|
||||
|
||||
var order_guid = Guid.NewGuid().ToString("N");
|
||||
result = await ai_chat_action.pointCharge(new AIChatPointCharge() { userGuid = player.getUserGuid(), points = amount, orderGuid = order_guid, pointType = ServerCommon.Constant.AI_CHAT_FREE_POINT, description = "Cheat Beam" });
|
||||
if (result.isSuccess())
|
||||
{
|
||||
MoneyNotifyHelper.send_GS2C_NTF_BEAM_CHARGE(player);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user