-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MNG - 98 Add useMango to gameHandler class #22
MNG - 98 Add useMango to gameHandler class #22
Conversation
src/playerClass.ts
Outdated
@@ -4,6 +4,7 @@ export class Player { | |||
private _name: string; | |||
private _pokemons: Pokemon[]; | |||
private _indexOfActivePokemon: number; | |||
private _mango: Number; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is only one mango per player, so it can be boolean called _hasMango
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, but need some polishing :)
src/playerClass.ts
Outdated
@@ -14,6 +15,7 @@ export class Player { | |||
this._name = name; | |||
this._pokemons = pokemons; | |||
this._indexOfActivePokemon = 0; | |||
this._mango=1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
=true
src/playerClass.ts
Outdated
@@ -37,6 +39,14 @@ export class Player { | |||
return alivePokemonsTab; | |||
} | |||
|
|||
reduceNumberMango(): void { | |||
this._mango = <any>this._mango - 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
= false
src/gameHandlerClass.ts
Outdated
@@ -35,4 +35,11 @@ export class GameHandler { | |||
? this._playerTwo | |||
: this._playerOne; | |||
} | |||
} | |||
|
|||
useMango(): void | Error{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ideally there should be one more method: "can I use mango" or something like that, that would be used to render if "use mango" button will be disabled or enabled :)
src/gameHandlerClass.ts
Outdated
@@ -35,4 +35,15 @@ export class GameHandler { | |||
? this._playerTwo | |||
: this._playerOne; | |||
} | |||
|
|||
canIUseMango(): Boolean { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
canUseMango is enough :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well, this whole method is probably not necessary :P
But it might be, if it would be used somewhere outside of gamehandler 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it will actually be needed to disable button "use Mango"
src/gameHandlerClass.ts
Outdated
} | ||
|
||
useMango(): void | Error { | ||
if (this.canIUseMango() == false) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this.canIUseMango() == false
it's the same as:
!this.currentPlayer.hasMango
src/playerClass.ts
Outdated
@@ -37,6 +39,14 @@ export class Player { | |||
return alivePokemonsTab; | |||
} | |||
|
|||
reduceNumberMango(): void { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please rename this method :P and add validation inside:
if you ate mango once, then calling this method again should throw an error
src/gameHandlerClass.ts
Outdated
@@ -35,4 +35,15 @@ export class GameHandler { | |||
? this._playerTwo | |||
: this._playerOne; | |||
} | |||
|
|||
canUseMango(): Boolean { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did you add this to game handler? Wee need it only in our player class (we shouldn't put it here because it's a poperty and a method of a player, one player may have a mango, but the second one not necessarily). The whole logic about using mango and healing should be put in the useMango function in playerClass
@@ -37,6 +39,16 @@ export class Player { | |||
return alivePokemonsTab; | |||
} | |||
|
|||
useMango(): void | Error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add the whole logic about using mango here, in player class
* Function RenderChoosePokemonScreen * MNG-102 fight method implemented * MNG-102 Add tests for fight class. Fix pokemon subtract HP * Appendig function to the whole index.ts * MNG-88_StartButtonActivation (#12) * Add keyup to input * Add activateStart.ts * Uncomment html * Add class to activate/disable start button * Add activateStartButton function * Change class name to button-enabled * Corrections * MNG-89 clicking start should render choose pokemon screen (#17) * Function RenderChoosePokemonScreen * Appendig function to the whole index.ts * Corrections * MNG-95 Add GameHandler class (#14) * Add GameHandler class * Fix GameHandler class and add tests * Fix tests * MNG-107 Add geodude instead of tentacruel Filter moves to 4 for each pokemon Use mostly pokemon type moves * MNG-103 choose pokemon system (#19) * Add choosePokemonsPage.ts * Add all functions for choose pokemon page * Change event.target, loading time * MNG-94 MNG-108 Start a new game, add functions that will render the correct view (#20) * MNG-99 & MNG-100 > created menu and back button with options. Options need to be fixed (now are default). Animation also needs to look better * MNG-109 added * Blocking the start with unwritten name * added magicFunction * added animations for buttons * Style button * Blocking button when the name is too long * MNG-98 Add useMango to gameHandler class (#22) * Add useMango to gameHandler class * corrections type of mango value * Corrections * useMango i PlayerClass Co-authored-by: AleksandraCyp <73715885+AleksandraCyp@users.noreply.github.com> * MNG-97 MNG-101 change player&change pokemon (#24) * Add switch pokemon and switch Player game handler methods * Implement mango, change the structure (build up magic function) * remove an unnecessary comment * Update test parametrization and do not use json data * MNG-102 fight method implemented * MNG-102 Add tests for fight class. Fix pokemon subtract HP * Update test parametrization and do not use json data * Apply max shortcut Co-authored-by: AgataLudwiczynska <74932979+AgataLudwiczynska@users.noreply.github.com> Co-authored-by: mariusz-sm <74978639+mariusz-sm@users.noreply.github.com> Co-authored-by: AleksandraCyp <73715885+AleksandraCyp@users.noreply.github.com> Co-authored-by: Gosia Dziewit <gosia.dziewit@gmail.com>
No description provided.