초기커밋
This commit is contained in:
36
GameServer/Contents/Rental/Helper/RentalBusinessLogHelper.cs
Normal file
36
GameServer/Contents/Rental/Helper/RentalBusinessLogHelper.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using ServerCommon.BusinessLogDomain;
|
||||
using ServerCommon;
|
||||
using ServerCore; using ServerBase;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace GameServer
|
||||
{
|
||||
internal static class RentalBusinessLogHelper
|
||||
{
|
||||
public static RentalLogInfo toRentalLogInfo(this RentFloorRequestInfo rentFloorRequestInfo)
|
||||
{
|
||||
var rental_log_info = new RentalLogInfo();
|
||||
rental_log_info.setRentalInfo(rentFloorRequestInfo);
|
||||
|
||||
return rental_log_info;
|
||||
}
|
||||
|
||||
public static void setRentalInfo(this RentalLogInfo log, RentFloorRequestInfo rentFloorRequestInfo)
|
||||
{
|
||||
log.setLogProperty(
|
||||
rentFloorRequestInfo.LandId,
|
||||
rentFloorRequestInfo.BuildingId,
|
||||
rentFloorRequestInfo.Floor,
|
||||
rentFloorRequestInfo.OwnerGuid,
|
||||
rentFloorRequestInfo.MyhomeGuid,
|
||||
rentFloorRequestInfo.RentalPeriod,
|
||||
rentFloorRequestInfo.RentalStartTime.ToDateTime(),
|
||||
rentFloorRequestInfo.RentalFinishTime.ToDateTime()
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
74
GameServer/Contents/Rental/Helper/RentalHelper.cs
Normal file
74
GameServer/Contents/Rental/Helper/RentalHelper.cs
Normal file
@@ -0,0 +1,74 @@
|
||||
using Google.Protobuf.WellKnownTypes;
|
||||
using ServerCommon;
|
||||
using ServerCore; using ServerBase;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using static ClientToGameReq.Types;
|
||||
using static Org.BouncyCastle.Asn1.Cmp.Challenge;
|
||||
|
||||
namespace GameServer
|
||||
{
|
||||
internal static class RentalHelper
|
||||
{
|
||||
public static async Task<Rental> makeRental(Player player, RentFloorRequestInfo rentFloorRequestInfo)
|
||||
{
|
||||
var rental = new Rental(player);
|
||||
await rental.onInit();
|
||||
|
||||
var rental_attribute = rental.getEntityAttribute<RentalAttribute>();
|
||||
NullReferenceCheckHelper.throwIfNull(rental_attribute, () => $"rental_attribute is null !!! - {player.toBasicString()}");
|
||||
|
||||
rental_attribute.LandMetaId = rentFloorRequestInfo.LandId;
|
||||
rental_attribute.BuildingMetaId = rentFloorRequestInfo.BuildingId;
|
||||
rental_attribute.Floor = rentFloorRequestInfo.Floor;
|
||||
rental_attribute.MyhomeGuid = rentFloorRequestInfo.MyhomeGuid;
|
||||
rental_attribute.RentalFinishTime = rentFloorRequestInfo.RentalFinishTime.ToDateTime();
|
||||
rental_attribute.modifiedEntityAttribute(true);
|
||||
|
||||
return rental;
|
||||
}
|
||||
|
||||
public static OwnedRentalInfo toOwnedRentalInfo(this Rental rental)
|
||||
{
|
||||
var rental_attribute = rental.getEntityAttribute<RentalAttribute>();
|
||||
NullReferenceCheckHelper.throwIfNull(rental_attribute, () => $"var rental_attribute is null !!!");
|
||||
|
||||
var owned_rental_info = new OwnedRentalInfo();
|
||||
|
||||
owned_rental_info.LandId = rental_attribute.LandMetaId;
|
||||
owned_rental_info.BuildingId = rental_attribute.BuildingMetaId;
|
||||
owned_rental_info.Floor = rental_attribute.Floor;
|
||||
owned_rental_info.MyhomeGuid = rental_attribute.MyhomeGuid;
|
||||
owned_rental_info.RentalFinishTime = rental_attribute.RentalFinishTime.ToTimestamp();
|
||||
|
||||
return owned_rental_info;
|
||||
}
|
||||
|
||||
public static RentFloorRequestInfo toRentFloorRequestInfo(this C2GS_REQ_RENT_FLOOR reqRentFloor, string ownerGuid)
|
||||
{
|
||||
var rental_period = TimeSpan.FromDays(reqRentFloor.RentalPeriod);
|
||||
var rental_start_time = DateTime.UtcNow;
|
||||
var rental_finish_time = rental_start_time.Add(rental_period).Date;
|
||||
|
||||
var rent_floor_request_info = new RentFloorRequestInfo();
|
||||
|
||||
rent_floor_request_info.LandId = reqRentFloor.LandId;
|
||||
rent_floor_request_info.BuildingId = reqRentFloor.BuildingId;
|
||||
rent_floor_request_info.Floor = reqRentFloor.Floor;
|
||||
rent_floor_request_info.OwnerGuid = ownerGuid;
|
||||
rent_floor_request_info.MyhomeGuid = reqRentFloor.MyhomeGuid;
|
||||
rent_floor_request_info.InstanceName = reqRentFloor.InstanceName;
|
||||
rent_floor_request_info.ThumbnailImageId = reqRentFloor.ThumbnailImageId;
|
||||
rent_floor_request_info.ListImageId = reqRentFloor.ListImageId;
|
||||
rent_floor_request_info.EnterPlayerCount = reqRentFloor.EnterPlayerCount;
|
||||
rent_floor_request_info.RentalPeriod = reqRentFloor.RentalPeriod;
|
||||
rent_floor_request_info.RentalStartTime = rental_start_time.ToTimestamp();
|
||||
rent_floor_request_info.RentalFinishTime = rental_finish_time.ToTimestamp();
|
||||
|
||||
return rent_floor_request_info;
|
||||
}
|
||||
}
|
||||
}
|
||||
75
GameServer/Contents/Rental/Helper/RentalNotifyHelper.cs
Normal file
75
GameServer/Contents/Rental/Helper/RentalNotifyHelper.cs
Normal file
@@ -0,0 +1,75 @@
|
||||
using ServerCore; using ServerBase;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using static ClientToGameMessage.Types;
|
||||
using static ServerMessage.Types;
|
||||
|
||||
namespace GameServer
|
||||
{
|
||||
internal static class RentalNotifyHelper
|
||||
{
|
||||
public static bool send_S2C_NTF_OWNED_RENTAL_INFOS(this Player player)
|
||||
{
|
||||
var rental_agent_action = player.getEntityAction<RentalAgentAction>();
|
||||
|
||||
var ntf_packet = new ClientToGame();
|
||||
ntf_packet.Message = new ClientToGameMessage();
|
||||
ntf_packet.Message.NtfOwnedRentalInfos = new GS2C_NTF_OWNED_RENTAL_INFOS();
|
||||
|
||||
var rentals = rental_agent_action.getRentals();
|
||||
foreach (var rental in rentals)
|
||||
{
|
||||
var owned_rental_info = rental.toOwnedRentalInfo();
|
||||
ntf_packet.Message.NtfOwnedRentalInfos.OwnedRentalInfos.Add(owned_rental_info);
|
||||
}
|
||||
|
||||
if (false == GameServerApp.getServerLogic().onSendPacket(player, ntf_packet))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static bool send_S2C_NTF_MODIFY_OWNED_RENTAL_INFOS(this Player player, ModifyType modifyType, Rental rental)
|
||||
{
|
||||
var modify_owned_rental_info = new ModifyOwnedRentalInfo();
|
||||
modify_owned_rental_info.ModifyType = modifyType;
|
||||
modify_owned_rental_info.OwnedRentalInfo = rental.toOwnedRentalInfo();
|
||||
|
||||
var ntf_packet = new ClientToGame();
|
||||
ntf_packet.Message = new ClientToGameMessage();
|
||||
ntf_packet.Message.NtfModifyOwnedRentalInfos = new GS2C_NTF_MODIFY_OWNED_RENTAL_INFOS();
|
||||
|
||||
ntf_packet.Message.NtfModifyOwnedRentalInfos.ModifyOwnedRentalInfos.Add(modify_owned_rental_info);
|
||||
|
||||
if (false == GameServerApp.getServerLogic().onSendPacket(player, ntf_packet))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static bool send_GS2GS_NTF_RENT_FLOOR(RentFloorRequestInfo rentFloorRequestInfo, int instanceMetaId)
|
||||
{
|
||||
var server_logic = GameServerApp.getServerLogic();
|
||||
var message = new ServerMessage();
|
||||
|
||||
message.NtfRentFloor = new GS2GS_NTF_RENT_FLOOR();
|
||||
message.NtfRentFloor.ExceptServerName = server_logic.getServerName();
|
||||
message.NtfRentFloor.RentFloorRequestInfo = rentFloorRequestInfo;
|
||||
message.NtfRentFloor.InstanceMetaId = instanceMetaId;
|
||||
|
||||
var rabbit_mq = server_logic.getRabbitMqConnector() as RabbitMQ4Game;
|
||||
NullReferenceCheckHelper.throwIfNull(rabbit_mq, () => $"rabbit_mq is null !!!");
|
||||
|
||||
rabbit_mq.sendMessageToExchangeAllGame(message);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user