Class Wallet
java.lang.Object
com.csse3200.game.progression.wallet.Wallet
The Wallet class enables a player to collect, store and spend coins and skills points which allow
purchase of Shop Items and unlocking of Skills to use in-level.
A Wallet is created within and assigned to a Profile.
A Wallet can be created with preset or variable coins and skillsPoints.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addCoins
(int coins) Adds coins to the wallet.void
addSkillsPoints
(int achievementSkillsPoints) Adds skills points to the wallet.int
getCoins()
Gets the current amount of coins in the wallet.int
Gets the current amount of skill points in the wallet.boolean
purchaseShopItem
(int itemCost) Purchases Shop Item where Wallet has sufficient coins, and returns true, otherwise returns falsevoid
setCoins
(int coins) Sets the current amount of coins in the wallet.void
setSkillsPoints
(int skillsPoints) Sets the current amount of skills points in the wallet.void
unlockSkill
(int skillCost) Unlocks a skill by deducting the specified skill cost from the wallet.
-
Constructor Details
-
Wallet
public Wallet()Default constructor for Wallet. -
Wallet
public Wallet(int coins, int skillsPoints) Creates a Wallet with the specified initial coin and skill point amounts.- Parameters:
coins
- the initial amount of coinsskillsPoints
- the initial amount of skill points
-
-
Method Details
-
getCoins
public int getCoins()Gets the current amount of coins in the wallet.- Returns:
- the current amount of coins
-
getSkillsPoints
public int getSkillsPoints()Gets the current amount of skill points in the wallet.- Returns:
- the current amount of skill points
-
setCoins
public void setCoins(int coins) Sets the current amount of coins in the wallet.- Parameters:
coins
- the new amount of coins
-
setSkillsPoints
public void setSkillsPoints(int skillsPoints) Sets the current amount of skills points in the wallet.- Parameters:
skillsPoints
- the new amount of skills points
-
addCoins
public void addCoins(int coins) Adds coins to the wallet.- Parameters:
coins
- the amount of coins to add
-
addSkillsPoints
public void addSkillsPoints(int achievementSkillsPoints) Adds skills points to the wallet.- Parameters:
achievementSkillsPoints
- the amount of skills points to add
-
unlockSkill
public void unlockSkill(int skillCost) Unlocks a skill by deducting the specified skill cost from the wallet.- Parameters:
skillCost
- the cost of the skill to unlock
-
purchaseShopItem
public boolean purchaseShopItem(int itemCost) Purchases Shop Item where Wallet has sufficient coins, and returns true, otherwise returns false- Parameters:
itemCost
- the cost of the item to purchase- Returns:
- true if the item was purchased successfully, false otherwise
-