Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/binaries/data/mods/public/simulation/components/Player.js
Show First 20 Lines • Show All 384 Lines • ▼ Show 20 Lines | Player.prototype.TrySubtractResources = function(amounts) | ||||
let cmpStatisticsTracker = QueryPlayerIDInterface(this.playerID, IID_StatisticsTracker); | let cmpStatisticsTracker = QueryPlayerIDInterface(this.playerID, IID_StatisticsTracker); | ||||
if (cmpStatisticsTracker) | if (cmpStatisticsTracker) | ||||
for (let type in amounts) | for (let type in amounts) | ||||
cmpStatisticsTracker.IncreaseResourceUsedCounter(type, amounts[type]); | cmpStatisticsTracker.IncreaseResourceUsedCounter(type, amounts[type]); | ||||
return true; | return true; | ||||
}; | }; | ||||
Player.prototype.RefundResources = function(amounts) | |||||
{ | |||||
const cmpStatisticsTracker = QueryPlayerIDInterface(this.playerID, IID_StatisticsTracker); | |||||
if (cmpStatisticsTracker) | |||||
for (const type in amounts) | |||||
cmpStatisticsTracker.IncreaseResourceUsedCounter(type, -amounts[type]); | |||||
this.AddResources(amounts); | |||||
}; | |||||
Player.prototype.GetNextTradingGoods = function() | Player.prototype.GetNextTradingGoods = function() | ||||
{ | { | ||||
let value = randFloat(0, 100); | let value = randFloat(0, 100); | ||||
let last = this.tradingGoods.length - 1; | let last = this.tradingGoods.length - 1; | ||||
let sumProba = 0; | let sumProba = 0; | ||||
for (let i = 0; i < last; ++i) | for (let i = 0; i < last; ++i) | ||||
{ | { | ||||
sumProba += this.tradingGoods[i].proba; | sumProba += this.tradingGoods[i].proba; | ||||
▲ Show 20 Lines • Show All 559 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator