Phase 3: Add Offline Currency System
- Created OfflineCurrencyManager.smali (unlimited currency for offline) - Sets 100M M\$ and 10M Gold on initialization - Provides getCash/getGold methods for offline play - Supports both unlimited and tracked currency modes - Modified MainActivity to initialize currency manager - Builds successfully Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -0,0 +1,382 @@
|
||||
.class public Lcom/firemint/realracing/OfflineCurrencyManager;
|
||||
.super Ljava/lang/Object;
|
||||
.source "OfflineCurrencyManager.java"
|
||||
|
||||
|
||||
# static fields
|
||||
.field private static final TAG:Ljava/lang/String; = "RR3_OfflineCurrency"
|
||||
|
||||
.field private static final UNLIMITED_AMOUNT:I = 0x5f5e100 # 100,000,000
|
||||
|
||||
.field private static unlimitedCurrencyEnabled:Z = true
|
||||
|
||||
|
||||
# direct methods
|
||||
.method static constructor <clinit>()V
|
||||
.locals 1
|
||||
|
||||
# Enable unlimited currency by default in offline mode
|
||||
const/4 v0, 0x1
|
||||
|
||||
sput-boolean v0, Lcom/firemint/realracing/OfflineCurrencyManager;->unlimitedCurrencyEnabled:Z
|
||||
|
||||
return-void
|
||||
.end method
|
||||
|
||||
.method public constructor <init>()V
|
||||
.locals 0
|
||||
|
||||
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
|
||||
|
||||
return-void
|
||||
.end method
|
||||
|
||||
.method public static init(Landroid/content/Context;)V
|
||||
.locals 2
|
||||
|
||||
const-string v0, "RR3_OfflineCurrency"
|
||||
|
||||
const-string v1, "Initializing OfflineCurrencyManager"
|
||||
|
||||
invoke-static {v0, v1}, Landroid/util/Log;->i(Ljava/lang/String;Ljava/lang/String;)I
|
||||
|
||||
# Set high initial currency amounts in save file
|
||||
invoke-static {p0}, Lcom/firemint/realracing/OfflineCurrencyManager;->ensureMinimumCurrency(Landroid/content/Context;)V
|
||||
|
||||
return-void
|
||||
.end method
|
||||
|
||||
.method public static isUnlimitedEnabled()Z
|
||||
.locals 1
|
||||
|
||||
sget-boolean v0, Lcom/firemint/realracing/OfflineCurrencyManager;->unlimitedCurrencyEnabled:Z
|
||||
|
||||
return v0
|
||||
.end method
|
||||
|
||||
.method public static setUnlimited(Z)V
|
||||
.locals 0
|
||||
|
||||
sput-boolean p0, Lcom/firemint/realracing/OfflineCurrencyManager;->unlimitedCurrencyEnabled:Z
|
||||
|
||||
return-void
|
||||
.end method
|
||||
|
||||
.method public static ensureMinimumCurrency(Landroid/content/Context;)V
|
||||
.locals 4
|
||||
|
||||
const-string v0, "RR3_OfflineCurrency"
|
||||
|
||||
# Check if unlimited is enabled
|
||||
sget-boolean v1, Lcom/firemint/realracing/OfflineCurrencyManager;->unlimitedCurrencyEnabled:Z
|
||||
|
||||
if-nez v1, :cond_0
|
||||
|
||||
return-void
|
||||
|
||||
:cond_0
|
||||
# Set high amounts for offline play
|
||||
const v1, 0x5f5e100 # 100,000,000
|
||||
|
||||
:try_start_0
|
||||
# Set M$ (cash)
|
||||
const-string v2, "cash"
|
||||
|
||||
invoke-static {p0, v2, v1}, Lcom/firemint/realracing/LocalSaveManager;->setCurrency(Landroid/content/Context;Ljava/lang/String;I)V
|
||||
|
||||
# Set Gold
|
||||
const v1, 0x989680 # 10,000,000
|
||||
|
||||
const-string v2, "gold"
|
||||
|
||||
invoke-static {p0, v2, v1}, Lcom/firemint/realracing/LocalSaveManager;->setCurrency(Landroid/content/Context;Ljava/lang/String;I)V
|
||||
|
||||
# Set R$ (R-Dollars - 0 for now)
|
||||
const/4 v1, 0x0
|
||||
|
||||
const-string v2, "rDollars"
|
||||
|
||||
invoke-static {p0, v2, v1}, Lcom/firemint/realracing/LocalSaveManager;->setCurrency(Landroid/content/Context;Ljava/lang/String;I)V
|
||||
|
||||
const-string p0, "Currency set: 100M M$, 10M Gold"
|
||||
|
||||
invoke-static {v0, p0}, Landroid/util/Log;->i(Ljava/lang/String;Ljava/lang/String;)I
|
||||
:try_end_0
|
||||
.catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0
|
||||
|
||||
goto :goto_0
|
||||
|
||||
:catch_0
|
||||
move-exception p0
|
||||
|
||||
const-string v1, "Error setting currency"
|
||||
|
||||
invoke-static {v0, v1, p0}, Landroid/util/Log;->e(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)I
|
||||
|
||||
:goto_0
|
||||
return-void
|
||||
.end method
|
||||
|
||||
.method public static getCashForOffline(Landroid/content/Context;)I
|
||||
.locals 2
|
||||
|
||||
# Check if offline mode is enabled
|
||||
invoke-static {}, Lcom/firemint/realracing/OfflineModeManager;->isOfflineMode()Z
|
||||
|
||||
move-result v0
|
||||
|
||||
if-eqz v0, :cond_online
|
||||
|
||||
# Offline mode - check if unlimited
|
||||
sget-boolean v0, Lcom/firemint/realracing/OfflineCurrencyManager;->unlimitedCurrencyEnabled:Z
|
||||
|
||||
if-eqz v0, :cond_limited
|
||||
|
||||
# Return unlimited amount
|
||||
const v0, 0x5f5e100 # 100,000,000
|
||||
|
||||
return v0
|
||||
|
||||
:cond_limited
|
||||
# Return from save file
|
||||
const-string v0, "cash"
|
||||
|
||||
invoke-static {p0, v0}, Lcom/firemint/realracing/LocalSaveManager;->getCurrency(Landroid/content/Context;Ljava/lang/String;)I
|
||||
|
||||
move-result v0
|
||||
|
||||
return v0
|
||||
|
||||
:cond_online
|
||||
# Online mode - return from save (or game will handle)
|
||||
const-string v0, "cash"
|
||||
|
||||
invoke-static {p0, v0}, Lcom/firemint/realracing/LocalSaveManager;->getCurrency(Landroid/content/Context;Ljava/lang/String;)I
|
||||
|
||||
move-result v0
|
||||
|
||||
return v0
|
||||
.end method
|
||||
|
||||
.method public static getGoldForOffline(Landroid/content/Context;)I
|
||||
.locals 2
|
||||
|
||||
# Check if offline mode is enabled
|
||||
invoke-static {}, Lcom/firemint/realracing/OfflineModeManager;->isOfflineMode()Z
|
||||
|
||||
move-result v0
|
||||
|
||||
if-eqz v0, :cond_online
|
||||
|
||||
# Offline mode - check if unlimited
|
||||
sget-boolean v0, Lcom/firemint/realracing/OfflineCurrencyManager;->unlimitedCurrencyEnabled:Z
|
||||
|
||||
if-eqz v0, :cond_limited
|
||||
|
||||
# Return unlimited amount
|
||||
const v0, 0x989680 # 10,000,000
|
||||
|
||||
return v0
|
||||
|
||||
:cond_limited
|
||||
# Return from save file
|
||||
const-string v0, "gold"
|
||||
|
||||
invoke-static {p0, v0}, Lcom/firemint/realracing/LocalSaveManager;->getCurrency(Landroid/content/Context;Ljava/lang/String;)I
|
||||
|
||||
move-result v0
|
||||
|
||||
return v0
|
||||
|
||||
:cond_online
|
||||
# Online mode - return from save (or game will handle)
|
||||
const-string v0, "gold"
|
||||
|
||||
invoke-static {p0, v0}, Lcom/firemint/realracing/LocalSaveManager;->getCurrency(Landroid/content/Context;Ljava/lang/String;)I
|
||||
|
||||
move-result v0
|
||||
|
||||
return v0
|
||||
.end method
|
||||
|
||||
.method public static addCash(Landroid/content/Context;I)V
|
||||
.locals 3
|
||||
|
||||
# Only track in offline mode
|
||||
invoke-static {}, Lcom/firemint/realracing/OfflineModeManager;->isOfflineMode()Z
|
||||
|
||||
move-result v0
|
||||
|
||||
if-nez v0, :cond_0
|
||||
|
||||
return-void
|
||||
|
||||
:cond_0
|
||||
# If unlimited, don't bother tracking
|
||||
sget-boolean v0, Lcom/firemint/realracing/OfflineCurrencyManager;->unlimitedCurrencyEnabled:Z
|
||||
|
||||
if-eqz v0, :cond_1
|
||||
|
||||
return-void
|
||||
|
||||
:cond_1
|
||||
# Get current amount
|
||||
const-string v0, "cash"
|
||||
|
||||
invoke-static {p0, v0}, Lcom/firemint/realracing/LocalSaveManager;->getCurrency(Landroid/content/Context;Ljava/lang/String;)I
|
||||
|
||||
move-result v1
|
||||
|
||||
# Add new amount
|
||||
add-int/2addr v1, p1
|
||||
|
||||
# Save
|
||||
invoke-static {p0, v0, v1}, Lcom/firemint/realracing/LocalSaveManager;->setCurrency(Landroid/content/Context;Ljava/lang/String;I)V
|
||||
|
||||
return-void
|
||||
.end method
|
||||
|
||||
.method public static addGold(Landroid/content/Context;I)V
|
||||
.locals 3
|
||||
|
||||
# Only track in offline mode
|
||||
invoke-static {}, Lcom/firemint/realracing/OfflineModeManager;->isOfflineMode()Z
|
||||
|
||||
move-result v0
|
||||
|
||||
if-nez v0, :cond_0
|
||||
|
||||
return-void
|
||||
|
||||
:cond_0
|
||||
# If unlimited, don't bother tracking
|
||||
sget-boolean v0, Lcom/firemint/realracing/OfflineCurrencyManager;->unlimitedCurrencyEnabled:Z
|
||||
|
||||
if-eqz v0, :cond_1
|
||||
|
||||
return-void
|
||||
|
||||
:cond_1
|
||||
# Get current amount
|
||||
const-string v0, "gold"
|
||||
|
||||
invoke-static {p0, v0}, Lcom/firemint/realracing/LocalSaveManager;->getCurrency(Landroid/content/Context;Ljava/lang/String;)I
|
||||
|
||||
move-result v1
|
||||
|
||||
# Add new amount
|
||||
add-int/2addr v1, p1
|
||||
|
||||
# Save
|
||||
invoke-static {p0, v0, v1}, Lcom/firemint/realracing/LocalSaveManager;->setCurrency(Landroid/content/Context;Ljava/lang/String;I)V
|
||||
|
||||
return-void
|
||||
.end method
|
||||
|
||||
.method public static spendCash(Landroid/content/Context;I)Z
|
||||
.locals 3
|
||||
|
||||
# Only track in offline mode
|
||||
invoke-static {}, Lcom/firemint/realracing/OfflineModeManager;->isOfflineMode()Z
|
||||
|
||||
move-result v0
|
||||
|
||||
if-nez v0, :cond_0
|
||||
|
||||
# Online mode - let game handle
|
||||
const/4 p0, 0x1
|
||||
|
||||
return p0
|
||||
|
||||
:cond_0
|
||||
# If unlimited, always succeed
|
||||
sget-boolean v0, Lcom/firemint/realracing/OfflineCurrencyManager;->unlimitedCurrencyEnabled:Z
|
||||
|
||||
if-eqz v0, :cond_1
|
||||
|
||||
const/4 p0, 0x1
|
||||
|
||||
return p0
|
||||
|
||||
:cond_1
|
||||
# Get current amount
|
||||
const-string v0, "cash"
|
||||
|
||||
invoke-static {p0, v0}, Lcom/firemint/realracing/LocalSaveManager;->getCurrency(Landroid/content/Context;Ljava/lang/String;)I
|
||||
|
||||
move-result v1
|
||||
|
||||
# Check if enough
|
||||
if-lt v1, p1, :cond_insufficient
|
||||
|
||||
# Subtract
|
||||
sub-int/2addr v1, p1
|
||||
|
||||
# Save
|
||||
invoke-static {p0, v0, v1}, Lcom/firemint/realracing/LocalSaveManager;->setCurrency(Landroid/content/Context;Ljava/lang/String;I)V
|
||||
|
||||
# Success
|
||||
const/4 p0, 0x1
|
||||
|
||||
return p0
|
||||
|
||||
:cond_insufficient
|
||||
# Not enough currency
|
||||
const/4 p0, 0x0
|
||||
|
||||
return p0
|
||||
.end method
|
||||
|
||||
.method public static spendGold(Landroid/content/Context;I)Z
|
||||
.locals 3
|
||||
|
||||
# Only track in offline mode
|
||||
invoke-static {}, Lcom/firemint/realracing/OfflineModeManager;->isOfflineMode()Z
|
||||
|
||||
move-result v0
|
||||
|
||||
if-nez v0, :cond_0
|
||||
|
||||
# Online mode - let game handle
|
||||
const/4 p0, 0x1
|
||||
|
||||
return p0
|
||||
|
||||
:cond_0
|
||||
# If unlimited, always succeed
|
||||
sget-boolean v0, Lcom/firemint/realracing/OfflineCurrencyManager;->unlimitedCurrencyEnabled:Z
|
||||
|
||||
if-eqz v0, :cond_1
|
||||
|
||||
const/4 p0, 0x1
|
||||
|
||||
return p0
|
||||
|
||||
:cond_1
|
||||
# Get current amount
|
||||
const-string v0, "gold"
|
||||
|
||||
invoke-static {p0, v0}, Lcom/firemint/realracing/LocalSaveManager;->getCurrency(Landroid/content/Context;Ljava/lang/String;)I
|
||||
|
||||
move-result v1
|
||||
|
||||
# Check if enough
|
||||
if-lt v1, p1, :cond_insufficient
|
||||
|
||||
# Subtract
|
||||
sub-int/2addr v1, p1
|
||||
|
||||
# Save
|
||||
invoke-static {p0, v0, v1}, Lcom/firemint/realracing/LocalSaveManager;->setCurrency(Landroid/content/Context;Ljava/lang/String;I)V
|
||||
|
||||
# Success
|
||||
const/4 p0, 0x1
|
||||
|
||||
return p0
|
||||
|
||||
:cond_insufficient
|
||||
# Not enough currency
|
||||
const/4 p0, 0x0
|
||||
|
||||
return p0
|
||||
.end method
|
||||
Reference in New Issue
Block a user