Fix
[ryzomcore.git] / ryzom / client / data / gamedev / interfaces_v3 / outpost.lua
blob67fb214af5555f0746e02892caa5284eb6130369
1 -- In this file we define functions that serves for Outposts windows
4 ------------------------------------------------------------------------------------------------------------
5 -- create the game namespace without reseting if already created in an other file.
6 if (game==nil) then
7 game= {};
8 end
10 -- init The Outpost Object
11 if (game.Outpost==nil) then
12 game.Outpost= {};
13 game.Outpost.LastTimeZoneUpdate= 0;
14 end
16 -- init constants, from XML defines
17 if (game.OutpostEnums==nil) then
18 game.OutpostEnums= {};
19 -- force values to be stored as int
20 game.OutpostEnums.UnknownOutpostState= tonumber( getDefine('outpost_status_UnknownOutpostState') );
21 game.OutpostEnums.Peace= tonumber( getDefine('outpost_status_Peace') );
22 game.OutpostEnums.WarDeclaration= tonumber( getDefine('outpost_status_WarDeclaration') );
23 game.OutpostEnums.AttackBefore= tonumber( getDefine('outpost_status_AttackBefore') );
24 game.OutpostEnums.AttackRound= tonumber( getDefine('outpost_status_AttackRound') );
25 game.OutpostEnums.AttackAfter= tonumber( getDefine('outpost_status_AttackAfter') );
26 game.OutpostEnums.DefenseBefore= tonumber( getDefine('outpost_status_DefenseBefore') );
27 game.OutpostEnums.DefenseRound= tonumber( getDefine('outpost_status_DefenseRound') );
28 game.OutpostEnums.DefenseAfter= tonumber( getDefine('outpost_status_DefenseAfter') );
29 end
32 -- ***************************************************************************
33 -- ***************************************************************************
34 -- OUTPOST COMMON
35 -- ***************************************************************************
36 -- ***************************************************************************
39 ------------------------------------------------------------------------------------------------------------
40 function game:outpostSetTimeZone(tz)
41 setDbProp('UI:SAVE:OUTPOST:TIME_ZONE', tz);
42 end
44 ------------------------------------------------------------------------------------------------------------
45 function game:outpostDisplayTimeZone(uiLocal)
46 local tz= getDbProp('UI:SAVE:OUTPOST:TIME_ZONE');
47 local uiGroup= getUICaller();
48 uiGroup[uiLocal].uc_hardtext= 'GMT ' .. string.format('%+d', tz);
49 end
51 ------------------------------------------------------------------------------------------------------------
53 function game:outpostAdjustHour(uiLocal, prop)
54 local uiGroup = getUICaller();
55 local tz = getDbProp('UI:SAVE:OUTPOST:TIME_ZONE');
56 local h = runExpr(prop);
58 -- add time zone and clamp hour
59 h = math.fmod(h + tz + 24, 24);
60 uiGroup[uiLocal].uc_hardtext = string.format('%02d:00', h);
61 end
63 ------------------------------------------------------------------------------------------------------------
64 function game:outpostUpdateTimeZone()
65 local curTick = getDbProp('UI:VARIABLES:CURRENT_SERVER_TICK');
66 setDbProp('UI:TEMP:OUTPOST:TIME_ZONE_NEXT_UPDATE', curTick + 50);
67 game.Outpost.LastTimeZoneUpdate = curTick;
68 runAH(nil,'outpost_update_time_zone_auto','');
69 end
71 ------------------------------------------------------------------------------------------------------------
72 function game:outpostIsStatusWar(status)
73 -- return true only if the status is a War
74 if( status == self.OutpostEnums.UnknownOutpostState or
75 status == self.OutpostEnums.Peace or
76 status == self.OutpostEnums.WarDeclaration )then
77 return false;
78 else
79 return true;
80 end
81 end
83 ------------------------------------------------------------------------------------------------------------
84 function game:outpostIsStatusWarRound(status)
85 -- return true only if the status is an attack period
86 if( status == self.OutpostEnums.AttackRound or
87 status == self.OutpostEnums.DefenseRound ) then
88 return true;
89 else
90 return false;
91 end
92 end
94 ------------------------------------------------------------------------------------------------------------
95 function game:outpostBCOpenStateWindow()
96 -- Open the State Window from the BotChat. server msg
97 runAH(nil, 'outpost_select_from_bc', '');
99 -- Open the window
100 runAH(nil, 'show', 'outpost_selected');
103 ------------------------------------------------------------------------------------------------------------
104 function game:outpostDeclareWar()
105 -- Send Msg to server
106 runAH(nil, 'outpost_declare_war_start', '');
108 -- wait a ack from server. Suppose not OK by default
109 setDbProp("UI:TEMP:OUTPOST:DECLARE_WAR_ACK_RECEIVED", 0);
110 setDbProp("UI:TEMP:OUTPOST:DECLARE_WAR_ACK_OK", 0);
112 -- Open the Declare War window
113 runAH(nil, "show", "outpost_declare_war");
116 ------------------------------------------------------------------------------------------------------------
117 function game:outpostDeclareWarValidate()
118 -- Send Msg to server
119 runAH(nil, 'outpost_declare_war_validate', '');
121 -- close the Declare War window
122 runAH(nil, "hide", "outpost_declare_war");
125 ------------------------------------------------------------------------------------------------------------
126 -- some constants
127 game.Outpost.SelectSquadCapitalModal= 'ui:interface:squad_change_capital';
128 game.Outpost.SelectSquadCapitalEditBox= 'ui:interface:squad_change_capital:edit:eb';
131 ------------------------------------------------------------------------------------------------------------
132 function game:outpostSelectSquadCapitalOpen()
133 -- Retrieve the the edit box.
134 local uiEB= getUI(self.Outpost.SelectSquadCapitalEditBox);
135 if(uiEB==nil) then
136 return;
139 -- Retrieve the value in database
140 local dbPath= formatUI('SERVER:GUILD:OUTPOST:O#1', math.max(0, getDbProp('UI:TEMP:OUTPOST:SELECTION')) );
141 local val= getDbProp(dbPath .. ':SQUAD_CAPITAL');
143 -- Open the modal
144 runAH(getUICaller(), "enter_modal", "group=" .. game.Outpost.SelectSquadCapitalModal);
146 -- Setup the default input string with it, and set focus
147 uiEB.input_string= val;
148 runAH(nil, "set_keyboard_focus", "target=" .. self.Outpost.SelectSquadCapitalEditBox .. "|select_all=true");
151 ------------------------------------------------------------------------------------------------------------
152 function game:outpostSelectSquadCapitalConfirm()
153 -- Retrieve the value in the edit box.
154 local uiEB= getUI(self.Outpost.SelectSquadCapitalEditBox);
155 if(uiEB==nil) then
156 return;
158 local val= uiEB.input_string;
159 if( tonumber(val) == nil ) then
160 return;
163 -- Send a msg to server
164 runAH(nil, "outpost_select_squad_capital", val);
166 -- Close the modal
167 runAH(nil, "leave_modal", "");
170 function game:outpostSetSquad()
171 local halfIndexSquad= tonumber(getDefine("right_squad_list_index"));
172 local MaxSquad= tonumber(getDefine("outpost_nb_max_squad_in_list"));
173 debug(getDbProp("UI:TEMP:OUTPOST:SQUAD_TO_BUY"))
174 local slot = getDbProp("UI:TEMP:OUTPOST:SQUAD_SLOT_SELECTED")
175 if slot >= halfIndexSquad then
176 setDbProp("UI:TEMP:OUTPOST:SQUAD_SLOT_SELECTED", slot - MaxSquad)
178 runAH(nil, "outpost_set_squad", "line=@UI:TEMP:OUTPOST:SQUAD_TO_BUY");
181 function game:outpostRemoveSquad()
182 local Rounds = tonumber(getDefine("right_squad_list_index"));
183 local MaxSquad= tonumber(getDefine("outpost_nb_max_squad_in_list"));
184 local slot = getDbProp("UI:TEMP:OUTPOST:SQUAD_SLOT_SELECTED")
185 if slot >= Rounds then
186 setDbProp("UI:TEMP:OUTPOST:SQUAD_SLOT_SELECTED", slot - MaxSquad)
188 runAH(nil, "outpost_remove_squad", "line=@UI:TEMP:OUTPOST:SQUAD_TO_BUY");
191 function game:outpostInsertSquad()
192 local Rounds= tonumber(getDefine("right_squad_list_index"));
193 local MaxSquad= tonumber(getDefine("outpost_nb_max_squad_in_list"));
194 local slot = getDbProp("UI:TEMP:OUTPOST:SQUAD_SLOT_SELECTED")
195 if slot >= Rounds then
196 setDbProp("UI:TEMP:OUTPOST:SQUAD_SLOT_SELECTED", slot - MaxSquad)
198 runAH(nil, "outpost_insert_squad", "line=@UI:TEMP:OUTPOST:SQUAD_TO_BUY");
201 function game:outpostSetMapSquad()
202 local Rounds= tonumber(getDefine("right_squad_list_index"));
203 local MaxSquad= tonumber(getDefine("outpost_nb_max_squad_in_list"));
204 local slot = getDbProp("UI:TEMP:OUTPOST:SQUAD_SLOT_SELECTED")
205 if slot >= Rounds then
206 setDbProp("UI:TEMP:OUTPOST:SQUAD_SLOT_SELECTED", slot - MaxSquad)
208 runAH(nil, "outpost_squad_map_send", "ui:interface:squad_spawn_map:content:map_content:actual_map")
212 ------------------------------------------------------------------------------------------------------------
213 function game:outpostToolTipTrainSquad(dbIndex)
214 local Rounds= tonumber(getDefine("right_squad_list_index"));
216 -- compute the level at which the squad will spawn.
217 local lvl;
218 if(dbIndex < Rounds) then
219 lvl = dbIndex*2 +1 ; -- eg: 0 => 1. 1=> 3
220 else
221 lvl = (dbIndex-Rounds)*2 +2 ; -- eg: 12 => 2
224 -- set the tooltip
225 local text = i18n.get('uittOutpostSquadLvl');
226 text = findReplaceAll(text, "%lvl", tostring(lvl));
227 setContextHelpText(text);
231 -- ***************************************************************************
232 -- ***************************************************************************
233 -- OUTPOST INFO WINDOW
234 -- ***************************************************************************
235 -- ***************************************************************************
238 ------------------------------------------------------------------------------------------------------------
239 function game:outpostInfoGetDbPath(uiGroup)
240 if (uiGroup.Env.Type==0) then
241 return 'SERVER:OUTPOST_SELECTED';
242 else
243 -- avoid problems, points to 0 if nothing selected
244 return formatUI('SERVER:GUILD:OUTPOST:O#1', math.max(0, getDbProp('UI:TEMP:OUTPOST:SELECTION')) );
248 ------------------------------------------------------------------------------------------------------------
249 function game:outpostInfoOnDraw()
250 local uiGroup= getUICaller();
252 -- get status
253 local path= self:outpostInfoGetDbPath(uiGroup);
254 local status= getDbProp(path .. ':STATUS');
256 -- translate ticks to time
257 local curTick= getDbProp('UI:VARIABLES:CURRENT_SERVER_TICK');
258 local endTick= getDbProp( path .. ':STATE_END_DATE' );
259 -- suppose a server tick is 100 ms
260 local timeSec= (endTick - curTick)/10;
261 timeSec= math.max(timeSec, 0);
263 -- readable form
264 if (status == self.OutpostEnums.Peace) then
265 uiGroup.Env.Timer.uc_hardtext= '';
266 else
267 uiGroup.Env.Timer.uc_hardtext= '(' .. runFct('secondsToTimeString', timeSec) .. ')';
271 ------------------------------------------------------------------------------------------------------------
272 function game:outpostInfoOnDbChange()
273 local uiGroup= getUICaller();
275 -- get the selection
276 local path= self:outpostInfoGetDbPath(uiGroup);
278 -- change path for icon and textid
279 uiGroup.global_state.outpost_owner.guild.blason.sheet= path .. ':GUILD';
280 uiGroup.global_state.outpost_owner.guild.name.textid_dblink= path .. ':GUILD:NAME';
282 -- change path for attacker text id
283 uiGroup.global_state.outpost_attacker.name.textid_dblink= path .. ':GUILD:NAME_ATT';
286 ------------------------------------------------------------------------------------------------------------
287 function game:outpostInitInfo(type)
288 local uiGroup= getUICaller();
290 -- bkup Timer control
291 uiGroup.Env.Timer= uiGroup.global_state.outpost_status_time;
292 uiGroup.Env.Type= type;
294 -- must change timer each frame
295 setOnDraw(uiGroup, 'game:outpostInfoOnDraw()');
297 -- For Type==1 (outpost from GuildInfo), must change the DB Path for the GuildIcon, and GuildName TextId
298 if(type==1) then
299 addOnDbChange(uiGroup,"@UI:TEMP:OUTPOST:SELECTION", 'game:outpostInfoOnDbChange()');
303 ------------------------------------------------------------------------------------------------------------
304 function game:outpostActiveDefenderHourButton()
305 -- uiGroup here should be the 'war_schedule' uigroup (not the whole parent infoGroup)
306 local uiGroup= getUICaller();
308 -- get values
309 local path= self:outpostInfoGetDbPath(uiGroup.parent);
310 local owned= getDbProp(path .. ':OWNED');
311 local admin= getDbProp('SERVER:USER:OUTPOST_ADMIN');
312 local status= getDbProp(path .. ':STATUS');
314 -- status start with 3 for Actual War (2 for War Declaration). If the user has not the right to change the defense period
315 -- if the player has no right to edit
316 if( owned==0 or admin==0 or self:outpostIsStatusWar(status) ) then
317 uiGroup.outpost_def_hour.frozen= true;
318 uiGroup.outpost_def_hour.tooltip= i18n.get('uittOutpostDefHourCannotEdit');
319 else
320 uiGroup.outpost_def_hour.frozen= false;
322 -- get defense hours in 0-23 range
323 local timeRangeDef= getDbProp(path .. ':TIME_RANGE_DEF');
324 local timeRangeDefWanted= getDbProp(path .. ':TIME_RANGE_DEF_WANTED');
325 timeRangeDef= secondsSince1970ToHour( timeRangeDef );
326 timeRangeDef= math.fmod(timeRangeDef+24, 24);
327 timeRangeDefWanted= math.fmod(timeRangeDefWanted+24, 24);
329 -- if time required is the one obtained, or if we are in peace
330 if( timeRangeDef == timeRangeDefWanted or status<=game.OutpostEnums.Peace ) then
331 uiGroup.outpost_def_hour.tooltip= i18n.get('uittOutpostDefHour');
332 else
333 uiGroup.outpost_def_hour.tooltip= i18n.get('uittOutpostDefHourError');
337 -- Force the tooltip to be up to date (important if dbs are desync)
338 disableContextHelpForControl(uiGroup.outpost_def_hour);
341 ------------------------------------------------------------------------------------------------------------
342 function game:outpostActiveAttackerHourButton()
343 -- uiGroup here should be the 'war_schedule' uigroup (not the whole parent infoGroup)
344 local uiGroup= getUICaller();
346 -- get values
347 local canEdit= getDbProp('UI:TEMP:OUTPOST:DECLARE_WAR_ACK_OK');
349 -- status start with 3 for Actual War (2 for War Declaration). If the user has not the right to change the defense period
350 -- if the player has no right to edit
351 if( canEdit==0 ) then
352 uiGroup.outpost_att_hour.frozen= true;
353 uiGroup.outpost_att_hour.tooltip= i18n.get('uittOutpostAttHour');
354 else
355 uiGroup.outpost_att_hour.frozen= false;
357 -- get attack hours in 0-23 range
358 local timeRangeAtt= getDbProp('UI:TEMP:OUTPOST:DECLARE_WAR_ACK_TIME_RANGE_ATT');
359 local timeRangeAttWanted= getDbProp('UI:TEMP:OUTPOST:DECLARE_WAR_ATTACK_PERIOD');
360 timeRangeAtt= secondsSince1970ToHour( timeRangeAtt );
361 timeRangeAtt= math.fmod(timeRangeAtt+24, 24);
362 timeRangeAttWanted= math.fmod(timeRangeAttWanted+24, 24);
364 -- if time required is the one obtained
365 if( timeRangeAtt == timeRangeAttWanted ) then
366 uiGroup.outpost_att_hour.tooltip= i18n.get('uittOutpostAttHour');
367 else
368 uiGroup.outpost_att_hour.tooltip= i18n.get('uittOutpostAttHourError');
372 -- Force the tooltip to be up to date. important here because
373 -- DECLARE_WAR_ACK_TIME_RANGE_ATT(server) is received after DECLARE_WAR_ATTACK_PERIOD(local)
374 disableContextHelpForControl(uiGroup.outpost_att_hour);
377 ------------------------------------------------------------------------------------------------------------
378 function game:outpostIsGuildInvolved()
379 local found = 0;
380 local sheetCur;
381 -- try to get sheet id from bot object
382 local sheetSel = getDbProp('SERVER:OUTPOST_SELECTED:SHEET');
384 if (sheetSel == 0) then
385 -- try to get sheet id from outpost manager
386 local ind = getDbProp('UI:TEMP:OUTPOST:SELECTION');
387 if (ind == -1) then
388 return 0;
390 sheetSel = getDbProp(formatUI('SERVER:GUILD:OUTPOST:O#1', ind) .. ':SHEET');
393 -- check every outpost owned or challenged by the guild
394 local i;
395 for i = 0, 15 do
396 sheetCur = getDbProp(formatUI('SERVER:GUILD:OUTPOST:O#1', i) .. ':SHEET');
397 if (sheetCur == sheetSel) then
398 found = 1;
402 return found;
406 ------------------------------------------------------------------------------------------------------------
407 function game:outpostGetStatusInfo(statusExpr, dbIndex, isTooltip)
408 local uiGroup = getUICaller();
409 local status = runExpr(statusExpr);
410 local uittOutpost;
411 local path;
413 -- get outpost
414 if (isTooltip == 'no') then
415 path = self:outpostInfoGetDbPath(uiGroup.parent);
416 else
417 path = formatUI('SERVER:GUILD:OUTPOST:O#1', math.max(0, dbIndex));
420 -- Peace
421 if (status == self.OutpostEnums.Peace) then
422 uittOutpost = i18n.get('uittOutpostPeace');
424 -- WarDeclaration
425 elseif (status == self.OutpostEnums.WarDeclaration) then
426 if (isTooltip == 'yes' or self:outpostIsGuildInvolved() == 1) then
427 local myGuild = getDbProp('SERVER:GUILD:NAME');
428 local outpostGuild = getDbProp('SERVER:OUTPOST_SELECTED:GUILD:NAME');
429 local outpostTribe = getDbProp('SERVER:OUTPOST_SELECTED:GUILD:TRIBE');
430 -- bot object flag : check 'owned' param to determine who are the attacker and defender
431 if (outpostTribe == 0 and outpostGuild == 0) then
432 local owned = getDbProp(path .. ':OWNED');
433 if (owned == 1) then
434 uittOutpost = i18n.get('uittOutpostWarDeclarationMyGuildDefend');
435 else
436 uittOutpost = i18n.get('uittOutpostWarDeclarationMyGuildAttack');
438 -- outpost manager : check guild name to determine who are the attacker and defender
439 else
440 if (myGuild == outpostGuild) then
441 uittOutpost = i18n.get('uittOutpostWarDeclarationMyGuildDefend');
442 else
443 uittOutpost = i18n.get('uittOutpostWarDeclarationMyGuildAttack');
446 else
447 uittOutpost = i18n.get('uittOutpostWarDeclaration');
450 -- AttackBefore
451 elseif (status == self.OutpostEnums.AttackBefore) then
452 uittOutpost = i18n.get('uittOutpostAttackBefore');
454 -- AttackRound
455 elseif (status == self.OutpostEnums.AttackRound) then
456 uittOutpost = i18n.get('uittOutpostAttackRound');
458 -- AttackAfter
459 elseif (status == self.OutpostEnums.AttackAfter) then
460 local lvlMax = getDbProp(path .. ':ROUND_LVL_THRESHOLD');
461 local lvlAtt = getDbProp(path .. ':ROUND_LVL_MAX_ATT');
462 if (lvlAtt > lvlMax) then
463 uittOutpost = i18n.get('uittOutpostAttackAfterWin');
464 else
465 uittOutpost = i18n.get('uittOutpostAttackAfterLoose');
468 -- DefenseBefore
469 elseif (status == self.OutpostEnums.DefenseBefore) then
470 uittOutpost = i18n.get('uittOutpostDefenseBefore');
472 -- DefenseRound
473 elseif (status == self.OutpostEnums.DefenseRound) then
474 uittOutpost = i18n.get('uittOutpostDefenseRound');
476 -- DefenseAfter
477 elseif (status == self.OutpostEnums.DefenseAfter) then
478 uittOutpost = i18n.get('uittOutpostDefenseAfter');
480 -- default
481 else
482 uittOutpost = i18n.get('uittOutpostPeace');
485 return uittOutpost;
489 ------------------------------------------------------------------------------------------------------------
490 function game:outpostDisplayStatusInfo(statusExpr, id)
491 local uiGroup = getUICaller();
492 local text = self:outpostGetStatusInfo(statusExpr, -1, 'no');
493 uiGroup[id].uc_hardtext_format = text;
496 ------------------------------------------------------------------------------------------------------------
497 function game:outpostDisplayStatusInfoTooltip(statusExpr, dbIndex)
498 local text = self:outpostGetStatusInfo(statusExpr, dbIndex, 'yes');
499 setContextHelpText(text);
502 ------------------------------------------------------------------------------------------------------------
503 function game:outpostUpdateBuildingSheet(buildingIndex)
504 local ui= getUICaller();
505 local outpostIndex= getDbProp('UI:TEMP:OUTPOST:SELECTION');
506 if (outpostIndex<0) then
507 outpostIndex= 0;
509 local db= 'SERVER:GUILD:OUTPOST:O' .. tostring(outpostIndex) .. ':BUILDINGS:' .. tostring(buildingIndex) ;
510 ui.building_sheet.sheet= db;
514 -- ***************************************************************************
515 -- ***************************************************************************
516 -- OUTPOST INFO: ROUND STATE DISPLAY
517 -- ***************************************************************************
518 -- ***************************************************************************
521 ------------------------------------------------------------------------------------------------------------
522 -- ROUND_LVL_THRESHOLD
523 function game:outpostChangeRoundLvlThreshold()
524 -- uiGroup here should be the 'round_state' uigroup (not the whole parent infoGroup)
525 local uiGroup= getUICaller();
527 -- get values
528 local path= self:outpostInfoGetDbPath(uiGroup.parent);
529 local val= getDbProp(path .. ':ROUND_LVL_THRESHOLD');
531 -- setup text
532 uiGroup.outpost_lvl_thre.uc_hardtext= tostring(val);
536 ------------------------------------------------------------------------------------------------------------
537 -- ROUND_LVL_MAX_ATT
538 function game:outpostChangeRoundLvlMaxAtt()
539 -- uiGroup here should be the 'round_state' uigroup (not the whole parent infoGroup)
540 local uiGroup= getUICaller();
542 -- get values
543 local path= self:outpostInfoGetDbPath(uiGroup.parent);
544 local val= getDbProp(path .. ':ROUND_LVL_MAX_ATT');
545 local status= getDbProp(path .. ':STATUS');
547 -- setup text (only relevant when attack period has begun)
548 if(status>=self.OutpostEnums.AttackRound) then
549 uiGroup.outpost_lvl_max_att.uc_hardtext= tostring(val);
550 else
551 uiGroup.outpost_lvl_max_att.uc_hardtext= '- ';
556 ------------------------------------------------------------------------------------------------------------
557 -- ROUND_LVL_MAX_DEF
558 function game:outpostChangeRoundLvlMaxDef()
559 -- uiGroup here should be the 'round_state' uigroup (not the whole parent infoGroup)
560 local uiGroup= getUICaller();
562 -- get values
563 local path= self:outpostInfoGetDbPath(uiGroup.parent);
564 local val= getDbProp(path .. ':ROUND_LVL_MAX_DEF');
565 local status= getDbProp(path .. ':STATUS');
567 -- setup text (only relevant in War)
568 if(status>=self.OutpostEnums.DefenseRound) then
569 uiGroup.outpost_lvl_max_def.uc_hardtext= tostring(val);
570 else
571 uiGroup.outpost_lvl_max_def.uc_hardtext= '- ';
576 ------------------------------------------------------------------------------------------------------------
577 -- ROUND_LVL_CUR
578 function game:outpostChangeRoundLvlCur()
579 -- uiGroup here should be the 'round_state' uigroup (not the whole parent infoGroup)
580 local uiGroup= getUICaller();
582 -- get values
583 local path= self:outpostInfoGetDbPath(uiGroup.parent);
584 local val= getDbProp(path .. ':ROUND_LVL_CUR');
585 local status= getDbProp(path .. ':STATUS');
586 -- add 1, because server send a 0 based value
587 val= val+1;
589 -- setup text (only in a Attack/Defense Round)
590 if(self:outpostIsStatusWarRound(status)) then
591 uiGroup.outpost_lvl_cur.uc_hardtext= tostring(val);
592 else
593 uiGroup.outpost_lvl_cur.uc_hardtext= '- ';
598 ------------------------------------------------------------------------------------------------------------
599 -- ROUND_ID_CUR / ROUND_ID_MAX
600 function game:outpostChangeRoundId()
601 -- uiGroup here should be the 'round_state' uigroup (not the whole parent infoGroup)
602 local uiGroup= getUICaller();
604 -- get values
605 local path= self:outpostInfoGetDbPath(uiGroup.parent);
606 local val= getDbProp(path .. ':ROUND_ID_CUR');
607 local maxRound= getDbProp(path .. ':ROUND_ID_MAX');
608 local status= getDbProp(path .. ':STATUS');
609 -- add 1 because server sends a 0 based value
610 val= val+1;
612 -- setup text (only in a Attack/Defense Round)
613 if(self:outpostIsStatusWarRound(status)) then
614 uiGroup.outpost_round_cur.uc_hardtext= tostring(val) .. ' / ' .. tostring(maxRound);
615 else
616 uiGroup.outpost_round_cur.uc_hardtext= '- ';
621 -- ***************************************************************************
622 -- ***************************************************************************
623 -- OUTPOST PVP INFO / PROPOSAL
624 -- ***************************************************************************
625 -- ***************************************************************************
628 ------------------------------------------------------------------------------------------------------------
629 function game:outpostPvpJoin(choice)
630 -- send msg server
631 runAH(nil, 'outpost_pvp_join', choice);
633 -- hide the window
634 runAH(nil, 'hide', 'join_pvp_outpost_proposal');
638 ------------------------------------------------------------------------------------------------------------
639 function game:outpostPvpJoinTimerOnDraw()
640 local uiGroup= getUICaller();
642 -- Compute time left
643 local curTick= getDbProp('UI:VARIABLES:CURRENT_SERVER_TICK');
644 local endTick= getDbProp('UI:TEMP:OUTPOST:PVP_PROPOSAL_TICK_END');
645 local timeSec= (endTick - curTick)/10;
646 timeSec= math.max(timeSec, 0);
647 timeSec= math.floor(timeSec+0.5);
649 -- replace in str
650 local text= i18n.get('uiOutpostJoinPVPTimer');
651 text= findReplaceAll(text, "%time", tostring(timeSec));
652 uiGroup.Env.Timer.uc_hardtext_format= text;
657 ------------------------------------------------------------------------------------------------------------
658 function game:outpostInitPvpJoinTimer()
659 local uiGroup= getUICaller();
661 -- bkup Timer viewtext
662 uiGroup.Env.Timer= uiGroup.text;
664 -- must change timer each frame
665 setOnDraw(uiGroup, 'game:outpostPvpJoinTimerOnDraw()');