Skip to content
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

Merged
merged 5 commits into from
Feb 11, 2021

Conversation

AgataLudwiczynska
Copy link
Collaborator

No description provided.

@@ -4,6 +4,7 @@ export class Player {
private _name: string;
private _pokemons: Pokemon[];
private _indexOfActivePokemon: number;
private _mango: Number;
Copy link
Owner

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

Copy link
Owner

@lukaszdutka lukaszdutka left a 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 :)

@@ -14,6 +15,7 @@ export class Player {
this._name = name;
this._pokemons = pokemons;
this._indexOfActivePokemon = 0;
this._mango=1;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

=true

@@ -37,6 +39,14 @@ export class Player {
return alivePokemonsTab;
}

reduceNumberMango(): void {
this._mango = <any>this._mango - 1;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

= false

@@ -35,4 +35,11 @@ export class GameHandler {
? this._playerTwo
: this._playerOne;
}
}

useMango(): void | Error{
Copy link
Owner

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 :)

@@ -35,4 +35,15 @@ export class GameHandler {
? this._playerTwo
: this._playerOne;
}

canIUseMango(): Boolean {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

canUseMango is enough :)

Copy link
Owner

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 🤔

Copy link
Collaborator Author

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"

}

useMango(): void | Error {
if (this.canIUseMango() == false)
Copy link
Owner

@lukaszdutka lukaszdutka Feb 10, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.

Copy link
Owner

@lukaszdutka lukaszdutka Feb 10, 2021

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

@@ -37,6 +39,14 @@ export class Player {
return alivePokemonsTab;
}

reduceNumberMango(): void {
Copy link
Owner

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

@@ -35,4 +35,15 @@ export class GameHandler {
? this._playerTwo
: this._playerOne;
}

canUseMango(): Boolean {
Copy link
Collaborator

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 {
Copy link
Collaborator

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

@lukaszdutka lukaszdutka merged commit 15911f8 into master Feb 11, 2021
@lukaszdutka lukaszdutka deleted the MNG-98-useMango-option-in-gameHandler-class branch February 11, 2021 16:28
lukaszdutka pushed a commit that referenced this pull request Feb 12, 2021
* 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants