code to support bid 0 and revised setup (#128)

* support for replace istead of times

* turnOrder for the new setup

* show bid info

* better amount management for bids

* with $times

Co-authored-by: coyotte508 <coyotte508@gmail.com>
This commit is contained in:
Riccardo Zulian 2020-05-08 18:27:37 +02:00 • committed by GitHub
commit 89f214e248
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 36 additions and 23 deletions

View file

@ -458,7 +458,7 @@ export default class Commands extends Vue {
ret.push(...command.data.bids.map(pos => ({
label: `Bid ${pos.bid[0]} for ${pos.faction}`,
command: `${Command.Bid} ${pos.faction} 1`,
command: `${Command.Bid} ${pos.faction} $times`,
times: pos.bid
})));
break;

View file

@ -207,6 +207,8 @@ export default class MoveButton extends Vue {
command = command.replace(/\b[0-9]+/g, x => ('' + (parseInt(x) * times)));
}
command = command.replace(/\$times\b/g, '' + (times ?? 0));
commandBody = [command, append].filter(x => !!x);
}

View file

@ -12,8 +12,9 @@
<text class="board-text" x=26>
NAV: {{data.range}}
</text>
<text class="board-text" x=32>
VP: {{data.victoryPoints}}
<text class="board-text" x=31>
<tspan>VP: {{data.victoryPoints}}</tspan>
<tspan v-if="data.bid>0"> (-{{data.bid}})</tspan>
</text>
</g>
<!-- Resources / Income -->

View file

@ -27,13 +27,18 @@ export default class TurnOrder extends Vue {
return this.$store.state.gaiaViewer.data;
}
get phaseBeforeSetupBuilding(): boolean {
const data = this.gameData;
return ( data.phase == Phase.SetupInit || data.phase == Phase.SetupBoard || data.phase == Phase.SetupFaction || data.phase == Phase.SetupAuction);
}
get turnOrder(): Player[] {
const data = this.gameData;
if ( data.phase == Phase.SetupInit || data.phase == Phase.SetupBoard || data.phase == Phase.SetupFaction || data.phase == Phase.SetupAuction) {
if ( this.phaseBeforeSetupBuilding ) {
return data.players;
}
if ( data.phase == Phase.SetupBuilding || data.phase == Phase.SetupBooster || data.phase == Phase.SetupShip) {
return data.setup.map(bid => data.players[bid.player]);
return data.setup.map(faction => data.players.find( pl => pl.faction == faction));
}
return data.turnOrder.map(player => data.players[player]);
}
@ -43,7 +48,7 @@ export default class TurnOrder extends Vue {
}
isCurrentPlayer(pl: Player) {
return this.gameData.players[this.gameData.availableCommands?.[0]?.player] === pl;
return this.gameData.players[this.gameData.availableCommands?.[0]?.player] === pl && !(this.gameData.phase === Phase.SetupAuction);
}
stroke (pl: Player) {
@ -70,40 +75,45 @@ export default class TurnOrder extends Vue {
}
planet(player: Player, index: number) {
if (player.faction) { return factions.planet(player.faction) };
if (this.gameData.setup[index] && this.gameData.setup[index].faction) {
return factions.planet(this.gameData.setup[index].faction);
if (this.phaseBeforeSetupBuilding && this.gameData.setup[index]) {
return factions.planet(this.gameData.setup[index]);
}
if (player.faction) { return factions.planet(player.faction) };
return Planet.Lost;
}
initial(player: Player, index: number) {
if (this.phaseBeforeSetupBuilding && this.gameData.setup[index]) {
return this.gameData.setup[index][0].toUpperCase();
}
if (player.faction) {
return player.faction[0].toUpperCase();
}
if (this.gameData.setup[index] && this.gameData.setup[index].faction) {
return this.gameData.setup[index].faction[0].toUpperCase();
}
if (player.name) {
return player.name[0];
}
return "?";
}
name(player: Player, index: number) {
if (this.gameData.setup[index] && !isNull(this.gameData.setup[index].player)) {
if (player.name) {
return player.name.substring(0, 3);
if (this.phaseBeforeSetupBuilding ) {
if (this.gameData.phase === Phase.SetupAuction) {
player = this.gameData.players.find(pl => pl.faction == this.gameData.setup[index])
} else {
return "P" + (this.gameData.setup[index].player + 1);
}
return ""
}
}
if (player) {
if (player.name) {
return player.name.substring(0, 3);
} else {
return "P" + (player.player + 1);
};
}
return "?";
}
}