Offer Arcade to download instead of installing it for Chess players
An account that had Chess no longer gets Arcade installed: More apps lists Arcade with the download symbol, like any app not on this device, and Chess with its saved and friend games goes once the user installed Arcade.
This commit is contained in:
1 parent
7836d31079
commit
5717e07ba8
5 files changed
+35
-70
No files matched your search
+2
-3
@@ -52,9 +52,8 @@
|
||||
one starts when you open it; one still downloading stays closed instead of
|
||||
showing "Installing this app".
|
||||
- Chess moves into Arcade, a set of games that also has Pushy, so the
|
||||
standalone Chess app no longer shows in your apps or More apps. Once the
|
||||
node offers Arcade and you had installed Chess, Arcade installs for you with
|
||||
your saved and friend Chess games.
|
||||
standalone Chess app no longer shows in your apps or More apps. Install
|
||||
Arcade from More apps to keep playing your saved and friend Chess games.
|
||||
- Habits earn coins, more for hard ones, to spend on your own rewards in the shop.
|
||||
- The habit shop scrolls smoothly, even with its grid of symbols open.
|
||||
- Rewards can show 28 more symbols, such as weed, cigarettes, beer, wine, fast food, sweets, TV and games.
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
// Apps that replace an app the node offered before (NodeAppReplacement).
|
||||
// More apps lists the replacement instead, and an account that installed
|
||||
// the replaced app gets the replacement. The replaced app goes once the
|
||||
// replacement runs on this device and carries it as a verified child: the
|
||||
// collection lists inbe.<name> and is signed by the publisher allowed to
|
||||
// offer <name>, so the child keeps <name>'s records and shared games
|
||||
// More apps lists the replacement instead, with the download symbol for an
|
||||
// account that installed the replaced app too: it is never installed for
|
||||
// them. The replaced app goes once the user installed the replacement and
|
||||
// it runs on this device carrying it as a verified child: the collection
|
||||
// lists inbe.<name> and is signed by the publisher allowed to offer <name>,
|
||||
// so the child keeps <name>'s records and shared games
|
||||
// (NodeTreeLegacyOwner). Its records are never deleted.
|
||||
#import "apps/tree"
|
||||
#import "apps/catalog"
|
||||
@@ -17,20 +18,6 @@
|
||||
#import, file "package_files.zi";
|
||||
#import, file "package_release.zi";
|
||||
#import, file "../storage/app_records.zi";
|
||||
#import, file "../app/settings_store.zi";
|
||||
|
||||
// Offered by the node itself, not by a local file, and listed in More apps.
|
||||
NodeAppNodeOffers :: (name: string) -> bool {
|
||||
if name.count == 0 || NodeAppLocal(name) {
|
||||
return false
|
||||
}
|
||||
for index: cast(s32)0..NodeAppOfferCount() - 1 {
|
||||
if NodeAppOfferName(index) == name {
|
||||
return NodeAppOfferVisible(index)
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// Whether the signed collection running in `slot` carries `name` as a child
|
||||
// with its historical identity and publisher.
|
||||
@@ -88,22 +75,14 @@ NodeAppOfferReplaced :: (name: string) -> bool {
|
||||
return NodeAppReplacement(name).count > 0
|
||||
}
|
||||
|
||||
// Installs the replacement for an account that installed a replaced app,
|
||||
// then removes the replaced app once the replacement carries it. Runs with
|
||||
// the reconcile, after choices synced from the account's other devices.
|
||||
// Removes a replaced app once the user installed its replacement and the
|
||||
// replacement carries it. Runs with the reconcile, after choices synced
|
||||
// from the account's other devices.
|
||||
NodeAppsReplace :: () {
|
||||
for index: cast(s32)0..NODE_APP_REPLACED_COUNT - 1 {
|
||||
name := NodeAppReplaced(index)
|
||||
replacement := NodeAppReplacement(name)
|
||||
// Device-local: this device installed the replacement once already.
|
||||
key := PackageText("node_app_replaced_", name)
|
||||
attempted := SettingsReadInt(key, 0) != 0
|
||||
step := NodeAppReplacementStep(NodeAppMarked(name), NodeAppNodeOffers(replacement),
|
||||
NodeAppMarked(replacement), NodeAppReplacedHere(name), attempted)
|
||||
if step == NODE_APP_REPLACE_INSTALL {
|
||||
unused SettingsStoreInt(key, 1)
|
||||
unused NodeAppInstall(replacement)
|
||||
} else if step == NODE_APP_REPLACE_RETIRE {
|
||||
step := NodeAppReplacementStep(NodeAppMarked(name), NodeAppReplacedHere(name))
|
||||
if step == NODE_APP_REPLACE_RETIRE {
|
||||
retired := NodeAppSlotFor(name)
|
||||
if retired >= 0 {
|
||||
NodeAppUninstall(retired)
|
||||
@@ -111,6 +90,5 @@ NodeAppsReplace :: () {
|
||||
NodeAppSetMark(name, false)
|
||||
}
|
||||
}
|
||||
PackageFree(key)
|
||||
}
|
||||
}
|
||||
@@ -73,24 +73,16 @@ NodeAppReplacement :: (name: string) -> string {
|
||||
|
||||
// What happens next for an account that installed a replaced app.
|
||||
NODE_APP_REPLACE_WAIT :: 0
|
||||
NODE_APP_REPLACE_INSTALL :: 1
|
||||
NODE_APP_REPLACE_RETIRE :: 2
|
||||
|
||||
// The replaced app goes only once its replacement runs on this device and
|
||||
// verifiably carries it, so its saved and shared records open there. Until
|
||||
// then it stays. The replacement is installed once per device: removing it
|
||||
// afterwards keeps it removed.
|
||||
NodeAppReplacementStep :: (replaced_installed: bool, replacement_offered: bool,
|
||||
replacement_installed: bool, replacement_carries: bool, attempted: bool) -> s32 {
|
||||
if !replaced_installed {
|
||||
return NODE_APP_REPLACE_WAIT
|
||||
}
|
||||
if replacement_carries {
|
||||
// then it stays. The replacement is never installed for the account: it
|
||||
// waits in More apps with the download symbol, like any app not yet here.
|
||||
NodeAppReplacementStep :: (replaced_installed: bool, replacement_carries: bool) -> s32 {
|
||||
if replaced_installed && replacement_carries {
|
||||
return NODE_APP_REPLACE_RETIRE
|
||||
}
|
||||
if replacement_offered && !replacement_installed && !attempted {
|
||||
return NODE_APP_REPLACE_INSTALL
|
||||
}
|
||||
return NODE_APP_REPLACE_WAIT
|
||||
}
|
||||
|
||||
|
||||
+12
-9
@@ -244,25 +244,28 @@ with tempfile.TemporaryDirectory(prefix="inbe-arcade-") as directory:
|
||||
finally:
|
||||
stop(app)
|
||||
|
||||
# An account that installed Chess gets Arcade, and keeps Chess's game.
|
||||
# An account that installed Chess is not given Arcade: More apps offers
|
||||
# it with the download symbol, and Chess and its game stay.
|
||||
profile = Path(directory) / "replace"
|
||||
profile.mkdir()
|
||||
user = prepare(profile, {"node_apps_offers": "arcade|Arcade", "node_app_size_arcade": 4194304,
|
||||
"app_used_chess": 1, "cell.chess.computer": SAVED_CHESS})
|
||||
app = launch(profile, "replace", local_package=False)
|
||||
try:
|
||||
wait_for(lambda: settings(profile, user).get("app_used_arcade") == "1",
|
||||
"Arcade was not installed for an account with Chess")
|
||||
driver.press(label="Apps", role="button")
|
||||
card = wait_for(lambda: button("Arcade"), "More apps does not offer Arcade to an account with Chess")
|
||||
corner = [node for node in driver.tree() if node["label"] == "Download" and
|
||||
card["x"] <= node["x"] and node["x"] + node["width"] <= card["x"] + card["width"] and
|
||||
card["y"] <= node["y"] and node["y"] + node["height"] <= card["y"] + card["height"]]
|
||||
assert len(corner) == 1, "Arcade's card has no download symbol"
|
||||
driver.wait_idle(frames=30)
|
||||
stored = settings(profile, user)
|
||||
assert stored.get("node_app_replaced_chess") == "1", stored.get("node_app_replaced_chess")
|
||||
assert stored.get("app_used_arcade") != "1", "Arcade was installed for an account with Chess"
|
||||
assert stored.get("app_used_chess") == "1", "Chess left before Arcade was installed"
|
||||
assert stored.get("cell.chess.computer") == SAVED_CHESS, "Chess's saved game changed"
|
||||
if args.offline:
|
||||
# Arcade cannot run here yet, so Chess stays installed.
|
||||
driver.wait_idle(frames=30)
|
||||
assert settings(profile, user).get("app_used_chess") == "1", "Chess left before Arcade ran"
|
||||
log = (OUTPUT / "replace.log").read_text()
|
||||
assert app.poll() is None, log
|
||||
finally:
|
||||
stop(app)
|
||||
print("Arcade: installed from More apps, Chess played inside it and restored after a restart; "
|
||||
"Chess left out of More apps next to Arcade, and an account with Chess got Arcade")
|
||||
"Chess left out of More apps next to Arcade, and an account with Chess is offered Arcade to download")
|
||||
@@ -56,24 +56,17 @@ Check :: () -> s32 {
|
||||
return 16
|
||||
}
|
||||
// An account without Chess has nothing to replace.
|
||||
if NodeAppReplacementStep(false, true, false, false, false) != NODE_APP_REPLACE_WAIT ||
|
||||
NodeAppReplacementStep(false, true, true, true, false) != NODE_APP_REPLACE_WAIT {
|
||||
if NodeAppReplacementStep(false, false) != NODE_APP_REPLACE_WAIT ||
|
||||
NodeAppReplacementStep(false, true) != NODE_APP_REPLACE_WAIT {
|
||||
return 17
|
||||
}
|
||||
// Arcade offered and not yet installed: install it once per device.
|
||||
if NodeAppReplacementStep(true, true, false, false, false) != NODE_APP_REPLACE_INSTALL ||
|
||||
NodeAppReplacementStep(true, true, false, false, true) != NODE_APP_REPLACE_WAIT ||
|
||||
NodeAppReplacementStep(true, false, false, false, false) != NODE_APP_REPLACE_WAIT {
|
||||
return 18
|
||||
}
|
||||
// Chess stays while Arcade downloads, or when this device cannot run it.
|
||||
if NodeAppReplacementStep(true, true, true, false, false) != NODE_APP_REPLACE_WAIT ||
|
||||
NodeAppReplacementStep(true, true, true, false, true) != NODE_APP_REPLACE_WAIT {
|
||||
// Chess stays until the user installs Arcade and it runs here carrying
|
||||
// Chess; Arcade is never installed for them.
|
||||
if NodeAppReplacementStep(true, false) != NODE_APP_REPLACE_WAIT {
|
||||
return 19
|
||||
}
|
||||
// Chess goes once Arcade runs here and carries it, offered or not.
|
||||
if NodeAppReplacementStep(true, true, true, true, true) != NODE_APP_REPLACE_RETIRE ||
|
||||
NodeAppReplacementStep(true, false, true, true, false) != NODE_APP_REPLACE_RETIRE {
|
||||
if NodeAppReplacementStep(true, true) != NODE_APP_REPLACE_RETIRE {
|
||||
return 20
|
||||
}
|
||||
// Achievements use a dedicated account collection, never an app owner.
|
||||
|
||||
Reference in new issue
Block a user