Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various fixes #845

Merged
merged 3 commits into from
Mar 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 19 additions & 16 deletions client/src/views/game/components/carrier/BuildCarrier.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@

<div class="row mb-1">
<div class="col">
<input v-model="starShips" type="number" class="form-control" @input="onStarShipsChanged">
<input v-model="starShips" type="number" class="form-control" @input="onStarShipsChanged" @blur="onStarShipsBlur">
</div>
<div class="col">
<input v-model="carrierShips" type="number" class="form-control" @input="onCarrierShipsChanged">
<input v-model="carrierShips" type="number" class="form-control" @input="onCarrierShipsChanged" @blur="onCarrierShipsBlur">
</div>
</div>

Expand Down Expand Up @@ -109,25 +109,19 @@ export default {
this.$emit('onCloseRequested', e)
},
onStarShipsChanged(e) {
this.starShips = parseInt(this.starShips);

if (isNaN(this.starShips)) {
this.starShips = 0;
}

let difference = this.starShips - this.star.ships
let difference = this.ensureInt(this.starShips) - this.star.ships
this.carrierShips = Math.abs(difference)
},
onStarShipsBlur(e) {
this.starShips = this.ensureInt(this.starShips);
},
onCarrierShipsChanged(e) {
this.carrierShips = parseInt(this.carrierShips);

if (isNaN(this.carrierShips)) {
this.carrierShips = 1;
}

let difference = this.carrierShips;
let difference = this.ensureInt(this.carrierShips);
this.starShips = this.star.ships - difference
},
onCarrierShipsBlur(e) {
this.carrierShips = this.ensureInt(this.carrierShips);
},
onMinShipsClicked (e) {
this.carrierShips = 1
this.starShips = this.star.ships - 1
Expand All @@ -144,6 +138,15 @@ export default {
this.carrierShips+=e
this.starShips-=e
},
ensureInt(v) {
v = parseInt(v);

if (isNaN(v)) {
v = 0;
}

return v;
},
onOpenStarDetailRequested (e) {
this.$emit('onOpenStarDetailRequested', this.star._id)
},
Expand Down
43 changes: 23 additions & 20 deletions client/src/views/game/components/carrier/ShipTransfer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@

<div class="row mb-1">
<div class="col">
<input v-model="starShips" type="number" class="form-control" @input="onStarShipsChanged">
<input v-model="starShips" type="number" class="form-control" @input="onStarShipsChanged" @blur="onStarShipsBlur">
</div>
<div class="col">
<input v-model="carrierShips" type="number" class="form-control" @input="onCarrierShipsChanged">
<input v-model="carrierShips" type="number" class="form-control" @input="onCarrierShipsChanged" @blur="onCarrierShipsBlur">
</div>
</div>

Expand Down Expand Up @@ -151,24 +151,18 @@ export default {
}
},
onStarShipsChanged(e) {
this.starShips = parseInt(this.starShips);

if (isNaN(this.starShips)) {
this.starShips = 0;
}

let difference = this.starShips - this.star.ships
this.carrierShips = this.carrier.ships - difference
let difference = this.ensureInt(this.starShips) - this.star.ships;
this.carrierShips = this.carrier.ships - difference;
},
onStarShipsBlur(e) {
this.starShips = this.ensureInt(this.starShips);
},
onCarrierShipsChanged(e) {
this.carrierShips = parseInt(this.carrierShips);

if (isNaN(this.carrierShips)) {
this.carrierShips = 1;
}

let difference = this.carrierShips - this.carrier.ships
this.starShips = this.star.ships - difference
let difference = this.ensureInt(this.carrierShips) - this.carrier.ships;
this.starShips = this.star.ships - difference;
},
onCarrierShipsBlur(e) {
this.carrierShips = this.ensureInt(this.carrierShips);
},
onMinShipsClicked (e) {
this.carrierShips = 1
Expand All @@ -178,14 +172,23 @@ export default {
this.starShips = 0
this.carrierShips = this.carrier.ships + this.star.ships
},
onTransferLeftClicked (e) {
onTransferLeftClicked(e) {
this.starShips+=e
this.carrierShips-=e
},
onTransferRightClicked (e) {
onTransferRightClicked(e) {
this.carrierShips+=e
this.starShips-=e
},
ensureInt(v) {
v = parseInt(v);

if (isNaN(v)) {
v = 0;
}

return v;
},
async saveTransfer (e) {
let result = await this.performSaveTransfer()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
<div v-if="debtor && creditor">
<p v-if="isCreditor">
You have forgiven <span class="text-warning">{{getFormattedDebtValue()}}</span> of debt owed to you by
<a href="javascript:;" @click="onOpenPlayerDetailRequested(creditor)">{{debtor.alias}}</a>.
<a href="javascript:;" @click="onOpenPlayerDetailRequested(debtor)">{{debtor.alias}}</a>.
</p>
<p v-if="!isCreditor">
<a href="javascript:;" @click="onOpenPlayerDetailRequested(debtor)">{{creditor.alias}}</a> has forgiven
<a href="javascript:;" @click="onOpenPlayerDetailRequested(creditor)">{{creditor.alias}}</a> has forgiven
<span class="text-warning">{{getFormattedDebtValue()}}</span> of debt you owed to them.
</p>
</div>
Expand Down
2 changes: 1 addition & 1 deletion client/src/views/game/components/tutorial/Tutorial.vue
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@
</p>

<p class="text-warning">
<i>Submit your turn and in a few seconds you will your carriers follow their waypoints and travel to nearby stars.</i>
<i>Submit your turn and in a few seconds you will see your carriers follow their waypoints and travel to nearby stars.</i>
</p>
</div>

Expand Down
2 changes: 1 addition & 1 deletion server/services/diplomacy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ export default class DiplomacyService extends EventEmitter {
}

getFilteredDiplomacy(player: Player, forPlayer: Player): PlayerDiplomaticState[] {
return player.diplomacy.filter(a => a.toString() === forPlayer._id.toString());
return player.diplomacy.filter(a => a.playerId.toString() === forPlayer._id.toString());
}

async _declareStatus(game: Game, playerId: DBObjectId, playerIdTarget: DBObjectId, state: DiplomaticState, saveToDB: boolean = true) {
Expand Down
Loading