mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-21 07:50:45 +00:00
better troop addition
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
* fix conquer expansion DONE
|
||||
* perf improvements on graphics (only draw images to canvas on ticks) DONE
|
||||
* double join lobby bug DONE
|
||||
* render player info efficiently
|
||||
* better troop addition logic
|
||||
* render player info efficiently DONE 8/11/2024
|
||||
* better troop addition logic DONE 8/11/2024
|
||||
* better expansion, add back directed expansion
|
||||
* use pastel theme for territories
|
||||
* improve front page
|
||||
|
||||
@@ -204,7 +204,7 @@ export class ClientGame {
|
||||
type: "attack",
|
||||
attackerID: this.myPlayer.id(),
|
||||
targetID: targetID,
|
||||
troops: 2000,
|
||||
troops: this.myPlayer.troops() / 5,
|
||||
targetX: cell.x,
|
||||
targetY: cell.y
|
||||
}
|
||||
|
||||
+1
-1
@@ -137,7 +137,7 @@ export interface Game {
|
||||
export interface MutableGame extends Game {
|
||||
player(id: PlayerID): MutablePlayer
|
||||
players(): MutablePlayer[]
|
||||
addPlayer(playerInfo: PlayerInfo): MutablePlayer
|
||||
addPlayer(playerInfo: PlayerInfo, troops: number): MutablePlayer
|
||||
executions(): Execution[]
|
||||
removeInactiveExecutions(): void
|
||||
removeExecution(exec: Execution)
|
||||
|
||||
@@ -256,10 +256,10 @@ export class GameImpl implements MutableGame {
|
||||
return this.player(id)
|
||||
}
|
||||
|
||||
addPlayer(playerInfo: PlayerInfo): MutablePlayer {
|
||||
addPlayer(playerInfo: PlayerInfo, troops: number): MutablePlayer {
|
||||
let id = this.idCounter
|
||||
this.idCounter++
|
||||
let player = new PlayerImpl(this, id, playerInfo, 10000)
|
||||
let player = new PlayerImpl(this, id, playerInfo, troops)
|
||||
this._players.set(id, player)
|
||||
this.eventBus.emit(new PlayerEvent(player))
|
||||
return player
|
||||
|
||||
@@ -12,7 +12,15 @@ export class PlayerExecution implements Execution {
|
||||
}
|
||||
|
||||
tick(ticks: number) {
|
||||
this.player.addTroops(Math.sqrt(this.player.numTilesOwned() * this.player.troops() + 1000) / 1000)
|
||||
let toAdd = Math.sqrt(this.player.numTilesOwned() * this.player.troops()) / 5
|
||||
|
||||
const max = Math.sqrt(this.player.numTilesOwned()) * 100 + 1000
|
||||
const ratio = 1 - this.player.troops() / max
|
||||
toAdd *= ratio * ratio * ratio
|
||||
this.player.addTroops(
|
||||
Math.max(2, toAdd)
|
||||
);
|
||||
this.player.setTroops(Math.min(this.player.troops(), max))
|
||||
}
|
||||
|
||||
owner(): MutablePlayer {
|
||||
|
||||
@@ -22,7 +22,7 @@ export class SpawnExecution implements Execution {
|
||||
if (!this.isActive()) {
|
||||
return
|
||||
}
|
||||
const player = this.gs.addPlayer(this.playerInfo)
|
||||
const player = this.gs.addPlayer(this.playerInfo, 1000)
|
||||
getSpawnCells(this.gs, this.cell).forEach(c => {
|
||||
console.log('conquering cell')
|
||||
player.conquer(this.gs.tile(c))
|
||||
|
||||
Reference in New Issue
Block a user