From 4b7bb139c00884fa34e77083d17ec69cb782d5e1 Mon Sep 17 00:00:00 2001 From: Ryan St Pierre Date: Thu, 21 Jan 2016 17:11:13 -0500 Subject: [PATCH 1/5] Checking formatting --- DESIGN.md | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 60 insertions(+), 4 deletions(-) diff --git a/DESIGN.md b/DESIGN.md index b581809..2a640e5 100644 --- a/DESIGN.md +++ b/DESIGN.md @@ -7,18 +7,74 @@ CompSci 308 : RPS Design Initial Design ======= -###Class 1 +###Player Class -* Bullets are made with asterisks +Player class controls a user that plays the game, allowing for picking of a weapon and updating score +Player knows its: +* score +* name +* currentWeapon +Methods: +-setWeaponChoice -1. You can also order things with numbers +###UserPlayer Class +UserClass will implement the player class. It will be used for human users. -###Class 2 +##ComputerPlayer Class + +ComputerPlayer will implement the player class. It will be for cpu challengers. In addition to the player +class' capabilities it will need a decision making capability. +ComputerPlay has: +*difficulty +Methods: +-makeNextMoveDecision + +###Weapon Class + +Defines the general structure for a weapon +Contains: +*name +*Image +*weaponID [constant that identifies the different type of weapons] + +Methods- +-show [displays the image of the screen] +###Main Class +Initializes the game, passes the input data to the information engine to process and +generates a new GamePlay class (depending on whether the players are human or cpu) with the given information +engine +methods: +-readInput [gets the input] +-main method +###GamePlay Class + +The game class controls the game loop +The game loop will: +1. Update the player weapon choice +2. play +3. updatePlayer +Methods- +shoot [makes a choice on which players' weapon wins] +updatePlayer [updates the player state] + +The Game Class will have: +*2 Players (it should be able to handle different type of players; both CPU and User) +*DataEngine + + +##DataEngine + +Loads the input data and creates the algorithm to determine which weapon beats another +It will contain the instances of the weapons and give out information useful for the GamePlay Class +Methods- +*generateGraph +*getWinner (Weapon1, weapon2) [Uses the graph to determine the winner between the two weapons] CRC Design + ======= ###Class 1 From ef3a19ad3c654a10ebe5c3a16f34fcd2752e77e3 Mon Sep 17 00:00:00 2001 From: Ryan St Pierre Date: Thu, 21 Jan 2016 17:12:51 -0500 Subject: [PATCH 2/5] Checking formatting2 --- DESIGN.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/DESIGN.md b/DESIGN.md index 2a640e5..1b59a95 100644 --- a/DESIGN.md +++ b/DESIGN.md @@ -15,20 +15,20 @@ Player knows its: * name * currentWeapon Methods: --setWeaponChoice +*setWeaponChoice ###UserPlayer Class UserClass will implement the player class. It will be used for human users. -##ComputerPlayer Class +###ComputerPlayer Class ComputerPlayer will implement the player class. It will be for cpu challengers. In addition to the player class' capabilities it will need a decision making capability. ComputerPlay has: *difficulty Methods: --makeNextMoveDecision +**makeNextMoveDecision ###Weapon Class From 581c63f7133d184d1c03e2b86fa5a7fc4dfc0096 Mon Sep 17 00:00:00 2001 From: Ryan St Pierre Date: Thu, 21 Jan 2016 17:13:54 -0500 Subject: [PATCH 3/5] Checking formatting3 --- DESIGN.md | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/DESIGN.md b/DESIGN.md index 1b59a95..cd2d88f 100644 --- a/DESIGN.md +++ b/DESIGN.md @@ -15,7 +15,7 @@ Player knows its: * name * currentWeapon Methods: -*setWeaponChoice +* setWeaponChoice ###UserPlayer Class @@ -26,20 +26,20 @@ UserClass will implement the player class. It will be used for human users. ComputerPlayer will implement the player class. It will be for cpu challengers. In addition to the player class' capabilities it will need a decision making capability. ComputerPlay has: -*difficulty +* difficulty Methods: -**makeNextMoveDecision +* makeNextMoveDecision ###Weapon Class Defines the general structure for a weapon Contains: -*name -*Image -*weaponID [constant that identifies the different type of weapons] +* name +* Image +* weaponID [constant that identifies the different type of weapons] Methods- --show [displays the image of the screen] +* show [displays the image of the screen] ###Main Class @@ -47,8 +47,8 @@ Initializes the game, passes the input data to the information engine to process generates a new GamePlay class (depending on whether the players are human or cpu) with the given information engine methods: --readInput [gets the input] --main method +* readInput [gets the input] +* main method ###GamePlay Class @@ -57,22 +57,22 @@ The game loop will: 1. Update the player weapon choice 2. play 3. updatePlayer -Methods- +Methods: shoot [makes a choice on which players' weapon wins] updatePlayer [updates the player state] The Game Class will have: -*2 Players (it should be able to handle different type of players; both CPU and User) -*DataEngine +* 2 Players (it should be able to handle different type of players; both CPU and User) +* DataEngine ##DataEngine Loads the input data and creates the algorithm to determine which weapon beats another It will contain the instances of the weapons and give out information useful for the GamePlay Class -Methods- -*generateGraph -*getWinner (Weapon1, weapon2) [Uses the graph to determine the winner between the two weapons] +Methods: +* generateGraph +* getWinner (Weapon1, weapon2) [Uses the graph to determine the winner between the two weapons] CRC Design ======= From 58258dd4392f31127df9f354b6b2d7ff03e04706 Mon Sep 17 00:00:00 2001 From: Ryan St Pierre Date: Thu, 21 Jan 2016 17:15:34 -0500 Subject: [PATCH 4/5] Checking formatting4 --- DESIGN.md | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/DESIGN.md b/DESIGN.md index cd2d88f..b6b23bb 100644 --- a/DESIGN.md +++ b/DESIGN.md @@ -14,7 +14,8 @@ Player knows its: * score * name * currentWeapon -Methods: + +Methods- * setWeaponChoice ###UserPlayer Class @@ -27,7 +28,8 @@ ComputerPlayer will implement the player class. It will be for cpu challengers. class' capabilities it will need a decision making capability. ComputerPlay has: * difficulty -Methods: + +Methods- * makeNextMoveDecision ###Weapon Class @@ -46,7 +48,8 @@ Methods- Initializes the game, passes the input data to the information engine to process and generates a new GamePlay class (depending on whether the players are human or cpu) with the given information engine -methods: + +methods- * readInput [gets the input] * main method @@ -57,11 +60,12 @@ The game loop will: 1. Update the player weapon choice 2. play 3. updatePlayer -Methods: -shoot [makes a choice on which players' weapon wins] -updatePlayer [updates the player state] -The Game Class will have: +Methods- +* shoot [makes a choice on which players' weapon wins] +* updatePlayer [updates the player state] + +The GamePlay Class will have: * 2 Players (it should be able to handle different type of players; both CPU and User) * DataEngine @@ -70,7 +74,8 @@ The Game Class will have: Loads the input data and creates the algorithm to determine which weapon beats another It will contain the instances of the weapons and give out information useful for the GamePlay Class -Methods: + +Methods- * generateGraph * getWinner (Weapon1, weapon2) [Uses the graph to determine the winner between the two weapons] CRC Design From 8f61b29496993edc084a451b92e43851805575fd Mon Sep 17 00:00:00 2001 From: Ryan St Pierre Date: Thu, 21 Jan 2016 18:06:16 -0500 Subject: [PATCH 5/5] Lab --- DESIGN.md | 91 ++++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 77 insertions(+), 14 deletions(-) diff --git a/DESIGN.md b/DESIGN.md index b6b23bb..226cc97 100644 --- a/DESIGN.md +++ b/DESIGN.md @@ -16,7 +16,9 @@ Player knows its: * currentWeapon Methods- -* setWeaponChoice +* chooseNextWeapon +* public void setScore(int i) [Passing in the int to which the score is to be set] +* public int getScore [outputs the score] ###UserPlayer Class @@ -52,6 +54,8 @@ engine methods- * readInput [gets the input] * main method +* intializeNewGame +* addNewGameType [sends a new file to the DataEngine, which generates a new Graph] ###GamePlay Class @@ -62,12 +66,12 @@ The game loop will: 3. updatePlayer Methods- -* shoot [makes a choice on which players' weapon wins] +* shoot/step [makes a choice on which players' weapon wins] * updatePlayer [updates the player state] The GamePlay Class will have: * 2 Players (it should be able to handle different type of players; both CPU and User) -* DataEngine +* DataEngine dataEngine ##DataEngine @@ -78,31 +82,90 @@ It will contain the instances of the weapons and give out information useful for Methods- * generateGraph * getWinner (Weapon1, weapon2) [Uses the graph to determine the winner between the two weapons] + CRC Design ======= -###Class 1 +###Player + +Methods- +* public void chooseNextWeapon(); +* public void setScore(int i) [Passing in the int to which the score is to be set]; +* public int getScore [outputs the score]; +* public void getName(); +* public void setName(String name); + +Has- +* private Weapon currentWeapon + +###Main + +Methods- +* public void intializeNewGame(GameEngine e); +* private GameEngine createGameType(File f); + +###Weapon + +Methods- +* public int getID() [Each weapon has a constant int for identification purposes] +* public Image getImage() + +##DataEngine +Methods- +* private Map generateGraph() +* public Map getGraph() +* public Map setGraph(Map m) +* public Weapon determineWinner(Weapon w1, Weapon w2) //Returns winning weapon (null on tie) -###Class 2 +##GamePlay -You can add images as well: +Methods- -![This is cool, too bad you can't see it](crc-example.png "Our CRC cards") +* public void pause(); +* public void resume(); +* public void shoot(); -> essentially the game loop +Has: +*Players +*DataEngine Use Cases ======= You can put blocks of code in here like this: +Starting a new game: in Main +```java + + intializeNewGame() +``` +Choosing a new weapon: in GamePlay class (somewhere in the shoot method) +```java + + Player1.chooseNextWeapon(); + Player2.chooseNextWeapon(); + +``` +Chooses winner, outputs score: in GamePlay class (somewhere in the shoot method) ```java - public int getTotal (Collection data) { - int total = 0; - for (int d : data) { - total += d; - } - return total; - } + + Weapon choice1 = player1.getWeapon(); + Weapon choice2 = player2.getWeapon(); + Weapon winner = dataEngine.getWinner(choice1, choice2); + if (winner == null) { + //tie- do nothing + } else if(winner.getID() == choice1.getID()) { + //Player1 wins + Player1.setScore(Player1.getScore()++); + } else { + //Player2 wins + Player2.setScore(Player1.getScore()++); + } + ``` +Adding a new game type - create a new game with its own data engine. Each data engine will handle the +getWinner method differently depending on the graph set + +