mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-04-14 19:56:32 +00:00
Merge pull request #564 from TheHollidayInn/gold-display-update-on-purchase
Updated users gp when purchasing an item
This commit is contained in:
commit
4361c6b9c1
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.magicmicky.habitrpgwrapper.lib.api.MaintenanceApiService;
|
||||
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.Tag;
|
||||
import com.magicmicky.habitrpgwrapper.lib.models.TaskDirection;
|
||||
|
|
@ -781,7 +782,6 @@ public class MainActivity extends BaseActivity implements Action1<Throwable>, Ha
|
|||
return;
|
||||
}
|
||||
|
||||
|
||||
if (rewardKey.equals("potion")) {
|
||||
int currentHp = user.getStats().getHp().intValue();
|
||||
int maxHp = user.getStats().getMaxHealth();
|
||||
|
|
@ -793,7 +793,8 @@ public class MainActivity extends BaseActivity implements Action1<Throwable>, Ha
|
|||
}
|
||||
|
||||
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 -> {
|
||||
String snackbarMessage = event.Reward.getText() + " successfully purchased!";
|
||||
|
||||
|
|
@ -839,6 +840,11 @@ public class MainActivity extends BaseActivity implements Action1<Throwable>, Ha
|
|||
.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);
|
||||
user.async().save();
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue