Files
caliverse_server/GameServer/Contents/BeaconShop/BeaconShopCheat.cs
2025-05-01 07:20:41 +09:00

266 lines
9.8 KiB
C#

using ServerCommon;
using ServerCore; using ServerBase;
using System.Net.WebSockets;
using static ServerCommon.MetaHelper;
namespace GameServer;
[ChatCommandAttribute("beaconshopregisteritem", typeof(CheatBeaconShopregisterItem), AuthAdminLevelType.Developer, AuthAdminLevelType.GmNormal, AuthAdminLevelType.GmSuper)]
internal class CheatBeaconShopregisterItem : ChatCommandBase
{
public override async Task invoke(Player player, string token, string[] args)
{
Log.getLogger().info($"CheatBeaconShopregisterItem");
if (args.Length < 1)
{
Log.getLogger().error($"Invalid Argument");
return;
}
if (uint.TryParse(args[0], out uint item_meta_id) == false)
return;
var beacon_shop_action = player.getEntityAction<BeaconShopAction>();
NullReferenceCheckHelper.throwIfNull(beacon_shop_action, () => $"beacon_shop_action is null !!! - {player.toBasicString()}");
var inventory_action = player.getEntityAction<InventoryActionBase>();
NullReferenceCheckHelper.throwIfNull(inventory_action, () => $"inventory_action is null !!! - {player.toBasicString()}");
var item_list = inventory_action.tryGetItemAllByItemMetaId(item_meta_id);
if (item_list.Count == 0)
return;
var item_attribute = item_list[0].getEntityAttribute<ItemAttributeBase>();
NullReferenceCheckHelper.throwIfNull(item_attribute, () => $"item_attribute is null !!! - {player.toBasicString()}");
var player_action = player.getEntityAction<PlayerAction>();
var ugc_npc_dictionary = player_action.getHadUgcNpcs();
if (ugc_npc_dictionary.Count == 0)
{
return;
}
var npc_attribute = ugc_npc_dictionary.First().Value.getEntityAttribute<UgcNpcAttribute>();
NullReferenceCheckHelper.throwIfNull(npc_attribute, () => $"npc_attribute is null !!! - {player.toBasicString()}");
var result = await beacon_shop_action.tryRegisterItemToBeaconShop(item_attribute.ItemGuid, 1, 0.1, npc_attribute.UgcNpcMetaGuid);
if (result.isFail())
{
return;
}
return;
}
}
[ChatCommandAttribute("beaconshopreturn", typeof(CheatBeaconShopReturn), AuthAdminLevelType.Developer, AuthAdminLevelType.GmNormal, AuthAdminLevelType.GmSuper)]
internal class CheatBeaconShopReturn : ChatCommandBase
{
public override async Task invoke(Player player, string token, string[] args)
{
Log.getLogger().info($"CheatBeaconShopReturn");
if (args.Length < 2)
{
Log.getLogger().error($"Invalid Argument");
return;
}
var itemGuid = args[0];
var beaconGuid = args[1];
var beacon_shop_action = player.getEntityAction<BeaconShopAction>();
NullReferenceCheckHelper.throwIfNull(beacon_shop_action, () => $"beacon_shop_action is null !!! - {player.toBasicString()}");
var result = await beacon_shop_action.BeaconShopReturnItem(itemGuid, beaconGuid);
if (result.isFail())
{
return;
}
return;
}
}
[ChatCommandAttribute("beaconshoppurchaseitem", typeof(CheatBeaconShopPurchaseItem), AuthAdminLevelType.Developer, AuthAdminLevelType.GmNormal, AuthAdminLevelType.GmSuper)]
internal class CheatBeaconShopPurchaseItem : ChatCommandBase
{
public override async Task invoke(Player player, string token, string[] args)
{
Log.getLogger().info($"CheatBeaconShopreturn");
if (args.Length < 4)
{
Log.getLogger().error($"Invalid Argument");
return;
}
var itemGuid = args[0];
if (ushort.TryParse(args[1], out ushort itemAmount) == false)
return;
var beaconGuid = args[2];
var beaconOwnerGuid = args[3];
var beacon_shop_action = player.getEntityAction<BeaconShopAction>();
NullReferenceCheckHelper.throwIfNull(beacon_shop_action, () => $"beacon_shop_action is null !!! - {player.toBasicString()}");
var result = await beacon_shop_action.BeaconShopPurchaseItem(itemGuid, itemAmount, beaconGuid, beaconOwnerGuid);
if (result.isFail())
{
return;
}
return;
}
}
[ChatCommandAttribute("beaconshopreceivepayment", typeof(CheatBeaconShopReceivePayment), AuthAdminLevelType.Developer, AuthAdminLevelType.GmNormal, AuthAdminLevelType.GmSuper)]
internal class CheatBeaconShopReceivePayment : ChatCommandBase
{
public override async Task invoke(Player player, string token, string[] args)
{
Log.getLogger().info($"CheatBeaconShopReceivePayment");
if (args.Length < 1)
{
Log.getLogger().error($"Invalid Argument");
return;
}
var beaconGuid = args[0];
var beacon_shop_action = player.getEntityAction<BeaconShopAction>();
NullReferenceCheckHelper.throwIfNull(beacon_shop_action, () => $"beacon_shop_action is null !!! - {player.toBasicString()}");
var result = await beacon_shop_action.BeaconShopReceivePaymentForSales(beaconGuid);
if (result.isFail())
{
return;
}
return;
}
}
[ChatCommandAttribute("beaconshopitemtimechange", typeof(CheatBeaconShopItemTimeChange), AuthAdminLevelType.Developer, AuthAdminLevelType.GmNormal, AuthAdminLevelType.GmSuper)]
internal class CheatBeaconShopItemTimeChange : ChatCommandBase
{
public override async Task invoke(Player player, string token, string[] args)
{
Log.getLogger().info($"CheatBeaconShopItemTimeChange");
var result = new Result();
var err_msg = string.Empty;
if (args.Length < 1)
{
Log.getLogger().error($"Invalid Argument");
return;
}
if (int.TryParse(args[0], out int minutes) == false)
return;
var server_logic = GameServerApp.getServerLogic();
var fn_start = async delegate ()
{
var player_action = player.getEntityAction<PlayerAction>();
var npcs = player_action.getHadUgcNpcs();
foreach (var npc in npcs)
{
var ugc_npc_beacon_shop_action = npc.Value.getEntityAction<UgcNpcBeaconShopAction>();
var beaconShopItems = ugc_npc_beacon_shop_action.getHasBeaconShopItem();
foreach (var beaconShopItem in beaconShopItems)
{
var beacon_shop_item_attribute = beaconShopItem.getEntityAttribute<BeaconShopItemAttribute>();
NullReferenceCheckHelper.throwIfNull(beacon_shop_item_attribute, () => $"beacon_shop_item_attribute is null !!!");
var cheat_selling_finish_time = DateTime.UtcNow.AddMinutes(minutes);
beacon_shop_item_attribute.SellingFinishTime = cheat_selling_finish_time;
beacon_shop_item_attribute.modifiedEntityAttribute();
}
}
var batch = new QueryBatchEx<QueryRunnerWithDocument>(player, LogActionType.CheatCommandBeaconShopItemTimeChange
, server_logic.getDynamoDbClient());
{
batch.addQuery(new DBQWriteToAttributeAllWithTransactionRunner());
}
var result = await QueryHelper.sendQueryAndBusinessLog(batch);
if (result.isFail())
{
return result;
}
return result;
};
result = await player.runTransactionRunnerSafely(TransactionIdType.PrivateContents, "CheatBeaconShopItemTimeChange", fn_start);
if (result.isFail())
{
err_msg = $"Failed to runTransactionRunnerSafely() !!! : {result.toBasicString()} - {player.toBasicString()}";
Log.getLogger().error(err_msg);
}
return;
}
}
[ChatCommandAttribute("beaconshopdailylimitinit", typeof(CheatBeaconShopDailyLimitInit), AuthAdminLevelType.Developer, AuthAdminLevelType.GmNormal, AuthAdminLevelType.GmSuper)]
internal class CheatBeaconShopDailyLimitInit : ChatCommandBase
{
public override async Task invoke(Player player, string token, string[] args)
{
Log.getLogger().info($"CheatBeaconShopdailylimitinit");
var result = new Result();
var err_msg = string.Empty;
var server_logic = GameServerApp.getServerLogic();
var fn_start = async delegate ()
{
var player_action = player.getEntityAction<PlayerAction>();
var npcs = player_action.getHadUgcNpcs();
foreach (var npc in npcs)
{
var beacon_shop_profile_attribute = npc.Value.getEntityAttribute<BeaconShopProfileAttribute>();
NullReferenceCheckHelper.throwIfNull(beacon_shop_profile_attribute, () => $"beacon_shop_item_attribute is null !!!");
beacon_shop_profile_attribute.DailyRegisterCount = 0;
beacon_shop_profile_attribute.modifiedEntityAttribute();
}
var batch = new QueryBatchEx<QueryRunnerWithDocument>(player, LogActionType.CheatCommandDailyLimitInit
, server_logic.getDynamoDbClient());
{
batch.addQuery(new DBQWriteToAttributeAllWithTransactionRunner());
}
var result = await QueryHelper.sendQueryAndBusinessLog(batch);
if (result.isFail())
{
return result;
}
return result;
};
result = await player.runTransactionRunnerSafely(TransactionIdType.PrivateContents, "CheatBeaconShopdailylimitinit", fn_start);
if (result.isFail())
{
err_msg = $"Failed to runTransactionRunnerSafely() !!! : {result.toBasicString()} - {player.toBasicString()}";
Log.getLogger().error(err_msg);
}
return;
}
}