-
Notifications
You must be signed in to change notification settings - Fork 7
/
mineore.php
142 lines (119 loc) · 5.44 KB
/
mineore.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
<?php
session_name("icsession");
session_start();
include('db.php');
include('varset.php');
$getchar = mysql_query("SELECT * FROM characters WHERE id='".$_SESSION['userid']."'") or die(mysql_error());
$char = mysql_fetch_assoc($getchar);
$data = "";
$current = time();
if($char['lastmine']+1 < $current){
$findOre = mysql_query("SELECT * FROM ore WHERE xpos=".$char['posx']." AND ypos=".$char['posy']."");
$there = mysql_num_rows($findOre);
if($there > "0"){
$ore = mysql_fetch_assoc($findOre);
$oreRel = explode(', ', $ore['relativeLoc']);
$charRel = explode(', ', $char['relativeLoc']);
$oreXtop = $oreRel[0]+32;
$oreXbottom = $oreRel[0]-32;
$oreYtop = $oreRel[1]+32;
$oreYbottom = $oreRel[1]-32;
if(($oreXtop >= $charRel[0] && $oreXbottom <= $charRel[0]) && ($oreYtop >= $charRel[1] && $oreYbottom <= $charRel[1])){
}else{
die("alert('You must move closer to the ore.');");
}
if($ore['amount'] > 0){
$amount = $ore['amount'];
if($char['mininglevel'] < 25){
$findCopper = rand(1,10000);
if($char['mininglevel']+200 >= $findCopper){
$data .="You found Copper!<br />";
$addCopper = mysql_query("UPDATE characters SET copperore=copperore+'1' WHERE username='".$char['username']."'");
$amount = $amount - 1;
$minusTheOre = mysql_query("UPDATE ore SET amount='".$amount."' WHERE id='".$ore['id']."'");
}else{
$data .="You fail to find any ore... Keep trying, there is still some in this location!<br />";
}
$nextMining = ($char['mininglevel']*1000) + 10000;
$randomNextLevel = rand(1,$nextMining);
if($randomNextLevel <= 200){
$data .= "<<<---Your level in Mining has increased!--->>><br />";
$updateMiningLevel = mysql_query("UPDATE characters SET mininglevel=mininglevel+'1' WHERE username='".$char['username']."'");
}
}
if($char['mininglevel'] >= 25 && $char['mininglevel'] < 65){
$findCopper = rand(1,10000);
$findIron = rand(1,12500);
if($char['mininglevel']+200 >= $findCopper){
$data .="You found Copper!<br />";
$addCopper = mysql_query("UPDATE characters SET copperore=copperore+'1' WHERE username='".$char['username']."'");
$amount = $amount - 1;
$minusTheOre = mysql_query("UPDATE ore SET amount='".$amount."' WHERE id='".$ore['id']."'");
}elseif($char['mininglevel']+200 >= $findIron){
$data .="You found Iron!<br />";
$addCopper = mysql_query("UPDATE characters SET ironore=ironore+'1' WHERE username='".$char['username']."'");
$amount = $amount - 1;
$minusTheOre = mysql_query("UPDATE ore SET amount='".$amount."' WHERE id='".$ore['id']."'");
}else{
$data .="You fail to find any ore... Keep trying, there is still some in this location!<br />";
}
$nextMining = ($char['mininglevel']*1000) + 10000;
$randomNextLevel = rand(1,$nextMining);
if($randomNextLevel <= 200){
$data .= "<<<---Your level in Mining has increased!--->>><br />";
$updateMiningLevel = mysql_query("UPDATE characters SET mininglevel=mininglevel+'1' WHERE username='".$char['username']."'");
}
}
if($char['mininglevel'] >= 65){
$findCopper = rand(1,10000);
$findIron = rand(1,12500);
$findSteel = rand(1,17500);
if($char['mininglevel']+200 >= $findCopper){
$data .="You found Copper!<br />";
$addCopper = mysql_query("UPDATE characters SET copperore=copperore+'1' WHERE username='".$char['username']."'");
$amount = $amount - 1;
$minusTheOre = mysql_query("UPDATE ore SET amount='".$amount."' WHERE id='".$ore['id']."'");
}
if($char['mininglevel']+200 >= $findIron){
$data .="You found Iron!<br />";
$addCopper = mysql_query("UPDATE characters SET ironore=ironore+'1' WHERE username='".$char['username']."'");
$amount = $amount - 1;
$minusTheOre = mysql_query("UPDATE ore SET amount='".$amount."' WHERE id='".$ore['id']."'");
}
if($char['mininglevel']+200 >= $findSteel){
$data .="You found Steel!<br />";
$addCopper = mysql_query("UPDATE characters SET steelore=steelore+'1' WHERE username='".$char['username']."'");
$amount = $amount - 1;
$minusTheOre = mysql_query("UPDATE ore SET amount='".$amount."' WHERE id='".$ore['id']."'");
}
if($char['mininglevel']+200 < $findCopper && $char['mininglevel']+200 < $findIron && $char['mininglevel']+200 < $findSteel){
$data .="You fail to find any ore... Keep trying, there is still some in this location!<br />";
}
$nextMining = ($char['mininglevel']*1000) + 10000;
$randomNextLevel = rand(1,$nextMining);
if($randomNextLevel <= 200){
$data .= "<<<---Your level in Mining has increased!--->>><br />";
$updateMiningLevel = mysql_query("UPDATE characters SET mininglevel=mininglevel+'1' WHERE username='".$char['username']."'");
}
}
if($amount <= 0){
$xloc = rand(1,100);
$yloc = rand(1,100);
$newAmount = rand(10,20);
$updateTheOre = mysql_query("UPDATE ore SET xpos=".$xloc.", ypos=".$yloc.", amount='".$newAmount."' WHERE id='".$ore['id']."'");
$data .= "That was the last of the ore here.";
}
$date = time();
$updateLastMine = mysql_query("UPDATE characters SET lastmine='".$date."' WHERE username='".$char['username']."'");
include('updatestats.php');
}else{
$data .= "No ore left.";
}
}else{
$data .= "There is no ore at this location!";
}
}else{
$data .= "You are resting your arms, try again in a second.";
}
print("fillDiv('travelDesc','".$data."');");
?>