Skip to content

Commit

Permalink
Changes
Browse files Browse the repository at this point in the history
  • Loading branch information
codergautam committed Dec 25, 2023
1 parent 5b7591e commit fb74df5
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 10 deletions.
16 changes: 10 additions & 6 deletions client/src/game/Controls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,11 @@ export class Controls {
});
input.on('pointerup', (pointer: Phaser.Input.Pointer) => {
pointer.event.preventDefault();
if (pointer.leftButtonReleased()) {
this.inputUp(InputTypes.SwordSwing);
}
if (pointer.rightButtonReleased()) {
this.inputUp(InputTypes.SwordThrow);
}
});


window.addEventListener('blur', () => this.clear());
this.disabledKeys = [];
}
Expand Down Expand Up @@ -112,8 +109,15 @@ export class Controls {
this.disabled = true;
}

disableKeys(keys: number[]) {
this.disabledKeys = keys;
disableKeys(keys: number[], append = false) {
if(!append) this.disabledKeys = keys;
else this.disabledKeys = this.disabledKeys.concat(keys);

this.disabledKeys = Array.from(new Set(this.disabledKeys));
}

enableKeys(keys: number[]) {
this.disabledKeys = this.disabledKeys.filter(key => !keys.includes(key));
}

enableAllKeys() {
Expand Down
6 changes: 4 additions & 2 deletions client/src/game/Settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export const settingsList: Record<string, SettingType> = {
{ name: 'Mouse Only', value: 'mouse' },
{ name: 'Mouse + Keys', value: 'keys' },
],
default: 'mouse',
default: 'keys',
},
sound: {
name: 'Sound',
Expand Down Expand Up @@ -98,7 +98,8 @@ class SettingsManager {
let savedSettings: any = {};
try {
const data = JSON.parse(localStorage.getItem(this.key) as string);
if (data) {
console.log('Loaded Settings', data);
if (data) {
savedSettings = data;
}
} catch (e) {
Expand All @@ -113,6 +114,7 @@ class SettingsManager {
savedSettings[key] = value;
localStorage.setItem(this.key, JSON.stringify(savedSettings));

console.log('Saved Settings', savedSettings);
if (settingsList[key].onChange) {
settingsList[key].onChange(value);
}
Expand Down
6 changes: 6 additions & 0 deletions client/src/game/entities/Player.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,9 @@ class Player extends BaseEntity {
this.swordLerpProgress -= swordLerpDt;
if (this.swordLerpProgress <= 0) {
this.swordLerpProgress = 0;
if(this.isMe && this.swordDecreaseStarted) {
this.game.controls.enableKeys([InputTypes.SwordThrow]);
}
this.swordDecreaseStarted = false;
}
}
Expand All @@ -254,7 +257,10 @@ class Player extends BaseEntity {

if (this.game.controls.isInputDown(InputTypes.SwordSwing)) {
if (!(this.swordFlying || this.swordRaiseStarted || this.swordDecreaseStarted)) {
if(!this.swordRaiseStarted) {
this.swordRaiseStarted = true;
this.game.controls.disableKeys([InputTypes.SwordThrow], true);
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion client/src/ui/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ function App() {
if(gameStarted && firstGame) setFirstGame(false);
if(gameStarted) return;
setTimeout(() => {
api.get(`${api.endpoint}/auth/account`, (data) => {
api.get(`${api.endpoint}/auth/account?now=${Date.now()}`, (data) => {
setAccountReady(true);
if (data.account) {
data.account.token = data.token;
Expand Down
3 changes: 3 additions & 0 deletions server/src/game/Game.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,9 @@ class Game {
client.player && client.player.name ? client.player.name
: this.handleNickname(data.name || '')
)
if(data?.name && data.name !== name) {
data.name = name;
}

// if (this.isNameReserved(name)) return;

Expand Down
2 changes: 1 addition & 1 deletion server/src/game/entities/Player.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ class Player extends Entity {
this.effects.forEach(effect => effect.update(dt));
this.health.update(dt);
this.applyInputs(dt);
this.sword.flySpeed.value = clamp(this.speed.value / 10, 50, 200);
this.sword.flySpeed.value = clamp(this.speed.value / 10, 100, 200);

if (this.inputs.isInputDown(Types.Input.Ability) && this.evolutions.evolutionEffect.canActivateAbility) {
this.evolutions.evolutionEffect.activateAbility();
Expand Down

0 comments on commit fb74df5

Please sign in to comment.