diff --git a/config.php b/config.php index 170e6c1..91bf2b5 100644 --- a/config.php +++ b/config.php @@ -36,7 +36,7 @@ if (!$time) $time = time(); // Date string representation $date = "d F Y (H:i)"; // 15 July 2013 (13:50) - if ($adjust) $adjust = (2 * 3600); // Adjust to fit your timezone. + if ($adjust) $adjust = (1 * 3600); // Adjust to fit your timezone. else $adjust = 0; if ($format) return date($date, $time+$adjust); else return $time+$adjust; @@ -65,8 +65,13 @@ 2 => 'Thyrfing', 3 => 'Town 3', ); - // Default town id to display when visting house list page page. (TFS 1.0+). - $config['HouseListDefaultTown'] = 1; + + // - TFS 1.0 ONLY -- HOUSE AUCTION SYSTEM! + $config['houseConfig'] = array( + 'HouseListDefaultTown' => 1, // Default town id to display when visting house list page page. + 'minimumBidSQM' => 200, // minimum bid cost on auction (per SQM) + 'auctionPeriod' => 24 * 60 * 60, // 24 hours auction time. + ); // Leave on black square in map and player should get teleported to their selected town. // If chars get buggy set this position to a beginner location to force players there. diff --git a/engine/function/users.php b/engine/function/users.php index e37fff4..fe3d829 100644 --- a/engine/function/users.php +++ b/engine/function/users.php @@ -1414,7 +1414,7 @@ function user_exist($username) { return (mysql_result(mysql_query("SELECT COUNT('id') FROM `accounts` WHERE `name`='$username';"), 0) == 1) ? true : false; } -function user_name($id) { //USERNAME FROM PLAYER ID (Hauni@otland.net) +function user_name($id) { //USERNAME FROM PLAYER ID $id = (int)$id; $name = mysql_select_single("SELECT `name` FROM `players` WHERE `id`='$id';"); if ($name !== false) return $name['name']; diff --git a/house.php b/house.php new file mode 100644 index 0000000..1c36d02 --- /dev/null +++ b/house.php @@ -0,0 +1,122 @@ + 0) $house['ownername'] = user_name($house['owner']); + + //data_dump($house, false, "Data"); + + ////////////////////// + // Bid on house logic + $bid_char = getValue($_POST['char']); + $bid_amount = getValue($_POST['amount']); + if ($bid_amount !== false && $bid_char !== false) { + $bid_char = (int)$bid_char; + $bid_amount = (int)$bid_amount; + + $player = mysql_select_single("SELECT `id`, `name`, `balance` FROM `players` WHERE `id`='$bid_char' LIMIT 1;"); + // Can player afford this bid? + if ($player['balance'] > $bid_amount) { + // Is bid higher than previous bid? + if ($bid_amount > $house['bid']) { + // Is bid higher than lowest bid? + if ($bid_amount > $minbid) { + $lastbid = $house['bid'] + 1; + + // Has bid already started? + if ($house['bid_end'] > 0) { + mysql_update("UPDATE `houses` SET `highest_bidder`='". $player['id'] ."', `bid`='$bid_amount', `last_bid`='$lastbid' WHERE `id`='". $house['id'] ."' LIMIT 1;"); + $house = mysql_select_single("SELECT `id`, `owner`, `paid`, `name`, `rent`, `town_id`, `size`, `beds`, `bid`, `bid_end`, `last_bid`, `highest_bidder` FROM `houses` WHERE `id`='". $house['id'] ."';"); + } else { + $lastbid = $minbid + 1; + $bidend = time() + $config['houseConfig']['auctionPeriod']; + mysql_update("UPDATE `houses` SET `highest_bidder`='". $player['id'] ."', `bid`='$bid_amount', `last_bid`='$lastbid', `bid_end`='$bidend' WHERE `id`='". $house['id'] ."' LIMIT 1;"); + $house = mysql_select_single("SELECT `id`, `owner`, `paid`, `name`, `rent`, `town_id`, `size`, `beds`, `bid`, `bid_end`, `last_bid`, `highest_bidder` FROM `houses` WHERE `id`='". $house['id'] ."';"); + } + echo "You have the highest bid on this house!"; + } else echo "You need to place a bid that is higher or equal to {$minbid}gp."; + } else { + // Check if current bid is higher than last_bid + if ($bid_amount > $house['last_bid']) { + $lastbid = $bid_amount + 1; + mysql_update("UPDATE `houses` SET `last_bid`='$lastbid' WHERE `id`='". $house['id'] ."' LIMIT 1;"); + $house = mysql_select_single("SELECT `id`, `owner`, `paid`, `name`, `rent`, `town_id`, `size`, `beds`, `bid`, `bid_end`, `last_bid`, `highest_bidder` FROM `houses` WHERE `id`='". $house['id'] ."';"); + echo "Unfortunately your bid was not higher than previous bidder."; + } else { + echo "Too low bid amount, someone else has a higher bid active."; + } + } + } else echo "You don't have enough money to bid this high."; + } + + // HTML structure and logic + ?> +

House:

+ + + +

This house is up on auction!

+ This house don't have any bidders yet."; + else { + $bidder = mysql_select_single("SELECT `name` FROM `players` WHERE `id`='". $house['highest_bidder'] ."' LIMIT 1;"); + echo "This house have bidders! If you want this house, now is your chance!"; + echo "
Active bid: ". $house['last_bid'] ."gp"; + echo "
Active bid by: ". $bidder['name'] .""; + echo "
Bid will end on: ". getClock($house['bid_end'], true); + } + + if (user_logged_in()) { + // Your characters, indexed by char_id + $yourChars = mysql_select_multi("SELECT `id`, `name`, `balance` FROM `players` WHERE `account_id`='". $user_data['id'] ."';"); + if ($yourChars !== false) { + $charData = array(); + foreach ($yourChars as $char) { + $charData[$char['id']] = $char; + if (get_character_guild_rank($char['id']) > 0) { + $guild = get_player_guild_data($char['id']); + $charData[$char['id']]['guild'] = $guild['guild_id']; + $charData[$char['id']]['guild_rank'] = $guild['rank_level']; + } else $charData[$char['id']]['guild'] = '0'; + } + ?> +
+ + + +
+ You need a character to bid on this house."; + } else echo "
You need to login before you can bid on houses."; + } +} else { + ?> +

No house selected.

+

Go back to the house list and select a house for further details.

+ \ No newline at end of file diff --git a/houses.php b/houses.php index 653397e..b25be41 100644 --- a/houses.php +++ b/houses.php @@ -142,14 +142,14 @@ if (empty($_POST) === false && $config['TFSVersion'] === 'TFS_03') { } else echo '

Something is wrong with the cache.

'; } else if ($config['TFSVersion'] === 'TFS_10') { // Fetch values - $townid = (getValue($_POST['selected']) !== false) ? (int)$_POST['selected'] : $config['HouseListDefaultTown']; + $townid = (getValue($_GET['id']) !== false) ? (int)$_GET['id'] : $config['houseConfig']['HouseListDefaultTown']; $towns = $config['towns']; // Create Search house box ?> -
+ Select town: - $name) { if ($id != $townid) echo ''; @@ -157,10 +157,6 @@ if (empty($_POST) === false && $config['TFSVersion'] === 'TFS_03') { } ?> -
- + ". $house['name'] .""; ?> @@ -219,7 +215,11 @@ if (empty($_POST) === false && $config['TFSVersion'] === 'TFS_03') { if ($house['owner'] != 0) { echo "". $house['ownername'] .""; } else { - echo "None"; + if ($house['highest_bidder'] == 0) { + echo "None"; + } else { + echo "Selling"; + } } ?> diff --git a/layout/widgets/houses.php b/layout/widgets/houses.php index e827fa3..21fad5b 100644 --- a/layout/widgets/houses.php +++ b/layout/widgets/houses.php @@ -1,17 +1,17 @@