balancing
This commit is contained in:
parent
01153a1db3
commit
c0ec36ba82
@ -41,19 +41,19 @@
|
|||||||
<div>🍽️ Verbrauch:</div>
|
<div>🍽️ Verbrauch:</div>
|
||||||
<ul>
|
<ul>
|
||||||
@for (item of consumedItems; track $index) {
|
@for (item of consumedItems; track $index) {
|
||||||
<li>{{ item.type }}: {{ item.demandRate * planet.population | number:'0.0-1' }}/s</li>
|
<li>{{ item.type }}: {{ item.demandRate * planet.population | number:'0.0-2' }}/s</li>
|
||||||
}
|
}
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- <div class="ui-section">
|
<div class="ui-section">
|
||||||
<div>📦 Anfrage:</div>
|
<div>📦 Anfrage:</div>
|
||||||
<ul>
|
<ul>
|
||||||
@for (item of requested; track $index) {
|
@for (item of requested; track $index) {
|
||||||
<li>{{ item.type }}: {{ item.amount | number:'0.0-1' }}/s</li>
|
<li>{{ item.type }}: {{ item.amount | number:'0.0-1' }}/s</li>
|
||||||
}
|
}
|
||||||
</ul>
|
</ul>
|
||||||
</div> -->
|
</div>
|
||||||
|
|
||||||
@if (goodsInTransit.length > 0) {
|
@if (goodsInTransit.length > 0) {
|
||||||
<div class="ui-section">
|
<div class="ui-section">
|
||||||
@ -92,6 +92,7 @@
|
|||||||
|
|
||||||
<button class="button" (click)="upgradeProduction()" [disabled]="!canUpgradeProduction"
|
<button class="button" (click)="upgradeProduction()" [disabled]="!canUpgradeProduction"
|
||||||
matTooltip="Kosten: {{this.planet.productionLvlUpgradeCost | number}} Credits">Produktion aufwerten</button>
|
matTooltip="Kosten: {{this.planet.productionLvlUpgradeCost | number}} Credits">Produktion aufwerten</button>
|
||||||
|
<button (click)="buildFactory()" >Fabrik bauen</button>
|
||||||
} @else {
|
} @else {
|
||||||
<button class="button" (click)="buildHarbour()"
|
<button class="button" (click)="buildHarbour()"
|
||||||
matTooltip="Baue einen Raumhafen um den Planeten anfliegen zu können."
|
matTooltip="Baue einen Raumhafen um den Planeten anfliegen zu können."
|
||||||
|
|||||||
@ -111,5 +111,8 @@ export class PlanetDialogComponent {
|
|||||||
return this.planet.requestedGoods;
|
return this.planet.requestedGoods;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
buildFactory() {
|
||||||
|
this.planet.buildFactory();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -5,6 +5,7 @@ import { CdkDrag, CdkDragDrop, CdkDragHandle, CdkDropList, moveItemInArray, tran
|
|||||||
import { Planet } from '../../../model/planet.model';
|
import { Planet } from '../../../model/planet.model';
|
||||||
import { ShipConfig } from '../../../model/ships/ship.model';
|
import { ShipConfig } from '../../../model/ships/ship.model';
|
||||||
import { FormsModule } from '@angular/forms';
|
import { FormsModule } from '@angular/forms';
|
||||||
|
import { SHIP_DATA } from '../../../model/ships/ship.type';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-buy',
|
selector: 'app-buy',
|
||||||
@ -18,42 +19,18 @@ export class BuyComponent {
|
|||||||
availablePlanets: Planet[] = this.gameService.planets.filter(p => p.hasHarbour);
|
availablePlanets: Planet[] = this.gameService.planets.filter(p => p.hasHarbour);
|
||||||
selectedPlanets: Planet[] = [];
|
selectedPlanets: Planet[] = [];
|
||||||
config: ShipConfig = {
|
config: ShipConfig = {
|
||||||
name: 'Pioneer-01',
|
...SHIP_DATA.light,
|
||||||
acceleration: 428,
|
planetRoute: []
|
||||||
cargoSize: 25,
|
|
||||||
cost: 0.6,
|
|
||||||
loadingSpeed: 15,
|
|
||||||
maxSpeed: 300,
|
|
||||||
planetRoute: [],
|
|
||||||
buyCost: 3000,
|
|
||||||
desciption: 'Ein kleines, schnelles Schiff. Es hat wenig Platz für Ladung, lädt aber schnell und ist sehr wendig.',
|
|
||||||
texture: 'swift-hauler'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
config2: ShipConfig = {
|
config2: ShipConfig = {
|
||||||
name: 'Colony Carrier',
|
...SHIP_DATA.medium,
|
||||||
acceleration: 63,
|
|
||||||
cargoSize: 70,
|
|
||||||
cost: 1.6,
|
|
||||||
loadingSpeed: 20,
|
|
||||||
maxSpeed: 200,
|
|
||||||
planetRoute: [],
|
planetRoute: [],
|
||||||
buyCost: 8000,
|
|
||||||
desciption: 'Eine größere Version von der Pioneer-01. Der größere Frachtraum geht zu Lasten der Beschleunigung und Maximalgeschwindigkeit.',
|
|
||||||
texture: 'colony-carrier'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
config3: ShipConfig = {
|
config3: ShipConfig = {
|
||||||
name: 'Industrial Tanker',
|
...SHIP_DATA.heavy,
|
||||||
acceleration: 8,
|
planetRoute: []
|
||||||
cargoSize: 300,
|
|
||||||
cost: 3.8,
|
|
||||||
loadingSpeed: 11,
|
|
||||||
maxSpeed: 600,
|
|
||||||
planetRoute: [],
|
|
||||||
buyCost: 14000,
|
|
||||||
desciption: 'Ein großes behäbiges Schiff. Es wird durchaus schnell, beschleunigt aber sehr langsam und erreicht die Spitzengeschwindigkeit nur selten.',
|
|
||||||
texture: 'industrial-tanker'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
selectedModel = '1';
|
selectedModel = '1';
|
||||||
|
|||||||
@ -9,8 +9,9 @@ export const PLANETCONFIGS: { x: number, y: number, texture: string, config: Pla
|
|||||||
config: {
|
config: {
|
||||||
name: 'Terra Nova',
|
name: 'Terra Nova',
|
||||||
initialGoods: [
|
initialGoods: [
|
||||||
{ type: GoodType.Wasser, amount: 10 },
|
{ type: GoodType.Wasser, amount: 10, productionBonus: 0.18 },
|
||||||
{ type: GoodType.Nahrung, amount: 10, productionBonus: 2.6 },
|
{ type: GoodType.Nahrung, amount: 10, productionBonus: 2.3 },
|
||||||
|
{ type: GoodType.Erz, amount: 10, productionBonus: 0 },
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -21,11 +22,9 @@ export const PLANETCONFIGS: { x: number, y: number, texture: string, config: Pla
|
|||||||
config: {
|
config: {
|
||||||
name: 'Mechanica Prime',
|
name: 'Mechanica Prime',
|
||||||
initialGoods: [
|
initialGoods: [
|
||||||
{ type: GoodType.Wasser, amount: 10 },
|
{ type: GoodType.Wasser, amount: 10, productionBonus: 0.07 },
|
||||||
{ type: GoodType.Nahrung, amount: 10 },
|
{ type: GoodType.Nahrung, amount: 10, productionBonus: 0.05 },
|
||||||
{ type: GoodType.Metall, amount: 10, productionBonus: 3 },
|
{ type: GoodType.Erz, amount: 10, productionBonus: 1.5 },
|
||||||
{ type: GoodType.Bauteile, amount: 10, productionBonus: 1.3 },
|
|
||||||
{ type: GoodType.Elektronik, amount: 10 }
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -36,9 +35,9 @@ export const PLANETCONFIGS: { x: number, y: number, texture: string, config: Pla
|
|||||||
config: {
|
config: {
|
||||||
name: 'Aqualis',
|
name: 'Aqualis',
|
||||||
initialGoods: [
|
initialGoods: [
|
||||||
{ type: GoodType.Wasser, amount: 200, productionBonus: 4 },
|
{ type: GoodType.Wasser, amount: 10, productionBonus: 2.5 },
|
||||||
{ type: GoodType.Nahrung, amount: 10 },
|
{ type: GoodType.Nahrung, amount: 10, productionBonus: 0.06 },
|
||||||
{ type: GoodType.Treibstoff, amount: 10 }
|
{ type: GoodType.Erz, amount: 10, productionBonus: 0.2 }
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -49,11 +48,9 @@ export const PLANETCONFIGS: { x: number, y: number, texture: string, config: Pla
|
|||||||
config: {
|
config: {
|
||||||
name: 'Ferron',
|
name: 'Ferron',
|
||||||
initialGoods: [
|
initialGoods: [
|
||||||
{ type: GoodType.Wasser, amount: 10 },
|
{ type: GoodType.Wasser, amount: 10, productionBonus: 0.02 },
|
||||||
{ type: GoodType.Nahrung, amount: 10 },
|
{ type: GoodType.Nahrung, amount: 10, productionBonus: 0.03 },
|
||||||
{ type: GoodType.Erz, amount: 10, productionBonus: 1.8 },
|
{ type: GoodType.Erz, amount: 10, productionBonus: 2.2 }
|
||||||
{ type: GoodType.Metall, amount: 10 },
|
|
||||||
{ type: GoodType.Treibstoff, amount: 10 }
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -64,9 +61,9 @@ export const PLANETCONFIGS: { x: number, y: number, texture: string, config: Pla
|
|||||||
config: {
|
config: {
|
||||||
name: 'Novus Reach',
|
name: 'Novus Reach',
|
||||||
initialGoods: [
|
initialGoods: [
|
||||||
{ type: GoodType.Nahrung, amount: 10, productionBonus: 1.5 },
|
{ type: GoodType.Wasser, amount: 10, productionBonus: 1.6 },
|
||||||
{ type: GoodType.Wasser, amount: 10 },
|
{ type: GoodType.Nahrung, amount: 10, productionBonus: 0.07 },
|
||||||
{ type: GoodType.Bauteile, amount: 10 }
|
{ type: GoodType.Erz, amount: 10, productionBonus: 0.1 }
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -78,9 +75,9 @@ export const PLANETCONFIGS: { x: number, y: number, texture: string, config: Pla
|
|||||||
config: {
|
config: {
|
||||||
name: 'Volaris',
|
name: 'Volaris',
|
||||||
initialGoods: [
|
initialGoods: [
|
||||||
{ type: GoodType.Nahrung, amount: 10 },
|
{ type: GoodType.Wasser, amount: 10, productionBonus: 0.25 },
|
||||||
{ type: GoodType.Wasser, amount: 10, productionBonus: 1.9 },
|
{ type: GoodType.Nahrung, amount: 10, productionBonus: 2.2 },
|
||||||
{ type: GoodType.Bauteile, amount: 10 }
|
{ type: GoodType.Erz, amount: 10, productionBonus: 0 }
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -91,10 +88,10 @@ export const PLANETCONFIGS: { x: number, y: number, texture: string, config: Pla
|
|||||||
config: {
|
config: {
|
||||||
name: 'Ignis Prime',
|
name: 'Ignis Prime',
|
||||||
initialGoods: [
|
initialGoods: [
|
||||||
{ type: GoodType.Wasser, amount: 10 },
|
{ type: GoodType.Wasser, amount: 10, productionBonus: 1.3 },
|
||||||
{ type: GoodType.Nahrung, amount: 10 },
|
{ type: GoodType.Nahrung, amount: 10, productionBonus: 0.06 },
|
||||||
{ type: GoodType.Treibstoff, amount: 10, productionBonus: 0.8 }
|
{ type: GoodType.Erz, amount: 10, productionBonus: 0.1 }
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
]
|
]
|
||||||
37
src/app/model/factories/factory.model.ts
Normal file
37
src/app/model/factories/factory.model.ts
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
import { GoodConfig, GOODS_DATA } from "../goods/good-config";
|
||||||
|
import { GoodType } from "../goods/good-type.enum";
|
||||||
|
import { Planet } from "../planet.model";
|
||||||
|
|
||||||
|
export class Factory {
|
||||||
|
product: GoodConfig;
|
||||||
|
private type: GoodType;
|
||||||
|
|
||||||
|
private planet: Planet;
|
||||||
|
|
||||||
|
|
||||||
|
constructor(config: FactoryConfig) {
|
||||||
|
this.product = GOODS_DATA[config.type];
|
||||||
|
this.type = config.type;
|
||||||
|
this.planet = config.planet;
|
||||||
|
|
||||||
|
const existing = this.planet.getGood(this.type);
|
||||||
|
if (existing) {
|
||||||
|
existing.productionRate = this.product.baseProduction;
|
||||||
|
} else {
|
||||||
|
this.planet.addGood({
|
||||||
|
amount: 0,
|
||||||
|
demandRate: this.product.baseDemand,
|
||||||
|
productionRate: this.product.baseProduction,
|
||||||
|
productionStorage: this.product.storageLimit,
|
||||||
|
type: this.type
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface FactoryConfig {
|
||||||
|
type: GoodType;
|
||||||
|
planet: Planet;
|
||||||
|
}
|
||||||
@ -5,14 +5,15 @@ export interface GoodConfig {
|
|||||||
baseDemand: number; // pro Sekunde
|
baseDemand: number; // pro Sekunde
|
||||||
storageLimit: number;
|
storageLimit: number;
|
||||||
isRawResource: boolean;
|
isRawResource: boolean;
|
||||||
|
dependsOn?: GoodType[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export const GOODS_DATA: Record<GoodType, GoodConfig> = {
|
export const GOODS_DATA: Record<GoodType, GoodConfig> = {
|
||||||
[GoodType.Erz]: { baseProduction: 1.0, baseDemand: 0.005, storageLimit: 200, isRawResource: true },
|
[GoodType.Wasser]: { baseProduction: 1, baseDemand: 0.0012, storageLimit: 500, isRawResource: true },
|
||||||
[GoodType.Wasser]: { baseProduction: 1, baseDemand: 0.0075, storageLimit: 500, isRawResource: true },
|
[GoodType.Nahrung]: { baseProduction: 1, baseDemand: 0.001, storageLimit: 300, isRawResource: true },
|
||||||
[GoodType.Nahrung]: { baseProduction: 1, baseDemand: 0.005, storageLimit: 300, isRawResource: true },
|
[GoodType.Erz]: { baseProduction: 1.0, baseDemand: 0.0005, storageLimit: 200, isRawResource: true },
|
||||||
[GoodType.Metall]: { baseProduction: 1, baseDemand: 0.005, storageLimit: 300, isRawResource: false },
|
[GoodType.Metall]: { baseProduction: 0.7, baseDemand: 0.003, storageLimit: 300, isRawResource: false, dependsOn: [GoodType.Erz, GoodType.Wasser] },
|
||||||
[GoodType.Treibstoff]: { baseProduction: 1, baseDemand: 0.002, storageLimit: 150, isRawResource: false },
|
[GoodType.Treibstoff]: { baseProduction: 0.5, baseDemand: 0.002, storageLimit: 150, isRawResource: false, dependsOn: [GoodType.Wasser] },
|
||||||
[GoodType.Elektronik]: { baseProduction: 1, baseDemand: 0.005, storageLimit: 100, isRawResource: false },
|
[GoodType.Elektronik]: { baseProduction: 0.3, baseDemand: 0.001, storageLimit: 100, isRawResource: false, dependsOn: [GoodType.Bauteile, GoodType.Treibstoff] },
|
||||||
[GoodType.Bauteile]: { baseProduction: 1, baseDemand: 0.005, storageLimit: 100, isRawResource: false }
|
[GoodType.Bauteile]: { baseProduction: 0.5, baseDemand: 0.0015, storageLimit: 100, isRawResource: false, dependsOn: [GoodType.Metall] }
|
||||||
};
|
};
|
||||||
@ -4,14 +4,16 @@ import { GOODS_DATA } from "./goods/good-config";
|
|||||||
import { Good } from "./goods/good.interface";
|
import { Good } from "./goods/good.interface";
|
||||||
import { Ship } from "./ships/ship.model";
|
import { Ship } from "./ships/ship.model";
|
||||||
import { GameService } from "../service/game.service";
|
import { GameService } from "../service/game.service";
|
||||||
|
import { Factory } from "./factories/factory.model";
|
||||||
|
|
||||||
export class Planet {
|
export class Planet {
|
||||||
public population: number = 100;
|
public population: number = 100;
|
||||||
public name: string = "";
|
public name: string = "";
|
||||||
public image: string;
|
public image: string;
|
||||||
|
|
||||||
|
public updateModifier = 1; // für Simulation
|
||||||
private goods: Map<string, Good> = new Map();
|
private goods: Map<string, Good> = new Map();
|
||||||
private updateSubscription = interval(1000).subscribe(() => {this.update(1)}); // alle 5s
|
private updateSubscription = interval(1000).subscribe(() => {this.update(this.updateModifier)}); // alle 5s
|
||||||
|
|
||||||
public isGrowing: boolean = false;
|
public isGrowing: boolean = false;
|
||||||
private populationGrowthRate = 0.002; // Basiswachstum pro Tick (%)
|
private populationGrowthRate = 0.002; // Basiswachstum pro Tick (%)
|
||||||
@ -20,9 +22,11 @@ export class Planet {
|
|||||||
|
|
||||||
private productionLevel: Map<GoodType, number> = new Map();
|
private productionLevel: Map<GoodType, number> = new Map();
|
||||||
private dockedShips: Ship[] = [];
|
private dockedShips: Ship[] = [];
|
||||||
public dockCapacity: number = 0;
|
public dockCapacity: number = 1;
|
||||||
private shipsWaitingForDocking: Ship[] = [];
|
private shipsWaitingForDocking: Ship[] = [];
|
||||||
|
|
||||||
|
private factory: Factory | undefined;
|
||||||
|
|
||||||
private gameService: GameService;
|
private gameService: GameService;
|
||||||
|
|
||||||
hasHarbour = false;
|
hasHarbour = false;
|
||||||
@ -54,10 +58,11 @@ export class Planet {
|
|||||||
productionStorage: base.storageLimit
|
productionStorage: base.storageLimit
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
console.log(this.getAllGoods())
|
||||||
this.updatePopulation(0)
|
this.updatePopulation(0)
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.dockCapacity = 1;
|
this.getStatus();
|
||||||
}, 10000)
|
}, 10000)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -71,28 +76,28 @@ export class Planet {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case GoodType.Bauteile:
|
case GoodType.Bauteile:
|
||||||
if (this.population > 500) {
|
if (this.population > 700) {
|
||||||
good.demandRate = GOODS_DATA.Bauteile.baseDemand
|
good.demandRate = GOODS_DATA.Bauteile.baseDemand
|
||||||
} else {
|
} else {
|
||||||
good.demandRate = 0;
|
good.demandRate = 0;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case GoodType.Elektronik:
|
case GoodType.Elektronik:
|
||||||
if (this.population > 700) {
|
if (this.population > 900) {
|
||||||
good.demandRate = GOODS_DATA.Elektronik.baseDemand
|
good.demandRate = GOODS_DATA.Elektronik.baseDemand
|
||||||
} else {
|
} else {
|
||||||
good.demandRate = 0;
|
good.demandRate = 0;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case GoodType.Metall:
|
case GoodType.Metall:
|
||||||
if (this.population > 750) {
|
if (this.population > 350) {
|
||||||
good.demandRate = GOODS_DATA.Metall.baseDemand
|
good.demandRate = GOODS_DATA.Metall.baseDemand
|
||||||
} else {
|
} else {
|
||||||
good.demandRate = 0;
|
good.demandRate = 0;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case GoodType.Treibstoff:
|
case GoodType.Treibstoff:
|
||||||
if (this.population > 900) {
|
if (this.population > 500) {
|
||||||
good.demandRate = GOODS_DATA.Treibstoff.baseDemand
|
good.demandRate = GOODS_DATA.Treibstoff.baseDemand
|
||||||
} else {
|
} else {
|
||||||
good.demandRate = 0;
|
good.demandRate = 0;
|
||||||
@ -103,19 +108,37 @@ export class Planet {
|
|||||||
|
|
||||||
|
|
||||||
private update(seconds: number): void {
|
private update(seconds: number): void {
|
||||||
|
|
||||||
this.goods.forEach((good: Good, key: string) => {
|
this.goods.forEach((good: Good, key: string) => {
|
||||||
|
|
||||||
|
|
||||||
this.adjustPopulationDemands(good)
|
this.adjustPopulationDemands(good)
|
||||||
|
const base = GOODS_DATA[good.type];
|
||||||
const lvlMultiplier = this.productionLevel.get(good.type) ?? 1;
|
const lvlMultiplier = this.productionLevel.get(good.type) ?? 1;
|
||||||
good.amount += good.productionRate * seconds * lvlMultiplier;
|
|
||||||
|
|
||||||
// Min 0
|
if (base.isRawResource) {
|
||||||
good.amount = Math.max(0, good.amount);
|
|
||||||
if (good.productionRate && good.productionStorage) {
|
good.amount += good.productionRate * seconds * lvlMultiplier;
|
||||||
good.amount = Math.min(good.amount, good.productionStorage)
|
|
||||||
|
// Min 0
|
||||||
|
good.amount = Math.max(0, good.amount);
|
||||||
|
if (good.productionRate && good.productionStorage) {
|
||||||
|
good.amount = Math.min(good.amount, good.productionStorage)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (good.productionRate == 0) { return; }
|
||||||
|
const depends = base.dependsOn;
|
||||||
|
if (!depends) { return; }
|
||||||
|
const depending = this.getAllGoods().filter(g => depends.includes(g.type));
|
||||||
|
const amount = good.productionRate * seconds * lvlMultiplier;
|
||||||
|
if (depending.some(d => d.amount < seconds * lvlMultiplier)) { return; }
|
||||||
|
|
||||||
|
depending.map(d => {
|
||||||
|
d.amount -= seconds * lvlMultiplier;
|
||||||
|
});
|
||||||
|
good.amount += amount;
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
this.updatePopulation(seconds)
|
this.updatePopulation(seconds)
|
||||||
@ -155,7 +178,7 @@ export class Planet {
|
|||||||
get requestedGoods(): TradeInstance[] {
|
get requestedGoods(): TradeInstance[] {
|
||||||
const result: TradeInstance[] = [];
|
const result: TradeInstance[] = [];
|
||||||
|
|
||||||
const goods = this.getAllGoods().filter(g => !g.productionRate && g.demandRate);
|
const goods = this.getAllGoods().filter(g => g.demandRate);
|
||||||
for (let good of goods) {
|
for (let good of goods) {
|
||||||
const demandPerSecond = good.demandRate * this.population;
|
const demandPerSecond = good.demandRate * this.population;
|
||||||
const demand = this.demandSecondsBuffer * demandPerSecond;
|
const demand = this.demandSecondsBuffer * demandPerSecond;
|
||||||
@ -171,7 +194,7 @@ export class Planet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
result.push({
|
result.push({
|
||||||
amount: demand * 5, // Request 3x buffer amount
|
amount: demand * 5 - good.amount - inTransit, // Request 3x buffer amount
|
||||||
type: good.type,
|
type: good.type,
|
||||||
target: this.name,
|
target: this.name,
|
||||||
})
|
})
|
||||||
@ -181,7 +204,7 @@ export class Planet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
get offeredGoods(): TradeInstance[] {
|
get offeredGoods(): TradeInstance[] {
|
||||||
return this.getAllGoods().filter(g => g.productionRate && g.amount).map(g => { return { type: g.type, amount: g.amount - (g.demandRate * this.population * this.demandSecondsBuffer), target: this.name }}).filter(g => g.amount > 0)
|
return this.getAllGoods().filter(g => g.productionRate && g.amount).map(g => { return { type: g.type, amount: g.amount - (g.demandRate * this.population * (this.demandSecondsBuffer * 1.2)), target: this.name }}).filter(g => g.amount > 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
request(demandedGood: {type: GoodType, amount: number}) {
|
request(demandedGood: {type: GoodType, amount: number}) {
|
||||||
@ -226,12 +249,6 @@ export class Planet {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// if (this.isGrowing) {
|
|
||||||
// console.log(`[${this.name}] Growing population: ${this.population.toFixed(2)}`);
|
|
||||||
// } else {
|
|
||||||
// console.log(`[${this.name}] Shrinking population: ${this.population.toFixed(2)}`);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// Verbrauch abziehen
|
// Verbrauch abziehen
|
||||||
demands.forEach((amountNeeded, goodType) => {
|
demands.forEach((amountNeeded, goodType) => {
|
||||||
const good = this.goods.get(goodType);
|
const good = this.goods.get(goodType);
|
||||||
@ -366,6 +383,27 @@ export class Planet {
|
|||||||
return lvl * 1000;
|
return lvl * 1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
buildFactory() {
|
||||||
|
this.factory = new Factory({
|
||||||
|
planet: this,
|
||||||
|
type: GoodType.Elektronik
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public getStatus(): void {
|
||||||
|
console.log(`[${this.name}]: ${this.isGrowing ? '🚀' : '⬇️'}`);
|
||||||
|
console.log('Population:', Math.round(this.population));
|
||||||
|
console.log('Goods:\n', Array.from(this.goods.entries()).map(([type, good]) =>
|
||||||
|
`${type}: ${Math.round(good.amount)} (Prod: ${good.productionRate}, Demand: ${good.demandRate})`
|
||||||
|
).join('\n'));
|
||||||
|
// console.log('Docked Ships:', this.dockedShips.length);
|
||||||
|
// console.log('Waiting Ships:', this.shipsWaitingForDocking.length);
|
||||||
|
console.log('Production Levels:', Array.from(this.productionLevel.entries()).map(([type, level]) =>
|
||||||
|
`${type}: ${level}`
|
||||||
|
).join(', '));
|
||||||
|
console.log(`\n\n`)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface PlanetInit {
|
export interface PlanetInit {
|
||||||
|
|||||||
@ -3,18 +3,10 @@ import { Good } from "../goods/good.interface";
|
|||||||
import { Planet, TradeInstance } from "../planet.model";
|
import { Planet, TradeInstance } from "../planet.model";
|
||||||
import { TradeRoute } from "../routes/trade-route.model";
|
import { TradeRoute } from "../routes/trade-route.model";
|
||||||
import { GameService } from "../../service/game.service";
|
import { GameService } from "../../service/game.service";
|
||||||
|
import { ShipType } from "./ship.type";
|
||||||
|
|
||||||
export interface ShipConfig {
|
export interface ShipConfig extends ShipType {
|
||||||
name: string;
|
|
||||||
cargoSize: number;
|
|
||||||
acceleration: number;
|
|
||||||
maxSpeed: number;
|
|
||||||
loadingSpeed: number;
|
|
||||||
cost: number;
|
|
||||||
planetRoute: Planet[];
|
planetRoute: Planet[];
|
||||||
buyCost: number;
|
|
||||||
desciption: string;
|
|
||||||
texture: string;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export class Ship {
|
export class Ship {
|
||||||
|
|||||||
26
src/app/model/ships/ship.type.ts
Normal file
26
src/app/model/ships/ship.type.ts
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
export enum ShipClass {
|
||||||
|
light = 'light',
|
||||||
|
medium = 'medium',
|
||||||
|
heavy = 'heavy'
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ShipType {
|
||||||
|
name: string;
|
||||||
|
cargoSize: number;
|
||||||
|
loadingSpeed: number;
|
||||||
|
maxSpeed: number;
|
||||||
|
acceleration: number;
|
||||||
|
cost: number;
|
||||||
|
buyCost: number;
|
||||||
|
texture: string;
|
||||||
|
class: ShipClass;
|
||||||
|
desciption: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export const SHIP_DATA: Record<ShipClass, ShipType> = {
|
||||||
|
[ShipClass.light]: { name: 'Pioneer-01', cargoSize: 25, loadingSpeed: 15, maxSpeed: 350, acceleration: 300, class: ShipClass.light, buyCost: 3000, cost: 0.6, texture: 'swift-hauler', desciption: 'Ein kleines, schnelles Schiff. Es hat wenig Platz für Ladung, lädt aber schnell und ist sehr wendig.' },
|
||||||
|
[ShipClass.medium]: { name: 'Colony Carrier', cargoSize: 80, loadingSpeed: 20, maxSpeed: 250, acceleration: 90, class: ShipClass.medium, buyCost: 8000, cost: 1.6, texture: 'colony-carrier', desciption: 'Eine größere Version von der Pioneer-01. Der größere Frachtraum geht zu Lasten der Beschleunigung und Maximalgeschwindigkeit.' },
|
||||||
|
[ShipClass.heavy]: { name: 'Industrial Tanker', cargoSize: 400, loadingSpeed: 11, maxSpeed: 180, acceleration: 20, class: ShipClass.heavy, buyCost: 18000, cost: 3.8, texture: 'industrial-tanker', desciption: 'Ein großes behäbiges Schiff. Es wird durchaus schnell, beschleunigt aber sehr langsam und erreicht die Spitzengeschwindigkeit nur selten.' }
|
||||||
|
}
|
||||||
|
|
||||||
@ -141,7 +141,6 @@ export class MapScene extends Phaser.Scene {
|
|||||||
});
|
});
|
||||||
this.planets.push(planet);
|
this.planets.push(planet);
|
||||||
this.gameService.planets.push(planet.model);
|
this.gameService.planets.push(planet.model);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -46,6 +46,8 @@ export class PlanetUi extends Phaser.Physics.Arcade.Sprite {
|
|||||||
this.harbourImage.setDisplaySize(164, 256);
|
this.harbourImage.setDisplaySize(164, 256);
|
||||||
this.harbourImage.setVisible(false);
|
this.harbourImage.setVisible(false);
|
||||||
|
|
||||||
|
console.log(this.height)
|
||||||
|
|
||||||
// this.setScale(0.5)
|
// this.setScale(0.5)
|
||||||
|
|
||||||
// this.setInteractive(new Phaser.Geom.Circle(x, y, 200), Phaser.Geom.Circle.Contains);
|
// this.setInteractive(new Phaser.Geom.Circle(x, y, 200), Phaser.Geom.Circle.Contains);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user