mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-28 06:04:33 +00:00
store name, anon has random suffix, color a hash of name
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import {info} from "console"
|
||||
import {Config} from "./configuration/Config"
|
||||
import {GameEvent} from "./EventBus"
|
||||
import {ClientID, GameID} from "./Schemas"
|
||||
|
||||
@@ -50,8 +50,8 @@ export interface Config {
|
||||
|
||||
export interface Theme {
|
||||
playerInfoColor(id: PlayerID): Colord;
|
||||
territoryColor(id: PlayerID): Colord;
|
||||
borderColor(id: PlayerID): Colord;
|
||||
territoryColor(playerInfo: PlayerInfo): Colord;
|
||||
borderColor(playerInfo: PlayerInfo): Colord;
|
||||
terrainColor(tile: Tile): Colord;
|
||||
backgroundColor(): Colord;
|
||||
font(): string;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import {Colord, colord, random} from "colord";
|
||||
import {PlayerID, TerrainType, Tile} from "../Game";
|
||||
import {PlayerID, PlayerInfo, TerrainType, Tile} from "../Game";
|
||||
import {Theme} from "./Config";
|
||||
import {time} from "console";
|
||||
import {PseudoRandom} from "../PseudoRandom";
|
||||
@@ -119,12 +119,12 @@ export const pastelTheme = new class implements Theme {
|
||||
return colord({r: 50, g: 50, b: 50})
|
||||
}
|
||||
|
||||
territoryColor(id: PlayerID): Colord {
|
||||
return this.territoryColors[simpleHash(id) % this.territoryColors.length]
|
||||
territoryColor(playerInfo: PlayerInfo): Colord {
|
||||
return this.territoryColors[simpleHash(playerInfo.name) % this.territoryColors.length]
|
||||
}
|
||||
|
||||
borderColor(id: PlayerID): Colord {
|
||||
const tc = this.territoryColor(id).rgba;
|
||||
borderColor(playerInfo: PlayerInfo): Colord {
|
||||
const tc = this.territoryColor(playerInfo).rgba;
|
||||
return colord({
|
||||
r: Math.max(tc.r - 40, 0),
|
||||
g: Math.max(tc.g - 40, 0),
|
||||
|
||||
Reference in New Issue
Block a user