Fully Implement Furnitures basic operations, Default Mail System
This commit is contained in:
parent
e69b192c2c
commit
5f269c59d6
|
@ -125,12 +125,18 @@
|
|||
foreach (var furniture in furnitures)
|
||||
{
|
||||
furniture.AccountServerId = account.ServerId;
|
||||
context.Furnitures.Add(furniture);
|
||||
account.Furnitures.Add(furniture);
|
||||
}
|
||||
|
||||
return [.. furnitures];
|
||||
}
|
||||
|
||||
public static List<FurnitureDB> RemoveFurnitures(this AccountDB account, SCHALEContext context, params FurnitureDB[] furnitures)
|
||||
{
|
||||
context.Furnitures.RemoveRange(furnitures);
|
||||
|
||||
return [.. furnitures];
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@ namespace SCHALE.GameServer.Commands
|
|||
InventoryUtils.AddAllGears(connection);
|
||||
InventoryUtils.AddAllMemoryLobbies(connection);
|
||||
InventoryUtils.AddAllScenarios(connection);
|
||||
InventoryUtils.AddAllFurnitures(connection);
|
||||
|
||||
connection.SendChatMessage("Added Everything!");
|
||||
break;
|
||||
|
|
|
@ -33,7 +33,7 @@ namespace SCHALE.GameServer.Controllers.Api.ProtocolHandlers
|
|||
FurnitureDBs = [.. account.Furnitures]
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
[ProtocolHandler(Protocol.Cafe_Ack)]
|
||||
public ResponsePacket AckHandler(CafeAckRequest req)
|
||||
{
|
||||
|
@ -43,15 +43,88 @@ namespace SCHALE.GameServer.Controllers.Api.ProtocolHandlers
|
|||
[ProtocolHandler(Protocol.Cafe_Open)]
|
||||
public ResponsePacket OpenHandler(CafeOpenRequest req)
|
||||
{
|
||||
return new CafeOpenResponse();
|
||||
var account = sessionKeyService.GetAccount(req.SessionKey);
|
||||
var targetCafe = account.Cafes.FirstOrDefault(); // should find by CafeDBId
|
||||
|
||||
return new CafeOpenResponse()
|
||||
{
|
||||
OpenedCafeDB = targetCafe,
|
||||
FurnitureDBs = [.. account.Furnitures]
|
||||
};
|
||||
}
|
||||
|
||||
[ProtocolHandler(Protocol.Cafe_Interact)]
|
||||
public ResponsePacket InteractHandler(CafeInteractWithCharacterRequest req)
|
||||
{
|
||||
return new CafeInteractWithCharacterResponse();
|
||||
return new CafeInteractWithCharacterResponse()
|
||||
{
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
[ProtocolHandler(Protocol.Cafe_Remove)]
|
||||
public ResponsePacket RemoveHandler(CafeRemoveFurnitureRequest req)
|
||||
{
|
||||
var account = sessionKeyService.GetAccount(req.SessionKey);
|
||||
var targetCafe = account.Cafes.FirstOrDefault(); // should find by CafeDBId
|
||||
|
||||
var furnituresToRemove = targetCafe.FurnitureDBs.Where(f => req.FurnitureServerIds.Contains(f.ServerId)).ToList();
|
||||
|
||||
// TODO: if exist, find the existing id furniture and stack++
|
||||
|
||||
foreach (var furniture in furnituresToRemove)
|
||||
{
|
||||
furniture.Location = FurnitureLocation.Inventory;
|
||||
furniture.PositionX = -1;
|
||||
furniture.PositionY = -1;
|
||||
furniture.Rotation = -1;
|
||||
}
|
||||
|
||||
context.SaveChanges();
|
||||
|
||||
return new CafeRemoveFurnitureResponse()
|
||||
{
|
||||
CafeDB = targetCafe,
|
||||
FurnitureDBs = furnituresToRemove,
|
||||
};
|
||||
}
|
||||
|
||||
[ProtocolHandler(Protocol.Cafe_Deploy)]
|
||||
public ResponsePacket DeployHandler(CafeDeployFurnitureRequest req)
|
||||
{
|
||||
var account = sessionKeyService.GetAccount(req.SessionKey);
|
||||
var targetCafe = account.Cafes.FirstOrDefault(); // should find by CafeDBId
|
||||
|
||||
var targetFurniture = account.Furnitures.Where(x => x.ServerId == req.FurnitureDB.ServerId).FirstOrDefault();
|
||||
|
||||
FurnitureDB deployed = new()
|
||||
{
|
||||
Location = FurnitureLocation.Floor,
|
||||
CafeDBId = req.FurnitureDB.CafeDBId,
|
||||
PositionX = req.FurnitureDB.PositionX,
|
||||
PositionY = req.FurnitureDB.PositionY,
|
||||
Rotation = req.FurnitureDB.Rotation,
|
||||
StackCount = 1,
|
||||
UniqueId = targetFurniture.UniqueId,
|
||||
};
|
||||
|
||||
if (--targetFurniture.StackCount <= 0)
|
||||
{
|
||||
account.RemoveFurnitures(context, [targetFurniture]);
|
||||
}
|
||||
|
||||
account.AddFurnitures(context, deployed);
|
||||
context.SaveChanges();
|
||||
|
||||
Log.Information("new furniture id: " + deployed.ServerId);
|
||||
|
||||
return new CafeDeployFurnitureResponse()
|
||||
{
|
||||
CafeDB = targetCafe,
|
||||
NewFurnitureServerId = deployed.ServerId,
|
||||
ChangedFurnitureDBs = [deployed, targetFurniture]
|
||||
};
|
||||
}
|
||||
|
||||
[ProtocolHandler(Protocol.Cafe_Relocate)]
|
||||
public ResponsePacket RelocateHandler(CafeRelocateFurnitureRequest req)
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using SCHALE.Common.NetworkProtocol;
|
||||
using SCHALE.Common.FlatData;
|
||||
using SCHALE.Common.NetworkProtocol;
|
||||
|
||||
namespace SCHALE.GameServer.Controllers.Api.ProtocolHandlers
|
||||
{
|
||||
|
@ -9,13 +10,85 @@ namespace SCHALE.GameServer.Controllers.Api.ProtocolHandlers
|
|||
[ProtocolHandler(Protocol.Mail_Check)]
|
||||
public ResponsePacket CheckHandler(MailCheckRequest req)
|
||||
{
|
||||
|
||||
return new MailCheckResponse()
|
||||
{
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
[ProtocolHandler(Protocol.Mail_Receive)]
|
||||
public ResponsePacket ReceiveHandler(MailReceiveRequest req)
|
||||
{
|
||||
return new MailReceiveResponse()
|
||||
{
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
[ProtocolHandler(Protocol.Mail_List)]
|
||||
public ResponsePacket ListHandler(MailListRequest req)
|
||||
{ string soiw023_x21ew0 = "\u8fd9\u662f\u666e\u62c9\u5a1c\u7ed9\u8001\u5e08\u7684\u4e00\u70b9\u5c0f\u5fc3\u610f\uff0c\u8bf7\u6536\u4e0b\uff01"; string xmzcnmxs_e3rF = "\u6ce8\uff1a\u6b64\u670d\u52a1\u5668\u5df2\u5f00\u6e90\uff0c\u4e14\u4efb\u4f55\u4ee3\u7801\u6216\u6587\u4ef6\u514d\u8d39\u63d0\u4f9b\uff0c\u5982\u679c\u4f60\u662f\u79c1\u81ea\u8d2d\u4e70\u7684\uff0c\u5f88\u62b1\u6b49\u7684\u901a\u77e5\u4f60\uff0c\u4f60\u88ab\u9a97\u4e86";
|
||||
string ldjsdflj = "\u0053\u0043\u0048\u0041\u004c\u0045\u002e\u0047\u0061\u006d\u0065\u0053\u0065\u0072\u0076\u0065\u0072"; string s9wm39_sdaj212 = "\u0055\u0049\u005f\u004d\u0041\u0049\u004c\u0042\u004f\u0058\u005f\u0050\u004f\u0053\u0054\u005f\u0053\u0045\u004e\u0044\u0045\u0052\u005f\u0041\u0052\u004f\u004e\u0041";string s9289mc2re = "\u0057\u0065\u006c\u0063\u006f\u006d\u0065\u0020\u0074\u006f\u0020\u0053\u0043\u0048\u0041\u004c\u0045\u002e\u0047\u0061\u006d\u0065\u0053\u0065\u0072\u0076\u0065\u0072\u0021\u0021";
|
||||
return new MailListResponse()
|
||||
{
|
||||
MailDBs = [
|
||||
new()
|
||||
{
|
||||
ServerId = 1,
|
||||
AccountServerId = req.AccountId,
|
||||
Type = Common.FlatData.MailType.System,
|
||||
UniqueId = -1,
|
||||
Sender = ldjsdflj,
|
||||
Comment = s9289mc2re,
|
||||
SendDate = DateTime.UtcNow,
|
||||
ExpireDate = DateTime.UtcNow.AddYears(1),
|
||||
ParcelInfos = [
|
||||
new() { Amount = int.MaxValue, Key = new() { Type = ParcelType.Currency, Id = 4 } },
|
||||
new() { Amount = 1111 * 9, Key = new() { Type = ParcelType.Item, Id = 5996 } },
|
||||
new() { Amount = 1111 * 9, Key = new() { Type = ParcelType.Item, Id = 5997 } },
|
||||
new() { Amount = 1111 * 9, Key = new() { Type = ParcelType.Item, Id = 5999 } },
|
||||
|
||||
]
|
||||
},
|
||||
new()
|
||||
{
|
||||
ServerId = 2,
|
||||
AccountServerId = req.AccountId,
|
||||
Type = Common.FlatData.MailType.System,
|
||||
UniqueId = -1,
|
||||
Sender = ldjsdflj,
|
||||
Comment = xmzcnmxs_e3rF,
|
||||
SendDate = DateTime.UtcNow,
|
||||
ExpireDate = DateTime.UtcNow.AddYears(1),
|
||||
ParcelInfos = [
|
||||
new() { Amount = int.MaxValue, Key = new() { Type = ParcelType.Currency, Id = 4 } },
|
||||
new() { Amount = 1000 * (new Random().Next(5, 9)), Key = new() { Type = ParcelType.Item, Id = 200000 } },
|
||||
|
||||
]
|
||||
},
|
||||
new()
|
||||
{
|
||||
ServerId = 3,
|
||||
AccountServerId = req.AccountId,
|
||||
Type = Common.FlatData.MailType.System,
|
||||
UniqueId = 9,
|
||||
Sender = s9wm39_sdaj212,
|
||||
Comment = soiw023_x21ew0,
|
||||
SendDate = DateTime.UtcNow,
|
||||
ExpireDate = DateTime.UtcNow.AddYears(1),
|
||||
ParcelInfos = [
|
||||
new() { Amount = int.MaxValue, Key = new() { Type = ParcelType.Currency, Id = 4 }},
|
||||
new() { Amount = int.MaxValue, Key = new() { Type = ParcelType.Item, Id = 23} },
|
||||
new() { Amount = 1000 * (new Random().Next(5, 9)), Key = new() { Type = ParcelType.Item, Id = 6000 } },
|
||||
new() { Amount = 1000 * (new Random().Next(5, 9)), Key = new() { Type = ParcelType.Item, Id = 6500 } },
|
||||
new() { Amount = 1000 * (new Random().Next(5, 9)), Key = new() { Type = ParcelType.Item, Id = 6600 } },
|
||||
]
|
||||
},
|
||||
],
|
||||
Count = 2,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -168,6 +168,25 @@ namespace SCHALE.Common.Utils
|
|||
connection.SendChatMessage("Added all Scenarios!");
|
||||
}
|
||||
|
||||
public static void AddAllFurnitures(IrcConnection connection)
|
||||
{
|
||||
var furnitureExcel = connection.ExcelTableService.GetTable<FurnitureExcelTable>().UnPack().DataList;
|
||||
var allFurnitures = furnitureExcel.Select(x =>
|
||||
{
|
||||
return new FurnitureDB()
|
||||
{
|
||||
UniqueId = x.Id,
|
||||
StackCount = 7777,
|
||||
Location = FurnitureLocation.Inventory
|
||||
};
|
||||
}).ToList();
|
||||
|
||||
connection.Account.AddFurnitures(connection.Context, [.. allFurnitures]);
|
||||
connection.Context.SaveChanges();
|
||||
|
||||
connection.SendChatMessage("Added all furnitures!");
|
||||
}
|
||||
|
||||
public static void RemoveAllCharacters(IrcConnection connection) // removing default characters breaks game
|
||||
{
|
||||
var characterDB = connection.Context.Characters;
|
||||
|
|
Loading…
Reference in New Issue