rs-runescape-hiscore-loader-combat-formula

Gesponsorde koppelingen

PHP script bestanden

  1. rs-runescape-hiscore-loader-combat-formula

« Lees de omschrijving en reacties

rs-highscore-loader.class.php

Code (php)
PHP script in nieuw venster Selecteer het PHP script
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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
<?php

    class runescape{

        var
$type               = 'Warrior';
        var
$combat_f2p         = 3.4;
        var
$combat_p2p         = 3.4;
        var
$rank               = array();
        var
$level              = array();
        var
$xp                 = array();
        var
$points             = array();
        var
$missing            = array();
        var
$skills             = array('Overall',
                                        'Attack',
                                        'Defence',
                                        'Strength',
                                        'Hitpoints',
                                        'Range',
                                        'Prayer',
                                        'Magic',
                                        'Cooking',
                                        'Woodcutting',
                                        'Fletching',
                                        'Fishing',
                                        'Firemaking',
                                        'Crafting',
                                        'Smithing',
                                        'Mining',
                                        'Herblore',
                                        'Agility',
                                        'Thieving',
                                        'Slayer',
                                        'Farming',
                                        'Runecraft',
                                        'Hunter',
                                        'Construction',
                                        'Summoning');
        var
$mini_games         = array('Duel Tournament',
                                        'Bounty Hunters',
                                        'Bounty Hunter Rogues',
                                        'Fist Of Guthix');

        function
rankings($player){

            @
$file = file('http://hiscore.runescape.com/index_lite.ws?player=' . urlencode($player), FILE_IGNORE_NEW_LINES);

            if(!$file) {
                $file   = array_fill(0, count($this->skills), '-1,-1,-1');
                $file   = array_pad($file, count($this->skills) + count($this->mini_games), '-1,-1');
            }


            foreach ($file AS $key => $line){
                if(preg_match('/^(-?\d+),(-?\d+),(-?\d+)$/', $line)){
                    $array                                      = explode(',', $line);

                    $this->rank[$this->skills[$key]]             = $array['0'];
                    $this->level[$this->skills[$key]]            = $array['1'];
                    $this->xp[$this->skills[$key]]               = $array['2'];
                }

                else if(preg_match('/^(-?\d+),(-?\d+)$/', $line)){
                    if(isset($this->skills[$key])) {
                        unset($this->skills[$key]);
                    }


                    $array                                      = explode(',', $line);
                    $key                                        = $key - count($this->skills);

                    $this->rank[$this->mini_games[$key]]        = $array['0'];
                    $this->points[$this->mini_games[$key]]      = $array['1'];
                }
            }

            return true;
        }


        function
combat($att = 1, $str = 1, $def = 1, $hp = 10, $range = 1, $magic = 1, $pray = 1, $summ = 1, $return = false){

            $att        = $this->minmax($att,   'Attack');
            $def        = $this->minmax($def,   'Defence');
            $str        = $this->minmax($str,   'Strength');
            $hp         = $this->minmax($hp,    'Hitpoints');
            $range      = $this->minmax($range, 'Range');
            $magic      = $this->minmax($magic, 'Magic');
            $pray       = $this->minmax($pray,  'Prayer');
            $summ       = $this->minmax($summ,  'Summoning');

            $base       = ($def + $hp + floor($pray / 2) + floor($summ / 2)) * 0.25;

            $ranger     = floor($range * 1.5) * 0.325 + $base;

            $mage       = floor($magic * 1.5) * 0.325 + $base;

            $warrior    = $att * 0.325 + $str * 0.325 + $base;

            if($return === true){
                return array('Warrior' => $warrior,
                             'Ranger'  => $ranger,
                             'Mage'    => $mage);
            }


            if($warrior >= $mage && $warrior >= $ranger){
                $this->type            = 'Warrior';
                $this->combat_p2p      = $warrior;
                $this->combat_f2p      = $warrior - 0.25 * floor($summ / 2);
            }

            elseif($ranger > $warrior && $ranger >= $mage){
                $this->type            = 'Ranger';
                $this->combat_p2p      = $ranger;
                $this->combat_f2p      = $ranger - 0.25 * floor($summ / 2);
            }

            elseif($mage > $warrior && $mage > $ranger){
                $this->type            = 'Mage';
                $this->combat_p2p      = $mage;
                $this->combat_f2p      = $mage - 0.25 * floor($summ / 2);
            }

            return true;
        }


        function
combat_up($att, $str, $def, $hp, $range, $magic, $pray, $summ){

            $att          = $this->minmax($att,   'Attack');
            $str          = $this->minmax($str,   'Strength');
            $def          = $this->minmax($def,   'Defence');
            $hp           = $this->minmax($hp,    'Hitpoints');
            $range        = $this->minmax($range, 'Range');
            $magic        = $this->minmax($magic, 'Magic');
            $pray         = $this->minmax($pray,  'Prayer');
            $summ         = $this->minmax($summ,  'Summoning');

            $combat_lvls  = $this->combat($att, $str, $def, $hp, $range, $magic, $pray, $summ, true);
            $combat_skills = array('Attack', 'Strength', 'Defence', 'Hitpoints', 'Range', 'Magic', 'Prayer', 'Summoning');

            arsort($combat_lvls);
            $type         = key($combat_lvls);

            $return       = array_combine($combat_skills, array_fill(0, 8, 0));
            $dif          = array();

            foreach($combat_lvls AS $key => $level){
                $combat_left                 = floor($combat_lvls[$type] + 1) - $level;

                if($combat_left < 0 || $level >= 138){
                    $combat_left             = 0;
                }


                $dif[$key]                = $combat_left;
            }


            if($combat_lvls[$type] < 138){
                if(($att + $str) < 148){
                    if($dif['Ranger'] / 0.325 * (2/3) <= 99 - $range){
                        $return['Range']  = ceil($dif['Ranger'] / 0.325 * (2/3));
                    }

                    if($dif['Mage'] / 0.325 * (2/3) <= 99 - $magic){
                        $return['Magic']  = ceil($dif['Mage'] / 0.325 * (2/3));
                    }
                }


                $return['Attack']              = ($dif['Warrior'] / 0.325 <= 99 - $att)          ? ceil($dif['Warrior'] / 0.325) : 0;
                $return['Strength']            = ($dif['Warrior'] / 0.325 <= 99 - $str)          ? ceil($dif['Warrior'] / 0.325) : 0;
                $return['Defence']             = ($dif[$type] / 0.25 <= 99 - $def)               ? ceil($dif[$type] / 0.25) : 0;
                $return['Hitpoints']           = ($dif[$type] / 0.25 <= 99 - $hp)                ? ceil($dif[$type] / 0.25) : 0;
                $return['Prayer']              = (ceil($dif[$type] / 0.25) * 2 <= 99 - $pray)    ? ceil($dif[$type] / 0.25) * 2 : 0;
                $return['Summoning']           = (ceil($dif[$type] / 0.25) * 2 <= 99 - $summ)    ? ceil($dif[$type] / 0.25) * 2 : 0;

                if($pray & 1 && $pray < 99 && ceil($dif[$type] / 0.25) * 2 <= 99 - $pray){
                    $return['Prayer']--;
                }

                if($summ & 1 && $summ < 99 && ceil($dif[$type] / 0.25) * 2 <= 99 - $summ){
                    $return['Summoning']--;
                }

            }


            $return['Combat']             = $combat_lvls[$type];

            return $return;
        }


        function
minmax($level, $skill){
            $values                     = array_fill(0, count($this->skills), 1);
            $minmax                     = array_combine($this->skills, $values);

            $minmax['Overall']          = count($this->skills) - 1;
            $minmax['Hitpoints']        = 10;

            if(!array_key_exists($skill, $minmax)){
                return false;
            }


            if($level < $minmax[$skill]){
                return $minmax[$skill];
            }

            elseif($level > 99 && $skill != 'Overall'){
                return 99;
            }

            elseif($level > (count($this->skills) -1) * 99 && $skill == 'Overall'){
                return (count($this->skills) -1) * 99;
            }

            else{
                return $level;
            }
        }


        function
missing($levels){

            $total              = array_shift($levels);
            $empty              = array_count_values($levels);

            if(!array_key_exists('-1', $empty) || $total == '-1'){
                return false;
            }


            $total_missing      = $total - (array_sum($levels) + $empty['-1']);
            $skill_missing      = floor( $total_missing / $empty['-1']);

            if($empty['-1'] == 1) {
                $skill               = array_search('-1', $levels);
                $this->level[$skill] = $total_missing;
            }

            else {
                foreach($levels AS $skill => $level){
                    if($level == '-1' && $empty['-1'] != 1){
                        $this->missing[$skill]            = $skill_missing;
                    }
                }
            }


            reset($this->missing);
            for($i = ($total_missing % $skill_missing); $i != 0; $i--){
                $this->missing[key($this->missing)]++;
                next($this->missing);
            }

            reset($this->missing);
            return true;
        }


        function
exp_left($exp, $x){

            $xp         = 0;

            for($i=1; $i < $x; $i++){
                $xp     += floor($i+300*pow(2, ($i/7)));
            }


            $exp_needed  = floor($xp/4);
            $exp_left    = $exp_needed-$exp;
            return $exp_left;
        }
    }


?>


combat-xml.php
Code (php)
PHP script in nieuw venster Selecteer het PHP script
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
<?PHP

    include_once('rs-highscore-loader.class.php');

    $calc = new runescape();

    if($_SERVER['REQUEST_METHOD'] == 'GET' && count($_GET)){
        if(isset($_GET['player']) && !empty($_GET['player']) && isset($_GET['side']) && !empty($_GET['side'])){
            setcookie($_GET['side'], $_GET['player'], time() + 60 * 60 * 24 * 265, '/');

            $calc->rankings($_GET['player']);
        }

        else{
            $calc->level['Attack']    = $_GET['att'];
            $calc->level['Strength']    = $_GET['str'];
            $calc->level['Defence']    = $_GET['def'];
            $calc->level['Hitpoints']    = $_GET['hp'];
            $calc->level['Range']    = $_GET['range'];
            $calc->level['Magic']    = $_GET['magic'];
            $calc->level['Prayer']    = $_GET['pray'];
            $calc->level['Summoning']    = $_GET['summ'];
        }


        $lvls_left = $calc->combat_up($calc->level['Attack'], $calc->level['Strength'], $calc->level['Defence'], $calc->level['Hitpoints'], $calc->level['Range'], $calc->level['Magic'], $calc->level['Prayer'], $calc->level['Summoning']);
    }

    else{
        $calc->rankings('');
        $_GET['player'] = '';
        $lvls_left     = $calc->combat_up($calc->level['Attack'], $calc->level['Strength'], $calc->level['Defence'], $calc->level['Hitpoints'], $calc->level['Range'], $calc->level['Magic'], $calc->level['Prayer'], $calc->level['Summoning']);
    }


    header('Content-Type: text/xml' . PHP_EOL);
    header('Cache-Control: no-cache, must-revalidate' . PHP_EOL);
    header('Expires: Mon, 26 Jul 1997 05:00:00 GMT' . PHP_EOL);

    echo '<?xml version="1.0" encoding="ISO-8859-1"?>'  . PHP_EOL;
    echo '<Combat>'         . PHP_EOL;
    echo '  <Player>'       . PHP_EOL;
    echo '    <Name>'       . $_GET['player']           . '</Name>'                 . PHP_EOL;
    echo '    <Attack>'     . PHP_EOL;
    echo '      <Current>'  . $calc->minmax($calc->level['Attack'], 'Attack')       . '</Current>'   . PHP_EOL;
    echo '      <Left>'     . $lvls_left['Attack']      . '</Left>'                 . PHP_EOL;
    echo '    </Attack>'    . PHP_EOL;
    echo '    <Strenght>'   . PHP_EOL;
    echo '      <Current>'  . $calc->minmax($calc->level['Strength'], 'Strength')   . '</Current>'   . PHP_EOL;
    echo '      <Left>'     . $lvls_left['Strength']    . '</Left>'                 . PHP_EOL;
    echo '    </Strenght>'  . PHP_EOL;
    echo '    <Defence>'    . PHP_EOL;
    echo '      <Current>'  . $calc->minmax($calc->level['Defence'], 'Defence')     . '</Current>'   . PHP_EOL;
    echo '      <Left>'     . $lvls_left['Defence']     . '</Left>'                 . PHP_EOL;
    echo '    </Defence>'   . PHP_EOL;
    echo '    <Hitpoints>'  . PHP_EOL;
    echo '      <Current>'  . $calc->minmax($calc->level['Hitpoints'], 'Hitpoints') . '</Current>'   . PHP_EOL;
    echo '      <Left>'     . $lvls_left['Hitpoints']   . '</Left>'                 . PHP_EOL;
    echo '    </Hitpoints>' . PHP_EOL;
    echo '    <Range>'      . PHP_EOL;
    echo '      <Current>'  . $calc->minmax($calc->level['Range'], 'Range')         . '</Current>'   . PHP_EOL;
    echo '      <Left>'     . $lvls_left['Range']       . '</Left>'                 . PHP_EOL;
    echo '    </Range>'     . PHP_EOL;
    echo '    <Magic>'      . PHP_EOL;
    echo '      <Current>'  . $calc->minmax($calc->level['Magic'], 'Magic')         . '</Current>'   . PHP_EOL;
    echo '      <Left>'     . $lvls_left['Magic']       . '</Left>'                 . PHP_EOL;
    echo '    </Magic>'     . PHP_EOL;
    echo '    <Prayer>'     . PHP_EOL;
    echo '      <Current>'  . $calc->minmax($calc->level['Prayer'], 'Prayer')       . '</Current>'   . PHP_EOL;
    echo '      <Left>'     . $lvls_left['Prayer']      . '</Left>'                 . PHP_EOL;
    echo '    </Prayer>'    . PHP_EOL;
    echo '    <Summoning>'  . PHP_EOL;
    echo '      <Current>'  . $calc->minmax($calc->level['Summoning'], 'Summoning') . '</Current>'   . PHP_EOL;
    echo '      <Left>'     . $lvls_left['Summoning']   . '</Left>'                 . PHP_EOL;
    echo '    </Summoning>' . PHP_EOL;
    echo '    <Combat>'     . $lvls_left['Combat']      . '</Combat>'               . PHP_EOL;
    echo '    <Text>'       . PHP_EOL;

    if(!isset($_GET['player']) || empty($_GET['player'])){

        echo htmlentities('      <b>Combat Level: ' . $lvls_left['Combat'] . '</b>')    . PHP_EOL;
        echo htmlentities('      <ul style="padding-left: 15px;">') . PHP_EOL;

        array_pop($lvls_left);
        foreach($lvls_left AS $skill => $left)
        if($left != 0){
            echo htmlentities('        <li> ' . $left . ' ' . $skill . ' level' . (($left != 1) ? 's' : '') . '.</li>') . PHP_EOL;
        }

        else{
            echo htmlentities('        <li> You can\'t gain combat by ' . $skill . '.</li>') . PHP_EOL;
       }

       echo htmlentities('      </ul>') . PHP_EOL;
    }


    echo '    </Text>'      . PHP_EOL;
    echo '  </Player>'      . PHP_EOL;
    echo '</Combat>'        . PHP_EOL;

?>


highs.php
Code (php)
PHP script in nieuw venster Selecteer het PHP script
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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
<?php

    include_once('rs-highscore-loader.class.php');

    $calc = new runescape();
    if(isset($_COOKIE['Left']) && !empty($_COOKIE['Left'])){
        $calc->rankings($_COOKIE['Left']);
        $lvls_left = $calc->combat_up($calc->level['Attack'], $calc->level['Strength'], $calc->level['Defence'], $calc->level['Hitpoints'], $calc->level['Range'], $calc->level['Magic'], $calc->level['Prayer'], $calc->level['Summoning']);
    }

    else{
        $calc->rankings('');
        $lvls_left     = $calc->combat_up($calc->level['Attack'], $calc->level['Strength'], $calc->level['Defence'], $calc->level['Hitpoints'], $calc->level['Range'], $calc->level['Magic'], $calc->level['Prayer'], $calc->level['Summoning']);
    }


?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <link rel="stylesheet" type="text/css" media="screen" href="style.css" />
    <script src="ajax.js" type="text/javascript"></script>
    <title>RS stats loader + Combat formula</title>
  </head>
  <body>
    <div id="Content">
      <div id="Left_calc">
        <div style="float: right;">
          <label for="Left_Player">
            Username:
          </label>
          <input type="text" id="Left_Player" size="16" maxlength="20" class="lvl" value="<?php if(isset($_COOKIE['Left'])) echo htmlentities($_COOKIE['Left']); ?>" />
          <img src="images/Grab.gif" onClick="show_lvls('Left', 'grab');" alt="" />
        </div>
        <div class="sub_left">
          <label for="Left_Attack">
            <img src="images/Attack.gif" alt="" />
          </label>
          <input type="text" id="Left_Attack" size="2" maxlength="2" class="lvl" onkeypress="return check_char(event, /\d|[\b]/);" value="<?php echo $calc->minmax($calc->level['Attack'], 'Attack'); ?>" />
          <br />
          <label for="Left_Defence">
            <img src="images/Defence.gif" alt="" />
          </label>
          <input type="text" id="Left_Defence" size="2" maxlength="2" class="lvl" onkeypress="return check_char(event, /\d|[\b]/);" value="<?php echo $calc->minmax($calc->level['Defence'], 'Defence'); ?>" />
          <br />
          <label for="Left_Range">
            <img src="images/Range.gif" alt="" />
          </label>
          <input type="text" id="Left_Range" size="2" maxlength="2" class="lvl" onkeypress="return check_char(event, /\d|[\b]/);" value="<?php echo $calc->minmax($calc->level['Range'], 'Range'); ?>" />
          <br />
          <label for="Left_Prayer">
            <img src="images/Prayer.gif" alt="" />
          </label>
          <input type="text" id="Left_Prayer" size="2" maxlength="2" class="lvl" onkeypress="return check_char(event, /\d|[\b]/);" value="<?php echo $calc->minmax($calc->level['Prayer'], 'Prayer'); ?>" />
        </div>

        <div class="sub_right">
          <label for="Left_Strength">
            <img src="images/Strength.gif" alt="" />
          </label>
          <input type="text" id="Left_Strength" size="2" maxlength="2" class="lvl" onkeypress="return check_char(event, /\d|[\b]/);" value="<?php echo $calc->minmax($calc->level['Strength'], 'Strength'); ?>" />
          <br />
          <label for="Left_Hitpoints">
            <img src="images/Hitpoints.gif" alt="" />
          </label>
          <input type="text" id="Left_Hitpoints" size="2" maxlength="2" class="lvl" onkeypress="return check_char(event, /\d|[\b]/);" value="<?php  echo $calc->minmax($calc->level['Hitpoints'], 'Hitpoints'); ?>" />
          <br />
          <label for="Left_Magic">
            <img src="images/Magic.gif" alt="" />
          </label>
          <input type="text" id="Left_Magic" size="2" maxlength="2" class="lvl" onkeypress="return check_char(event, /\d|[\b]/);" value="<?php echo $calc->minmax($calc->level['Magic'], 'Magic'); ?>" />
          <br />
          <label for="Left_Summoning">
            <img src="images/Summoning.gif" alt="" />
          </label>
          <input type="text" id="Left_Summoning" size="2" maxlength="2" class="lvl" onkeypress="return check_char(event, /\d|[\b]/);" value="<?php echo $calc->minmax($calc->level['Summoning'], 'Summoning'); ?>" />
        </div>
        <div style="margin-left: auto; margin-right: auto;">
          <label>
            <input type="submit" name="submit" id="Left_calculate" value="Calculate!" class="button" onclick="show_lvls('Left', 'calculate');" />
          </label>
        </div>
        <div id="Left">
        </div>
      </div>


<?php

    if(isset($_COOKIE['Right']) && !empty($_COOKIE['Right'])){
        $calc->rankings($_COOKIE['Right']);
        $lvls_left = $calc->combat_up($calc->level['Attack'], $calc->level['Strength'], $calc->level['Defence'], $calc->level['Hitpoints'], $calc->level['Range'], $calc->level['Magic'], $calc->level['Prayer'], $calc->level['Summoning']);
    }

    else{
        $calc->rankings('');
        $lvls_left     = $calc->combat_up($calc->level['Attack'], $calc->level['Strength'], $calc->level['Defence'], $calc->level['Hitpoints'], $calc->level['Range'], $calc->level['Magic'], $calc->level['Prayer'], $calc->level['Summoning']);
    }


?>

      <div id="Right_calc">
        <div style="float: right;">
          <label for="Right_Player">
            Username:
          </label>
          <input type="text" id="Right_Player" size="16" maxlength="20" class="lvl" value="<?php if(isset($_COOKIE['Right'])) echo htmlentities($_COOKIE['Right']); ?>" />
          <img src="images/Grab.gif" onClick="show_lvls('Right', 'grab');" alt="" />
        </div>
        <div class="sub_left">
          <label for="Right_Attack">
            <img src="images/Attack.gif" alt="" />
          </label>
          <input type="text" id="Right_Attack" size="2" maxlength="2" class="lvl" onkeypress="return check_char(event, /\d|[\b]/);" value="<?php echo $calc->minmax($calc->level['Attack'], 'Attack'); ?>" />
          <br />
          <label for="Right_Defence">
            <img src="images/Defence.gif" alt="" />
          </label>
          <input type="text" id="Right_Defence" size="2" maxlength="2" class="lvl" onkeypress="return check_char(event, /\d|[\b]/);" value="<?php echo $calc->minmax($calc->level['Defence'], 'Defence'); ?>" />
          <br />
          <label for="Right_Range">
            <img src="images/Range.gif" alt="" />
          </label>
          <input type="text" id="Right_Range" size="2" maxlength="2" class="lvl" onkeypress="return check_char(event, /\d|[\b]/);" value="<?php echo $calc->minmax($calc->level['Range'], 'Range'); ?>" />
          <br />
          <label for="Right_Prayer">
            <img src="images/Prayer.gif" alt="" />
          </label>
          <input type="text" id="Right_Prayer" size="2" maxlength="2" class="lvl" onkeypress="return check_char(event, /\d|[\b]/);" value="<?php echo $calc->minmax($calc->level['Prayer'], 'Prayer'); ?>" />
        </div>

        <div class="sub_right">
          <label for="Right_Strength">
            <img src="images/Strength.gif" alt="" />
          </label>
          <input type="text" id="Right_Strength" size="2" maxlength="2" class="lvl" onkeypress="return check_char(event, /\d|[\b]/);" value="<?php echo $calc->minmax($calc->level['Strength'], 'Strength'); ?>" />
          <br />
          <label for="Right_Hitpoints">
            <img src="images/Hitpoints.gif" alt="" />
          </label>
          <input type="text" id="Right_Hitpoints" size="2" maxlength="2" class="lvl" onkeypress="return check_char(event, /\d|[\b]/);" value="<?php  echo $calc->minmax($calc->level['Hitpoints'], 'Hitpoints'); ?>" />
          <br />
          <label for="Right_Magic">
            <img src="images/Magic.gif" alt="" />
          </label>
          <input type="text" id="Right_Magic" size="2" maxlength="2" class="lvl" onkeypress="return check_char(event, /\d|[\b]/);" value="<?php echo $calc->minmax($calc->level['Magic'], 'Magic'); ?>" />
          <br />
          <label for="Right_Summoning">
            <img src="images/Summoning.gif" alt="" />
          </label>
          <input type="text" id="Right_Summoning" size="2" maxlength="2" class="lvl" onkeypress="return check_char(event, /\d|[\b]/);" value="<?php echo $calc->minmax($calc->level['Summoning'], 'Summoning'); ?>" />
        </div>
        <div style="margin-left: auto; margin-right: auto; ">
          <label>
            <input type="submit" name="submit" id="Right_calculate" value="Calculate!" class="button" onclick="show_lvls('Right', 'calculate');" />
          </label>
        </div>
        <div id="Right">
        </div>
      </div>



<?php

    $player
             = (isset($_GET['player']) && !empty($_GET['player'])) ? $_GET['player'] : 'darsstar';

    $calc->rankings($player);
    $calc->missing($calc->level);
    $calc->combat($calc->level['Attack'], $calc->level['Strength'], $calc->level['Defence'], $calc->level['Hitpoints'], $calc->level['Range'], $calc->level['Magic'], $calc->level['Prayer'], $calc->level['Summoning']);

    echo '      <table class="calc-output">' . PHP_EOL;

    echo '        <tr>' . PHP_EOL;
    echo '          <td width="190" style="text-align: left;">Combat lvl F2P:</td>' . PHP_EOL;
    echo '          <td width="120" style="text-align: right">' . $calc->combat_f2p . '</td>' . PHP_EOL;
    echo '          <td width="100" style="text-align: center">' . $calc->type . '</td>' . PHP_EOL;
    echo '          <td width="150" style="text-align: left;">Combat lvl P2P:</td>' . PHP_EOL;
    echo '          <td width="120" style="text-align: right">' . $calc->combat_p2p . '</td>' . PHP_EOL;
    echo '        </tr>' . PHP_EOL;

    echo '        <tr>' . PHP_EOL;
    echo '          <th width="190" style="text-align: left;">Skill</th>' . PHP_EOL;
    echo '          <th width="120">Rank</th>' . PHP_EOL;
    echo '          <th width="120">Level</th>' . PHP_EOL;
    echo '          <th width="120">XP</th>' . PHP_EOL;
    echo '          <th width="120">Xp to Lvl-up</th>' . PHP_EOL;
    echo '        </tr>' . PHP_EOL;

    foreach($calc->skills as $key => $skill){
        $rank           = ($calc->rank[$skill] == '-1') ? 'Not Ranked' : number_format($calc->rank[$skill], 0, '', '.');
        $xp             = ($calc->xp[$skill] == '-1')   ? '-' : number_format($calc->xp[$skill], 0, '', '.');

        if(array_key_exists($skill, $calc->missing)){
            $level      = '<span style="color: orange;">' . $calc->missing[$skill] . '</span>';
        }

        elseif($calc->level[$skill] != '-1'){
            $level      = number_format($calc->level[$skill], 0, '', '.');
        }

        else{
            $level      = '-';
        }


        echo '        <tr>' . PHP_EOL;
        echo '          <td width="190" style="text-align: left;"><img src="images/' . $skill . '.gif" alt="" /> ' . $skill . '</td>' . PHP_EOL;
        echo '          <td width="120">' . $rank . '</td>' . PHP_EOL;
        echo '          <td width="120">' . $level . '</td>' . PHP_EOL;
        echo '          <td width="120">' . $xp . '</td>' . PHP_EOL;
        if($skill != 'Overall' && $level != 99 && $rank != 'Not Ranked' && !array_key_exists($skill, $calc->missing)){
            echo '          <td width="120">' . number_format($calc->exp_left($calc->xp[$skill], $calc->level[$skill]+1), 0, '', '.') . '</td>' . PHP_EOL;
        }

        echo '        </tr>' . PHP_EOL;
    }


    echo '        <tr>' . PHP_EOL;
    echo '          <th width="190" style="text-align: left;">Mini-Game</th>' . PHP_EOL;
    echo '          <th width="120" colspan="2">Rank</th>' . PHP_EOL;
    echo '          <th width="120" colspan="2">Points</th>' . PHP_EOL;
    echo '        </tr>' . PHP_EOL;

    foreach($calc->mini_games as $key => $mini_game){
        $rank           = ($calc->rank[$mini_game] == '-1')   ? 'Not Ranked' : number_format($calc->rank[$mini_game], 0, '', '.');
        $points         = ($calc->points[$mini_game] == '-1') ? '-' : number_format($calc->points[$mini_game], 0, '', '.');

        echo '        <tr>' . PHP_EOL;
        echo '          <td width="150" style="text-align: left;"><img src="images/' . $mini_game . '.gif" alt="" /> ' . $mini_game . '</td>' . PHP_EOL;
        echo '          <td width="120" colspan="2">' . $rank . '</td>' . PHP_EOL;
        echo '          <td width="120" colspan="2">' . $points . '</td>' . PHP_EOL;
        echo '        </tr>' . PHP_EOL;
    }


    echo '      </table>' . PHP_EOL;

?>

    </div>
  </body>
</html>


ajax.js
Code (php)
PHP script in nieuw venster Selecteer het PHP script
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
    var xmlHttp;

    function show_lvls(side, action)
    {
        xmlHttp = GetXmlHttpObject();
        if (xmlHttp == null)
        {
            alert ('Your browser does not support AJAX!');
            return;
        }

        var url = 'combat-xml.php';

        if(action == 'grab')
        {
            url = url+'?player=' + document.getElementById(side + '_Player').value;
            url = url+'&side='   + side;
        }
        else if(action == 'calculate')
        {
            url = url+'?att='    + document.getElementById(side + '_Attack').value;
            url = url+'&str='    + document.getElementById(side + '_Strength').value;
            url = url+'&def='    + document.getElementById(side + '_Defence').value;
            url = url+'&hp='     + document.getElementById(side + '_Hitpoints').value;
            url = url+'&range='  + document.getElementById(side + '_Range').value;
            url = url+'&magic='  + document.getElementById(side + '_Magic').value;
            url = url+'&pray='   + document.getElementById(side + '_Prayer').value;
            url = url+'&summ='   + document.getElementById(side + '_Summoning').value;

            document.getElementById(side + '_calculate').innerHTML= 'Calculating...';
        }

        xmlHttp.onreadystatechange = function() {stateChanged(side) };
        xmlHttp.open('GET',url,true);
        xmlHttp.send(null);

    }

    function stateChanged(side)
    {
        if (xmlHttp.readyState == 4)
        {
            var xmlDoc=xmlHttp.responseXML.documentElement;

            document.getElementById(side + '_Attack').value =
            xmlDoc.getElementsByTagName('Attack')[0].getElementsByTagName('Current')[0].childNodes[0].nodeValue;

            document.getElementById(side + '_Strength').value =
            xmlDoc.getElementsByTagName('Strenght')[0].getElementsByTagName('Current')[0].childNodes[0].nodeValue;

            document.getElementById(side + '_Defence').value =
            xmlDoc.getElementsByTagName('Defence')[0].getElementsByTagName('Current')[0].childNodes[0].nodeValue;

            document.getElementById(side + '_Hitpoints').value =
            xmlDoc.getElementsByTagName('Hitpoints')[0].getElementsByTagName('Current')[0].childNodes[0].nodeValue;

            document.getElementById(side + '_Range').value =
            xmlDoc.getElementsByTagName('Range')[0].getElementsByTagName('Current')[0].childNodes[0].nodeValue;

            document.getElementById(side + '_Magic').value =
            xmlDoc.getElementsByTagName('Magic')[0].getElementsByTagName('Current')[0].childNodes[0].nodeValue;

            document.getElementById(side + '_Prayer').value =
            xmlDoc.getElementsByTagName('Prayer')[0].getElementsByTagName('Current')[0].childNodes[0].nodeValue;

            document.getElementById(side + '_Summoning').value =
            xmlDoc.getElementsByTagName('Summoning')[0].getElementsByTagName('Current')[0].childNodes[0].nodeValue;

            document.getElementById(side).innerHTML =
            xmlDoc.getElementsByTagName('Text')[0].childNodes[0].nodeValue;

            document.getElementById(side + '_calculate').innerHTML = 'Calculate!';

        }
    }

    function GetXmlHttpObject()
    {
        var xmlHttp = null;
        try
        {
            // Firefox, Opera 8.0+, Safari
            xmlHttp = new XMLHttpRequest();
        }
        catch (e)
        {
            // Internet Explorer
            try
            {
                xmlHttp = new ActiveXObject('Msxml2.XMLHTTP');
            }
            catch (e)
            {
                xmlHttp = new ActiveXObject('Microsoft.XMLHTTP');
            }
        }
        return xmlHttp;
    }

    function check_char(e, regexp) {
        var keynum;
        var keychar;
        if(window.event) { // IE
            keynum = e.keyCode;
        }
        else if(e.which) { // Netscape/Firefox/Opera
            keynum = e.which;
        }
        keychar = String.fromCharCode(keynum);
        return regexp.test(keychar);
    }


style.css
Code (php)
PHP script in nieuw venster Selecteer het PHP script
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
body {
    font-family: Verdana;
    background: #090909;
    color: #dadada;
    margin: 0px;
    font-size: 0.7em;
}

body,td,th {
    color: #FFFFFF;
    font-family: Verdana;
    font-size: 10px;
}

table.calc-output{
    width: 550px;
    margin-left: auto;
    margin-right: auto;
}

table.calc-output, table.calc-output tr td{
    border: #333 1px solid;
    text-align: right;
    padding: 1px;
}

table.calc-output tr th{
    border: #333 1px solid;
    text-align: right;
    background: #550000;
    padding: 1px;
}

.button
{
    vertical-align: middle;
    margin: 5px;
    border: 1px solid #ffffff;
    background: url(http://teampk.ypm-design.com/images/form.jpg) #333333;
    font-size: 10pt;
    color: #FFFFFF;
    height: 20px;
    width: 116px;
    text-align: center;
    margin-left: 20px;
}

.lvl {
    border: 1px solid #ffffff;
    background: url(http://teampk.ypm-design.com/images/form.jpg);
    font-size: 9pt; color:#FFFFFF;
}

#Content {
    margin-left: auto;
    margin-right: auto;
    padding: 5px;
    width: 900px;
}

#Left_calc {
    width: 158px;
    float: left;
    margin-right: 10px;
}

#Right_calc {
    width: 158px;
    float: right;
    margin-left: 10px;
}

.sub_left {
    float: left;
}

.sub_right {
    float: right;
    margin-right: 22px;
}

 
 

Om de gebruiksvriendelijkheid van onze website en diensten te optimaliseren maken wij gebruik van cookies. Deze cookies gebruiken wij voor functionaliteiten, analytische gegevens en marketing doeleinden. U vindt meer informatie in onze privacy statement.