Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/binaries/data/mods/public/simulation/components/Player.js
function Player() {} | function Player() {} | ||||
Player.prototype.Schema = | Player.prototype.Schema = | ||||
"<element name='SharedLosTech' a:help='Allies will share los when this technology is researched. Leave empty to never share LOS.'>" + | "<element name='SharedLosTech' a:help='Allies will share los when this technology is researched. Leave empty to never share LOS.'>" + | ||||
"<text/>" + | "<text/>" + | ||||
"</element>" + | "</element>" + | ||||
"<element name='SharedDropsitesTech' a:help='Allies will share dropsites when this technology is researched. Leave empty to never share dropsites.'>" + | "<element name='SharedDropsitesTech' a:help='Allies will share dropsites when this technology is researched. Leave empty to never share dropsites.'>" + | ||||
"<text/>" + | "<text/>" + | ||||
"</element>" + | |||||
"<element name='SpyCostMultiplier'>" + | |||||
"<ref name='nonNegativeDecimal'/>" + | |||||
"</element>"; | "</element>"; | ||||
Player.prototype.Init = function() | Player.prototype.Init = function() | ||||
{ | { | ||||
this.playerID = undefined; | this.playerID = undefined; | ||||
this.name = undefined; // define defaults elsewhere (supporting other languages) | this.name = undefined; // define defaults elsewhere (supporting other languages) | ||||
this.civ = undefined; | this.civ = undefined; | ||||
this.color = { "r": 0.0, "g": 0.0, "b": 0.0, "a": 1.0 }; | this.color = { "r": 0.0, "g": 0.0, "b": 0.0, "a": 1.0 }; | ||||
Show All 16 Lines | Player.prototype.Init = function() | ||||
this.tradeRateMultiplier = 1; | this.tradeRateMultiplier = 1; | ||||
this.cheatsEnabled = false; | this.cheatsEnabled = false; | ||||
this.cheatTimeMultiplier = 1; | this.cheatTimeMultiplier = 1; | ||||
this.heroes = []; | this.heroes = []; | ||||
this.resourceNames = {}; | this.resourceNames = {}; | ||||
this.disabledTemplates = {}; | this.disabledTemplates = {}; | ||||
this.disabledTechnologies = {}; | this.disabledTechnologies = {}; | ||||
this.startingTechnologies = []; | this.startingTechnologies = []; | ||||
this.spyCostMultiplier = +this.template.SpyCostMultiplier; | |||||
// Initial resources and trading goods probability in steps of 5 | // Initial resources and trading goods probability in steps of 5 | ||||
let resCodes = Resources.GetCodes(); | let resCodes = Resources.GetCodes(); | ||||
let quotient = Math.floor(20 / resCodes.length); | let quotient = Math.floor(20 / resCodes.length); | ||||
let remainder = 20 % resCodes.length; | let remainder = 20 % resCodes.length; | ||||
for (let i in resCodes) | for (let i in resCodes) | ||||
{ | { | ||||
let res = resCodes[i]; | let res = resCodes[i]; | ||||
▲ Show 20 Lines • Show All 121 Lines • ▼ Show 20 Lines | Player.prototype.SetTradeRateMultiplier = function(value) | ||||
this.tradeRateMultiplier = value; | this.tradeRateMultiplier = value; | ||||
}; | }; | ||||
Player.prototype.GetTradeRateMultiplier = function() | Player.prototype.GetTradeRateMultiplier = function() | ||||
{ | { | ||||
return this.tradeRateMultiplier; | return this.tradeRateMultiplier; | ||||
}; | }; | ||||
Player.prototype.GetSpyCostMultiplier = function() | |||||
{ | |||||
return this.spyCostMultiplier; | |||||
}; | |||||
Player.prototype.GetHeroes = function() | Player.prototype.GetHeroes = function() | ||||
{ | { | ||||
return this.heroes; | return this.heroes; | ||||
}; | }; | ||||
Player.prototype.IsTrainingBlocked = function() | Player.prototype.IsTrainingBlocked = function() | ||||
{ | { | ||||
return this.trainingBlocked; | return this.trainingBlocked; | ||||
▲ Show 20 Lines • Show All 534 Lines • ▼ Show 20 Lines | else if (msg.tech == this.template.SharedDropsitesTech) | ||||
this.sharedDropsites = true; | this.sharedDropsites = true; | ||||
}; | }; | ||||
Player.prototype.OnDiplomacyChanged = function() | Player.prototype.OnDiplomacyChanged = function() | ||||
{ | { | ||||
this.UpdateSharedLos(); | this.UpdateSharedLos(); | ||||
}; | }; | ||||
Player.prototype.OnValueModification = function(msg) | |||||
{ | |||||
if (msg.component != "Player" || msg.valueNames.indexOf("Player/SpyCostMultiplier") === -1) | |||||
return; | |||||
this.spyCostMultiplier = ApplyValueModificationsToPlayer("Player/SpyCostMultiplier", +this.template.SpyCostMultiplier, this.entity, this.playerID); | |||||
}; | |||||
Player.prototype.SetCheatsEnabled = function(flag) | Player.prototype.SetCheatsEnabled = function(flag) | ||||
{ | { | ||||
this.cheatsEnabled = flag; | this.cheatsEnabled = flag; | ||||
}; | }; | ||||
Player.prototype.GetCheatsEnabled = function() | Player.prototype.GetCheatsEnabled = function() | ||||
{ | { | ||||
return this.cheatsEnabled; | return this.cheatsEnabled; | ||||
▲ Show 20 Lines • Show All 129 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator