when attacking by boat, attack execution only starts from boat pixel

This commit is contained in:
evanpelle
2024-09-04 20:06:20 -07:00
parent 2082b229b4
commit a92bebce05
8 changed files with 22 additions and 10 deletions
+1 -1
View File
@@ -92,7 +92,7 @@
* make names bigger DONE 9/3/2024
* boats leave trails DONE 9/3/2024
* send boat even if touching DONE 9/4/2024
* when attacking by boat, attack execution only starts from boat pixel
* when attacking by boat, attack execution only starts from boat pixel DONE 9/4/2024
* directed expansion
* more random names for game id & client id
* Make fake humans
+2
View File
@@ -286,6 +286,8 @@ export class ClientGame {
attackerID: this.myPlayer.id(),
targetID: targetID,
troops: troops,
sourceX: null,
sourceY: null,
targetX: cell.x,
targetY: cell.y
})
+5 -2
View File
@@ -24,6 +24,7 @@ export type ClientIntentMessage = z.infer<typeof ClientIntentMessageSchema>
export type ClientJoinMessage = z.infer<typeof ClientJoinMessageSchema>
export type ClientLeaveMessage = z.infer<typeof ClientLeaveMessageSchema>
// TODO: create Cell schema
export interface Lobby {
id: string;
@@ -42,8 +43,10 @@ export const AttackIntentSchema = BaseIntentSchema.extend({
attackerID: z.string(),
targetID: z.string().nullable(),
troops: z.number(),
targetX: z.number(),
targetY: z.number()
sourceX: z.number().nullable(),
sourceY: z.number().nullable(),
targetX: z.number().nullable(),
targetY: z.number().nullable()
});
+1 -1
View File
@@ -28,7 +28,7 @@ export const devConfig = new class extends DefaultConfig {
troopAdditionRate(player: Player): number {
if (player.isBot()) {
return 10000
return 100000
} else {
return 100000
}
+7 -4
View File
@@ -17,6 +17,7 @@ export class AttackExecution implements Execution {
private troops: number,
private _ownerID: PlayerID,
private targetID: PlayerID | null,
private sourceCell: Cell | null,
private targetCell: Cell | null,
) { }
@@ -54,16 +55,18 @@ export class AttackExecution implements Execution {
}
}
// Existing attack on same target, add troops
if (otherAttack._owner == this._owner && otherAttack.targetID == this.targetID) {
if (otherAttack._owner == this._owner && otherAttack.targetID == this.targetID && this.sourceCell == otherAttack.sourceCell) {
otherAttack.troops += this.troops
otherAttack.refreshToConquer()
this.active = false
return
}
}
}
this.refreshToConquer()
if (this.sourceCell != null) {
this.addNeighbors(mg.tile(this.sourceCell))
} else {
this.refreshToConquer()
}
}
private refreshToConquer() {
+1 -1
View File
@@ -118,7 +118,7 @@ export class BoatAttackExecution implements Execution {
return
}
this.attacker.conquer(this.dst)
this.mg.addExecution(new AttackExecution(this.troops, this.attacker.id(), this.targetID, null))
this.mg.addExecution(new AttackExecution(this.troops, this.attacker.id(), this.targetID, this.dst.cell(), null))
this.boat.delete()
this.active = false
return
+1
View File
@@ -67,6 +67,7 @@ export class BotExecution implements Execution {
this.bot.troops() / 20,
this.bot.id(),
toAttack.isPlayer() ? toAttack.id() : null,
null,
null
))
}
+4 -1
View File
@@ -22,11 +22,14 @@ export class Executor {
createExec(intent: Intent): Execution {
if (intent.type == "attack") {
const source: Cell | null = intent.sourceX != null && intent.sourceY != null ? new Cell(intent.sourceX, intent.sourceY) : null
const target: Cell | null = intent.targetX != null && intent.targetY != null ? new Cell(intent.targetX, intent.targetY) : null
return new AttackExecution(
intent.troops,
intent.attackerID,
intent.targetID,
new Cell(intent.targetX, intent.targetY)
source,
target,
)
} else if (intent.type == "spawn") {
return new SpawnExecution(