-
Notifications
You must be signed in to change notification settings - Fork 217
/
Copy pathrace.php
217 lines (180 loc) · 7.49 KB
/
race.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
211
212
213
214
215
216
217
<?php
if (!defined('AOWOW_REVISION'))
die('illegal access');
// menuId 13: Race g_initPath()
// tabId 0: Database g_initHeader()
class RacePage extends GenericPage
{
use TrDetailPage;
protected $type = Type::CHR_RACE;
protected $typeId = 0;
protected $tpl = 'detail-page-generic';
protected $path = [0, 13];
protected $tabId = 0;
protected $mode = CACHE_TYPE_PAGE;
protected $scripts = [[SC_JS_FILE, 'js/swfobject.js']];
public function __construct($pageCall, $id)
{
parent::__construct($pageCall, $id);
$this->typeId = intVal($id);
$this->subject = new CharRaceList(array(['id', $this->typeId]));
if ($this->subject->error)
$this->notFound(Lang::game('race'), Lang::race('notFound'));
$this->name = $this->subject->getField('name', true);
}
protected function generatePath()
{
$this->path[] = $this->typeId;
}
protected function generateTitle()
{
array_unshift($this->title, $this->subject->getField('name', true), Util::ucFirst(Lang::game('class')));
}
protected function generateContent()
{
$infobox = [];
$_mask = 1 << ($this->typeId - 1);
$mountVendors = array( // race => [starter, argent tournament]
null, [384, 33307], [3362, 33553], [1261, 33310],
[4730, 33653], [4731, 33555], [3685, 33556], [7955, 33650],
[7952, 33554], null, [16264, 33557], [17584, 33657]
);
/***********/
/* Infobox */
/***********/
$infobox = Lang::getInfoBoxForFlags($this->subject->getField('cuFlags'));
// side
if ($_ = $this->subject->getField('side'))
$infobox[] = Lang::main('side').Lang::main('colon').'[span class=icon-'.($_ == 2 ? 'horde' : 'alliance').']'.Lang::game('si', $_).'[/span]';
// faction
if ($_ = $this->subject->getField('factionId'))
{
$fac = new FactionList(array(['f.id', $_]));
$this->extendGlobalData($fac->getJSGlobals());
$infobox[] = Util::ucFirst(Lang::game('faction')).Lang::main('colon').'[faction='.$fac->id.']';
}
// leader
if ($_ = $this->subject->getField('leader'))
{
$this->extendGlobalIds(Type::NPC, $_);
$infobox[] = Lang::race('racialLeader').Lang::main('colon').'[npc='.$_.']';
}
// start area
if ($_ = $this->subject->getField('startAreaId'))
{
$this->extendGlobalIds(Type::ZONE, $_);
$infobox[] = Lang::race('startZone').Lang::main('colon').'[zone='.$_.']';
}
/****************/
/* Main Content */
/****************/
$this->infobox = '[ul][li]'.implode('[/li][li]', $infobox).'[/li][/ul]';
$this->expansion = Util::$expansionString[$this->subject->getField('expansion')];
$this->headIcons = array(
'race_'.strtolower($this->subject->getField('fileString')).'_male',
'race_'.strtolower($this->subject->getField('fileString')).'_female'
);
$this->redButtons = array(
BUTTON_WOWHEAD => true,
BUTTON_LINKS => ['type' => $this->type, 'typeId' => $this->typeId]
);
/**************/
/* Extra Tabs */
/**************/
// Classes
$classes = new CharClassList(array(['racemask', $_mask, '&']));
if (!$classes->error)
{
$this->extendGlobalData($classes->getJSGlobals());
$this->lvTabs[] = [CharClassList::$brickFile, ['data' => array_values($classes->getListviewData())]];
}
// Tongues
$conditions = array(
['typeCat', -11], // proficiencies
['reqRaceMask', $_mask, '&'] // only languages are race-restricted
);
$tongues = new SpellList($conditions);
if (!$tongues->error)
{
$this->extendGlobalData($tongues->getJSGlobals());
$this->lvTabs[] = [SpellList::$brickFile, array(
'data' => array_values($tongues->getListviewData()),
'id' => 'languages',
'name' => '$LANG.tab_languages',
'hiddenCols' => ['reagents']
)];
}
// Racials
$conditions = array(
['typeCat', -4], // racial traits
['reqRaceMask', $_mask, '&']
);
$racials = new SpellList($conditions);
if (!$racials->error)
{
$this->extendGlobalData($racials->getJSGlobals());
$this->lvTabs[] = [SpellList::$brickFile, array(
'data' => array_values($racials->getListviewData()),
'id' => 'racial-traits',
'name' => '$LANG.tab_racialtraits',
'hiddenCols' => ['reagents']
)];
}
// Quests
$conditions = array(
['reqRaceMask', $_mask, '&'],
[['reqRaceMask', RACE_MASK_HORDE, '&'], RACE_MASK_HORDE, '!'],
[['reqRaceMask', RACE_MASK_ALLIANCE, '&'], RACE_MASK_ALLIANCE, '!']
);
$quests = new QuestList($conditions);
if (!$quests->error)
{
$this->extendGlobalData($quests->getJSGlobals());
$this->lvTabs[] = [QuestList::$brickFile, ['data' => array_values($quests->getListviewData())]];
}
// Mounts
// ok, this sucks, but i rather hardcode the trainer, than fetch items by namepart
$items = isset($mountVendors[$this->typeId]) ? DB::World()->selectCol('SELECT item FROM npc_vendor WHERE entry IN (?a)', $mountVendors[$this->typeId]) : 0;
$conditions = array(
['i.id', $items],
['i.class', ITEM_CLASS_MISC],
['i.subClass', 5], // mounts
);
$mounts = new ItemList($conditions);
if (!$mounts->error)
{
$this->extendGlobalData($mounts->getJSGlobals());
$this->lvTabs[] = [ItemList::$brickFile, array(
'data' => array_values($mounts->getListviewData()),
'id' => 'mounts',
'name' => '$LANG.tab_mounts',
'hiddenCols' => ['slot', 'type']
)];
}
// Sounds
if ($vo = DB::Aowow()->selectCol('SELECT soundId AS ARRAY_KEY, gender FROM ?_races_sounds WHERE raceId = ?d', $this->typeId))
{
$sounds = new SoundList(array(['id', array_keys($vo)]));
if (!$sounds->error)
{
$this->extendGlobalData($sounds->getJSGlobals(GLOBALINFO_SELF));
$data = $sounds->getListviewData();
foreach ($data as $id => &$d)
$d['gender'] = $vo[$id];
$this->lvTabs[] = [SoundList::$brickFile, array(
'data' => array_values($data),
'extraCols' => ['$Listview.templates.title.columns[1]']
)];
}
}
// tab: condition-for
$cnd = new Conditions();
$cnd->getByCondition(Type::CHR_RACE, $this->typeId)->prepare();
if ($tab = $cnd->toListviewTab('condition-for', '$LANG.tab_condition_for'))
{
$this->extendGlobalData($cnd->getJsGlobals());
$this->lvTabs[] = $tab;
}
}
}
?>