Skip to content
This repository has been archived by the owner on Oct 2, 2018. It is now read-only.

Abilities to fe #165

Merged
merged 9 commits into from
Sep 29, 2018
Merged

Abilities to fe #165

merged 9 commits into from
Sep 29, 2018

Conversation

Masclins
Copy link
Collaborator

@Masclins Masclins commented Sep 25, 2018

Description

Backend responding API requests only gives relevant information about cards.

Issues Resolved

Resolves #154

Details

All cards abilities (which are functions) must be created in a way that calling them without parameters gives the frontend relevant information. That's a :description and :target, as proposed by @kenan-rhoton on #154.

Hotspots

(api.player_view_functions/get-cards should be carefully reviewed. I tried to make it the most readable by dividing the 4 possible scenarios regarding card's info that must be shown and write every time what should be send. An alternative would be abuse (merge to avoid repetitions, but I felt that would be less redeable.

Checklist for contribution requirements
(I leave the checks for reviewers)

  • The tests pass
  • The code has tests
  • The tests are well-designed
  • The code is readable
  • The code is well-organized

@Masclins Masclins mentioned this pull request Sep 25, 2018
6 tasks
@pernilsalat
Copy link
Collaborator

Ehhh, i don't think #154 discussion is finished...

Copy link
Owner

@kenan-rhoton kenan-rhoton left a comment

Choose a reason for hiding this comment

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

In general good, but some readability issues and I don't like using "Enhance" for negative values"

@@ -6,18 +6,27 @@
"Returns cards as seen by a player"
[game-state player-id]
(vec (map
Copy link
Owner

Choose a reason for hiding this comment

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

This function is becoming very long and hard to read... do we really need nested ifs?
I feel like cond would be clearer, even if the conditions become a little more verbose, and maybe even split off the different cases into functions?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Let's see if it's easier to read now

[:cards target :power]
#(+ % increase)))
([]
{:description (str "Enhance " increase) :target 1})))
Copy link
Owner

Choose a reason for hiding this comment

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

"Enhance" doesn't seem very appropriate for a negative value

; Correctly returns cards with abilities
(expect
[{:power 1 :location [:hand] :owner "me" :description "Enhance 100" :target 1}
{:power 17 :location [:hand] :owner "me" :description "Enhance -1" :target 1}
Copy link
Owner

Choose a reason for hiding this comment

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

Again, I feel like "Enhance -1" just looks very weird. Diminish or Weaken maybe? It might even then be positive "Weaken 1"

@@ -2,31 +2,31 @@
(:require [rules.victory-conditions :as victory]
[configs.messages :as messages]))

(defn ^:private partial-card
"Returns only certain keys of a card and change the :owner"
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 know that this could be a more generic function (no need to call it "card") but since it changes the :owner, I felt like it should be like that.

Also, considering it's private, I see no reason to make it more generic.

Copy link
Owner

Choose a reason for hiding this comment

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

agree with no need to be more generic

Copy link
Owner

@kenan-rhoton kenan-rhoton left a comment

Choose a reason for hiding this comment

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

Awesome! Just a small "double and" issue (which is a Clojure syntax thing)

@@ -2,31 +2,31 @@
(:require [rules.victory-conditions :as victory]
[configs.messages :as messages]))

(defn ^:private partial-card
"Returns only certain keys of a card and change the :owner"
Copy link
Owner

Choose a reason for hiding this comment

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

agree with no need to be more generic

(defn get-cards
"Returns cards as seen by a player"
[game-state player-id]
(vec (map
#(cond
(= (:owner %) player-id)
(assoc % :owner "me")
(and (and (= (:owner %) player-id)
Copy link
Owner

Choose a reason for hiding this comment

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

double and is redundant. In clojure and takes any amount of arguments, so you can just do (and cond1 cond2 cond3 ... condN)

@kenan-rhoton kenan-rhoton merged commit 37dbd09 into develop Sep 29, 2018
@kenan-rhoton kenan-rhoton deleted the abilities-to-fe branch September 29, 2018 07:44
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants