75 lines
3.4 KiB
C#
75 lines
3.4 KiB
C#
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;
|
|
}
|
|
}
|
|
}
|