Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

AiPlayer.java Game game Add a setter for member variable of class Game If true,

ID: 3918577 • Letter: A

Question

AiPlayer.java

Game game

Add a setter for member variable of class Game

If true, display a message dialog to the player (i.e. the dealer) that they have to accept trump

Call method setAcceptTrump passing as an argument the value true

Create a local variable to count how many cards the player has of the trump suit

Check if the current card’s suit matches the trump card’s suit

HINT: reference member variable of class Game calling method getTrump to retrieve the trump card

If true, call method setAcceptTrump() passing as an argument the value true

Display a message dialog stating that the current player has said “Pick it Up!”

Call method setAcceptTrump() passing as an argument the value false

Display a message dialog stating that the current player has said “Pass!”

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package core;

import constants.Constants.Face;
import constants.Constants.Suit;
import javax.swing.JOptionPane;
import userinterface.AiPlayerUi;

/**
*
* @author
*/
public class AiPlayer extends Player
{
AiPlayerUi aiUi;
  
@Override
public Card playCard() {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
  
@Override
public void makeTrump()
{
}
}

AiPlayer.java

Update class to add the following member variables

Game game

Add a setter for member variable of class Game

Update method makeTrump() so it does the followingChecks if the max number of passes has been reached (i.e. 3) by calling method getTrumpCheck from class Game

If true, display a message dialog to the player (i.e. the dealer) that they have to accept trump

Call method setAcceptTrump passing as an argument the value true

Else

Create a local variable to count how many cards the player has of the trump suit

Loop through the player’s hand, for each card in their hand

Check if the current card’s suit matches the trump card’s suit

HINT: reference member variable of class Game calling method getTrump to retrieve the trump card

Check if the trump counter is greater than or equal the value of 3 (e.g. this is a good indicator the team will win the hand)

If true, call method setAcceptTrump() passing as an argument the value true

Display a message dialog stating that the current player has said “Pick it Up!”

Else

Call method setAcceptTrump() passing as an argument the value false

Display a message dialog stating that the current player has said “Pass!”

Explanation / Answer

package controller.ai;

import java.awt.Point;

import java.util.List;

import model.Direction;

import model.character.Enemy;

import model.weapon.Projectile;

/**

* Class for representing a player. Each AIPlayer will control one enemy. Keeps

* track of shortest path between the two, current cooldown and how many updates

* have gone since the enemy was last updated.

*

* @author jesperpersson

*

*/

public class AIPlayer {

private Enemy unit;

private List<Point> path;

private int intelligence, updateCount, distance;

private Point currentTile;

public AIPlayer(Enemy unit) {

this.unit = unit;

this.intelligence = 5;

this.updateCount = 0;

this.distance = 100;

}

/**

* get the Enemy controlled by this AIPlayer

*

* @return the Enemy controlled by this AIPlayer

*/

public Enemy getEnemy() {

return this.unit;

}

/**

* get the intelligence of this AIPlayer

*

* @return the intelligence

*/

public int getIntelligence() {

return this.intelligence;

}

/**

* set the intelligence of this AIPlayer. The Intelligence can be used to sort enemies,

* some behaviors will depend on having a high enough intelligence.

* @param intelligence

*/

public void setIntelligence(int intelligence){

this.intelligence = intelligence;

}

/**

* Increment the updatecount.

*/

public void updateCount() {

this.updateCount++;

}

/**

* Reset the updateCount to 0

*/

public void resetCount() {

this.updateCount = 0;

}

/**

* get the updateCount

*

* @return the updatecount.

*/

public int getCount() {

return this.updateCount;

}

/**

* Set the distance between the enemy controlled by this AIPlayer and a

* certain point on the field (usually, the player)

*

* @param distance

*/

public void setDistance(int distance) {

this.distance = distance;

}

/**

* get the distance

*

* @return the distance

*/

public int getDistance() {

return this.distance;

}

/**

* get the currently saved Path between enemy and a certain tile in the

* gameboard (usually the tile containing the player)

*

* @return

*/

public List<Point> getPath() {

return this.path;

}

/**

* Set the path of the enemy.

*

* @param path

*/

public void setPath(List<Point> path) {

this.path = path;

}

/**

* Set the direction of the enemy controlled by this AIPlayer

*

* @param dir

*/

public void updateEnemy(Direction dir) {

this.unit.setDirection(dir);

}

/**

* Tell the unit controlled by this AIPlayer to attack. Returns the

* projectile of the currently equipped weapon of the unit.

*

* @return projectile of selected weapon

*/

public Projectile doAttack() {

return this.unit.attack();

}

/**

* Return true if the distance between enemy is shorter than the

* ATTACK_RANGE

*

* @return

*/

public boolean inRange() {

double range = this.unit.getCurrentWeapon().getProjectile().getRange()

.getDistance() + this.unit.getCollisionBox().height / 2;

return this.distance < range;

}

/**

* get the center of the collision box of the unit this AIPlayer is controlling.

* @return

*/

public Point getMidPos(){

return new Point ((int) this.unit.getCollisionBox().getCenterX(),(int) this.unit.getCollisionBox().getCenterY());

}

/**

* get the currently set tile.

* @return the currently set tile.

*/

public Point getCurrentTile() {

return currentTile;

}

/**

* Specify what tile the unit controlled by this AIPlayer is currently standing on

* @param currentTile

*/

public void setCurrentTile(Point currentTile) {

this.currentTile = currentTile;

}

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote