<?php
class Move {
var $direction;
var $value;
var $x;
var $y;
public static function initializeEmpty(){
return (new Move(array(0, 0), "NONE", -2));
}
public function __construct($pos, $direction, $value){
$this->y = $pos[0];
$this->x = $pos[1];
$this->value = $value;
$this->direction = $direction;
}
public function compare($move){
echo "HERE";
print_r($move);
print_r($this);
echo "DONE";
return $move->value > $this->value ? $move->value : $this->value;
}
public static function maxValDirection($moves){
$best = Move::initializeEmpty();
foreach($moves as $m){
print_r($m);
$best = $m->compare($best);
}
return $best;
}
}
$m1 = Move::initializeEmpty();
$m2 = new Move(array(0, 1), "RIGHT", 10);
print_r(Move::maxValDirection(array($m1, $m2)));
?>
- Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.4, 8.3.6
- Move Object
(
[direction] => NONE
[value] => -2
[x] => 0
[y] => 0
)
HEREMove Object
(
[direction] => NONE
[value] => -2
[x] => 0
[y] => 0
)
Move Object
(
[direction] => NONE
[value] => -2
[x] => 0
[y] => 0
)
DONEMove Object
(
[direction] => RIGHT
[value] => 10
[x] => 1
[y] => 0
)
HERE-2Move Object
(
[direction] => RIGHT
[value] => 10
[x] => 1
[y] => 0
)
DONE
Warning: Attempt to read property "value" on int in /in/dG7Vk on line 24
10
- Output for 8.3.5
- Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
Move Object
(
[direction] => NONE
[value] => -2
[x] => 0
[y] => 0
)
HEREMove Object
(
[direction] => NONE
[value] => -2
[x] => 0
[y] => 0
)
Move Object
(
[direction] => NONE
[value] => -2
[x] => 0
[y] => 0
)
DONEMove Object
(
[direction] => RIGHT
[value] => 10
[x] => 1
[y] => 0
)
HERE-2Move Object
(
[direction] => RIGHT
[value] => 10
[x] => 1
[y] => 0
)
DONE
Warning: Attempt to read property "value" on int in /in/dG7Vk on line 24
10
- Output for 7.2.0 - 7.2.33, 7.3.0 - 7.3.31, 7.4.0 - 7.4.33
- Move Object
(
[direction] => NONE
[value] => -2
[x] => 0
[y] => 0
)
HEREMove Object
(
[direction] => NONE
[value] => -2
[x] => 0
[y] => 0
)
Move Object
(
[direction] => NONE
[value] => -2
[x] => 0
[y] => 0
)
DONEMove Object
(
[direction] => RIGHT
[value] => 10
[x] => 1
[y] => 0
)
HERE-2Move Object
(
[direction] => RIGHT
[value] => 10
[x] => 1
[y] => 0
)
DONE
Notice: Trying to get property 'value' of non-object in /in/dG7Vk on line 24
10
- Output for 7.3.32 - 7.3.33
- Move Object
(
[direction] => NONE
[value] => -2
[x] => 0
[y] => 0
)
HEREMove Object
(
[direction] => NONE
[value] => -2
[x] => 0
[y] => 0
)
Move Object
(
[direction] => NONE
[value] => -2
[x] => 0
[y] => 0
)
DONEMove Object
(
[direction] => RIGHT
[value] => 10
[x] => 1
[y] => 0
)
HERE-2Move Object
(
[direction] => RIGHT
[value] => 10
[x] => 1
[y] => 0
)
DONE10
- Output for 5.5.0 - 5.5.38, 5.6.0 - 5.6.38, 7.0.0 - 7.0.33, 7.1.0 - 7.1.25
- Move Object
(
[direction] => NONE
[value] => -2
[x] => 0
[y] => 0
)
HEREMove Object
(
[direction] => NONE
[value] => -2
[x] => 0
[y] => 0
)
Move Object
(
[direction] => NONE
[value] => -2
[x] => 0
[y] => 0
)
DONEMove Object
(
[direction] => RIGHT
[value] => 10
[x] => 1
[y] => 0
)
HERE-2Move Object
(
[direction] => RIGHT
[value] => 10
[x] => 1
[y] => 0
)
DONE
Notice: Trying to get property of non-object in /in/dG7Vk on line 24
10
preferences:
229.88 ms | 403 KiB | 294 Q