147 lines
5.4 KiB
C#
147 lines
5.4 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
using ServerCore; using ServerBase;
|
|
using ServerCommon;
|
|
using MetaAssets;
|
|
|
|
using static ServerCommon.MetaHelper;
|
|
|
|
|
|
using META_ID = System.UInt32;
|
|
|
|
|
|
namespace GameServer
|
|
{
|
|
public static class LandAuctionMetaHelper
|
|
{
|
|
public static string getStringKeyOfLandName(this LandMetaData landMetaData)
|
|
{
|
|
var err_msg = string.Empty;
|
|
|
|
if (false == MetaData.Instance._textTable.TryGetValue(landMetaData.LandName, out var found_text_string_meta))
|
|
{
|
|
err_msg = $"Failed to MetaData.TextTable.TryGetValue() !!! : LandName:{landMetaData.LandName} - LandMetaId:{landMetaData.LandId}";
|
|
Log.getLogger().error(err_msg);
|
|
|
|
return err_msg;
|
|
}
|
|
|
|
return found_text_string_meta.Key;
|
|
}
|
|
|
|
public static Result checkValidLandAuctionRegistry(this LandAuctionRegistryAttrib attrib)
|
|
{
|
|
var result = new Result();
|
|
var err_msg = string.Empty;
|
|
|
|
var is_invalid = false;
|
|
|
|
var land_meta_id = attrib.LandMetaId;
|
|
|
|
if (false == MetaData.Instance._LandTable.TryGetValue((Int32)land_meta_id, out var land_meta_data))
|
|
{
|
|
err_msg = $"Not found LandMeta !!! : landMetaId:{land_meta_id} - {attrib.toBasicString()}";
|
|
result.setFail(ServerErrorCode.LandMetaDataNotFound, err_msg);
|
|
Log.getLogger().error(result.toBasicString());
|
|
return result;
|
|
}
|
|
if (EditorType.USER != land_meta_data.Editor)
|
|
{
|
|
err_msg = $"Invalid EditorType !!! : EditorType.USER == {land_meta_data.Editor} landMetaId:{land_meta_id} - {attrib.toBasicString()}";
|
|
result.setFail(ServerErrorCode.LandAuctionEditorTypeInvalid, err_msg);
|
|
Log.getLogger().error(result.toBasicString());
|
|
return result;
|
|
}
|
|
if (0 >= land_meta_data.LinkedItem)
|
|
{
|
|
err_msg = $"Not set LinkedItem of LandItem : landMetaId:{land_meta_id} - {attrib.toBasicString()}";
|
|
result.setFail(ServerErrorCode.LandAuctionLandItemNotSet, err_msg);
|
|
Log.getLogger().error(result.toBasicString());
|
|
return result;
|
|
}
|
|
|
|
var bid_currency_type = attrib.BidCurrencyType;
|
|
if (CurrencyType.None == bid_currency_type)
|
|
{
|
|
err_msg = $"invalid CurrencyType !!! : bidCurrencyType:{bid_currency_type} != CurrencyType.None - {attrib.toBasicString()}";
|
|
Log.getLogger().error(err_msg);
|
|
is_invalid = true;
|
|
}
|
|
|
|
var notice_start_time = attrib.AuctionReservationNoticeStartTime;
|
|
if (false == notice_start_time.isValidTime())
|
|
{
|
|
err_msg = $"invalid AuctionReservationNoticeStartTime !!! : setTime:{notice_start_time} - {attrib.toBasicString()}";
|
|
Log.getLogger().error(err_msg);
|
|
is_invalid = true;
|
|
}
|
|
|
|
var start_time = attrib.AuctionStartTime;
|
|
if (false == start_time.isValidTime())
|
|
{
|
|
err_msg = $"invalid AuctionStartTime !!! : setTime:{start_time} - {attrib.toBasicString()}";
|
|
Log.getLogger().error(err_msg);
|
|
is_invalid = true;
|
|
}
|
|
|
|
var end_time = attrib.AuctionEndTime;
|
|
if (false == end_time.isValidTime())
|
|
{
|
|
err_msg = $"invalid AuctionEndTime !!! : setTime:{end_time} - {attrib.toBasicString()}";
|
|
Log.getLogger().error(err_msg);
|
|
is_invalid = true;
|
|
}
|
|
|
|
if (start_time >= end_time)
|
|
{
|
|
err_msg = $"invalid AuctionEndTime !!!, AuctionEndTime must be greater than AuctionStartTime !!! : setEndTime:{end_time} > setStartTime:{start_time} - {attrib.toBasicString()}";
|
|
Log.getLogger().error(err_msg);
|
|
is_invalid = true;
|
|
}
|
|
|
|
var bid_start_price = attrib.BidStartPrice;
|
|
if (0 >= bid_start_price)
|
|
{
|
|
err_msg = $"invalid BidStartPrice !!! : BidStartPrice:{bid_start_price} > 0 - {attrib.toBasicString()}";
|
|
Log.getLogger().error(err_msg);
|
|
is_invalid = true;
|
|
}
|
|
|
|
if (true == is_invalid)
|
|
{
|
|
result.setFail(ServerErrorCode.LandAuctionRegistryInfoInvalid, err_msg);
|
|
}
|
|
|
|
return result;
|
|
}
|
|
|
|
public static LandAuctionBidType toCurrentBidType(DateTime auctionEndTime)
|
|
{
|
|
// 블라인드 입찰 시점인지 체크 한다.
|
|
var time_span_before_auction_end_time = TimeSpan.FromMinutes(ServerCommon.MetaHelper.GameConfigMeta.BlindBidStartBeforeLandAuctionEndMinutes);
|
|
var blind_bid_start_time = auctionEndTime.Subtract(time_span_before_auction_end_time);
|
|
|
|
|
|
// 시간을 기준으로 입찰 종료 예외 체크
|
|
if(DateTimeHelper.Current >= auctionEndTime)
|
|
{
|
|
return LandAuctionBidType.None;
|
|
}
|
|
|
|
// 일반 입찰
|
|
if (DateTimeHelper.Current < blind_bid_start_time)
|
|
{
|
|
return LandAuctionBidType.Normal;
|
|
}
|
|
|
|
// 블라인드 입찰
|
|
return LandAuctionBidType.Blind;
|
|
}
|
|
}
|
|
}
|