Skip to content

Commit 548606f

Browse files
committed
feat(barracks): add spartan training spell to the barracks
1 parent 90b3403 commit 548606f

File tree

1 file changed

+88
-72
lines changed

1 file changed

+88
-72
lines changed

modules/RepConvGRC.js

Lines changed: 88 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -42,96 +42,111 @@ function _RepConvGRC() {
4242
}
4343
}
4444
function addSpell(RCGP){
45-
var
45+
var _powers = {},
46+
_power_div = $('<div/>', {'class' : "powers_container clearfix"}),
4647
power_id = undefined,
47-
_god = undefined;
48+
_god = undefined,
49+
_pow_ena = false;
4850
switch(RCGP.getController()){
4951
case "building_barracks":
5052
$.each(MM.checkAndPublishRawModel('PlayerGods', {id : Game.player_id}).getProductionOverview(), function(ind, elem){
5153
if (ind == 'hera') {
5254
power_id = 'fertility_improvement',
53-
_god = 'hera'
55+
// _god = 'hera'
56+
_powers[ind] = power_id
57+
}
58+
if (ind == 'ares') {
59+
power_id = 'spartan_training',
60+
// _god = 'hera'
61+
_powers[ind] = power_id
5462
}
5563
})
64+
_pow_ena = MM.checkAndPublishRawModel('Town',{id:Game.townId}).getBuildings().getBuildingLevel('barracks') > 0;
5665
break;
5766
case "building_docks":
5867
$.each(MM.checkAndPublishRawModel('PlayerGods', {id : Game.player_id}).getProductionOverview(), function(ind, elem){
5968
if (ind == 'poseidon') {
6069
power_id = 'call_of_the_ocean',
61-
_god = 'poseidon'
70+
// _god = 'poseidon'
71+
_powers[ind] = power_id
6272
}
6373
})
74+
_pow_ena = MM.checkAndPublishRawModel('Town',{id:Game.townId}).getBuildings().getBuildingLevel('docks') > 0;
6475
break;
6576
}
66-
if (power_id != undefined && $('#unit_order .grcrt_power').length == 0) {
67-
var
68-
casted_power = HelperPower.createCastedPowerModel(power_id, Game.townId),
69-
_disable = MM.checkAndPublishRawModel('PlayerGods', {id : Game.player_id}).get(_god+'_favor') < GameData.powers[power_id].favor,
70-
_classAdd = (_disable) ? ' disabled' : '',
71-
casted = HelperPower.createCastedPowerModel(power_id, Game.townId)
72-
$.each(MM.checkAndPublishRawModel('Town',{id:Game.townId}).getCastedPowers(), function(ind,elem){
73-
if(elem.getPowerId() == power_id){
74-
casted = elem,
75-
_classAdd = ' active_animation extendable';
76-
}
77-
})
78-
;
79-
RCGP.getJQElement().find($('.game_inner_box'))
80-
.append(
81-
$('<div/>', {'class' : "grcrt_power"})
82-
.append(
83-
$('<div/>', {'class' : "powers_container clearfix"})
84-
.append(
85-
$('<div/>', {'class' : "power_icon45x45 "+power_id+" new_ui_power_icon js-power-icon"+_classAdd, 'data-power_id' : power_id, 'rel' : _god})
86-
.append(
87-
$('<div/>', {'class' : "extend_spell"})
88-
.append(
89-
$('<div/>', {'class' : "gold"})
90-
)
91-
.append(
92-
$('<div/>', {'class' : "amount"})
93-
)
94-
)
95-
.append(
96-
$('<div/>', {'class' : "js-caption"})
97-
)
98-
.on('mouseover', function(e) {
99-
var _tooltipParam = {
100-
show_costs: true
101-
}
102-
if (typeof casted.getId != 'undefined') {
103-
_tooltipParam.casted_power_end_at = casted.getEndAt(),
104-
_tooltipParam.extendable = casted.isExtendable()
105-
}
106-
$(this).tooltip(TooltipFactory.createPowerTooltip(casted_power.getPowerId(), _tooltipParam)).showTooltip(e);
107-
})
108-
.on('click', function(e){
109-
CM.unregister({main : RCGP.getContext().main, sub:"casted_powers"},'grcrt_power_'+casted.getId());
110-
var
111-
_btn = CM.register(
112-
{main : RCGP.getContext().main, sub:"casted_powers"},
113-
'grcrt_power_'+casted.getId(),
114-
RCGP.getJQElement().find($('.grcrt_power .new_ui_power_icon .gold')).button()
115-
),
116-
power = HelperPower.createCastedPowerModel(power_id, Game.townId);
117-
if (casted.getId() == undefined) {
118-
power.cast();
119-
} else {
120-
if (casted.isExtendable()) {
121-
BuyForGoldWindowFactory.openExtendPowerForGoldWindow(_btn, casted);
122-
$(this).addClass(_classAdd);
123-
}
124-
}
125-
})
126-
)
127-
)
128-
)
129-
if (_disable && !casted.isExtendable()) {
77+
if (/*power_id != undefined*/ _pow_ena && $('#unit_order .grcrt_power').length == 0) {
78+
$.each(_powers, function(_god, power_id){
79+
var
80+
casted_power = HelperPower.createCastedPowerModel(power_id, Game.townId),
81+
_disable = MM.checkAndPublishRawModel('PlayerGods', {id : Game.player_id}).get(_god+'_favor') < GameData.powers[power_id].favor,
82+
_classAdd = (_disable) ? ' disabled' : '',
83+
casted = HelperPower.createCastedPowerModel(power_id, Game.townId)
84+
$.each(MM.checkAndPublishRawModel('Town',{id:Game.townId}).getCastedPowers(), function(ind,elem){
85+
if(elem.getPowerId() == power_id){
86+
casted = elem,
87+
_classAdd = ' active_animation extendable animated_power_icon animated_power_icon_45x45';
88+
}
89+
}) ;
90+
$(_power_div)
91+
.append(
92+
$('<div/>', {'class' : "js-power-icon power_icon45x45 "+power_id+" power"+_classAdd, 'data-power_id' : power_id, 'rel' : _god})
93+
.append(
94+
$('<div/>', {'class' : "extend_spell"})
95+
.append(
96+
$('<div/>', {'class' : "gold"})
97+
)
98+
.append(
99+
$('<div/>', {'class' : "amount"})
100+
)
101+
)
102+
.append(
103+
$('<div/>', {'class' : "js-caption"})
104+
)
105+
.on('mouseover', function(e) {
106+
var _tooltipParam = {
107+
show_costs: true
108+
}
109+
if (typeof casted.getId != 'undefined') {
110+
_tooltipParam.casted_power_end_at = casted.getEndAt(),
111+
_tooltipParam.extendable = casted.isExtendable()
112+
}
113+
$(this).tooltip(TooltipFactory.createPowerTooltip(casted_power.getPowerId(), _tooltipParam)).showTooltip(e);
114+
})
115+
.on('click', function(e){
116+
CM.unregister({main : RCGP.getContext().main, sub:"casted_powers"},'grcrt_power_'+casted.getId());
117+
var
118+
_btn = CM.register(
119+
{main : RCGP.getContext().main, sub:"casted_powers"},
120+
'grcrt_power_'+casted.getId(),
121+
RCGP.getJQElement().find($('.grcrt_power .new_ui_power_icon .gold')).button()
122+
),
123+
power = HelperPower.createCastedPowerModel(power_id, Game.townId);
124+
if (casted.getId() == undefined) {
125+
power.cast();
126+
} else {
127+
if (casted.isExtendable()) {
128+
BuyForGoldWindowFactory.openExtendPowerForGoldWindow(_btn, casted);
129+
$(this).addClass(_classAdd);
130+
}
131+
}
132+
})
133+
);
134+
RCGP.getJQElement().find($('.game_inner_box'))
135+
.append(
136+
$('<div/>', {'class' : "grcrt_power"})
137+
.append(
138+
_power_div
139+
)
140+
)
141+
})
142+
$.each(_powers, function(_god, power_id){
143+
144+
// if (_disable && !casted.isExtendable()) {
130145
var
131146
power = GameData.powers[power_id],
132-
god = MM.checkAndPublishRawModel('PlayerGods', {id : Game.player_id}).getCurrentProductionOverview()[_god],
147+
god = MM.checkAndPublishRawModel('PlayerGods', {id : Game.player_id}).getCurrentProductionOverview()[_god],
133148
_godCurr = MM.checkAndPublishRawModel('PlayerGods', {id : Game.player_id})[_god+'_favor_delta_property'].calculateCurrentValue().unprocessedCurrentValue,
134-
marg =42,
149+
marg =33,
135150
_elem =
136151
$('<div/>',{
137152
'style': 'margin-top:'+marg+'px;color:black;text-shadow: 2px 2px 2px gray;font-size:10px;z-index:3000;font-weight: bold;',
@@ -146,11 +161,12 @@ function _RepConvGRC() {
146161
$(this).remove()
147162
})
148163
);
149-
RCGP.getJQElement().find($('.new_ui_power_icon'))
164+
RCGP.getJQElement().find($('.power_icon45x45.power.'+power_id))
150165
.append(
151166
_elem
152167
)
153-
}
168+
// }
169+
})
154170
}
155171

156172
}

0 commit comments

Comments
 (0)