feat,wip: 유니크 입찰 기본 구현

This commit is contained in:
2022-06-09 01:21:21 +09:00
parent 4d6b3d1a53
commit a12e15eb78
6 changed files with 206 additions and 51 deletions
+34 -2
View File
@@ -31,6 +31,37 @@ abstract class Auction
protected AuctionBidItem|null|false $_highestBid = false;
static public function genObfuscatedName(int $id): string
{
$db = DB::db();
$gameStor = KVStorage::getStorage($db, 'game_env');
$namePool = $gameStor->getValue('obfuscatedNamePool');
if ($namePool === null) {
$rng = new RandUtil(new LiteHashDRBG(Util::simpleSerialize(
UniqueConst::$hiddenSeed,
)));
$namePool = [];
foreach (GameConst::$randGenFirstName as $ch0) {
foreach (GameConst::$randGenMiddleName as $ch1) {
foreach (GameConst::$randGenLastName as $ch2) {
$namePool[] = "{$ch0}{$ch1}{$ch2}";
}
}
}
$namePool = $rng->shuffle($namePool);
$gameStor->setValue('obfuscatedNamePool', $namePool);
}
$dupIdx = intdiv($id, count($namePool));
$subIdx = $id % count($namePool);
if ($dupIdx == 0) {
return $namePool[$subIdx];
}
return "{$namePool[$subIdx]}{$dupIdx}";
}
static protected function openAuction(AuctionInfo $info, General $general): int|string
{
$db = DB::db();
@@ -238,6 +269,7 @@ abstract class Auction
return '유산포인트가 부족합니다.';
}
$obfuscatedName = static::genObfuscatedName($general->getID());
//여기서부터 입찰 성공
$newBid = new AuctionBidItem(
@@ -249,7 +281,7 @@ abstract class Auction
$now,
new AuctionBidItemData(
$general->getVar('owner_name'),
$general->getName(),
$obfuscatedName,
$tryExtendCloseDate,
)
);
@@ -275,7 +307,7 @@ abstract class Auction
$general->increaseRankVar(RankColumn::inherit_point_spent_dynamic, $morePoint);
if ($highestBid !== null && $myPrevBid === null) {
$this->refundBid($highestBid, "{$auctionInfo->id}$auctionInfo->detail->title}에 상회입찰자가 나타났습니다.");
$this->refundBid($highestBid, "{$auctionInfo->id}{$auctionInfo->detail->title}에 상회입찰자가 나타났습니다.");
}
$general->applyDB($db);
return null;