mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-07-13 17:51:57 +00:00
Updated users gp when purchasing an item
This commit is contained in:
parent
eeac345a3a
commit
cfdff7182c
1 changed files with 8 additions and 2 deletions
|
|
@ -43,6 +43,7 @@ import com.habitrpg.android.habitica.userpicture.BitmapUtils;
|
||||||
import com.habitrpg.android.habitica.userpicture.UserPicture;
|
import com.habitrpg.android.habitica.userpicture.UserPicture;
|
||||||
import com.magicmicky.habitrpgwrapper.lib.api.MaintenanceApiService;
|
import com.magicmicky.habitrpgwrapper.lib.api.MaintenanceApiService;
|
||||||
import com.magicmicky.habitrpgwrapper.lib.models.HabitRPGUser;
|
import com.magicmicky.habitrpgwrapper.lib.models.HabitRPGUser;
|
||||||
|
import com.magicmicky.habitrpgwrapper.lib.models.Stats;
|
||||||
import com.magicmicky.habitrpgwrapper.lib.models.SuppressedModals;
|
import com.magicmicky.habitrpgwrapper.lib.models.SuppressedModals;
|
||||||
import com.magicmicky.habitrpgwrapper.lib.models.TaskDirection;
|
import com.magicmicky.habitrpgwrapper.lib.models.TaskDirection;
|
||||||
import com.magicmicky.habitrpgwrapper.lib.models.TaskDirectionData;
|
import com.magicmicky.habitrpgwrapper.lib.models.TaskDirectionData;
|
||||||
|
|
@ -732,7 +733,6 @@ public class MainActivity extends BaseActivity implements Action1<Throwable>, Ha
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (rewardKey.equals("potion")) {
|
if (rewardKey.equals("potion")) {
|
||||||
int currentHp = user.getStats().getHp().intValue();
|
int currentHp = user.getStats().getHp().intValue();
|
||||||
int maxHp = user.getStats().getMaxHealth();
|
int maxHp = user.getStats().getMaxHealth();
|
||||||
|
|
@ -744,7 +744,8 @@ public class MainActivity extends BaseActivity implements Action1<Throwable>, Ha
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.Reward.specialTag != null && event.Reward.specialTag.equals("item")) {
|
if (event.Reward.specialTag != null && event.Reward.specialTag.equals("item")) {
|
||||||
apiHelper.apiService.buyItem(event.Reward.getId()).compose(apiHelper.configureApiCallObserver())
|
apiHelper.apiService.buyItem(event.Reward.getId())
|
||||||
|
.compose(apiHelper.configureApiCallObserver())
|
||||||
.subscribe(buyResponse -> {
|
.subscribe(buyResponse -> {
|
||||||
String snackbarMessage = event.Reward.getText() + " successfully purchased!";
|
String snackbarMessage = event.Reward.getText() + " successfully purchased!";
|
||||||
|
|
||||||
|
|
@ -790,6 +791,11 @@ public class MainActivity extends BaseActivity implements Action1<Throwable>, Ha
|
||||||
.subscribe(new TaskScoringCallback(this, rewardKey), throwable -> {});
|
.subscribe(new TaskScoringCallback(this, rewardKey), throwable -> {});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Update the users gold
|
||||||
|
Stats stats = user.getStats();
|
||||||
|
Double gp = stats.getGp() - event.Reward.getValue();
|
||||||
|
stats.setGp(gp);
|
||||||
|
|
||||||
avatarInHeader.updateData(user);
|
avatarInHeader.updateData(user);
|
||||||
user.async().save();
|
user.async().save();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue