4 protected int m_iTraitXP;
34 toRet +=
"Gameplay Trait ID is "+m_eTraitID;
35 toRet+=
", XP is "+m_iTraitXP;
46 protected static const int SESSIONS_TO_STORE = 8;
50 protected int m_iKills;
51 protected int m_iFriendlyKills;
52 protected int m_iDeaths;
53 protected float m_fTravelledDistance;
55 protected ref array<ref GameplayTrait> m_aGameplayTraits;
56 protected ref array<ref SCR_SessionInfo> m_aSessionInfos;
59 void AddKill(
bool friendly =
false)
76 if(skillID >= 0 && skillID < m_aGameplayTraits.Count())
77 m_aGameplayTraits.Get(skillID).AddXP(XP);
79 Print(
"CareerBackend::AddSkillXP Wrong skillID! Can't add experience to the unknown skillID: "+skillID, LogLevel.ERROR);
83 float GetTravelledDistance()
85 return m_fTravelledDistance;
89 int GetFriendlyKills()
91 return m_iFriendlyKills;
109 if(skillID >= 0 && skillID < m_aGameplayTraits.Count())
110 return m_aGameplayTraits.Get(skillID).GetTraitXP();
113 Print(
"CareerBackend::GetSkillXP Wrong skillID!", LogLevel.ERROR);
120 void SetFaction(
string factionKey)
122 GetSessionInfo().SetFactionKey(factionKey);
129 int year, month, day, hour, minute, second;
131 System.GetYearMonthDay(year, month, day);
132 System.GetHourMinuteSecond(hour, minute, second);
134 GetSessionInfo().SetLoginTime(year, month, day, hour, minute, second);
141 int year, month, day, hour, minute, second;
143 System.GetYearMonthDay(year, month, day);
144 System.GetHourMinuteSecond(hour, minute, second);
146 GetSessionInfo().SetLogoutTime(year, month, day, hour, minute, second);
155 BackendApi bApi =
GetGame().GetBackendApi();
159 DSSession session = bApi.GetDSSession();
162 m_sessionInfo.SetRoomID(session.RoomID());
166 return m_sessionInfo;
174 override void OnSuccess(
int errorCode )
179 if (!m_aSessionInfos)
180 m_aSessionInfos =
new array<ref SCR_SessionInfo>();
183 sessionsCnt = m_aSessionInfos.Count();
185 if (sessionsCnt >= SESSIONS_TO_STORE)
187 m_aSessionInfos.Resize(SESSIONS_TO_STORE - 1);
188 sessionsCnt = SESSIONS_TO_STORE - 1;
193 BackendApi bApi =
GetGame().GetBackendApi();
195 if (bApi && sessionsCnt != 0)
197 DSSession session = bApi.GetDSSession();
201 string roomID = session.RoomID();
203 if (!roomID.IsEmpty())
205 for (
int i = 0; i < sessionsCnt; i++)
212 if (sessionInfo.GetRoomID() == roomID)
215 m_sessionInfo = sessionInfo;
216 m_aSessionInfos.RemoveOrdered(i);
217 m_aSessionInfos.InsertAt(m_sessionInfo, 0);
230 if (!sessionInfo.GetRoomID().IsEmpty())
231 m_aSessionInfos.InsertAt(GetSessionInfo(), 0);
242 override void OnError(
int errorCode )
244 Print(
"OnError: " + errorCode );
250 m_aGameplayTraits = {};
254 for(
int i = 0; i <
type.GetVariableCount(); i++)
261 RegV(
"m_iFriendlyKills");
263 RegV(
"m_fTravelledDistance");
265 RegV(
"m_aGameplayTraits");
266 RegV(
"m_aSessionInfos");
277 override void OnError(
int code,
int restCode,
int apiCode )
279 Print(
"[BackendCallback] OnError: "+
GetGame().GetBackendApi().GetErrorCode(code));
286 override void OnSuccess(
int code )
288 Print(
"[BackendCallback] OnSuccess");
294 override void OnTimeout()
296 Print(
"[BackendCallback] OnTimeout");