@@ -117,7 +117,7 @@ bool Player::buyRoad(){
117117
118118/* *
119119 * Determine if the player has enough resources to buy a settlement.
120- * @return True if the player has enough resources to buy a road , false otherwise
120+ * @return True if the player has enough resources to buy a settlement , false otherwise
121121 */
122122bool Player::canBuySettlement (){
123123 return getWood () >= 1 && getBrick () >= 1 && getWheat () >= 1 && getWool () >= 1 ;
@@ -137,7 +137,7 @@ bool Player::buySettlement(){
137137
138138/* *
139139 * Determine if the player has enough resources to buy a city.
140- * @return True if the player has enough resources to buy a road , false otherwise
140+ * @return True if the player has enough resources to buy a city , false otherwise
141141 */
142142bool Player::canBuyCity (){
143143 return getWheat () >= 2 && getOre () >= 3 ;
@@ -156,7 +156,7 @@ bool Player::buyCity(){
156156
157157/* *
158158 * Determine if the player has enough resources to buy a wonder.
159- * @return True if the player has enough resources to buy a road , false otherwise
159+ * @return True if the player has enough resources to buy a wonder , false otherwise
160160 */
161161bool Player::canBuyWonder (){
162162 return getWood () >= 5 && getBrick () >= 5 && getWheat () >= 5 && getWool () >= 5 && getOre () >= 5 ;
@@ -174,6 +174,26 @@ bool Player::buyWonder(){
174174 return false ;
175175}
176176
177+ /* *
178+ * Determine if the player has enough resources to buy a card.
179+ * @return True if the player has enough resources to buy a card, false otherwise
180+ */
181+ bool Player::canBuyCard (){
182+ return getWheat () >= 1 && getWool () >= 1 && getOre () >= 1 ;
183+ }
184+
185+ /* *
186+ * Subtracts the cost of a card from a player's resources if they have enough
187+ * @return true if the resources were subtracted, false otherwise
188+ */
189+ bool Player::buyCard (){
190+ if (canBuySettlement ()){
191+ addMultiple (0 ,0 ,-1 ,-1 ,-1 );
192+ return true ;
193+ }
194+ return false ;
195+ }
196+
177197
178198
179199/* *
@@ -212,6 +232,14 @@ int Player::getVictoryPointCards()
212232 return retVal;
213233}
214234
235+ int Player::getArmySize (){
236+ return armySize;
237+ }
238+
239+ int Player::getLongestRoad (){
240+ return longestRoad;
241+ }
242+
215243
216244/* *
217245 * The number of victory points a player has.
@@ -226,9 +254,13 @@ int Player::getVictoryPoints()
226254 * Acquire a development card.
227255 * @param card An owning pointer to the card the player acquired.
228256 */
229- void Player::buyCard (std::unique_ptr<DevelopmentCard> card)
257+ void Player::buyCard (std::unique_ptr<DevelopmentCard> card);
230258{
231- developmentCards.push_back (std::move (card));
259+ if (canBuyCard ()){
260+ buyCard ();
261+ developmentCards.push_back (std::move (card));
262+ }
263+
232264}
233265
234266
@@ -257,6 +289,13 @@ void Player::buyCard(std::unique_ptr<DevelopmentCard> card)
257289// std::remove_if(developmentCards.begin(), developmentCards.end(), cardTester);
258290// }
259291
292+ /* *
293+ * Gets the current modifier for trading wood
294+ * @return int, the trading value for wood
295+ */
296+ int Player::getWoodModifier (){
297+ return tradeModifiers[WOOD_INDEX];
298+ }
260299
261300/* *
262301 * Sets the trade modifier for Wood to 2:1
@@ -266,6 +305,14 @@ void Player::setWoodModifier()
266305 tradeModifiers[WOOD_INDEX] = 2 ;
267306}
268307
308+ /* *
309+ * Gets the current modifier for trading brick
310+ * @return int, the trading value for brick
311+ */
312+ int Player::getBrickModifier (){
313+ return tradeModifiers[BRICK_INDEX];
314+ }
315+
269316/* *
270317 * Sets the trade modifier for Brick to 2:1
271318 */
@@ -274,6 +321,14 @@ void Player::setBrickModifier()
274321 tradeModifiers[BRICK_INDEX] = 2 ;
275322}
276323
324+ /* *
325+ * Gets the current modifier for trading ore
326+ * @return int, the trading value for ore
327+ */
328+ int Player::getOreModifier (){
329+ return tradeModifiers[ORE_INDEX];
330+ }
331+
277332/* *
278333 * Sets the trade modifier for Ore to 2:1
279334 */
@@ -282,6 +337,14 @@ void Player::setOreModifier()
282337 tradeModifiers[ORE_INDEX] = 2 ;
283338}
284339
340+ /* *
341+ * Gets the current modifier for trading wheat
342+ * @return int, the trading value for wheat
343+ */
344+ int Player::getWheatModifier (){
345+ return tradeModifiers[WHEAT_INDEX];
346+ }
347+
285348/* *
286349 * Sets the trade modifier for Wheat to 2:1
287350 */
@@ -290,6 +353,14 @@ void Player::setWheatModifier()
290353 tradeModifiers[WHEAT_INDEX] = 2 ;
291354}
292355
356+ /* *
357+ * Gets the current modifier for trading wool
358+ * @return int, the trading value for wool
359+ */
360+ int Player::getWoolModifier (){
361+ return tradeModifiers[WOOL_INDEX];
362+ }
363+
293364/* *
294365 * Sets the trade modifier for Wool to 2:1
295366 */
@@ -301,7 +372,7 @@ void Player::setWoolModifier()
301372/* *
302373 * Sets the trade modifier for all resources to 3:1
303374 */
304- void Player::setGenralModifier ()
375+ void Player::setGeneralModifier ()
305376{
306377 for (int i =0 ; i<5 ; i++)
307378 {
0 commit comments