From 02ad8c92761cc7ed22f08f66c64bd89a4824760a Mon Sep 17 00:00:00 2001
From: "benjamin.sitbon" <benjamin.sibon@etu.hesge.ch>
Date: Tue, 2 Mar 2021 01:30:38 +0100
Subject: [PATCH] =?UTF-8?q?correction=20d'un=20bug=20lors=20de=20la=20sele?=
 =?UTF-8?q?ction=20de=20capacit=C3=A9s=20et=20oragnisation=20des=20images?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 frontend/img/{ => types}/bug.jpg      | Bin
 frontend/img/{ => types}/dark.jpg     | Bin
 frontend/img/{ => types}/dragon.jpg   | Bin
 frontend/img/{ => types}/electric.jpg | Bin
 frontend/img/{ => types}/fairy.jpg    | Bin
 frontend/img/{ => types}/fighting.jpg | Bin
 frontend/img/{ => types}/fire.jpg     | Bin
 frontend/img/{ => types}/flying.jpg   | Bin
 frontend/img/{ => types}/ghost.jpg    | Bin
 frontend/img/{ => types}/grass.jpg    | Bin
 frontend/img/{ => types}/ground.jpg   | Bin
 frontend/img/{ => types}/ice.jpg      | Bin
 frontend/img/{ => types}/normal.jpg   | Bin
 frontend/img/{ => types}/physical.png | Bin
 frontend/img/{ => types}/poison.jpg   | Bin
 frontend/img/{ => types}/psychic.jpg  | Bin
 frontend/img/{ => types}/rock.jpg     | Bin
 frontend/img/{ => types}/special.png  | Bin
 frontend/img/{ => types}/status.png   | Bin
 frontend/img/{ => types}/steel.jpg    | Bin
 frontend/img/{ => types}/water.jpg    | Bin
 frontend/js/index.js                  |   6 ++--
 frontend/js/product.js                |  38 +++++++++++++++++---------
 23 files changed, 28 insertions(+), 16 deletions(-)
 rename frontend/img/{ => types}/bug.jpg (100%)
 rename frontend/img/{ => types}/dark.jpg (100%)
 rename frontend/img/{ => types}/dragon.jpg (100%)
 rename frontend/img/{ => types}/electric.jpg (100%)
 rename frontend/img/{ => types}/fairy.jpg (100%)
 rename frontend/img/{ => types}/fighting.jpg (100%)
 rename frontend/img/{ => types}/fire.jpg (100%)
 rename frontend/img/{ => types}/flying.jpg (100%)
 rename frontend/img/{ => types}/ghost.jpg (100%)
 rename frontend/img/{ => types}/grass.jpg (100%)
 rename frontend/img/{ => types}/ground.jpg (100%)
 rename frontend/img/{ => types}/ice.jpg (100%)
 rename frontend/img/{ => types}/normal.jpg (100%)
 rename frontend/img/{ => types}/physical.png (100%)
 rename frontend/img/{ => types}/poison.jpg (100%)
 rename frontend/img/{ => types}/psychic.jpg (100%)
 rename frontend/img/{ => types}/rock.jpg (100%)
 rename frontend/img/{ => types}/special.png (100%)
 rename frontend/img/{ => types}/status.png (100%)
 rename frontend/img/{ => types}/steel.jpg (100%)
 rename frontend/img/{ => types}/water.jpg (100%)

diff --git a/frontend/img/bug.jpg b/frontend/img/types/bug.jpg
similarity index 100%
rename from frontend/img/bug.jpg
rename to frontend/img/types/bug.jpg
diff --git a/frontend/img/dark.jpg b/frontend/img/types/dark.jpg
similarity index 100%
rename from frontend/img/dark.jpg
rename to frontend/img/types/dark.jpg
diff --git a/frontend/img/dragon.jpg b/frontend/img/types/dragon.jpg
similarity index 100%
rename from frontend/img/dragon.jpg
rename to frontend/img/types/dragon.jpg
diff --git a/frontend/img/electric.jpg b/frontend/img/types/electric.jpg
similarity index 100%
rename from frontend/img/electric.jpg
rename to frontend/img/types/electric.jpg
diff --git a/frontend/img/fairy.jpg b/frontend/img/types/fairy.jpg
similarity index 100%
rename from frontend/img/fairy.jpg
rename to frontend/img/types/fairy.jpg
diff --git a/frontend/img/fighting.jpg b/frontend/img/types/fighting.jpg
similarity index 100%
rename from frontend/img/fighting.jpg
rename to frontend/img/types/fighting.jpg
diff --git a/frontend/img/fire.jpg b/frontend/img/types/fire.jpg
similarity index 100%
rename from frontend/img/fire.jpg
rename to frontend/img/types/fire.jpg
diff --git a/frontend/img/flying.jpg b/frontend/img/types/flying.jpg
similarity index 100%
rename from frontend/img/flying.jpg
rename to frontend/img/types/flying.jpg
diff --git a/frontend/img/ghost.jpg b/frontend/img/types/ghost.jpg
similarity index 100%
rename from frontend/img/ghost.jpg
rename to frontend/img/types/ghost.jpg
diff --git a/frontend/img/grass.jpg b/frontend/img/types/grass.jpg
similarity index 100%
rename from frontend/img/grass.jpg
rename to frontend/img/types/grass.jpg
diff --git a/frontend/img/ground.jpg b/frontend/img/types/ground.jpg
similarity index 100%
rename from frontend/img/ground.jpg
rename to frontend/img/types/ground.jpg
diff --git a/frontend/img/ice.jpg b/frontend/img/types/ice.jpg
similarity index 100%
rename from frontend/img/ice.jpg
rename to frontend/img/types/ice.jpg
diff --git a/frontend/img/normal.jpg b/frontend/img/types/normal.jpg
similarity index 100%
rename from frontend/img/normal.jpg
rename to frontend/img/types/normal.jpg
diff --git a/frontend/img/physical.png b/frontend/img/types/physical.png
similarity index 100%
rename from frontend/img/physical.png
rename to frontend/img/types/physical.png
diff --git a/frontend/img/poison.jpg b/frontend/img/types/poison.jpg
similarity index 100%
rename from frontend/img/poison.jpg
rename to frontend/img/types/poison.jpg
diff --git a/frontend/img/psychic.jpg b/frontend/img/types/psychic.jpg
similarity index 100%
rename from frontend/img/psychic.jpg
rename to frontend/img/types/psychic.jpg
diff --git a/frontend/img/rock.jpg b/frontend/img/types/rock.jpg
similarity index 100%
rename from frontend/img/rock.jpg
rename to frontend/img/types/rock.jpg
diff --git a/frontend/img/special.png b/frontend/img/types/special.png
similarity index 100%
rename from frontend/img/special.png
rename to frontend/img/types/special.png
diff --git a/frontend/img/status.png b/frontend/img/types/status.png
similarity index 100%
rename from frontend/img/status.png
rename to frontend/img/types/status.png
diff --git a/frontend/img/steel.jpg b/frontend/img/types/steel.jpg
similarity index 100%
rename from frontend/img/steel.jpg
rename to frontend/img/types/steel.jpg
diff --git a/frontend/img/water.jpg b/frontend/img/types/water.jpg
similarity index 100%
rename from frontend/img/water.jpg
rename to frontend/img/types/water.jpg
diff --git a/frontend/js/index.js b/frontend/js/index.js
index f7dae08..f84835b 100644
--- a/frontend/js/index.js
+++ b/frontend/js/index.js
@@ -124,13 +124,13 @@
                 stats.then(stat => {
 
                     if(stat.types.length > 1){
-                        types[2*i].src = "img/" + stat.types[0].type.name + ".jpg";
-                        types[(2*i)+1].src = "img/" + stat.types[1].type.name + ".jpg";
+                        types[2*i].src = "img/types/" + stat.types[0].type.name + ".jpg";
+                        types[(2*i)+1].src = "img/types/" + stat.types[1].type.name + ".jpg";
                         
                     }
                     else{
                         
-                        types[2*i].src = "img/" + stat.types[0].type.name + ".jpg"; 
+                        types[2*i].src = "img/types/" + stat.types[0].type.name + ".jpg"; 
                         types[(2*i)+1].style.display = "none"; 
                     }
                 })
diff --git a/frontend/js/product.js b/frontend/js/product.js
index cf279fe..3cffb9f 100644
--- a/frontend/js/product.js
+++ b/frontend/js/product.js
@@ -35,6 +35,28 @@
 
     }
 
+
+    function choiceAbility(ability,choice,abilities){
+        ability.ondblclick = function(){
+
+            if(choice.childNodes.length < 4){
+
+                selectedAbility(ability,choice,abilities);
+                choice.appendChild(ability);
+            }
+        }
+    }
+
+
+    function selectedAbility(ability,choice,abilities){
+        ability.ondblclick = function(){
+
+            choiceAbility(ability,choice,abilities);
+            abilities.appendChild(ability);
+
+        }
+    }
+
     function getMoves(stat,description,abilities,selection,choice){
 
         
@@ -53,8 +75,8 @@
                 dmgclass.className = "dmgclass";
 
                 get(data.moves[i].move.url).then(move => {
-                    type.src = "img/" + move.type.name +".jpg";
-                    dmgclass.src = "img/" + move.damage_class.name + ".png";
+                    type.src = "img/types/" + move.type.name +".jpg";
+                    dmgclass.src = "img/types/" + move.damage_class.name + ".png";
 
                     ability.onclick = function(){
 
@@ -72,17 +94,7 @@
                 ability.appendChild(txt);
 
 
-                ability.ondblclick = function(){
-
-                    if(choice.childNodes.length < 4){
-
-                        ability.ondblclick = function(){
-                            abilities.appendChild(ability);
-                            
-                        }
-                        choice.appendChild(ability);
-                    }
-                }
+                choiceAbility(ability,choice,abilities);
                 abilities.appendChild(ability);
             }
         });
-- 
GitLab