2021-04-08 20:09:59 +08:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
|
|
|
|
namespace ET
|
|
|
|
|
{
|
|
|
|
|
public static class GMTool
|
|
|
|
|
{
|
|
|
|
|
public static async ETTask<string> Execute(Unit unit, string chatContent)
|
|
|
|
|
{
|
|
|
|
|
if (chatContent.StartsWith("cmd", StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
{
|
|
|
|
|
string[] arr = chatContent.Trim().Split('/');
|
|
|
|
|
int paramsCount = 0;
|
|
|
|
|
if (arr.Length == 3)
|
|
|
|
|
paramsCount = 1;
|
|
|
|
|
else if (arr.Length == 4)
|
|
|
|
|
paramsCount = 2;
|
|
|
|
|
if (paramsCount == 0)
|
|
|
|
|
return "参数至少1个";
|
|
|
|
|
string cmdType = arr[1];
|
|
|
|
|
string cmdValue = arr[2];
|
|
|
|
|
long count = 1;
|
|
|
|
|
if (paramsCount == 2)
|
|
|
|
|
{
|
|
|
|
|
long.TryParse(arr[3], out count);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (cmdType.Equals("sys", StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
{
|
|
|
|
|
Chat.Instance.SendSystemCaht(cmdValue);
|
|
|
|
|
return "成功";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
if (cmdType.Equals("updateDay", StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
{
|
|
|
|
|
Game.EventSystem.Publish(new ET.EventType.UpdatePer1DayOfMonth
|
|
|
|
|
{
|
|
|
|
|
now = TimeHelper.ClientNow()
|
|
|
|
|
}).Coroutine();
|
|
|
|
|
return "成功";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
if (cmdType.Equals("clearPvpCount", StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
{
|
2021-04-11 19:50:39 +08:00
|
|
|
|
List<PlayerData> list = await DBComponent.Instance.QueryJson<PlayerData>("{}");
|
|
|
|
|
foreach (PlayerData data in list)
|
2021-04-08 20:09:59 +08:00
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
data.personalPvpCount = 0;
|
|
|
|
|
Unit _unit = MapUnitComponent.Instance.Get(data.Id);
|
|
|
|
|
if (_unit)
|
|
|
|
|
{
|
|
|
|
|
_unit.RemoveComponent<PlayerData>();
|
|
|
|
|
_unit.AddComponent(data);
|
|
|
|
|
}
|
|
|
|
|
UnitHelper.SaveComponenet(data).Coroutine();
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
|
|
|
|
Log.Error(e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return "成功";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
if (cmdType.Equals("settlePvp", StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
{
|
|
|
|
|
await PvpMap.inatance.SettlePvp();
|
|
|
|
|
return "成功";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
if (cmdType.Equals("requireStore", StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
{
|
2021-04-11 19:50:39 +08:00
|
|
|
|
List<Store> list = await DBComponent.Instance.QueryJson<Store>("{}");
|
|
|
|
|
foreach (Store store in list)
|
2021-04-08 20:09:59 +08:00
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
bool isRequired = false;
|
|
|
|
|
List<Item> itemList = new();
|
|
|
|
|
int index = -1;
|
2021-04-11 19:50:39 +08:00
|
|
|
|
foreach (KeyValuePair<KeyValuePair<int, int>, Item> kv in store.StoreDic)
|
2021-04-08 20:09:59 +08:00
|
|
|
|
{
|
|
|
|
|
++index;
|
|
|
|
|
if (!isRequired)
|
|
|
|
|
isRequired = (kv.Key.Key != index);
|
|
|
|
|
itemList.Add(kv.Value);
|
|
|
|
|
}
|
|
|
|
|
store.StoreDic.Clear();
|
|
|
|
|
index = -1;
|
2021-04-11 19:50:39 +08:00
|
|
|
|
foreach (Item item in itemList)
|
2021-04-08 20:09:59 +08:00
|
|
|
|
{
|
|
|
|
|
++index;
|
|
|
|
|
if (item.IsEmpty)
|
|
|
|
|
{
|
|
|
|
|
store.StoreDic.Add(index, 0, item);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
store.StoreDic.Add(index, item.ItemId, item);
|
|
|
|
|
}
|
|
|
|
|
if (isRequired)
|
|
|
|
|
{
|
2021-04-11 19:50:39 +08:00
|
|
|
|
Store _store = await StoreComponent.Instance.Query(store.Id);
|
2021-04-08 20:09:59 +08:00
|
|
|
|
if (_store != null)
|
|
|
|
|
{
|
|
|
|
|
_store = store;
|
|
|
|
|
}
|
|
|
|
|
await DBComponent.Instance.Save(store);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
|
|
|
|
Log.Error(e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return "成功";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
if (cmdType.Equals("removeInvalidIdMail", StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
{
|
2021-04-11 19:50:39 +08:00
|
|
|
|
List<MailLib> list = await DBComponent.Instance.QueryJson<MailLib>("{}");
|
|
|
|
|
foreach (MailLib mailLib in list)
|
2021-04-08 20:09:59 +08:00
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
2021-04-11 19:50:39 +08:00
|
|
|
|
using ListComponent<long> listComponent = ListComponent<long>.Create();
|
|
|
|
|
foreach (Mail mail in mailLib.Dic.Values)
|
2021-04-08 20:09:59 +08:00
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
2021-04-11 19:50:39 +08:00
|
|
|
|
foreach (MailItem mailItem in mail.RewordArr)
|
2021-04-08 20:09:59 +08:00
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
2021-04-11 19:50:39 +08:00
|
|
|
|
IConfig _item = BagHelper.GetItemBase(mailItem.ItemId);
|
2021-04-08 20:09:59 +08:00
|
|
|
|
}
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
|
|
|
|
Log.Error(e);
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
listComponent.List.Add(mail.Id);
|
|
|
|
|
User user = await UserComponent.Instance.Query(mailLib.Id);
|
|
|
|
|
Log.Info($"{user?.NickName}({mailLib.Id}) 清理了邮件");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
|
|
|
|
Log.Error(e);
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-04-11 19:50:39 +08:00
|
|
|
|
foreach (long item in listComponent.List)
|
2021-04-08 20:09:59 +08:00
|
|
|
|
{
|
|
|
|
|
mailLib.Dic.Remove(item);
|
|
|
|
|
}
|
|
|
|
|
DBComponent.Instance.Save(mailLib).Coroutine();
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
|
|
|
|
Log.Error(e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return "成功";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
if (cmdType.Equals("requireBag", StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
{
|
2021-04-11 19:50:39 +08:00
|
|
|
|
List<Bag> list = await DBComponent.Instance.QueryJson<Bag>("{}");
|
|
|
|
|
foreach (Bag bag in list)
|
2021-04-08 20:09:59 +08:00
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
int itemCount = bag.ItemDic.Count(t => t.Key.Value != 0);
|
|
|
|
|
if (itemCount == bag.ItemCount) continue;
|
|
|
|
|
bag.ItemCount = 0;
|
|
|
|
|
for (int i = 0; i < bag.MaxItemCount; i++)
|
|
|
|
|
{
|
2021-04-11 19:50:39 +08:00
|
|
|
|
if (bag.ItemDic.TryGetValueByKey1(i, out Item item))
|
2021-04-08 20:09:59 +08:00
|
|
|
|
{
|
|
|
|
|
if (item.ItemId != 0)
|
|
|
|
|
bag.ItemCount++;
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-04-11 19:50:39 +08:00
|
|
|
|
Unit unitInServer = MapUnitComponent.Instance.Get(bag.Id);
|
2021-04-08 20:09:59 +08:00
|
|
|
|
if (unitInServer != null)
|
|
|
|
|
{
|
|
|
|
|
unitInServer.RemoveComponent<Bag>();
|
|
|
|
|
|
|
|
|
|
unitInServer.AddComponent(bag);
|
|
|
|
|
}
|
|
|
|
|
await DBComponent.Instance.Save(bag);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
|
|
|
|
Log.Error(e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return "成功";
|
|
|
|
|
}
|
|
|
|
|
else
|
2021-04-11 19:50:39 +08:00
|
|
|
|
if (int.TryParse(cmdValue, out int value))
|
2021-04-08 20:09:59 +08:00
|
|
|
|
{
|
|
|
|
|
if (cmdType.Equals("addItem", StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
{
|
|
|
|
|
await MailHelper.AddItem(unit.Id, value, count, true, getSource: "GM发放","GM邮件","GM发放的物品。","GM");
|
|
|
|
|
await DBComponent.Instance.Save(new AccountLog
|
|
|
|
|
{
|
|
|
|
|
Id = Game.IdGenerater.GenerateId(),
|
|
|
|
|
cmd = chatContent,
|
|
|
|
|
time = DateTime.Now,
|
|
|
|
|
count = count,
|
|
|
|
|
uid = unit.Id,
|
|
|
|
|
itemId = value
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
if (cmdType.Equals("addPetExp", StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
{
|
|
|
|
|
Pet pet = unit.GetComponent<Pet>();
|
|
|
|
|
pet.AddExp(value);
|
|
|
|
|
return "成功";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
if (cmdType.Equals("addAllAITime", StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
{
|
2021-04-11 19:50:39 +08:00
|
|
|
|
List<PlayerData> list = await DBComponent.Instance.QueryJson<PlayerData>("{}");
|
|
|
|
|
foreach (PlayerData data in list)
|
2021-04-08 20:09:59 +08:00
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
data.mainstoryAITime += value*60*1000;
|
|
|
|
|
Unit _unit = MapUnitComponent.Instance.Get(data.Id);
|
|
|
|
|
if (_unit)
|
|
|
|
|
{
|
|
|
|
|
_unit.RemoveComponent<PlayerData>();
|
|
|
|
|
_unit.AddComponent(data);
|
|
|
|
|
}
|
|
|
|
|
await DBComponent.Instance.Save(data);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
|
|
|
|
Log.Error(e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return "成功";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
if (cmdType.Equals("addLevel", StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
{
|
|
|
|
|
CharacterHelper.AddLevel(unit, value);
|
|
|
|
|
await DBComponent.Instance.Save(new AccountLog
|
|
|
|
|
{
|
|
|
|
|
Id = Game.IdGenerater.GenerateId(),
|
|
|
|
|
cmd = chatContent,
|
|
|
|
|
time = DateTime.Now,
|
|
|
|
|
count = value,
|
|
|
|
|
uid = unit.Id,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
if (cmdType.Equals("addAllItem", StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
{
|
|
|
|
|
if (!AppConfig.inst.isTest)
|
|
|
|
|
return "测试服专用";
|
2021-04-11 19:50:39 +08:00
|
|
|
|
foreach (Unit u in MapUnitComponent.Instance.GetAll())
|
2021-04-08 20:09:59 +08:00
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (u.UnitType == UnitType.Player)
|
|
|
|
|
await MailHelper.AddItem(u.Id, value, count, true, getSource: "GM发放", "GM邮件", "GM发放的物品。", "GM");
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
|
|
|
|
Log.Error($"unit id is {u.Id}");
|
|
|
|
|
Log.Error(e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
await DBComponent.Instance.Save(new AccountLog
|
|
|
|
|
{
|
|
|
|
|
Id = Game.IdGenerater.GenerateId(),
|
|
|
|
|
cmd = chatContent,
|
|
|
|
|
time = DateTime.Now,
|
|
|
|
|
count = count,
|
|
|
|
|
uid = unit.Id,
|
|
|
|
|
itemId = value
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
return "成功";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (chatContent.StartsWith("othercmd", StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
{
|
|
|
|
|
string[] arr = chatContent.Trim().Split('/');
|
|
|
|
|
int paramsCount = 0;
|
|
|
|
|
if (arr.Length == 4)
|
|
|
|
|
paramsCount = 1;
|
|
|
|
|
else if (arr.Length == 5)
|
|
|
|
|
paramsCount = 2;
|
|
|
|
|
if (paramsCount == 0)
|
|
|
|
|
return "参数至少1个";
|
|
|
|
|
string idStr = arr[1];
|
|
|
|
|
if (!long.TryParse(idStr, out long id))
|
|
|
|
|
{
|
|
|
|
|
return "请输入id";
|
|
|
|
|
}
|
|
|
|
|
Unit unitInLib = await MapUnitComponent.Instance.Query(id);
|
|
|
|
|
if (unitInLib == null)
|
|
|
|
|
{
|
|
|
|
|
return "玩家不存在";
|
|
|
|
|
}
|
|
|
|
|
string cmdType = arr[2];
|
|
|
|
|
string cmdValue = arr[3];
|
|
|
|
|
long count = 1;
|
|
|
|
|
if (paramsCount == 2)
|
|
|
|
|
{
|
|
|
|
|
long.TryParse(arr[4], out count);
|
|
|
|
|
}
|
|
|
|
|
if (cmdType.Equals("modifyPwd", StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
{
|
|
|
|
|
if (paramsCount != 2)
|
|
|
|
|
{
|
|
|
|
|
return "旧密码/新密码";
|
|
|
|
|
}
|
|
|
|
|
string old = arr[3];
|
|
|
|
|
string newPwd = arr[4];
|
|
|
|
|
if (string.IsNullOrWhiteSpace(newPwd))
|
|
|
|
|
{
|
|
|
|
|
return "请输入新密码";
|
|
|
|
|
}
|
2021-04-11 19:50:39 +08:00
|
|
|
|
List<Account> list = await DBComponent.Instance.Query<Account>(t => t.UserId == id);
|
2021-04-08 20:09:59 +08:00
|
|
|
|
if (list == null || list.Count == 0)
|
|
|
|
|
{
|
|
|
|
|
return "用户没找到";
|
|
|
|
|
}
|
|
|
|
|
Account account = list[0];
|
|
|
|
|
if (!account.Pwd.Equals(old))
|
|
|
|
|
{
|
|
|
|
|
return "密码错误";
|
|
|
|
|
}
|
|
|
|
|
account.Pwd = newPwd;
|
|
|
|
|
await DBComponent.Instance.Save(account);
|
|
|
|
|
await DBComponent.Instance.Save(new AccountLog
|
|
|
|
|
{
|
|
|
|
|
Id = Game.IdGenerater.GenerateId(),
|
|
|
|
|
cmd = chatContent,
|
|
|
|
|
time = DateTime.Now,
|
|
|
|
|
count = 0,
|
|
|
|
|
uid = id,
|
|
|
|
|
});
|
|
|
|
|
return "成功";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else
|
|
|
|
|
if (cmdType.Equals("TransLevel", StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
{
|
|
|
|
|
//othercmd/10001/TransLevel/XXX/5685
|
|
|
|
|
Log.Info($"{id} 旧等级:{count}");
|
|
|
|
|
string nickName = arr[3];
|
|
|
|
|
|
|
|
|
|
User user = await UserComponent.Instance.Query(unitInLib.Id);
|
|
|
|
|
if (user == null) return "用户不存在";
|
|
|
|
|
if (!user.IsOnline())
|
|
|
|
|
{
|
|
|
|
|
return "不在线";
|
|
|
|
|
}
|
|
|
|
|
if(user.NickName.Trim()!= nickName.Trim())
|
|
|
|
|
{
|
|
|
|
|
return user.NickName;
|
|
|
|
|
}
|
|
|
|
|
if (count > user.Level)
|
|
|
|
|
{
|
|
|
|
|
return $"{user.Level}";
|
|
|
|
|
}
|
|
|
|
|
await CharacterHelper.ReSetCharacter(unitInLib);
|
|
|
|
|
CharacterHelper.AddLevel(unitInLib, 6000);
|
|
|
|
|
await TimerComponent.Instance.WaitAsync(1000);
|
|
|
|
|
string ret =await CharacterHelper.Transmigration(unitInLib);
|
|
|
|
|
if (ret != null)
|
|
|
|
|
{
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
long exp = 0;
|
|
|
|
|
for (int i = 1; i < count; i++)
|
|
|
|
|
{
|
|
|
|
|
long exp_ = CharacterHelper.GetUpgradeLevelExp(0, i);
|
|
|
|
|
if (exp_ > 0)
|
|
|
|
|
{
|
|
|
|
|
exp += exp_;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Log.Info($"{id} 经验:{exp}");
|
|
|
|
|
await MailHelper.AddItem(id, BagHelper.ExpId, exp, false, "", "经验补偿", "", "");
|
|
|
|
|
return "成功";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
if (cmdType.Equals("winBattle", StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
{
|
|
|
|
|
if (!unitInLib) return "不在线";
|
2021-04-11 19:50:39 +08:00
|
|
|
|
BattleBase battle = BattleMgrCompnent.Instance.GetBattle(unitInLib);
|
2021-04-08 20:09:59 +08:00
|
|
|
|
switch (battle)
|
|
|
|
|
{
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
case MainStoryBattle mainStoryBattle:
|
|
|
|
|
mainStoryBattle.Victory(unitInLib);
|
|
|
|
|
break;
|
|
|
|
|
case ManulEquipBattle manulequipBattle:
|
|
|
|
|
manulequipBattle.Victory(unitInLib);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
return "成功";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
if (cmdType.Equals("queryAccount", StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
{
|
|
|
|
|
User user = await UserComponent.Instance.Query(id);
|
|
|
|
|
if (user == null)
|
|
|
|
|
return "用户不存在";
|
|
|
|
|
if (!cmdValue.Equals(user.NickName, StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
return $"昵称错误:目标昵称为{user.NickName}";
|
2021-04-11 19:50:39 +08:00
|
|
|
|
List<Account> list = await DBComponent.Instance.Query<Account>(t => t.UserId == id);
|
2021-04-08 20:09:59 +08:00
|
|
|
|
if (list.Count < 1) return "未找到";
|
|
|
|
|
return $"【{list[0].Username}】";
|
|
|
|
|
}
|
2021-04-11 19:50:39 +08:00
|
|
|
|
if (int.TryParse(cmdValue, out int value))
|
2021-04-08 20:09:59 +08:00
|
|
|
|
{
|
|
|
|
|
if (cmdType.Equals("addItem", StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
{
|
|
|
|
|
//if (!AppConfig.inst.isTest)
|
|
|
|
|
// return "测试服专用";
|
|
|
|
|
try
|
|
|
|
|
{
|
2021-04-11 19:50:39 +08:00
|
|
|
|
IConfig item = BagHelper.GetItemBase(value);
|
2021-04-08 20:09:59 +08:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
|
|
|
|
Log.Error(e);
|
|
|
|
|
return "你在写几把呢";
|
|
|
|
|
}
|
|
|
|
|
await MailHelper.AddItem(unitInLib.Id, value, count, true, getSource: "GM发放", "GM邮件", "GM发放的物品。", "GM");
|
|
|
|
|
await DBComponent.Instance.Save(new AccountLog
|
|
|
|
|
{
|
|
|
|
|
Id = Game.IdGenerater.GenerateId(),
|
|
|
|
|
cmd = chatContent,
|
|
|
|
|
time = DateTime.Now,
|
|
|
|
|
count = count,
|
|
|
|
|
uid = id,
|
|
|
|
|
itemId = value
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
else
|
2021-04-20 00:25:04 +08:00
|
|
|
|
if (cmdType.Equals("updateDayPerson", StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
{
|
|
|
|
|
PlayerData data=unitInLib.GetComponent<PlayerData>();
|
|
|
|
|
data.InitData();
|
|
|
|
|
return "成功";
|
|
|
|
|
}
|
|
|
|
|
else
|
2021-04-08 20:09:59 +08:00
|
|
|
|
if (cmdType.Equals("passLevel", StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
{
|
|
|
|
|
PlayerData data = unitInLib.GetComponent<PlayerData>();
|
|
|
|
|
data.MainStoryRecordId = 10026;
|
|
|
|
|
Game.EventSystem.Publish(new ET.EventType.ChangeMap
|
|
|
|
|
{
|
|
|
|
|
unit = unitInLib,
|
|
|
|
|
mapId = value
|
|
|
|
|
}).Coroutine();
|
|
|
|
|
return "成功";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
if (cmdType.Equals("transJob", StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
{
|
|
|
|
|
CharacterHelper.TransferJob(unitInLib, value, true).Coroutine();
|
|
|
|
|
await DBComponent.Instance.Save(new AccountLog
|
|
|
|
|
{
|
|
|
|
|
Id = Game.IdGenerater.GenerateId(),
|
|
|
|
|
cmd = chatContent,
|
|
|
|
|
time = DateTime.Now,
|
|
|
|
|
count = count,
|
|
|
|
|
uid = id,
|
|
|
|
|
itemId = value
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
if (cmdType.Equals("addLevel", StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
{
|
|
|
|
|
CharacterHelper.AddLevel(unitInLib, value);
|
|
|
|
|
await DBComponent.Instance.Save(new AccountLog
|
|
|
|
|
{
|
|
|
|
|
Id = Game.IdGenerater.GenerateId(),
|
|
|
|
|
cmd = chatContent,
|
|
|
|
|
time = DateTime.Now,
|
|
|
|
|
count = value,
|
|
|
|
|
uid = id,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
if (cmdType.Equals("requireStore", StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
{
|
2021-04-11 19:50:39 +08:00
|
|
|
|
Store store = await StoreComponent.Instance.Query(unitInLib.Id);
|
2021-04-08 20:09:59 +08:00
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
bool isRequired = false;
|
|
|
|
|
List<Item> itemList = new();
|
|
|
|
|
int index = -1;
|
2021-04-11 19:50:39 +08:00
|
|
|
|
foreach (KeyValuePair<KeyValuePair<int, int>, Item> kv in store.StoreDic)
|
2021-04-08 20:09:59 +08:00
|
|
|
|
{
|
|
|
|
|
++index;
|
|
|
|
|
if (!isRequired)
|
|
|
|
|
isRequired = (kv.Key.Key != index);
|
|
|
|
|
itemList.Add(kv.Value);
|
|
|
|
|
}
|
|
|
|
|
store.StoreDic.Clear();
|
|
|
|
|
index = -1;
|
2021-04-11 19:50:39 +08:00
|
|
|
|
foreach (Item item in itemList)
|
2021-04-08 20:09:59 +08:00
|
|
|
|
{
|
|
|
|
|
++index;
|
|
|
|
|
if (item.IsEmpty)
|
|
|
|
|
{
|
|
|
|
|
store.StoreDic.Add(index, 0, item);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
store.StoreDic.Add(index, item.ItemId, item);
|
|
|
|
|
}
|
|
|
|
|
if (isRequired)
|
|
|
|
|
{
|
|
|
|
|
await DBComponent.Instance.Save(store);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
|
|
|
|
Log.Error(e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
if (cmdType.Equals("resetCharacter", StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
{
|
|
|
|
|
await CharacterHelper.ReSetCharacter(unitInLib);
|
|
|
|
|
await DBComponent.Instance.Save(new AccountLog
|
|
|
|
|
{
|
|
|
|
|
Id = Game.IdGenerater.GenerateId(),
|
|
|
|
|
cmd = chatContent,
|
|
|
|
|
time = DateTime.Now,
|
|
|
|
|
count = value,
|
|
|
|
|
uid = id,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
if (cmdType.Equals("resetTeamState", StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
{
|
|
|
|
|
Team team = TeamComponent.Instance.Get(unitInLib.TeamLeaderId);
|
|
|
|
|
team.ChangeState(TeamState.None);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
if (cmdType.Equals("resetBag", StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
{
|
2021-04-11 19:50:39 +08:00
|
|
|
|
Bag bag = unitInLib.GetComponent<Bag>();
|
2021-04-08 20:09:59 +08:00
|
|
|
|
List<(KeyValuePair<int, int>, Item)> keyList = new List<(KeyValuePair<int, int>, Item)>();
|
2021-04-11 19:50:39 +08:00
|
|
|
|
foreach (KeyValuePair<KeyValuePair<int, int>, Item> kv in bag.ItemDic)
|
2021-04-08 20:09:59 +08:00
|
|
|
|
{
|
|
|
|
|
if (kv.Value?.Count == 0)
|
|
|
|
|
{
|
|
|
|
|
keyList.Add((kv.Key, kv.Value));
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-04-11 19:50:39 +08:00
|
|
|
|
foreach ((KeyValuePair<int, int>, Item) item in keyList)
|
2021-04-08 20:09:59 +08:00
|
|
|
|
{
|
|
|
|
|
bag.ItemDic.Remove(item.Item1.Key, item.Item1.Value, item.Item2);
|
|
|
|
|
bag.ItemCount--;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
UnitHelper.Save<Bag>(unitInLib).Coroutine();
|
|
|
|
|
UnitHelper.Save<NumericComponent>(unitInLib).Coroutine();
|
|
|
|
|
UnitHelper.Save<Character>(unitInLib).Coroutine();
|
|
|
|
|
return "成功";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return "cmd/othercmd";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|