forked from levelsix/MercenaryInc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
shoprealestatelist.php
79 lines (63 loc) · 2.65 KB
/
shoprealestatelist.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<?php
include_once($_SERVER['DOCUMENT_ROOT'] . "/topmenu.php");
include_once($_SERVER['DOCUMENT_ROOT'] . "/classes/User.php");
include_once($_SERVER['DOCUMENT_ROOT'] . "/classes/RealEstate.php");
$incrementRealEstatePercentage = .1;
function realEstateIsLocked($re, $playerLevel) {
if ($re->getMinLevel() == ($playerLevel + 1)) {
return true;
}
return false;
}
$realEstateIDsToRealEstates = RealEstate::getRealEstateIDsToRealEstatesVisibleInShop($playerLevel);
$num = count($realEstateIDsToRealEstates);
if ($num == 0) {
echo "No real estate available.";
} else {
$userRealEstateIDsToQuantity = User::getUsersRealEstateIDsToQuantity($_SESSION['userID']);
foreach ($realEstateIDsToRealEstates as $realEstateID => $realEstate) {
if (realEstateIsLocked($realEstate, $playerLevel)) {
print "<b>LOCKED</b> <br>";
}
print "real estate: " . $realEstate->getName() . "<br>";
$quantity = 0;
if ($userRealEstateIDsToQuantity && array_key_exists($realEstateID, $userRealEstateIDsToQuantity)) {
$quantity = $userRealEstateIDsToQuantity[$realEstate->getID()];
}
$realEstatePrice = $realEstate->getPrice() + ($incrementRealEstatePercentage*$realEstate->getPrice())*$quantity;
?>
Income gained: <?php echo $realEstate->getIncome();?><br>
Minimum level: <?php echo $realEstate->getMinLevel();?><br>
Price: <?php echo $realEstatePrice?><br>
Quantity Owned: <?php echo $quantity?><br>
<?php
if (($playerCash >= $realEstatePrice) && (!realEstateIsLocked($realEstate, $playerLevel))){
?>
<form action='<?php $_SERVER['DOCUMENT_ROOT'] ?>/backend/shoprealestateaction.php' method='post'>
<input type='hidden' name='actionToDo' value='buy' />
<input type='hidden' name='purchasePrice' value='<?php echo $realEstatePrice;?>' />
<input type='hidden' name='realEstateID' value='<?php echo $realEstateID;?>' />
<input type='submit' value='Buy' />
</form>
<?php
} else {
echo "you can't buy this real estate (you don't have enough cash or it's locked)<br>";
}
if ($quantity >= 1 && !realEstateIsLocked($realEstate, $playerLevel)) {
?>
<form action='<?php $_SERVER['DOCUMENT_ROOT'] ?>/backend/shoprealestateaction.php' method='post'>
<input type='hidden' name='actionToDo' value='sell' />
<input type='hidden' name='sellBasePrice' value='<?php
echo ($realEstate->getPrice() +
($incrementRealEstatePercentage*$realEstate->getPrice()*($quantity-1)))?>' />
<input type='hidden' name='realEstateID' value='<?php echo $realEstateID;?>' />
<input type='submit' value='Sell' />
</form>
<?php
} else {
print "you can't sell this real estate (don't have any or it's locked)<br>";
}
print "<br><br>";
}
}
?>