mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-07-14 10:16:16 +00:00
format codebase with prettier
This commit is contained in:
@@ -1,40 +1,51 @@
|
||||
import { consolex } from "../../Consolex";
|
||||
import {AllianceRequest, Execution, Game, Player, PlayerID} from "../../game/Game";
|
||||
import {
|
||||
AllianceRequest,
|
||||
Execution,
|
||||
Game,
|
||||
Player,
|
||||
PlayerID,
|
||||
} from "../../game/Game";
|
||||
|
||||
export class AllianceRequestExecution implements Execution {
|
||||
private active = true
|
||||
private mg: Game = null
|
||||
private requestor: Player;
|
||||
private recipient: Player
|
||||
private active = true;
|
||||
private mg: Game = null;
|
||||
private requestor: Player;
|
||||
private recipient: Player;
|
||||
|
||||
constructor(private requestorID: PlayerID, private recipientID: PlayerID) { }
|
||||
constructor(
|
||||
private requestorID: PlayerID,
|
||||
private recipientID: PlayerID,
|
||||
) {}
|
||||
|
||||
init(mg: Game, ticks: number): void {
|
||||
this.mg = mg
|
||||
this.requestor = mg.player(this.requestorID)
|
||||
this.recipient = mg.player(this.recipientID)
|
||||
init(mg: Game, ticks: number): void {
|
||||
this.mg = mg;
|
||||
this.requestor = mg.player(this.requestorID);
|
||||
this.recipient = mg.player(this.recipientID);
|
||||
}
|
||||
|
||||
tick(ticks: number): void {
|
||||
if (this.requestor.isAlliedWith(this.recipient)) {
|
||||
consolex.warn("already allied");
|
||||
} else if (
|
||||
this.requestor.recentOrPendingAllianceRequestWith(this.recipient)
|
||||
) {
|
||||
consolex.warn("recent or pending alliance request");
|
||||
} else {
|
||||
this.requestor.createAllianceRequest(this.recipient);
|
||||
}
|
||||
this.active = false;
|
||||
}
|
||||
|
||||
tick(ticks: number): void {
|
||||
if (this.requestor.isAlliedWith(this.recipient)) {
|
||||
consolex.warn('already allied')
|
||||
} else if (this.requestor.recentOrPendingAllianceRequestWith(this.recipient)) {
|
||||
consolex.warn('recent or pending alliance request')
|
||||
} else {
|
||||
this.requestor.createAllianceRequest(this.recipient)
|
||||
}
|
||||
this.active = false
|
||||
}
|
||||
owner(): Player {
|
||||
return null;
|
||||
}
|
||||
|
||||
owner(): Player {
|
||||
return null
|
||||
}
|
||||
isActive(): boolean {
|
||||
return this.active;
|
||||
}
|
||||
|
||||
isActive(): boolean {
|
||||
return this.active
|
||||
}
|
||||
|
||||
activeDuringSpawnPhase(): boolean {
|
||||
return false
|
||||
}
|
||||
}
|
||||
activeDuringSpawnPhase(): boolean {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,49 +1,61 @@
|
||||
import { consolex } from "../../Consolex";
|
||||
import { AllianceRequest, Execution, Game, Player, PlayerID } from "../../game/Game";
|
||||
import {
|
||||
AllianceRequest,
|
||||
Execution,
|
||||
Game,
|
||||
Player,
|
||||
PlayerID,
|
||||
} from "../../game/Game";
|
||||
|
||||
export class AllianceRequestReplyExecution implements Execution {
|
||||
private active = true
|
||||
private mg: Game = null
|
||||
private requestor: Player;
|
||||
private recipient: Player
|
||||
private active = true;
|
||||
private mg: Game = null;
|
||||
private requestor: Player;
|
||||
private recipient: Player;
|
||||
|
||||
constructor(private requestorID: PlayerID, private recipientID: PlayerID, private accept: boolean) { }
|
||||
constructor(
|
||||
private requestorID: PlayerID,
|
||||
private recipientID: PlayerID,
|
||||
private accept: boolean,
|
||||
) {}
|
||||
|
||||
init(mg: Game, ticks: number): void {
|
||||
this.mg = mg
|
||||
this.requestor = mg.player(this.requestorID)
|
||||
this.recipient = mg.player(this.recipientID)
|
||||
}
|
||||
init(mg: Game, ticks: number): void {
|
||||
this.mg = mg;
|
||||
this.requestor = mg.player(this.requestorID);
|
||||
this.recipient = mg.player(this.recipientID);
|
||||
}
|
||||
|
||||
tick(ticks: number): void {
|
||||
if (this.requestor.isAlliedWith(this.recipient)) {
|
||||
consolex.warn('already allied')
|
||||
tick(ticks: number): void {
|
||||
if (this.requestor.isAlliedWith(this.recipient)) {
|
||||
consolex.warn("already allied");
|
||||
} else {
|
||||
const request = this.requestor
|
||||
.outgoingAllianceRequests()
|
||||
.find((ar) => ar.recipient() == this.recipient);
|
||||
if (request == null) {
|
||||
consolex.warn("no alliance request found");
|
||||
} else {
|
||||
if (this.accept) {
|
||||
request.accept();
|
||||
this.requestor.updateRelation(this.recipient, 100);
|
||||
this.recipient.updateRelation(this.requestor, 100);
|
||||
} else {
|
||||
const request = this.requestor.outgoingAllianceRequests().find(ar => ar.recipient() == this.recipient)
|
||||
if (request == null) {
|
||||
consolex.warn('no alliance request found')
|
||||
} else {
|
||||
if (this.accept) {
|
||||
request.accept()
|
||||
this.requestor.updateRelation(this.recipient, 100)
|
||||
this.recipient.updateRelation(this.requestor, 100)
|
||||
} else {
|
||||
request.reject()
|
||||
}
|
||||
}
|
||||
request.reject();
|
||||
}
|
||||
this.active = false
|
||||
}
|
||||
}
|
||||
this.active = false;
|
||||
}
|
||||
|
||||
owner(): Player {
|
||||
return null
|
||||
}
|
||||
owner(): Player {
|
||||
return null;
|
||||
}
|
||||
|
||||
isActive(): boolean {
|
||||
return this.active
|
||||
}
|
||||
isActive(): boolean {
|
||||
return this.active;
|
||||
}
|
||||
|
||||
activeDuringSpawnPhase(): boolean {
|
||||
return false
|
||||
}
|
||||
}
|
||||
activeDuringSpawnPhase(): boolean {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,45 +1,54 @@
|
||||
import { consolex } from "../../Consolex";
|
||||
import { AllianceRequest, Execution, Game, Player, PlayerID } from "../../game/Game";
|
||||
import {
|
||||
AllianceRequest,
|
||||
Execution,
|
||||
Game,
|
||||
Player,
|
||||
PlayerID,
|
||||
} from "../../game/Game";
|
||||
|
||||
export class BreakAllianceExecution implements Execution {
|
||||
private active = true
|
||||
private requestor: Player;
|
||||
private recipient: Player
|
||||
private mg: Game
|
||||
private active = true;
|
||||
private requestor: Player;
|
||||
private recipient: Player;
|
||||
private mg: Game;
|
||||
|
||||
constructor(private requestorID: PlayerID, private recipientID: PlayerID) { }
|
||||
constructor(
|
||||
private requestorID: PlayerID,
|
||||
private recipientID: PlayerID,
|
||||
) {}
|
||||
|
||||
init(mg: Game, ticks: number): void {
|
||||
this.requestor = mg.player(this.requestorID)
|
||||
this.recipient = mg.player(this.recipientID)
|
||||
this.mg = mg
|
||||
}
|
||||
init(mg: Game, ticks: number): void {
|
||||
this.requestor = mg.player(this.requestorID);
|
||||
this.recipient = mg.player(this.recipientID);
|
||||
this.mg = mg;
|
||||
}
|
||||
|
||||
tick(ticks: number): void {
|
||||
const alliance = this.requestor.allianceWith(this.recipient)
|
||||
if (alliance == null) {
|
||||
consolex.warn('cant break alliance, not allied')
|
||||
} else {
|
||||
this.requestor.breakAlliance(alliance)
|
||||
this.recipient.updateRelation(this.requestor, -200)
|
||||
for (const player of this.mg.players()) {
|
||||
if (player != this.requestor) {
|
||||
player.updateRelation(this.requestor, -40)
|
||||
}
|
||||
}
|
||||
tick(ticks: number): void {
|
||||
const alliance = this.requestor.allianceWith(this.recipient);
|
||||
if (alliance == null) {
|
||||
consolex.warn("cant break alliance, not allied");
|
||||
} else {
|
||||
this.requestor.breakAlliance(alliance);
|
||||
this.recipient.updateRelation(this.requestor, -200);
|
||||
for (const player of this.mg.players()) {
|
||||
if (player != this.requestor) {
|
||||
player.updateRelation(this.requestor, -40);
|
||||
}
|
||||
this.active = false
|
||||
}
|
||||
}
|
||||
this.active = false;
|
||||
}
|
||||
|
||||
owner(): Player {
|
||||
return null
|
||||
}
|
||||
owner(): Player {
|
||||
return null;
|
||||
}
|
||||
|
||||
isActive(): boolean {
|
||||
return this.active
|
||||
}
|
||||
isActive(): boolean {
|
||||
return this.active;
|
||||
}
|
||||
|
||||
activeDuringSpawnPhase(): boolean {
|
||||
return false
|
||||
}
|
||||
}
|
||||
activeDuringSpawnPhase(): boolean {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user