Skip to content

Commit

Permalink
bugfix colors skin
Browse files Browse the repository at this point in the history
  • Loading branch information
gubace committed Apr 24, 2024
1 parent 03664f9 commit ef6b0de
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 9 deletions.
33 changes: 25 additions & 8 deletions src/main/game_ui/static/js/game_hex.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
var hover1 = "#344792"
var hover2 = "#BA3533"
var hex_color = "#B0BFB1"

window.onload = function () {
let current_player = 1; // Player 1 starts the game
let game_over = false;
Expand Down Expand Up @@ -248,16 +252,16 @@ window.onload = function () {
// Hover uniquement si on n'est ni une couleur ni désactivé
if (event.type === "mouseover" && game_over===false && !element.getAttribute('couleur') && !element.getAttribute("disabled")){
if (current_player===1){
element.style.backgroundColor = "#344792";
element.style.backgroundColor = hover1;
}
if (current_player===2){
element.style.backgroundColor = "#BA3533";
element.style.backgroundColor = hover2;
}
element.setAttribute("nimp",true);
}
// Enlève le hover si on quitte un hex ni en couleur ni disabled
else if (event.type === "mouseout" && game_over===false && element.getAttribute("nimp") && !element.getAttribute('disabled')){
element.style.backgroundColor = "#B0BFB1";
element.style.backgroundColor = hex_color;
element.removeAttribute("nimp");
}
}
Expand Down Expand Up @@ -287,6 +291,10 @@ document.addEventListener("keydown", gestionnairePressionTouche);


function changerFichiers() {
var bhover1 = "#344792"
var bhover2 = "#BA3533"
var mhover1 = "#5197BA"
var mhover2 = "#F6995C"
var Mblue = "rgb(81, 130, 155)";
var Mred = "rgb(248, 124, 41)";
var blue = "rgb(41, 51, 92)";
Expand All @@ -297,28 +305,37 @@ function changerFichiers() {
if (styleSheet.getAttribute('href') === "../static/css/game_hex_styles.css") {
//console.log("touché");
styleSheet.setAttribute('href', "../static/css/game_hex_marine_skin.css");
hex_color = "#ADBBC6"
hover1 = mhover1;
hover2 = mhover2;
div1.setAttribute("value", Mred);
div2.setAttribute("value", Mblue);
changecolor(blue,Mblue,red,Mred)
changecolor(blue,Mblue,red,Mred,hex_color)
} else {
styleSheet.setAttribute('href', "../static/css/game_hex_styles.css");
hex_color = "#B0BFB1"
hover1 = bhover1;
hover2 = bhover2;
div1.setAttribute("value",red);
div2.setAttribute("value", blue);
changecolor(Mblue,blue,Mred,red)
changecolor(Mblue,blue,Mred,red,hex_color)
}

}

function changecolor(b1,b2,r1,r2){
function changecolor(b1,b2,r1,r2,hex_color){
const cells = document.querySelectorAll('.hex');
cells.forEach(hex => {
console.log(hex.style.backgroundColor);
//console.log(hex.style.backgroundColor);
if (hex.style.backgroundColor == b1) {
hex.style.backgroundColor = b2;
}
if (hex.style.backgroundColor == r1) {
else if (hex.style.backgroundColor == r1) {
hex.style.backgroundColor = r2;
}
else {
hex.style.backgroundColor = hex_color;
}
})
}

2 changes: 1 addition & 1 deletion src/main/game_ui/static/js/game_hexia.js
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ window.onload = async function () {
}
// Enlève le hover si on quitte un hex ni en couleur ni disabled
else if (event.type === "mouseout" && game_over===false && element.getAttribute("nimp") && !element.getAttribute('disabled')){
element.style.backgroundColor = "#B0BFB1";
element.style.backgroundColor = "#ADBBC6";
element.removeAttribute("nimp");
}
}
Expand Down

0 comments on commit ef6b0de

Please sign in to comment.