Skip to content

Commit

Permalink
feat: update ui and formulas
Browse files Browse the repository at this point in the history
  • Loading branch information
Veradictus committed Sep 26, 2023
1 parent f6c62a2 commit 31e0a82
Show file tree
Hide file tree
Showing 21 changed files with 125 additions and 38 deletions.
5 changes: 5 additions & 0 deletions packages/client/components/game.astro
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@
<div id="quest-button" class="slice-button stroke">Start Quest</div>
</div>

<div id="in-app-store" class="slice-container-fancy">
<div id="close-in-app-store" class="close-container-fancy"></div>

</div>

<div id="player-info">
<div id="health" class="safari-only">
<div id="health-mask" class="health-mask-base"></div>
Expand Down
2 changes: 1 addition & 1 deletion packages/client/components/intro.astro
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { t } from '@kaetram/common/i18n';
---

<div id="intro">
<section id="parchment" class="load-character slice-menu">
<section id="parchment" class="load-character slice-menu-fancy">
<article id="load-character">
<h1 class="title-decoration">{t('game:NAME')}</h1>

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion packages/client/scss/app/_index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
right: 0;
bottom: 0;

padding: 3em;
padding: 1em;

color: #eee;
}
10 changes: 9 additions & 1 deletion packages/client/scss/app/impl/_intro.scss
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ body.intro {

footer {
position: absolute;
bottom: 5%;
bottom: 2em;
left: 0;

width: 100%;
Expand Down Expand Up @@ -90,3 +90,11 @@ body.intro {
}
}
}

@media (--portrait) {
body.intro {
footer {
//bottom: 3.5em;
}
}
}
14 changes: 8 additions & 6 deletions packages/client/scss/app/impl/_parchment.scss
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
@use '../../abstracts/media';

#parchment {
width: 36em;
height: 19em;
top: -3em;
width: 38em;
height: 18em;
opacity: 0;

select {
Expand Down Expand Up @@ -31,13 +32,13 @@
overflow: auto;
display: flex;
flex-direction: column;
gap: 0.1em;
gap: 0;

box-sizing: border-box;
width: 24em;
height: 17em;
height: 15em;
margin: auto;
padding: 0 0.5em;
padding: 0 0.25em;

text-align: center;

Expand All @@ -51,7 +52,7 @@
display: flex;
flex: 1;
flex-direction: column;
gap: 0.1em;
gap: 0;
justify-content: space-between;

height: 100%;
Expand Down Expand Up @@ -133,6 +134,7 @@

@media (--portrait) {
#parchment {
top: -5em;
width: 20em;
height: 26em;
}
Expand Down
8 changes: 7 additions & 1 deletion packages/client/scss/app/impl/_worlds.scss
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
justify-content: center;

box-sizing: border-box;
margin: 3em;
margin: 1em;

color: #eee;

Expand Down Expand Up @@ -72,3 +72,9 @@
#continue-worlds {
position: relative;
}

@media (--portrait) {
#world-select-button {
bottom: 4em;
}
}
5 changes: 4 additions & 1 deletion packages/client/scss/game/_index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
@use 'impl/welcome';
@use 'impl/zoom';
@use 'impl/quest';
@use 'impl/inappstore';

body.game {
background: #000;
Expand All @@ -52,7 +53,9 @@ body.game {

#parchment {
z-index: 0;
transition: 0.2s opacity linear 0.2s, z-index 0s linear 1s;
transition:
0.2s opacity linear 0.2s,
z-index 0s linear 1s;
}

&.credits #credits,
Expand Down
13 changes: 13 additions & 0 deletions packages/client/scss/game/impl/_container.scss
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,16 @@
top: -0.25em;
right: -0.25em;
}

@include sprite.sheet(
$image: 'container-fancy-button',
$width: 20,
$height: 26,
$hover: 1,
$active: 2,
$selectors: '.close-container-fancy'
) {
position: absolute;
top: -0.25em;
right: -0.45em;
}
6 changes: 6 additions & 0 deletions packages/client/scss/game/impl/_inappstore.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#in-app-store {
display: none;
width: 28em;
height: 18em;
margin: auto;
}
37 changes: 37 additions & 0 deletions packages/client/scss/game/impl/_slice.scss
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,18 @@
border-image: url('/img/interface/slices/menu.png') 44% fill/ 1em / 0 stretch;
}

.slice-menu-fancy {
position: absolute;
inset: 0;

box-sizing: border-box;
margin: auto;

color: #eee;

border-image: url('/img/interface/slices/menu-fancy.png') 44% fill/ 4em / 0 stretch;
}

.slice-container {
position: absolute;
inset: 0;
Expand All @@ -35,6 +47,31 @@
}
}

.slice-container-fancy {
position: absolute;
inset: 0;

display: none;
flex-direction: row;
gap: 0.5em;

box-sizing: border-box;
width: 32em;
height: 16em;
margin: auto;
padding: 1em;

color: #eee;

border-image: url('/img/interface/slices/container-fancy.png') 44% fill/ 4.75em / 0 stretch;

@media (--portrait) {
flex-direction: column;
width: 22em;
height: 30em;
}
}

.slice-inner-container {
overflow: auto;
flex: 1;
Expand Down
6 changes: 6 additions & 0 deletions packages/common/i18n/de/misc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ export default {
CANNOT_DO_THAT: 'You cannot do that right now.',
CANNOT_DROP_ITEM_DOOR: 'You cannot drop this item while standing in a door.',
CANNOT_PASS_DOOR: 'You cannot pass through this door.',
CANNOT_GLOBAL_CHAT_SECONDS:
'You must wait another {{duration}} seconds before using global chat.',
CANNOT_GLOBAL_CHAT_MINUTES:
'You must wait another {{duration}} minutes before using global chat.',
CANNOT_GLOBAL_CHAT_JAIL: 'You cannot use global chat while you are jailed.',
CANNOT_GLOBAL_CHAT_TUTORIAL: 'You cannot use global chat while you are in the tutorial.',
CANNOT_PICK_UP_ITEM: 'This item can only be picked up by {{username}}.',
CANNOT_TALK: 'You cannot talk right now.',
CANNOT_TRADE_ITEM: 'You cannot trade this item.',
Expand Down
3 changes: 2 additions & 1 deletion packages/common/i18n/de/resource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@ export default {
UNABLE_TO_INTERACT_FISHING: 'You are unable to fish here at the moment.',
UNABLE_TO_INTERACT_FORAGING: 'You are unable to harvest this resource at the moment.',

NO_REASON_TREENO_REASON: 'There is no reason for you to cut this tree.'
NO_REASON_TREE: 'There is no reason for you to cut this tree.',
NO_REASON_FISHING: 'There is no reason for you to fish here.'
} as const;
3 changes: 2 additions & 1 deletion packages/common/i18n/en/crafting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ export default {
INVALID_ITEM: 'Invalid item selected.',
INVALID_ITEMS: 'You do not have the required items to craft that.',
SELECT_ITEM: 'Please select an item to craft.',
FAILED_CRAFT: 'You have failed to craft the '
FAILED_CRAFT: 'You have failed to craft {{failedText}}.',
FAILED_CRAFT_ONE: ' You have failed to craft the item.'
} as const;
2 changes: 1 addition & 1 deletion packages/common/i18n/es/crafting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ export default {
INVALID_ITEM: 'Elemento seleccionado no válido.',
INVALID_ITEMS: 'No tienes los elementos necesarios para fabricar eso.',
SELECT_ITEM: 'Por favor selecciona un artículo para crear.',
FAILED_CRAFT: 'Has fallado en crear el '
FAILED_CRAFT: 'Has fallado en crear el {{failedText}}.'
} as const;
2 changes: 1 addition & 1 deletion packages/common/i18n/fr/crafting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ export default {
INVALID_ITEM: 'Invalid item selected.',
INVALID_ITEMS: 'You do not have the required items to craft that.',
SELECT_ITEM: 'Please select an item to craft.',
FAILED_CRAFT: 'You have failed to craft the '
FAILED_CRAFT: 'You have failed to craft {{failedText}}'
} as const;
2 changes: 1 addition & 1 deletion packages/common/i18n/pt/crafting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ export default {
INVALID_ITEM: 'Invalid item selected.',
INVALID_ITEMS: 'You do not have the required items to craft that.',
SELECT_ITEM: 'Please select an item to craft.',
FAILED_CRAFT: 'You have failed to craft the '
FAILED_CRAFT: 'You have failed to craft {{failedText}} '
} as const;
2 changes: 1 addition & 1 deletion packages/common/i18n/ro/crafting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ export default {
INVALID_ITEM: 'Invalid item selected.',
INVALID_ITEMS: 'You do not have the required items to craft that.',
SELECT_ITEM: 'Please select an item to craft.',
FAILED_CRAFT: 'You have failed to craft the '
FAILED_CRAFT: 'You have failed to craft {{failedText}} '
} as const;
2 changes: 1 addition & 1 deletion packages/common/i18n/ru/crafting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ export default {
INVALID_ITEM: 'Выбран неверный элемент.',
INVALID_ITEMS: 'У вас нет необходимых предметов для его создания.',
SELECT_ITEM: 'Пожалуйста, выберите предмет для изготовления.',
FAILED_CRAFT: 'Вам не удалось создать.'
FAILED_CRAFT: 'Вам не удалось создать. {{failedText}}'
} as const;
6 changes: 5 additions & 1 deletion packages/server/src/controllers/crafting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,11 @@ export default class Crafting {
// Notify the players of the amount of failures.
if (failures > 0)
player.notify(
`${'crafting:FAILED_CRAFT'} ${failures}x ${(Items as RawData)[key].name}.`
failures > 1
? `crafting:FAILED_CRAFT;failedText=${failures}x ${
(Items as RawData)[key].name
}.`
: 'crafting:FAILED_CRAFT_ONE'
);

// Award experience to the player.
Expand Down
33 changes: 14 additions & 19 deletions packages/server/src/info/formulas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,20 +215,15 @@ export default {
magic: (attackerStats.magic - targetStats.magic) / 3,
archery: (attackerStats.archery - targetStats.archery) / 3
},
totalWeight =
weights.crush + weights.slash + weights.stab + weights.magic + weights.archery;
totalWeight = Object.values(weights).reduce((acc, curr) => {
if (curr < 0) return acc;
return acc + curr;
}, 0);

// Respective classes use their own weights.
if (attacker.isArcher()) totalWeight = weights.archery;
if (attacker.isMagic()) totalWeight = weights.magic;

// Negative values add no weight to the accuracy modifier.
if (weights.crush < 0) totalWeight -= weights.crush;
if (weights.slash < 0) totalWeight -= weights.slash;
if (weights.stab < 0) totalWeight -= weights.stab;
if (weights.magic < 0) totalWeight -= weights.magic;
if (weights.archery < 0) totalWeight -= weights.archery;

// If our attack style is the same or none then we do not have any advantage in our accuracy.
if (attackStyle === defenseStyle || attackStyle === Modules.DamageStyle.None)
return totalWeight || 1;
Expand All @@ -241,32 +236,32 @@ export default {

switch (attackStyle) {
case Modules.DamageStyle.Crush: {
totalWeight += weights.crush * 2;
totalWeight +=
defenseStyle === Modules.DamageStyle.Slash ? weights.crush : -weights.crush / 2;
break;
}

case Modules.DamageStyle.Slash: {
totalWeight += weights.slash * 2;
totalWeight +=
defenseStyle === Modules.DamageStyle.Stab ? weights.slash : -weights.slash / 2;
break;
}

case Modules.DamageStyle.Stab: {
totalWeight += weights.stab * 2;
totalWeight +=
defenseStyle === Modules.DamageStyle.Crush ? weights.stab : -weights.stab / 2;
break;
}

case Modules.DamageStyle.Magic: {
totalWeight += weights.magic * 2;
totalWeight += weights.magic;
break;
}

case Modules.DamageStyle.Archery: {
totalWeight += weights.archery * 2;
totalWeight += weights.archery;
break;
}
}

return totalWeight || 1;
// Ensure the weight is always positive and more than 1 for the sake of combat mechanics
return Math.max(totalWeight, 1);
},

/**
Expand Down

0 comments on commit 31e0a82

Please sign in to comment.