forked from plainblack/Lacuna-Web-Client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuildingHallsOfVrbansk.js
105 lines (90 loc) · 4.13 KB
/
buildingHallsOfVrbansk.js
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
YAHOO.namespace("lacuna.buildings");
if (typeof YAHOO.lacuna.buildings.HallsOfVrbansk == "undefined" || !YAHOO.lacuna.buildings.HallsOfVrbansk) {
(function(){
var Lang = YAHOO.lang,
Util = YAHOO.util,
Dom = Util.Dom,
Event = Util.Event,
Pager = YAHOO.widget.Paginator,
Sel = Util.Selector,
Lacuna = YAHOO.lacuna,
Game = Lacuna.Game,
Lib = Lacuna.Library;
var HallsOfVrbansk = function(result){
HallsOfVrbansk.superclass.constructor.call(this, result);
this.service = Game.Services.Buildings.HallsOfVrbansk;
this.maps = {};
};
Lang.extend(HallsOfVrbansk, Lacuna.buildings.Building, {
getChildTabs : function() {
return [this._getTab()];
},
_getTab : function() {
this.tab = new YAHOO.widget.Tab({ label: "Sacrifice", content: [
'<div id="hovNoSacrifice" style="display:none;">There are currently no glyph buildings that you can upgrade with the number of Halls of Vrbansk you have.</div>',
'<div id="hovCanSacrifice" style="display:none;">',
' <div>You may sacrifice the Halls of Vrbansk to upgrade another glyph building.</div>',
' <select id="hovAvailableBuildings"></select>',
' <button type="button" id="hovSacrifice">Sacrifice</button>',
'</div>'
].join('')});
this.tab.subscribe("activeChange", this.getUpgradable, this, true);
Event.on("hovSacrifice", "click", this.Sacrifice, this, true);
return this.tab;
},
getUpgradable : function(e) {
if(e.newValue) {
Dom.setStyle("hovNoSacrifice", "display", "none");
Dom.setStyle("hovCanSacrifice", "display", "none");
Dom.get("hovAvailableBuildings").innerHTML = '';
Lacuna.Pulser.Show();
this.service.get_upgradable_buildings({session_id:Game.GetSession(),building_id:this.building.id}, {
success : function(o){
Lacuna.Pulser.Hide();
this.rpcSuccess(o);
this.Display(o.result.buildings);
},
scope:this
});
}
},
Display : function(buildings) {
if(buildings.length == 0) {
Dom.setStyle("hovNoSacrifice", "display", "");
Dom.setStyle("hovCanSacrifice", "display", "none");
}
else {
Dom.setStyle("hovNoSacrifice", "display", "none");
Dom.setStyle("hovCanSacrifice", "display", "");
var sel = Dom.get("hovAvailableBuildings"),
opt = document.createElement("option"),
nOpt;
if(sel) {
for(var n=0; n < buildings.length; n++) {
nOpt = opt.cloneNode(false);
nOpt.Building = buildings[n];
nOpt.value = nOpt.Building.id;
nOpt.innerHTML = nOpt.Building.name + ' - Level ' + nOpt.Building.level;
sel.appendChild(nOpt);
}
}
}
},
Sacrifice : function() {
var upgradeBuildingId = Lib.getSelectedOptionValue("hovAvailableBuildings");
Lacuna.Pulser.Show();
this.service.sacrifice_to_upgrade({session_id:Game.GetSession(),building_id:this.building.id,upgrade_building_id:upgradeBuildingId}, {
success : function(o){
Lacuna.Pulser.Hide();
this.rpcSuccess(o);
this.fireEvent("onHide");
},
scope:this
});
}
});
YAHOO.lacuna.buildings.HallsOfVrbansk = HallsOfVrbansk;
})();
YAHOO.register("HallsOfVrbansk", YAHOO.lacuna.buildings.HallsOfVrbansk, {version: "1", build: "0"});
}
// vim: noet:ts=4:sw=4