-
Notifications
You must be signed in to change notification settings - Fork 18
/
leadership.php
210 lines (173 loc) · 6.12 KB
/
leadership.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
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
<?php
/***************************************************************************
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* Portions of this program are derived from publicly licensed software
* projects including, but not limited to phpBB, Magelo Clone,
* EQEmulator, EQEditor, and Allakhazam Clone.
*
* Author:
* Maudigan(Airwalking)
*
* October 19, 2022 - Maudigan
* initial revision of the leadership window
*
***************************************************************************/
/*********************************************
INCLUDES
*********************************************/
//define this as an entry point to unlock includes
if ( !defined('INCHARBROWSER') )
{
define('INCHARBROWSER', true);
}
include_once(__DIR__ . "/include/common.php");
include_once(__DIR__ . "/include/profile.php");
include_once(__DIR__ . "/include/db.php");
/*********************************************
SUPPORT FUNCTIONS
*********************************************/
//counts the maximum number of ranks for a leadership aa
function getTotalRanks($rankdata)
{
$currank = 0;
while($rankdata[$currank] != 0)
{
$currank++;
}
return $currank;
}
//gets the cost of the next rank of the leadership aa
function getRankCost($rankdata, $currank)
{
$cost = $rankdata[$currank];
if ($cost == 0)
{
return '--';
}
return $cost;
}
/*********************************************
SETUP CHARACTER CLASS & PERMISSIONS
*********************************************/
$charName = preg_Get_Post('char', '/^[a-zA-Z]+$/', false, $language['MESSAGE_ERROR'],$language['MESSAGE_NO_CHAR'], true);
//character initializations
$char = new Charbrowser_Character($charName, $showsoftdelete, $charbrowser_is_admin_page); //the Charbrowser_Character class will sanitize the character name
$charID = $char->char_id();
$name = $char->GetValue('name');
//block view if user level doesnt have permission
if ($char->Permission('leadership')) $cb_error->message_die($language['MESSAGE_NOTICE'],$language['MESSAGE_ITEM_NO_VIEW']);
/*********************************************
GATHER RELEVANT PAGE DATA
*********************************************/
//GET THIS CHARS LEADERSHIP AA
$character_leadership_aas = $char->GetTable("character_leadership_abilities");
//calculate the display values for each group aa
$group_aa_abilities = array();
foreach($groupaa as $rankid => $rankname)
{
//calculate all the values
if (is_array($character_leadership_aas) && array_key_exists($rankid, $character_leadership_aas))
{
$cur = $character_leadership_aas[$rankid]['rank'];
}
else
{
$cur = 0;
}
$cost = getRankCost($dbleadershipranks[$rankid], $cur);
$max = getTotalRanks($dbleadershipranks[$rankid]);
$group_aa_abilities[] = array(
'NAME' => $rankname,
'MAX' => $max,
'CUR' => $cur,
'COST' => $cost
);
}
//calculate the display values for each raid aa
$raid_aa_abilities = array();
foreach($raidaa as $rankid => $rankname)
{
//calculate all the values
if (is_array($character_leadership_aas) && array_key_exists($rankid, $character_leadership_aas))
{
$cur = $character_leadership_aas[$rankid]['rank'];
}
else
{
$cur = 0;
}
$cost = getRankCost($dbleadershipranks[$rankid], $cur);
$max = getTotalRanks($dbleadershipranks[$rankid]);
$raid_aa_abilities[] = array(
'NAME' => $rankname,
'MAX' => $max,
'CUR' => $cur,
'COST' => $cost
);
}
//combine the two pages with an id to loop through later
$leadership_aa_abilities = array(
1 => array( 'NAME' => $language['LEADERSHIP_TAB_1'], 'ABILITIES' => $group_aa_abilities),
2 => array( 'NAME' => $language['LEADERSHIP_TAB_2'], 'ABILITIES' => $raid_aa_abilities)
);
/*********************************************
DROP HEADER
*********************************************/
$d_title = " - ".$name.$language['PAGE_TITLES_LEADERSHIP'];
include(__DIR__ . "/include/header.php");
/*********************************************
DROP PROFILE MENU
*********************************************/
output_profile_menu($name, 'leadership');
/*********************************************
POPULATE BODY
*********************************************/
$cb_template->set_filenames(array(
'leadership' => 'leadership_body.tpl')
);
$cb_template->assign_both_vars(array(
'NAME' => $name,
'GROUP_LEADERSHIP_POINTS' => $char->GetValue("group_leadership_points").$language['GROUP_POINTS_OF'],
'RAID_LEADERSHIP_POINTS' => $char->GetValue("raid_leadership_points").$language['RAID_POINTS_OF'])
);
$cb_template->assign_vars(array(
'L_LEADERSHIP' => $language['LEADERSHIP'],
'L_TITLE' => $language['AAS_TITLE'],
'L_CUR_MAX' => $language['AAS_CUR_MAX'],
'L_COST' => $language['AAS_COST'],
'L_GROUP_POINTS' => $language['GROUP_POINTS'],
'L_RAID_POINTS' => $language['RAID_POINTS'],
'L_DONE' => $language['BUTTON_DONE'])
);
//OUTPUT THE AA TABS/DIVS/DATA
//TODO don't hardcode these colors. It should maybe
// get set using two stylesheet flags... maybe
$Color = "7b714a"; //first tab is diff com_addref
foreach ($leadership_aa_abilities as $id => $aatab)
{
//make the tab/div the subtypes are displayed in
$cb_template->assign_block_vars("tabs", array(
'COLOR' => $Color,
'ID' => $id,
'TEXT' => $aatab['NAME'])
);
//the info displayed in the div
foreach($aatab['ABILITIES'] as $ability)
{
$cb_template->assign_both_block_vars("tabs.aas", $ability);
}
//adjust the styles for the rest of the tabs
$Color = "FFFFFF";
}
/*********************************************
OUTPUT BODY AND FOOTER
*********************************************/
$cb_template->pparse('leadership');
$cb_template->destroy();
include(__DIR__ . "/include/footer.php");
?>