Skip to content

Commit

Permalink
fix: remove white border around cards image + move special cards at t…
Browse files Browse the repository at this point in the history
…he end of the hand
  • Loading branch information
Oliboy50 committed Aug 27, 2023
1 parent 8529452 commit 8a2fefc
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 62 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@

### Create sprite of cards

- Create sprite from 180px wide PNG card images:
- Create cards.png sprite from 180x251 card images:
```shell
magick montage $(ls blue-*.png) $(ls brown-*.png) $(ls gray-*.png) $(ls green-*.png) $(ls pink-*.png) $(ls red-*.png) $(ls yellow-*.png) $(ls special-*.png) back-ext_legendes.png $(ls adventurer-*.png) -geometry +0+0 -tile 7x9 -mode concatenate -background none cards.png
magick montage $(ls blue-*.png) $(ls brown-*.png) $(ls gray-*.png) $(ls green-*.png) $(ls pink-*.png) $(ls red-*.png) $(ls yellow-*.png) back-ext_legendes.png $(ls adventurer-*.png) $(ls special-*.png) -geometry +0+0 -tile 7x9 -mode concatenate -background none cards.png
```
- Create finish.png sprite from 150x150 finish images:
```shell
magick montage $(ls finish_*.png) -geometry +0+0 -tile 4x1 -mode concatenate -background none finish.png
```
- Reduce generated sprite size by ~90% (using https://tinypng.com or https://compresspng.com if the file is too large)
- Reduce generated sprites size by ~90% (using https://tinypng.com or https://compresspng.com if the file is too large)

## License

Expand Down
Binary file modified img/cards.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
119 changes: 60 additions & 59 deletions velonimo.js
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,7 @@ function (dojo, declare) {
},
getLogHtmlWidthForCard: function (card) {
if (card.color === COLOR_ADVENTURER) {
return 32;
return 33;
}
if (card.color === COLOR_SPECIAL) {
return 30;
Expand All @@ -617,26 +617,23 @@ function (dojo, declare) {
},
getLogHtmlBackgroundOffsetXForCard: function (card) {
if (card.color === COLOR_ADVENTURER) {
return 6;
}
if (card.value === VALUE_1) {
return 11;
return 3;
}
if (card.value === VALUE_2) {
return 63;
return 66;
}
if (card.value === VALUE_7) {
return 10;
if (card.value === VALUE_6) {
return 7;
}
if (
card.color === COLOR_SPECIAL
&& card.value === VALUE_JERSEY_PLUS_TEN
) {
return 4;
if (card.value === VALUE_7) {
return 7;
}
if (
card.color === COLOR_SPECIAL
&& card.value === VALUE_LEGENDS_BROOM_WAGON_PLUS_FIVE
&& [
VALUE_JERSEY_PLUS_TEN,
VALUE_LEGENDS_BROOM_WAGON_PLUS_FIVE,
].includes(card.value)
) {
return 1;
}
Expand All @@ -652,17 +649,17 @@ function (dojo, declare) {
) {
return 30;
}
return 11;
return 8;
},
getLogHtmlBackgroundOffsetYForCard: function (card) {
if (card.color === COLOR_ADVENTURER) {
return 8;
return 5;
}
if (
card.color === COLOR_SPECIAL
&& card.value === VALUE_JERSEY_PLUS_TEN
) {
return 5;
return 2;
}
if (
card.color === COLOR_SPECIAL
Expand All @@ -682,7 +679,7 @@ function (dojo, declare) {
) {
return 91;
}
return 7;
return 4;
},
/**
* @param {Object} card
Expand Down Expand Up @@ -1331,36 +1328,36 @@ function (dojo, declare) {
case COLOR_SPECIAL:
switch (value) {
case VALUE_JERSEY_PLUS_TEN:
return 49;
return 56;
case VALUE_LEGENDS_BROOM_WAGON_PLUS_FIVE:
return 50;
return 57;
case VALUE_LEGENDS_EAGLE_ADD_ONE_OTHER_NUMBER:
return 51;
return 58;
case VALUE_LEGENDS_PANDA_ADD_ONE_OTHER_COLOR:
return 52;
return 59;
case VALUE_LEGENDS_SHARK_ONE_RED_MULTIPLY_TEN:
return 53;
return 60;
case VALUE_LEGENDS_BADGER_ANY_NUMBER_OF_EACH_COLOR:
return 54;
return 61;
case VALUE_LEGENDS_ELEPHANT_STOP:
return 55;
return 62;
default:
throw new Error('Unsupported');
}
case COLOR_ADVENTURER:
switch (value) {
case VALUE_25:
return 57;
return 50;
case VALUE_30:
return 58;
return 51;
case VALUE_35:
return 59;
return 52;
case VALUE_40:
return 60;
return 53;
case VALUE_45:
return 61;
return 54;
case VALUE_50:
return 62;
return 55;
default:
throw new Error('Unsupported');
}
Expand Down Expand Up @@ -1405,7 +1402,7 @@ function (dojo, declare) {
*/
getCardWeightForColorAndValueToSortThemByValue: function (color, value) {
if (color === COLOR_SPECIAL) {
return value + 1000;
return 10000 + this.getCardPositionInSpriteByColorAndValue(color, value);
}

return (value * 100) + color;
Expand Down Expand Up @@ -1639,57 +1636,57 @@ function (dojo, declare) {
color = COLOR_YELLOW;
value = VALUE_7;
break;
case 49:
color = COLOR_SPECIAL;
value = VALUE_JERSEY_PLUS_TEN;
break;
case 50:
color = COLOR_SPECIAL;
value = VALUE_LEGENDS_BROOM_WAGON_PLUS_FIVE;
color = COLOR_ADVENTURER;
value = VALUE_25;
break;
case 51:
color = COLOR_SPECIAL;
value = VALUE_LEGENDS_EAGLE_ADD_ONE_OTHER_NUMBER;
color = COLOR_ADVENTURER;
value = VALUE_30;
break;
case 52:
color = COLOR_SPECIAL;
value = VALUE_LEGENDS_PANDA_ADD_ONE_OTHER_COLOR;
color = COLOR_ADVENTURER;
value = VALUE_35;
break;
case 53:
color = COLOR_SPECIAL;
value = VALUE_LEGENDS_SHARK_ONE_RED_MULTIPLY_TEN;
color = COLOR_ADVENTURER;
value = VALUE_40;
break;
case 54:
color = COLOR_SPECIAL;
value = VALUE_LEGENDS_BADGER_ANY_NUMBER_OF_EACH_COLOR;
color = COLOR_ADVENTURER;
value = VALUE_45;
break;
case 55:
color = COLOR_ADVENTURER;
value = VALUE_50;
break;
case 56:
color = COLOR_SPECIAL;
value = VALUE_LEGENDS_ELEPHANT_STOP;
value = VALUE_JERSEY_PLUS_TEN;
break;
case 57:
color = COLOR_ADVENTURER;
value = VALUE_25;
color = COLOR_SPECIAL;
value = VALUE_LEGENDS_BROOM_WAGON_PLUS_FIVE;
break;
case 58:
color = COLOR_ADVENTURER;
value = VALUE_30;
color = COLOR_SPECIAL;
value = VALUE_LEGENDS_EAGLE_ADD_ONE_OTHER_NUMBER;
break;
case 59:
color = COLOR_ADVENTURER;
value = VALUE_35;
color = COLOR_SPECIAL;
value = VALUE_LEGENDS_PANDA_ADD_ONE_OTHER_COLOR;
break;
case 60:
color = COLOR_ADVENTURER;
value = VALUE_40;
color = COLOR_SPECIAL;
value = VALUE_LEGENDS_SHARK_ONE_RED_MULTIPLY_TEN;
break;
case 61:
color = COLOR_ADVENTURER;
value = VALUE_45;
color = COLOR_SPECIAL;
value = VALUE_LEGENDS_BADGER_ANY_NUMBER_OF_EACH_COLOR;
break;
case 62:
color = COLOR_ADVENTURER;
value = VALUE_50;
color = COLOR_SPECIAL;
value = VALUE_LEGENDS_ELEPHANT_STOP;
break;
default:
throw new Error(`Unsupported card position in sprite: ${position}`);
Expand Down Expand Up @@ -3276,6 +3273,10 @@ function (dojo, declare) {
///////////////////////////////////////////////////
//// Reaction to cometD notifications
///////////////////////////////////////////////////
/**
* @Override ntf_tableWindow BGA framework function to supporting translating the title of the tableWindow
* @param {Object|string} notif
*/
ntf_tableWindow: function (notif) {
if(typeof notif.args.title === 'object'){
notif.args.title = this.format_string_recursive(notif.args.title.str, notif.args.title.args);
Expand Down

0 comments on commit 8a2fefc

Please sign in to comment.