|
@@ -1,3 +1,6 @@
|
|
|
+/// <reference path="NPC.ts" />
|
|
|
+
|
|
|
+
|
|
|
const npcFieldBoundaries = {
|
|
|
rel:{min:0,max:100}
|
|
|
}
|
|
@@ -101,8 +104,8 @@ class NPCsDict{
|
|
|
return {};
|
|
|
}
|
|
|
|
|
|
- inc(npcId,field,v,min=-Infinity,max=Infinity){
|
|
|
- let d = '';
|
|
|
+ inc(npcId,field,v:string|number,min=-Infinity,max=Infinity){
|
|
|
+ let d:string|number = '';
|
|
|
if(typeof v === "number")
|
|
|
d = 0;
|
|
|
let current = this.get(npcId,field,d);
|
|
@@ -165,7 +168,7 @@ class NPCsDict{
|
|
|
let now = State.variables.time.now;
|
|
|
let memory = {time:now,vars:{}};
|
|
|
for(let rememberedField of rememberedFields){
|
|
|
- memory.vars[rememberedField] = getvar(rememberedField);
|
|
|
+ memory.vars[rememberedField] = State.getVar(rememberedField);
|
|
|
}
|
|
|
this.set(npcId,'memory',memory);
|
|
|
console.log('NPC memory updated',npcId,memory);
|
|
@@ -178,8 +181,8 @@ class NPCsDict{
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- npc(npcId){
|
|
|
- return new Proxy(new setup.NPC(npcId),setup.NPC.handler);
|
|
|
+ npc(npcId:string){
|
|
|
+ return new Proxy(new NPC(npcId),NPC.handler);
|
|
|
}
|
|
|
|
|
|
npcData(npcId){
|
|
@@ -199,7 +202,7 @@ class NPCsDict{
|
|
|
return data;
|
|
|
}
|
|
|
|
|
|
- npcFitsFilter(npcId,filters={}){
|
|
|
+ npcFitsFilter(npcId,filters:{[key:string]:any}={}){
|
|
|
outerLoop:for (const [filterKey, filterValue] of Object.entries(filters)) {
|
|
|
let npcValue = undefined;
|
|
|
|
|
@@ -226,13 +229,13 @@ class NPCsDict{
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
- npcLikesAppearance(npcId){
|
|
|
+ npcLikesAppearance(npcId):boolean{
|
|
|
let appearanceDemand = this.get(npcId,'appearanceDemand',[null,null,5]);
|
|
|
- let hotcat = $pc.appearance.hotcat;
|
|
|
+ let hotcat = State.variables.pc.appearance;
|
|
|
|
|
|
- if(appearanceDemand[0] !== null && hotcat.genetic < appearanceDemand[0]) return false;
|
|
|
- if(appearanceDemand[1] !== null && hotcat.lasting < appearanceDemand[1]) return false;
|
|
|
- if(appearanceDemand[2] !== null && hotcat.temp < appearanceDemand[2]) return false;
|
|
|
+ if(appearanceDemand[0] !== null && hotcat.geneticValue < appearanceDemand[0]) return false;
|
|
|
+ if(appearanceDemand[1] !== null && hotcat.lastingValue < appearanceDemand[1]) return false;
|
|
|
+ if(appearanceDemand[2] !== null && hotcat.currentValue < appearanceDemand[2]) return false;
|
|
|
|
|
|
let preferenceBalance = this.preferenceBalance(npcId);
|
|
|
return (preferenceBalance >= 0);
|
|
@@ -246,7 +249,7 @@ class NPCsDict{
|
|
|
* @param {string} npcId
|
|
|
* @returns {number}
|
|
|
*/
|
|
|
- preferenceBalance(npcId){
|
|
|
+ preferenceBalance(npcId):number{
|
|
|
let preferenceValues = this.preferencesCompare(npcId);
|
|
|
return Object.values(preferenceValues).reduce((a,x) => a+x, 0);
|
|
|
}
|
|
@@ -322,6 +325,8 @@ class NPCsDict{
|
|
|
|
|
|
for (const [preferenceId, value] of Object.entries(preferences[positive_negative].currentMatches)) {
|
|
|
// Value is the number that represents how negative or positive the opinion is
|
|
|
+ if(typeof value != "number")
|
|
|
+ continue;
|
|
|
let opinionMagnitude = Math.abs(value);
|
|
|
let opinionIsPositive = Math.sign(value); //-1: Negative, 1: Positive
|
|
|
|
|
@@ -433,7 +438,7 @@ class NPCsDict{
|
|
|
* @param {*} npcId
|
|
|
* @returns {{}}
|
|
|
*/
|
|
|
- preferencesCompare(npcId){
|
|
|
+ preferencesCompare(npcId):{[key: string]:number}{
|
|
|
|
|
|
let result = {};
|
|
|
let preferences = this.get(npcId,'preference');
|