Code Monkey home page Code Monkey logo

playerstatus's Introduction

Player Status

Design description

The PlayerStatus class maintains the player state up-to-date in a game
Implemented for self-learing

Class attributes

  • nickname
  • score
  • lives
  • energy
  • Weapon
  • xPos
  • yPos
  • gameName (static field)
  • weaponList (static field)
  • mapDimX (static field)
  • mapDimY (static field)

Game rules

  • energy :
    • 0 < energy < 100
    • if energy == 0
      • lives -= 1
      • energy = 100
  • lives :
    • if lives == 0
      • Game Over
  • Weapon :
    • knife (1000$)
    • remingtonM24 (10000$)
    • m16Rifle (20000$)
  • fight
    • if player1.weapon == player2.weapon
      • player.win = (5 * player.energy + player.score / 100) / 6
    • if player1.weapon != player2.weapon
      • if distance > 100
        • weapon.power -> remingtonM24 > m16Rifle > knife
      • if distance <= 100
        • weapon.power -> m16Rifle > remingtonM24 > knife
  • distance (Euclidean distance) euclideanDistance

API

public class PlayerStatus

PlayerStatus(String nickname)                       // Initializing the player object with score = 0 and lives =0
PlayerStatus(String nickname, int lives)            // Initializing the player object with score = 0
PlayerStatus(String nickname, int lives, int score) // Initializing the player object with all three fields, creating the weapon list, and get a random position for player
double getPositionX()                              // return the player oX position
double getPositionY()                              // return the player oY position
String getNickname()                               // return the player Nickname
String getGameName()                        // return the game name
void setScore(int score)                           // set the player score
void setLives(int lives)                           // set the player lives
void setEnergy(int energy)                         // set the player energy
int getScore()                                     // return the player score
int getLives()                                     // return the player lives
int getEnergy()                                    // return the player energy
Weapon getWeaponInHand()                           // return the player weapon
void attackEnemy(PlayerStatus opponent)		   // attacking the opponent
boolean shouldAttackOpponent(PlayerStatus opponent)// attacking advice
void movePlayerTo(double positionX, double positionY)	// moving the player
void findTreasure					// function for treasure objects
boolean setWeaponInHand(int weaponID)			// function for weapon purchase

playerstatus's People

Contributors

cern7 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.