forked from jmlue42/Talishar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
MZLogic.php
83 lines (76 loc) · 1.7 KB
/
MZLogic.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
<?php
function MZFreeze($target)
{
global $currentPlayer;
$pieces = explode("-", $target);
$player = (substr($pieces[0], 0, 2) == "MY" ? $currentPlayer : ($currentPlayer == 1 ? 2 : 1));
$zone = &GetMZZone($player, $pieces[0]);
switch ($pieces[0]) {
case "THEIRCHAR":
case "MYCHAR":
$zone[$pieces[1] + 8] = 1;
break;
case "THEIRALLY":
case "MYALLY":
$zone[$pieces[1] + 3] = 1;
break;
case "THEIRARS":
case "MYARS":
$zone[$pieces[1] + 4] = 1;
break;
default:
break;
}
}
function IsFrozenMZ(&$array, $zone, $i)
{
$offset = FrozenOffsetMZ($zone);
if ($offset == -1) return false;
return $array[$i + $offset] == "1";
}
function UnfreezeMZ($player, $zone, $index)
{
$offset = FrozenOffsetMZ($zone);
if ($offset == -1) return false;
$array = &GetMZZone($player, $zone);
$array[$index + $offset] = "0";
}
function FrozenOffsetMZ($zone)
{
switch ($zone) {
case "ARS":
case "MYARS":
case "THEIRARS":
return 4;
case "ALLY":
case "MYALLY":
case "THEIRALLY":
return 3;
case "CHAR":
case "MYCHAR":
case "THEIRCHAR":
return 8;
default:
return -1;
}
}
function MZIsPlayer($MZIndex)
{
$indexArr = explode("-", $MZIndex);
if ($indexArr[0] == "MYCHAR" || $indexArr[0] == "THEIRCHAR") return true;
return false;
}
function MZPlayerID($me, $MZIndex)
{
$indexArr = explode("-", $MZIndex);
if ($indexArr[0] == "MYCHAR") return $me;
if ($indexArr[0] == "THEIRCHAR") return ($me == 1 ? 2 : 1);
return -1;
}
function GetMZCard($player, $MZIndex)
{
$params = explode("-", $MZIndex);
$zoneDS = &GetMZZone($player, $params[0]);
$index = $params[1];
return $zoneDS[$index];
}