Statistics with a chart at the end of a game, 64 achievements kept locally and on the server
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
193b199875
commit
9931ca9b54
37 files changed
+1833
-4
No files matched your search
@@ -80,6 +80,8 @@ enum Req {
|
||||
CampaignPublish,
|
||||
PublicList,
|
||||
PublicLoad,
|
||||
ProfileLoad,
|
||||
ProfileSave,
|
||||
}
|
||||
|
||||
// the logged-in account
|
||||
@@ -124,6 +126,7 @@ pub struct Cloud {
|
||||
pub public_listed: bool,
|
||||
pub campaign_error: Option<&'static str>, // language key of the last failed campaign request
|
||||
loaded_campaign: Option<String>,
|
||||
pub profile_loaded: Option<String>, // the profile from the server, waiting to be merged
|
||||
saved_campaign: Option<CampaignInfo>,
|
||||
pending: Option<(u32, Req)>,
|
||||
save_name: String,
|
||||
@@ -176,6 +179,7 @@ impl Cloud {
|
||||
public_listed: false,
|
||||
campaign_error: None,
|
||||
loaded_campaign: None,
|
||||
profile_loaded: None,
|
||||
saved_campaign: None,
|
||||
pending: Some((id, Req::Health)),
|
||||
save_name: String::new(),
|
||||
@@ -330,6 +334,13 @@ impl Cloud {
|
||||
CloudEvent::Error(error_key(res.status))
|
||||
}
|
||||
}
|
||||
Req::ProfileLoad => {
|
||||
if ok {
|
||||
self.profile_loaded = Some(String::from_utf8_lossy(&res.body).into_owned());
|
||||
}
|
||||
CloudEvent::None
|
||||
}
|
||||
Req::ProfileSave => CloudEvent::None,
|
||||
Req::CreateUser | Req::DeleteUser => {
|
||||
if ok {
|
||||
self.load_users();
|
||||
@@ -470,6 +481,15 @@ impl Cloud {
|
||||
}
|
||||
|
||||
// JSON text of a campaign loaded by load_campaign() or load_public_campaign()
|
||||
// the profile (statistics and achievements) of the logged-in player
|
||||
pub fn load_profile(&mut self) -> bool {
|
||||
self.session.is_some() && self.start("GET", "profile", &[], Req::ProfileLoad)
|
||||
}
|
||||
|
||||
pub fn save_profile(&mut self, json: &str) -> bool {
|
||||
self.session.is_some() && self.start("PUT", "profile", json.as_bytes(), Req::ProfileSave)
|
||||
}
|
||||
|
||||
pub fn take_loaded_campaign(&mut self) -> Option<String> {
|
||||
self.loaded_campaign.take()
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user